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.
- 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bitops.hlinux/minmax.hlinux/module.hlinux/regmap.hlinux/soundwire/sdw_registers.hlinux/types.hsound/sdca.hsound/sdca_function.hsound/sdca_regmap.h
Detected Declarations
function function_find_entityfunction entity_find_controlfunction function_find_controlfunction sdca_regmap_readablefunction sdca_regmap_writeablefunction sdca_regmap_volatilefunction sdca_regmap_deferrablefunction sdca_regmap_mbq_sizefunction sdca_regmap_count_constantsfunction sdca_regmap_populate_constantsfunction for_each_set_bitfunction populate_control_defaultsfunction BITS_PER_TYPEfunction sdca_regmap_write_defaultsfunction sdca_regmap_write_init
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
- Immediate include surface: `linux/bitops.h`, `linux/minmax.h`, `linux/module.h`, `linux/regmap.h`, `linux/soundwire/sdw_registers.h`, `linux/types.h`, `sound/sdca.h`, `sound/sdca_function.h`.
- Detected declarations: `function function_find_entity`, `function entity_find_control`, `function function_find_control`, `function sdca_regmap_readable`, `function sdca_regmap_writeable`, `function sdca_regmap_volatile`, `function sdca_regmap_deferrable`, `function sdca_regmap_mbq_size`, `function sdca_regmap_count_constants`, `function sdca_regmap_populate_constants`.
- Atlas domain: Driver Families / sound/soc.
- Implementation status: integration implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.