mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git
synced 2026-04-27 03:49:57 -04:00
firmware: cs_dsp: Add mock regmap for KUnit testing
Add a mock regmap implementation to act as a simulated DSP for KUnit testing. This is built as a utility module so that it could be used by clients of cs_dsp to create a mock "DSP" for their own testing. cs_dsp interacts with the DSP only through registers. Most of the register space of the DSP is RAM. ADSP cores have a small set of control registers. HALO Core DSPs have a much larger set of control registers but only a small subset are used. Most writes are "blind" in the sense that cs_dsp does not expect to receive any sort of response from the DSP. So there isn't any need to emulate a "DSP", only a set of registers that can be written and read back. The idea of the mock regmap is to use the cache to accumulate writes which can then be tested against the values that are expected to be in the registers. Stray writes can be detected by dropping the cache entries for all addresses that should have been written and then issuing a regcache_sync(). If this causes bus writes it means there were writes to unexpected registers. Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com> Link: https://patch.msgid.link/20241212143725.1381013-2-rf@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
committed by
Mark Brown
parent
3ce8df13f6
commit
d54a3fc6bf
46
include/linux/firmware/cirrus/cs_dsp_test_utils.h
Normal file
46
include/linux/firmware/cirrus/cs_dsp_test_utils.h
Normal file
@@ -0,0 +1,46 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||
/*
|
||||
* Support utilities for cs_dsp testing.
|
||||
*
|
||||
* Copyright (C) 2024 Cirrus Logic, Inc. and
|
||||
* Cirrus Logic International Semiconductor Ltd.
|
||||
*/
|
||||
|
||||
#include <linux/regmap.h>
|
||||
#include <linux/firmware/cirrus/wmfw.h>
|
||||
|
||||
struct kunit;
|
||||
struct cs_dsp_test;
|
||||
struct cs_dsp_test_local;
|
||||
|
||||
/**
|
||||
* struct cs_dsp_test - base class for test utilities
|
||||
*
|
||||
* @test: Pointer to struct kunit instance.
|
||||
* @dsp: Pointer to struct cs_dsp instance.
|
||||
* @local: Private data for each test suite.
|
||||
*/
|
||||
struct cs_dsp_test {
|
||||
struct kunit *test;
|
||||
struct cs_dsp *dsp;
|
||||
|
||||
struct cs_dsp_test_local *local;
|
||||
|
||||
/* Following members are private */
|
||||
bool saw_bus_write;
|
||||
};
|
||||
|
||||
extern const unsigned int cs_dsp_mock_adsp2_32bit_sysbase;
|
||||
extern const unsigned int cs_dsp_mock_adsp2_16bit_sysbase;
|
||||
extern const unsigned int cs_dsp_mock_halo_core_base;
|
||||
extern const unsigned int cs_dsp_mock_halo_sysinfo_base;
|
||||
|
||||
int cs_dsp_mock_regmap_init(struct cs_dsp_test *priv);
|
||||
void cs_dsp_mock_regmap_drop_range(struct cs_dsp_test *priv,
|
||||
unsigned int first_reg, unsigned int last_reg);
|
||||
void cs_dsp_mock_regmap_drop_regs(struct cs_dsp_test *priv,
|
||||
unsigned int first_reg, size_t num_regs);
|
||||
void cs_dsp_mock_regmap_drop_bytes(struct cs_dsp_test *priv,
|
||||
unsigned int first_reg, size_t num_bytes);
|
||||
void cs_dsp_mock_regmap_drop_system_regs(struct cs_dsp_test *priv);
|
||||
bool cs_dsp_mock_regmap_is_dirty(struct cs_dsp_test *priv, bool drop_system_regs);
|
||||
Reference in New Issue
Block a user