firmware: cs_dsp: Add KUnit testing of bin file download
This adds a KUnit test suite to test downloading bin files.
The general technique is
1. Create mock bin file content
2. Tell cs_dsp to download the bin file
3. Check in the emulated regmap registers that the correct values have
been written to DSP memory
4. Drop the regmap cache for the expected written registers and then do a
regcache_sync() to check for unexpected writes to other registers.
The test covers ADSP2 v1 and v2, and HALO Core DSPs. (ADSP1 is very
obsolete so isn't tested).
There is a large number of test cases and parameterized variants of tests
because of the many different addressing schemes supported by the Cirrus
devices. The DSP has 2 or 3 memory spaces: XM, YM and ZM. The DSP sees
these using its native addressing, which is word-addressed (not
byte-addressed). The host sees these through one of several register
mappings (depending on the DSP type and parent codec family). The
registers have three different addressing schemes: 16-bit registers
addressed by register number, 32-bit registers addressed by register
number, or 32-bit registers addressed by byte (with a stride of 4). In
addition to these multiple addressing schemes, the Halo Core DSPs have a
"packed" register mapping that maps 4 DSP words into 3 registers. The bin
file addresses the data blob relative to the base address of an algorithm,
which has to be calculated in both DSP words (for the DSP to access) and
register addresses (for the host).
This results in many different addressing schemes used in parallel, hence
the complexity of the address and size manipulation in the test cases:
word addresses in DSP memory, byte offsets, word offsets, register
addresses (either byte-addressed 32-bit or index-addressed 16-bit), and
packed register addresses.
The test cases intentionally have relatively little factoring-out of
similar code. This makes it much easier to visually verify that a test
case is testing correctly, and what exactly it is testing. Factoring out
large amounts of code into helper functions tends to obscure what the
actual test procedure is, so increasing the chance of hidden errors where
test cases don't actually test as intended.
Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Link: https://patch.msgid.link/20241212143725.1381013-6-rf@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>