[PATCH 0/4] ASoC: cs35l56: Update hibernate/wake sequences and enable hibernation
Update the hibernate and wake command sequences to meet the latest datasheet specification and enable hibernation for I2C and SPI control interfaces.
Richard Fitzgerald (1): ASoC: cs35l56: Enable low-power hibernation mode on SPI
Simon Trimmer (3): ASoC: cs35l56: Change hibernate sequence to use allow auto hibernate ASoC: cs35l56: Wake transactions need to be issued twice ASoC: cs35l56: Enable low-power hibernation mode on i2c
include/sound/cs35l56.h | 1 + sound/soc/codecs/cs35l56-i2c.c | 1 + sound/soc/codecs/cs35l56-shared.c | 66 +++++++++++++++++++------------ sound/soc/codecs/cs35l56-spi.c | 1 + 4 files changed, 43 insertions(+), 26 deletions(-)
From: Simon Trimmer simont@opensource.cirrus.com
If the hardware uses SPI_MOSI, I2C_SCL or I2C_SDA as the wake source the bus activity of sending HIBERNATE_NOW will wake up the amps that were already put into hibernate.
ALLOW_AUTO_HIBERNATE tells the firmware to hibernate itself after a timeout of a few seconds, giving the driver instances time to send this before any amps have gone into hibernate.
Signed-off-by: Simon Trimmer simont@opensource.cirrus.com Signed-off-by: Richard Fitzgerald rf@opensource.cirrus.com --- sound/soc/codecs/cs35l56-shared.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-)
diff --git a/sound/soc/codecs/cs35l56-shared.c b/sound/soc/codecs/cs35l56-shared.c index 01b6fa97b36b..68dc93b82789 100644 --- a/sound/soc/codecs/cs35l56-shared.c +++ b/sound/soc/codecs/cs35l56-shared.c @@ -439,7 +439,7 @@ EXPORT_SYMBOL_NS_GPL(cs35l56_is_fw_reload_needed, SND_SOC_CS35L56_SHARED);
static const struct reg_sequence cs35l56_hibernate_seq[] = { /* This must be the last register access */ - REG_SEQ0(CS35L56_DSP_VIRTUAL1_MBOX_1, CS35L56_MBOX_CMD_HIBERNATE_NOW), + REG_SEQ0(CS35L56_DSP_VIRTUAL1_MBOX_1, CS35L56_MBOX_CMD_ALLOW_AUTO_HIBERNATE), };
static const struct reg_sequence cs35l56_hibernate_wake_seq[] = { @@ -473,12 +473,6 @@ int cs35l56_runtime_suspend_common(struct cs35l56_base *cs35l56_base) return 0; }
- /* - * Enable auto-hibernate. If it is woken by some other wake source - * it will automatically return to hibernate. - */ - cs35l56_mbox_send(cs35l56_base, CS35L56_MBOX_CMD_ALLOW_AUTO_HIBERNATE); - /* * Must enter cache-only first so there can't be any more register * accesses other than the controlled hibernate sequence below. @@ -545,11 +539,12 @@ int cs35l56_runtime_resume_common(struct cs35l56_base *cs35l56_base, bool is_sou return 0;
err: - regmap_write(cs35l56_base->regmap, CS35L56_DSP_VIRTUAL1_MBOX_1, - CS35L56_MBOX_CMD_HIBERNATE_NOW); - regcache_cache_only(cs35l56_base->regmap, true);
+ regmap_multi_reg_write_bypassed(cs35l56_base->regmap, + cs35l56_hibernate_seq, + ARRAY_SIZE(cs35l56_hibernate_seq)); + return ret; } EXPORT_SYMBOL_NS_GPL(cs35l56_runtime_resume_common, SND_SOC_CS35L56_SHARED);
From: Simon Trimmer simont@opensource.cirrus.com
As the dummy wake is a toggling signal (either I2C or SPI activity) it is not guaranteed to meet the minimum asserted hold time for a wake signal. In this case the wake must guarantee rising edges separated by at least the minimum hold time.
Signed-off-by: Simon Trimmer simont@opensource.cirrus.com Signed-off-by: Richard Fitzgerald rf@opensource.cirrus.com --- include/sound/cs35l56.h | 1 + sound/soc/codecs/cs35l56-shared.c | 51 +++++++++++++++++++++---------- 2 files changed, 36 insertions(+), 16 deletions(-)
diff --git a/include/sound/cs35l56.h b/include/sound/cs35l56.h index 762b96b29211..8c18e8b6d27d 100644 --- a/include/sound/cs35l56.h +++ b/include/sound/cs35l56.h @@ -243,6 +243,7 @@ #define CS35L56_HALO_STATE_POLL_US 1000 #define CS35L56_HALO_STATE_TIMEOUT_US 50000 #define CS35L56_RESET_PULSE_MIN_US 1100 +#define CS35L56_WAKE_HOLD_TIME_US 1000
#define CS35L56_SDW1_PLAYBACK_PORT 1 #define CS35L56_SDW1_CAPTURE_PORT 3 diff --git a/sound/soc/codecs/cs35l56-shared.c b/sound/soc/codecs/cs35l56-shared.c index 68dc93b82789..953ba066bab1 100644 --- a/sound/soc/codecs/cs35l56-shared.c +++ b/sound/soc/codecs/cs35l56-shared.c @@ -446,6 +446,32 @@ static const struct reg_sequence cs35l56_hibernate_wake_seq[] = { REG_SEQ0(CS35L56_DSP_VIRTUAL1_MBOX_1, CS35L56_MBOX_CMD_WAKEUP), };
+static void cs35l56_issue_wake_event(struct cs35l56_base *cs35l56_base) +{ + /* + * Dummy transactions to trigger I2C/SPI auto-wake. Issue two + * transactions to meet the minimum required time from the rising edge + * to the last falling edge of wake. + * + * It uses bypassed write because we must wake the chip before + * disabling regmap cache-only. + * + * This can NAK on I2C which will terminate the write sequence so the + * single-write sequence is issued twice. + */ + regmap_multi_reg_write_bypassed(cs35l56_base->regmap, + cs35l56_hibernate_wake_seq, + ARRAY_SIZE(cs35l56_hibernate_wake_seq)); + + usleep_range(CS35L56_WAKE_HOLD_TIME_US, 2 * CS35L56_WAKE_HOLD_TIME_US); + + regmap_multi_reg_write_bypassed(cs35l56_base->regmap, + cs35l56_hibernate_wake_seq, + ARRAY_SIZE(cs35l56_hibernate_wake_seq)); + + cs35l56_wait_control_port_ready(); +} + int cs35l56_runtime_suspend_common(struct cs35l56_base *cs35l56_base) { unsigned int val; @@ -500,17 +526,9 @@ int cs35l56_runtime_resume_common(struct cs35l56_base *cs35l56_base, bool is_sou if (!cs35l56_base->can_hibernate) goto out_sync;
- if (!is_soundwire) { - /* - * Dummy transaction to trigger I2C/SPI auto-wake. This will NAK on I2C. - * Must be done before releasing cache-only. - */ - regmap_multi_reg_write_bypassed(cs35l56_base->regmap, - cs35l56_hibernate_wake_seq, - ARRAY_SIZE(cs35l56_hibernate_wake_seq)); - - cs35l56_wait_control_port_ready(); - } + /* Must be done before releasing cache-only */ + if (!is_soundwire) + cs35l56_issue_wake_event(cs35l56_base);
out_sync: regcache_cache_only(cs35l56_base->regmap, false); @@ -578,13 +596,14 @@ int cs35l56_hw_init(struct cs35l56_base *cs35l56_base) unsigned int devid, revid, otpid, secured;
/* - * If the system is not using a reset_gpio then issue a - * dummy read to force a wakeup. + * When the system is not using a reset_gpio ensure the device is + * awake, otherwise the device has just been released from reset and + * the driver must wait for the control port to become usable. */ if (!cs35l56_base->reset_gpio) - regmap_read(cs35l56_base->regmap, CS35L56_DSP_VIRTUAL1_MBOX_1, &devid); - - cs35l56_wait_control_port_ready(); + cs35l56_issue_wake_event(cs35l56_base); + else + cs35l56_wait_control_port_ready();
/* * The HALO_STATE register is in different locations on Ax and B0
From: Simon Trimmer simont@opensource.cirrus.com
This can now be re-enabled as the sequence to reliably wake the device has been implemented in the shared code.
Signed-off-by: Simon Trimmer simont@opensource.cirrus.com Signed-off-by: Richard Fitzgerald rf@opensource.cirrus.com --- sound/soc/codecs/cs35l56-i2c.c | 1 + 1 file changed, 1 insertion(+)
diff --git a/sound/soc/codecs/cs35l56-i2c.c b/sound/soc/codecs/cs35l56-i2c.c index 9e5670b09af6..7063c400e896 100644 --- a/sound/soc/codecs/cs35l56-i2c.c +++ b/sound/soc/codecs/cs35l56-i2c.c @@ -27,6 +27,7 @@ static int cs35l56_i2c_probe(struct i2c_client *client) return -ENOMEM;
cs35l56->base.dev = dev; + cs35l56->base.can_hibernate = true;
i2c_set_clientdata(client, cs35l56); cs35l56->base.regmap = devm_regmap_init_i2c(client, regmap_config);
Hibernation can be enabled on SPI-connected devices now that the hibernate and wake sequences have been updated to work with wake-on-MOSI.
Signed-off-by: Richard Fitzgerald rf@opensource.cirrus.com --- sound/soc/codecs/cs35l56-spi.c | 1 + 1 file changed, 1 insertion(+)
diff --git a/sound/soc/codecs/cs35l56-spi.c b/sound/soc/codecs/cs35l56-spi.c index 768ffe8213dc..b07b798b0b45 100644 --- a/sound/soc/codecs/cs35l56-spi.c +++ b/sound/soc/codecs/cs35l56-spi.c @@ -32,6 +32,7 @@ static int cs35l56_spi_probe(struct spi_device *spi) }
cs35l56->base.dev = &spi->dev; + cs35l56->base.can_hibernate = true;
ret = cs35l56_common_probe(cs35l56); if (ret != 0)
On Fri, 06 Oct 2023 12:10:35 +0100, Richard Fitzgerald wrote:
Update the hibernate and wake command sequences to meet the latest datasheet specification and enable hibernation for I2C and SPI control interfaces.
Richard Fitzgerald (1): ASoC: cs35l56: Enable low-power hibernation mode on SPI
[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[1/4] ASoC: cs35l56: Change hibernate sequence to use allow auto hibernate commit: a47cf4dac7dcc43ef25d009ca0ad28fc86ba0eef [2/4] ASoC: cs35l56: Wake transactions need to be issued twice commit: 3df761bdbc8bc1bb679b5a4d4e068728d930a552 [3/4] ASoC: cs35l56: Enable low-power hibernation mode on i2c commit: 79b101947a829a1c4c3eca4b6365093d2b534cf4 [4/4] ASoC: cs35l56: Enable low-power hibernation mode on SPI commit: 634ed138d80b1cc8a903edb226458ea203c44abd
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks, Mark
participants (2)
-
Mark Brown
-
Richard Fitzgerald