ASoC: cs35l56: Replace open-coded SoundWire regmap with generic regmap-sdw
Subsystems (3)
Richard Fitzgerald
maintainerv2 cover ASoC: cs35l56: Replace open-coded SoundWire regmap with generic regmap-sdw
This series replaces the entirely custom SoundWire regmap with the generic regmap-sdw. The reasons for doing this are:
- Avoid code duplication
- Avoid effort of keeping custom implementation up-to-date
- Prepare for supporting BRA
Changes in V2:
- Select REGMAP_SOUNDWIRE
Richard Fitzgerald (2):
ASoC: cs35l56: Use reg_base to offset addresses on SoundWire
ASoC: cs35l56: Use standard SoundWire regmap implementation
sound/soc/codecs/Kconfig | 2 +- sound/soc/codecs/cs35l56-sdw.c | 137 +++++++++++------------------- sound/soc/codecs/cs35l56-shared.c | 2 + sound/soc/codecs/cs35l56.h | 1 + 4 files changed, 53 insertions(+), 89 deletions(-)
Signature · 1 line
2.47.3
Richard Fitzgerald
maintainerPATCH v2 1/2 ASoC: cs35l56: Use reg_base to offset addresses on SoundWire
Set the reg_base member of regmap_config for SoundWire so that the regmap core will apply the 0x8000 offset to addresses, instead of doing it within our low-level regmap read/write callbacks.
---
No changes since V1.
sound/soc/codecs/cs35l56-sdw.c | 7 +------ sound/soc/codecs/cs35l56-shared.c | 2 ++ 2 files changed, 3 insertions(+), 6 deletions(-)
sound/soc/codecs/cs35l56-sdw.c +1 -6
@@ -59,8 +59,6 @@ static int cs35l56_sdw_slow_read(struct sdw_slave *peripheral, unsigned int reg, {int ret, i; - reg +=CS35L56_SDW_ADDR_OFFSET ; -for (i =0 ; i < val_size; i +=sizeof (u32)) {/* Poll for bus bridge idle */ ret = cs35l56_sdw_poll_mem_status(peripheral,
@@ -123,11 +121,9 @@ static int cs35l56_sdw_read(void *context, const void *reg_buf, reg =le32_to_cpu (*(const __le32 *)reg_buf); -if (cs35l56_is_otp_register (reg)) +if (cs35l56_is_otp_register (reg -CS35L56_SDW_ADDR_OFFSET ))return cs35l56_sdw_slow_read (peripheral, reg, buf8, val_size); - reg +=CS35L56_SDW_ADDR_OFFSET ; -if (val_size ==4 )return cs35l56_sdw_read_one (peripheral, reg, val_buf);
@@ -186,7 +182,6 @@ static int cs35l56_sdw_gather_write(void *context,int ret; reg =le32_to_cpu (*(const __le32 *)reg_buf); - reg +=CS35L56_SDW_ADDR_OFFSET ;if (val_size ==4 )return cs35l56_sdw_write_one (peripheral, reg, src_be);
sound/soc/codecs/cs35l56-shared.c +2 -0
@@ -1880,6 +1880,7 @@ EXPORT_SYMBOL_NS_GPL(cs35l56_regmap_spi, "SND_SOC_CS35L56_SHARED");const struct regmap_config cs35l56_regmap_sdw = { .reg_bits =32 , + .reg_base =0x8000 , .val_bits =32 , .reg_stride =4 , .reg_format_endian =REGMAP_ENDIAN_LITTLE ,
@@ -1915,6 +1916,7 @@ const struct regmap_config cs35l63_regmap_sdw = { .reg_bits = 32, .val_bits = 32, .reg_stride = 4, + .reg_base = 0x8000, .reg_format_endian = REGMAP_ENDIAN_LITTLE, .val_format_endian = REGMAP_ENDIAN_BIG, .max_register = CS35L56_DSP1_PMEM_5114,
Signature · 1 line
2.47.3
Richard Fitzgerald
maintainerPATCH v2 2/2 ASoC: cs35l56: Use standard SoundWire regmap implementation
In reply to Richard FitzgeraldUse the regmap_sdw implementation for SoundWire instead of re-implementing the low-level bus transactions in cs35l56-sdw.c
The cs35l56 registers are big-endian on I2C and SPI but little-endian over SoundWire. The firmware files are all big-endian and contain opaque blobs in big-endian order. So these must be endian-swapped to transfer over SoundWire. A custom regmap bus implementation is used to do this endian-swapping.
The original implementation of this custom regmap bus was a complete bus backend, performing the endian swapping and low-level SoundWire bus read/write.
This commit changes the custom regmap bus to only perform the endian-swap. It uses an underlying simple uncached regmap_sdw bus to deal with transferring the 32-bit registers over the SoundWire bus. Although this adds a small amount of overhead, from passing through the regmap APIs twice, it avoids having a local duplicate implementation of what regmap_sdw already does.
The slow-read handling for OTP registers must access 8-bit SoundWire registers so it still uses low-level SoundWire bus reads.
---
Changed in V2:
- Select REGMAP_SOUNDWIRE
sound/soc/codecs/Kconfig | 2 +- sound/soc/codecs/cs35l56-sdw.c | 132 ++++++++++++--------------------- sound/soc/codecs/cs35l56.h | 1 + 3 files changed, 51 insertions(+), 84 deletions(-)
sound/soc/codecs/Kconfig +1 -1
@@ -887,7 +887,7 @@ config SND_SOC_CS35L56_SPI config SND_SOC_CS35L56_SDW tristate "Cirrus Logic CS35L56 CODEC (SDW)" depends on SOUNDWIRE - select REGMAP + select REGMAP_SOUNDWIRE select SND_SOC_CS35L56 select SND_SOC_CS35L56_SHARED help
sound/soc/codecs/cs35l56-sdw.c +49 -83
188 lines not on this page · raw message
sound/soc/codecs/cs35l56.h +1 -0
@@ -37,6 +37,7 @@ struct cs35l56_private {struct snd_soc_component *component;struct regulator_bulk_data supplies[CS35L56_NUM_BULK_SUPPLIES ];struct sdw_slave *sdw_peripheral; +struct regmap *sdw_bus_regmap;const char *fallback_fw_suffix;struct work_struct sdw_irq_work;bool sdw_irq_no_unmask;
Signature · 1 line
2.47.3
Richard Fitzgerald
maintainerRe: [PATCH v2 1/2] ASoC: cs35l56: Use reg_base to offset addresses on SoundWire
In reply to Richard FitzgeraldQuoted 6 lines · Richard Fitzgerald
Set the
reg_basemember ofregmap_configfor SoundWire so that the regmap core will apply the0x8000offset to addresses, instead of doing it within our low-level regmap read/write callbacks.Signed-off-by Richard Fitzgerald <[email protected]>---
STOP!
This also needs an update to the cs35l56 KUnit test for the changed addresses being passed to the dummy bus driver.
(This patch was written before the KUnit test existed)