sound/soc/sdca/sdca_regmap.c

Source file repositories/reference/linux-study-clean/sound/soc/sdca/sdca_regmap.c

File Facts

System
Linux kernel
Corpus path
sound/soc/sdca/sdca_regmap.c
Extension
.c
Size
10363 bytes
Lines
382
Domain
Driver Families
Bucket
sound/soc
Inferred role
Driver Families: exported/initcall integration point
Status
integration implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

BITS_PER_TYPE(control->cn_list)) {
				consts[k].reg = SDW_SDCA_CTL(function->desc->adr,
							     entity->id,
							     control->sel, cn);
				if (control->mode == SDCA_ACCESS_MODE_DC)
					consts[k].def = control->values[l];
				else
					consts[k].def = control->reset;
				k++;
				l++;
			}
		}
	}

	return k;
}
EXPORT_SYMBOL_NS(sdca_regmap_populate_constants, "SND_SOC_SDCA");

static int populate_control_defaults(struct device *dev, struct regmap *regmap,
				     struct sdca_function_data *function,
				     struct sdca_entity *entity,
				     struct sdca_control *control)
{
	int i, ret;
	int cn;

	if (control->mode == SDCA_ACCESS_MODE_DC)
		return 0;

	if (control->layers & SDCA_ACCESS_LAYER_DEVICE)
		return 0;

	i = 0;
	for_each_set_bit(cn, (unsigned long *)&control->cn_list,
			 BITS_PER_TYPE(control->cn_list)) {
		unsigned int reg, val;

		reg = SDW_SDCA_CTL(function->desc->adr, entity->id, control->sel, cn);

		if (control->has_default || control->has_fixed) {
			ret = regmap_write(regmap, reg, control->values[i]);
			if (ret) {
				dev_err(dev, "Failed to write default %#x: %d\n",
					reg, ret);
				return ret;
			}

			i++;
		} else if (!control->is_volatile) {
			if (control->has_reset)
				regcache_drop_region(regmap, reg, reg);

			ret = regmap_read(regmap, reg, &val);
			if (ret) {
				dev_err(dev, "Failed to read initial %#x: %d\n",
					reg, ret);
				return ret;
			}
		}
	}

	return 0;
}

/**
 * sdca_regmap_write_defaults - write out DisCo defaults to device
 * @dev: Pointer to the device.
 * @regmap: Pointer to the Function register map.
 * @function: Pointer to the Function information, to be parsed.
 *
 * This function will write out to the hardware all the DisCo default and
 * fixed value controls. This will cause them to be populated into the cache,
 * and subsequent handling can be done through a cache sync. It will also
 * read any non-volatile registers that don't have defaults/fixed values to
 * populate those into the cache, this ensures they are available for reads
 * even when the device is runtime suspended.
 *
 * Return: Returns zero on success, and a negative error code on failure.
 */
int sdca_regmap_write_defaults(struct device *dev, struct regmap *regmap,
			       struct sdca_function_data *function)
{
	int i, j;
	int ret;

	for (i = 0; i < function->num_entities; i++) {
		struct sdca_entity *entity = &function->entities[i];

		for (j = 0; j < entity->num_controls; j++) {
			struct sdca_control *control = &entity->controls[j];

Annotation

Implementation Notes