drivers/firmware/cirrus/test/cs_dsp_mock_regmap.c
Source file repositories/reference/linux-study-clean/drivers/firmware/cirrus/test/cs_dsp_mock_regmap.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/firmware/cirrus/test/cs_dsp_mock_regmap.c- Extension
.c- Size
- 12040 bytes
- Lines
- 368
- Domain
- Driver Families
- Bucket
- drivers/firmware
- 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
kunit/test.hlinux/firmware/cirrus/cs_dsp.hlinux/firmware/cirrus/cs_dsp_test_utils.hlinux/firmware/cirrus/wmfw.hlinux/regmap.h
Detected Declarations
function cs_dsp_mock_regmap_readfunction cs_dsp_mock_regmap_gather_writefunction cs_dsp_mock_regmap_writefunction cs_dsp_mock_regmap_drop_rangefunction cs_dsp_mock_regmap_drop_regsfunction cs_dsp_mock_regmap_drop_bytesfunction cs_dsp_mock_regmap_drop_system_regsfunction cs_dsp_mock_regmap_is_dirtyfunction cs_dsp_mock_regmap_init
Annotated Snippet
if (priv->dsp->base) {
regcache_drop_region(priv->dsp->regmap,
priv->dsp->base,
priv->dsp->base + 0x7c);
}
return;
case WMFW_HALO:
if (priv->dsp->base) {
regcache_drop_region(priv->dsp->regmap,
priv->dsp->base,
priv->dsp->base + 0x47000);
}
/* sysinfo registers are read-only so don't drop them */
return;
default:
return;
}
}
EXPORT_SYMBOL_NS_GPL(cs_dsp_mock_regmap_drop_system_regs, "FW_CS_DSP_KUNIT_TEST_UTILS");
/**
* cs_dsp_mock_regmap_is_dirty() - Test for dirty registers in the cache.
*
* @priv: Pointer to struct cs_dsp_test object.
* @drop_system_regs: If true the DSP system regs will be dropped from
* the cache before checking for dirty.
*
* All registers that are expected to be written must have been dropped
* from the cache (DSP system registers can be dropped by passing
* drop_system_regs == true). If any unexpected registers were written
* there will still be dirty entries in the cache and a cache sync will
* cause a write.
*
* Returns: true if there were dirty entries, false if not.
*/
bool cs_dsp_mock_regmap_is_dirty(struct cs_dsp_test *priv, bool drop_system_regs)
{
if (drop_system_regs)
cs_dsp_mock_regmap_drop_system_regs(priv);
priv->saw_bus_write = false;
regcache_cache_only(priv->dsp->regmap, false);
regcache_sync(priv->dsp->regmap);
regcache_cache_only(priv->dsp->regmap, true);
return priv->saw_bus_write;
}
EXPORT_SYMBOL_NS_GPL(cs_dsp_mock_regmap_is_dirty, "FW_CS_DSP_KUNIT_TEST_UTILS");
/**
* cs_dsp_mock_regmap_init() - Initialize a mock regmap.
*
* @priv: Pointer to struct cs_dsp_test object. This must have a
* valid pointer to a struct cs_dsp in which the type and
* rev fields are set to the type of DSP to be simulated.
*
* On success the priv->dsp->regmap will point to the created
* regmap instance.
*
* Return: zero on success, else negative error code.
*/
int cs_dsp_mock_regmap_init(struct cs_dsp_test *priv)
{
const struct regmap_config *config;
int ret;
switch (priv->dsp->type) {
case WMFW_HALO:
config = &cs_dsp_mock_regmap_halo;
break;
case WMFW_ADSP2:
if (priv->dsp->rev == 0)
config = &cs_dsp_mock_regmap_adsp2_16bit;
else
config = &cs_dsp_mock_regmap_adsp2_32bit;
break;
default:
config = NULL;
break;
}
priv->dsp->regmap = devm_regmap_init(priv->dsp->dev,
&cs_dsp_mock_regmap_bus,
priv,
config);
if (IS_ERR(priv->dsp->regmap)) {
ret = PTR_ERR(priv->dsp->regmap);
kunit_err(priv->test, "Failed to allocate register map: %d\n", ret);
return ret;
Annotation
- Immediate include surface: `kunit/test.h`, `linux/firmware/cirrus/cs_dsp.h`, `linux/firmware/cirrus/cs_dsp_test_utils.h`, `linux/firmware/cirrus/wmfw.h`, `linux/regmap.h`.
- Detected declarations: `function cs_dsp_mock_regmap_read`, `function cs_dsp_mock_regmap_gather_write`, `function cs_dsp_mock_regmap_write`, `function cs_dsp_mock_regmap_drop_range`, `function cs_dsp_mock_regmap_drop_regs`, `function cs_dsp_mock_regmap_drop_bytes`, `function cs_dsp_mock_regmap_drop_system_regs`, `function cs_dsp_mock_regmap_is_dirty`, `function cs_dsp_mock_regmap_init`.
- Atlas domain: Driver Families / drivers/firmware.
- 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.