Add low power hibernation support to cs35l41
Subsystems (3)
cover Add low power hibernation support to cs35l41
This patch series adds support for the low power hibernation feature on cs35l41. This allows the DSP memory to be retained whilst the device enters a very low power state.
These patches will cause some very minor conflicts with Lucas's currently outstanding work on the HDA version of cs35l41. Whilst things will still build (well now I fixed my silly mistake), this patch adds a test key function his code will now have to call.
It looks like Lucas's patch might get a respin based on the comments from Andy, in which case I guess we can pull the small change into the next version of it. But either way these patches are not urgent so I am happy if they sit around until Lucas's stuff is merged too.
Thanks,
Charles
Charles Keepax (2):
ASoC: cs35l41: Update handling of test key registers
ASoC: cs35l41: Add support for hibernate memory retention mode
include/sound/cs35l41.h | 7 ++ sound/soc/codecs/cs35l41-i2c.c | 1 + sound/soc/codecs/cs35l41-lib.c | 73 +++++++------ sound/soc/codecs/cs35l41-spi.c | 1 + sound/soc/codecs/cs35l41.c | 233 +++++++++++++++++++++++++++++++++++++---- sound/soc/codecs/cs35l41.h | 4 + 6 files changed, 268 insertions(+), 51 deletions(-)
Signature · 1 line
2.11.0
PATCH v2 2/2 ASoC: cs35l41: Add support for hibernate memory retention mode
The cs35l41 supports a low power DSP memory retention mode. Add support for entering this mode when then device is not in use.
---
Changes since v1:
- Add missing export symbol for cs35l41_pm_ops
include/sound/cs35l41.h | 5 + sound/soc/codecs/cs35l41-i2c.c | 1 + sound/soc/codecs/cs35l41-lib.c | 6 ++ sound/soc/codecs/cs35l41-spi.c | 1 + sound/soc/codecs/cs35l41.c | 201 ++++++++++++++++++++++++++++++++++++++++- sound/soc/codecs/cs35l41.h | 4 + 6 files changed, 214 insertions(+), 4 deletions(-)
include/sound/cs35l41.h +5 -0
@@ -40,6 +40,9 @@#define CS35L41_PROTECT_REL_ERR_IGN 0x00002034#define CS35L41_GPIO_PAD_CONTROL 0x0000242C#define CS35L41_JTAG_CONTROL 0x00002438 +#define CS35L41_PWRMGT_CTL 0x00002900 +#define CS35L41_WAKESRC_CTL 0x00002904 +#define CS35L41_PWRMGT_STS 0x00002908#define CS35L41_PLL_CLK_CTRL 0x00002C04#define CS35L41_DSP_CLK_CTRL 0x00002C08#define CS35L41_GLOBAL_CLK_CTRL 0x00002C0C
@@ -635,6 +638,8 @@#define CS35L41_INPUT_DSP_TX1 0x32#define CS35L41_INPUT_DSP_TX2 0x33 +#define CS35L41_WR_PEND_STS_MASK 0x2 +#define CS35L41_PLL_CLK_SEL_MASK 0x07#define CS35L41_PLL_CLK_SEL_SHIFT 0#define CS35L41_PLL_CLK_EN_MASK 0x10
sound/soc/codecs/cs35l41-i2c.c +1 -0
@@ -86,6 +86,7 @@ MODULE_DEVICE_TABLE(acpi, cs35l41_acpi_match);static struct i2c_driver cs35l41_i2c_driver = { .driver = { .name ="cs35l41" , + .pm = &cs35l41_pm_ops, .of_match_table =of_match_ptr (cs35l41_of_match), .acpi_match_table =ACPI_PTR (cs35l41_acpi_match), },
sound/soc/codecs/cs35l41-lib.c +6 -0
@@ -90,6 +90,9 @@ static bool cs35l41_readable_reg(struct device *dev, unsigned int reg)case CS35L41_PROTECT_REL_ERR_IGN :case CS35L41_GPIO_PAD_CONTROL :case CS35L41_JTAG_CONTROL : +case CS35L41_PWRMGT_CTL : +case CS35L41_WAKESRC_CTL : +case CS35L41_PWRMGT_STS :case CS35L41_PLL_CLK_CTRL :case CS35L41_DSP_CLK_CTRL :case CS35L41_GLOBAL_CLK_CTRL :
@@ -376,6 +379,9 @@ static bool cs35l41_volatile_reg(struct device *dev, unsigned int reg)case CS35L41_OTPID :case CS35L41_TEST_KEY_CTL :case CS35L41_USER_KEY_CTL : +case CS35L41_PWRMGT_CTL : +case CS35L41_WAKESRC_CTL : +case CS35L41_PWRMGT_STS :case CS35L41_DTEMP_EN :case CS35L41_IRQ1_STATUS :case CS35L41_IRQ1_STATUS1 :
sound/soc/codecs/cs35l41-spi.c +1 -0
@@ -84,6 +84,7 @@ MODULE_DEVICE_TABLE(acpi, cs35l41_acpi_match);static struct spi_driver cs35l41_spi_driver = { .driver = { .name ="cs35l41" , + .pm = &cs35l41_pm_ops, .of_match_table =of_match_ptr (cs35l41_of_match), .acpi_match_table =ACPI_PTR (cs35l41_acpi_match), },
sound/soc/codecs/cs35l41.c +197 -4
282 lines not on this page · raw message
sound/soc/codecs/cs35l41.h +4 -0
@@ -21,6 +21,8 @@#define CS35L41_RX_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE)#define CS35L41_TX_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE) +extern const struct dev_pm_ops cs35l41_pm_ops; +enum cs35l41_cspl_mbox_status {CSPL_MBOX_STS_RUNNING =0 ,CSPL_MBOX_STS_PAUSED =1 ,
@@ -33,6 +35,8 @@ enum cs35l41_cspl_mbox_cmd {CSPL_MBOX_CMD_RESUME =2 ,CSPL_MBOX_CMD_REINIT =3 ,CSPL_MBOX_CMD_STOP_PRE_REINIT =4 , +CSPL_MBOX_CMD_HIBERNATE =5 , +CSPL_MBOX_CMD_OUT_OF_HIBERNATE =6 ,CSPL_MBOX_CMD_UNKNOWN_CMD =-1 , CSPL_MBOX_CMD_INVALID_SEQUENCE = -2, };
Signature · 1 line
2.11.0
PATCH v2 1/2 ASoC: cs35l41: Update handling of test key registers
In reply to Charles KeepaxIn preparation for the addition of PM runtime support move the test key out of the register patches themselves. This is necessary to allow the test key to be held during cache synchronisation, which is required by the OTP settings which were unpacked from the device and written by the driver.
Also whilst at it, the driver uses a mixture of accessing the test key register by name and by address, consistently use the name.
---
Changes since v1:
- Add missing export symbol for new test_key functions
include/sound/cs35l41.h | 2 ++ sound/soc/codecs/cs35l41-lib.c | 67 +++++++++++++++++++++--------------------- sound/soc/codecs/cs35l41.c | 32 +++++++++++--------- 3 files changed, 54 insertions(+), 47 deletions(-)
include/sound/cs35l41.h +2 -0
@@ -762,6 +762,8 @@ struct cs35l41_otp_map_element_t {extern struct regmap_config cs35l41_regmap_i2c;extern struct regmap_config cs35l41_regmap_spi; +int cs35l41_test_key_unlock (struct device *dev,struct regmap *regmap); +int cs35l41_test_key_lock (struct device *dev,struct regmap *regmap);int cs35l41_otp_unpack (struct device *dev,struct regmap *regmap);int cs35l41_register_errata_patch (struct device *dev,struct regmap *reg,unsigned int reg_revid); int cs35l41_set_channels(struct device *dev, struct regmap *reg,
sound/soc/codecs/cs35l41-lib.c +34 -33
125 lines not on this page · raw message
sound/soc/codecs/cs35l41.c +18 -14
@@ -534,19 +534,19 @@ static irqreturn_t cs35l41_irq(int irq, void *data) }static const struct reg_sequence cs35l41_pup_patch[] = { - {0x00000040 ,0x00000055 }, - {0x00000040 ,0x000000AA }, + {CS35L41_TEST_KEY_CTL ,0x00000055 }, + {CS35L41_TEST_KEY_CTL ,0x000000AA }, {0x00002084 ,0x002F1AA0 }, - {0x00000040 ,0x000000CC }, - {0x00000040 ,0x00000033 }, + {CS35L41_TEST_KEY_CTL ,0x000000CC }, + {CS35L41_TEST_KEY_CTL ,0x00000033 }, };static const struct reg_sequence cs35l41_pdn_patch[] = { - {0x00000040 ,0x00000055 }, - {0x00000040 ,0x000000AA }, + {CS35L41_TEST_KEY_CTL ,0x00000055 }, + {CS35L41_TEST_KEY_CTL ,0x000000AA }, {0x00002084 ,0x002F1AA3 }, - {0x00000040 ,0x000000CC }, - {0x00000040 ,0x00000033 }, + {CS35L41_TEST_KEY_CTL ,0x000000CC }, + {CS35L41_TEST_KEY_CTL ,0x00000033 }, }; static int cs35l41_main_amp_event(struct snd_soc_dapm_widget *w,
@@ -1329,10 +1329,20 @@ int cs35l41_probe(struct cs35l41_private *cs35l41, goto err; } +cs35l41_test_key_unlock (cs35l41->dev, cs35l41->regmap); + ret =cs35l41_register_errata_patch (cs35l41->dev, cs35l41->regmap, reg_revid);if (ret) goto err; + ret =cs35l41_otp_unpack (cs35l41->dev, cs35l41->regmap); +if (ret <0 ) { +dev_err (cs35l41->dev,"OTP Unpack failed: %d\n" , ret); + goto err; + } + +cs35l41_test_key_lock (cs35l41->dev, cs35l41->regmap); + irq_pol =cs35l41_irq_gpio_config (cs35l41);/* Set interrupt masks for critical errors */
@@ -1347,12 +1357,6 @@ int cs35l41_probe(struct cs35l41_private *cs35l41, goto err; } - ret =cs35l41_otp_unpack (cs35l41->dev, cs35l41->regmap); -if (ret <0 ) { -dev_err (cs35l41->dev,"OTP Unpack failed: %d\n" , ret); - goto err; - } - ret =cs35l41_set_pdata (cs35l41);if (ret <0 ) {dev_err (cs35l41->dev,"Set pdata failed: %d\n" , ret);
Signature · 1 line
2.11.0
Mark Brown
maintainerQuoted 4 lines · Charles Keepax
These patches will cause some very minor conflicts with Lucas's currently outstanding work on the HDA version of cs35l41. Whilst things will still build (well now I fixed my silly mistake), this patch adds a test key function his code will now have to call.
Which patches are these? It looks like everything I was aware of is merged.
Quoted 10 lines · Charles Keepax
This patch series adds support for the low power hibernation feature on cs35l41. This allows the DSP memory to be retained whilst the device enters a very low power state.
These patches will cause some very minor conflicts with Lucas's currently outstanding work on the HDA version of cs35l41. Whilst things will still build (well now I fixed my silly mistake), this patch adds a test key function his code will now have to call.
Quoted 4 lines
It looks like Lucas's patch might get a respin based on the comments from Andy, in which case I guess we can pull the small change into the next version of it. But either way these patches are not urgent so I am happy if they sit around until Lucas's stuff is merged too.
Well, I've already merged HD-audio part, so any changes will be incremental over it.
CS35L41 HD-audio stuff still won't work as of now with my tree alone because of the lack of the ACPI patch. So it's fine to merge those changes to Mark's tree and break the stuff now, supposing it'll be synced again before 5.17-rc1 pull request. After it's merged to my tree, you can submit the HD-audio fix, to be merged before rc1.
thanks,
Takashi
Quoted 17 lines · Takashi Iwai
Quoted 10 lines · Charles Keepax
This patch series adds support for the low power hibernation feature on cs35l41. This allows the DSP memory to be retained whilst the device enters a very low power state.
These patches will cause some very minor conflicts with Lucas's currently outstanding work on the HDA version of cs35l41. Whilst things will still build (well now I fixed my silly mistake), this patch adds a test key function his code will now have to call.
Quoted 4 lines
It looks like Lucas's patch might get a respin based on the comments from Andy, in which case I guess we can pull the small change into the next version of it. But either way these patches are not urgent so I am happy if they sit around until Lucas's stuff is merged too.
Quoted 9 lines
Well, I've already merged HD-audio part, so any changes will be incremental over it.
CS35L41 HD-audio stuff still won't work as of now with my tree alone because of the lack of the ACPI patch. So it's fine to merge those changes to Mark's tree and break the stuff now, supposing it'll be synced again before 5.17-rc1 pull request. After it's merged to my tree, you can submit the HD-audio fix, to be merged before rc1.
Apologies I didn't realise those were already merged. I will do a patch to update them to use the new functions.
Thanks,
Charles
Mark Brown
maintainerQuoted 10 lines · Charles Keepax
This patch series adds support for the low power hibernation feature on cs35l41. This allows the DSP memory to be retained whilst the device enters a very low power state.
These patches will cause some very minor conflicts with Lucas's currently outstanding work on the HDA version of cs35l41. Whilst things will still build (well now I fixed my silly mistake), this patch adds a test key function his code will now have to call.
[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[1/2] ASoC: cs35l41: Update handling of test key registers
commit: d92321bbe46b0ecae0941461379d39599610d869
[2/2] ASoC: cs35l41: Add support for hibernate memory retention mode
commit: f517ba4924ad026f2583553db02f3c8bc69de88bAll 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