/** * cs_dsp_mock_regmap_drop_range() - drop a range of registers from the cache. * * @priv: Pointer to struct cs_dsp_test object. * @first_reg: Address of first register to drop. * @last_reg: Address of last register to drop.
*/ void cs_dsp_mock_regmap_drop_range(struct cs_dsp_test *priv, unsignedint first_reg, unsignedint last_reg)
{
regcache_drop_region(priv->dsp->regmap, first_reg, last_reg);
}
EXPORT_SYMBOL_NS_GPL(cs_dsp_mock_regmap_drop_range, "FW_CS_DSP_KUNIT_TEST_UTILS");
/** * cs_dsp_mock_regmap_drop_regs() - drop a number of registers from the cache. * * @priv: Pointer to struct cs_dsp_test object. * @first_reg: Address of first register to drop. * @num_regs: Number of registers to drop.
*/ void cs_dsp_mock_regmap_drop_regs(struct cs_dsp_test *priv, unsignedint first_reg, size_t num_regs)
{ int stride = regmap_get_reg_stride(priv->dsp->regmap); unsignedint last = first_reg + (stride * (num_regs - 1));
/** * cs_dsp_mock_regmap_drop_bytes() - drop a number of bytes from the cache. * * @priv: Pointer to struct cs_dsp_test object. * @first_reg: Address of first register to drop. * @num_bytes: Number of bytes to drop from the cache. Will be rounded * down to a whole number of registers. Trailing bytes that * are not a multiple of the register size will not be dropped. * (This is intended to help detect math errors in test code.)
*/ void cs_dsp_mock_regmap_drop_bytes(struct cs_dsp_test *priv, unsignedint first_reg, size_t num_bytes)
{
size_t num_regs = num_bytes / regmap_get_val_bytes(priv->dsp->regmap);
/** * cs_dsp_mock_regmap_drop_system_regs() - Drop DSP system registers from the cache. * * @priv: Pointer to struct cs_dsp_test object. * * Drops all DSP system registers from the regmap cache.
*/ void cs_dsp_mock_regmap_drop_system_regs(struct cs_dsp_test *priv)
{ switch (priv->dsp->type) { case WMFW_ADSP2: 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);
/** * 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)
{ conststruct 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;
}
/* Put regmap in cache-only so it accumulates the writes done by cs_dsp */
regcache_cache_only(priv->dsp->regmap, true);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.