Skip to contentSkip to conversation

Add low power hibernation support to cs35l41

PATCH In review Charles Keepax 3 participants 16 messages Jan 5, 2022

Subsystems (5)
lore
Share & tools
lore
author maintainer
#4 lore raw

PATCH 4/8 ASoC: cs35l41: Correct handling of some registers in the cache

In reply to Charles Keepax

It makes no sense to cache the test/user key registers, since they require values written at specific times, mark them volatile. It is probably best if they can't be accessed from user-space either, so mark them precious as well.

The interrupt force, edge, polarity and debounce are all settings applied to the IRQ rather than status bits and as such should not be volatile.

The OTP trim values will require re-application in the event of a cache sync and as such should not be volatile. The OTPID however should be volatile.

The DSP scratch registers are used to read back an error/debug code from the DSP on shutdown, as such these should be marked volatile.

Finally, add some missing defaults, add TST_FS_MON0, and allow the DSP core control register to be cached.

---
 sound/soc/codecs/cs35l41-lib.c | 81 ++++++++++++------------------------------
 1 file changed, 22 insertions(+), 59 deletions(-)
sound/soc/codecs/cs35l41-lib.c +22 -59
index d026c5e3a378b..639dcd25b17e9 100644
@@ -20,6 +20,11 @@ static const struct reg_default cs35l41_reg[] = {
 	{ CS35L41_PWR_CTRL2,			0x00000000 },
 	{ CS35L41_PWR_CTRL3,			0x01000010 },
 	{ CS35L41_GPIO_PAD_CONTROL,		0x00000000 },
+	{ CS35L41_GLOBAL_CLK_CTRL,		0x00000003 },
+	{ CS35L41_TST_FS_MON0,			0x00020016 },
+	{ CS35L41_BSTCVRT_COEFF,		0x00002424 },
+	{ CS35L41_BSTCVRT_SLOPE_LBST,		0x00007500 },
+	{ CS35L41_BSTCVRT_PEAK_CUR,		0x0000004A },
 	{ CS35L41_SP_ENABLES,			0x00000000 },
 	{ CS35L41_SP_RATE_CTRL,			0x00000028 },
 	{ CS35L41_SP_FORMAT,			0x18180200 },
@@ -48,11 +53,16 @@ static const struct reg_default cs35l41_reg[] = {
 	{ CS35L41_WKFET_CFG,			0x00000111 },
 	{ CS35L41_NG_CFG,			0x00000033 },
 	{ CS35L41_AMP_GAIN_CTRL,		0x00000000 },
+	{ CS35L41_IRQ1_MASK1,			0xFFFFFFFF },
+	{ CS35L41_IRQ1_MASK2,			0xFFFFFFFF },
+	{ CS35L41_IRQ1_MASK3,			0xFFFF87FF },
+	{ CS35L41_IRQ1_MASK4,			0xFEFFFFFF },
 	{ CS35L41_GPIO1_CTRL1,			0xE1000001 },
 	{ CS35L41_GPIO2_CTRL1,			0xE1000001 },
 	{ CS35L41_MIXER_NGATE_CFG,		0x00000000 },
 	{ CS35L41_MIXER_NGATE_CH1_CFG,		0x00000303 },
 	{ CS35L41_MIXER_NGATE_CH2_CFG,		0x00000303 },
+	{ CS35L41_DSP1_CCM_CORE_CTRL,		0x00000101 },
 };
 
 static bool cs35l41_readable_reg(struct device *dev, unsigned int reg)
@@ -84,6 +94,7 @@ static bool cs35l41_readable_reg(struct device *dev, unsigned int reg)
 	case CS35L41_DSP_CLK_CTRL:
 	case CS35L41_GLOBAL_CLK_CTRL:
 	case CS35L41_DATA_FS_SEL:
+	case CS35L41_TST_FS_MON0:
 	case CS35L41_MDSYNC_EN:
 	case CS35L41_MDSYNC_TX_ID:
 	case CS35L41_MDSYNC_PWR_CTRL:
@@ -342,7 +353,10 @@ static bool cs35l41_readable_reg(struct device *dev, unsigned int reg)
 static bool cs35l41_precious_reg(struct device *dev, unsigned int reg)
 {
 	switch (reg) {
+	case CS35L41_TEST_KEY_CTL:
+	case CS35L41_USER_KEY_CTL:
 	case CS35L41_OTP_MEM0 ... CS35L41_OTP_MEM31:
+	case CS35L41_TST_FS_MON0:
 	case CS35L41_DSP1_XMEM_PACK_0 ... CS35L41_DSP1_XMEM_PACK_3068:
 	case CS35L41_DSP1_YMEM_PACK_0 ... CS35L41_DSP1_YMEM_PACK_1532:
 	case CS35L41_DSP1_PMEM_0 ... CS35L41_DSP1_PMEM_5114:
@@ -359,6 +373,9 @@ static bool cs35l41_volatile_reg(struct device *dev, unsigned int reg)
 	case CS35L41_SFT_RESET:
 	case CS35L41_FABID:
 	case CS35L41_REVID:
+	case CS35L41_OTPID:
+	case CS35L41_TEST_KEY_CTL:
+	case CS35L41_USER_KEY_CTL:
 	case CS35L41_DTEMP_EN:
 	case CS35L41_IRQ1_STATUS:
 	case CS35L41_IRQ1_STATUS1:
@@ -369,17 +386,6 @@ static bool cs35l41_volatile_reg(struct device *dev, unsigned int reg)
 	case CS35L41_IRQ1_RAW_STATUS2:
 	case CS35L41_IRQ1_RAW_STATUS3:
 	case CS35L41_IRQ1_RAW_STATUS4:
-	case CS35L41_IRQ1_FRC1:
-	case CS35L41_IRQ1_FRC2:
-	case CS35L41_IRQ1_FRC3:
-	case CS35L41_IRQ1_FRC4:
-	case CS35L41_IRQ1_EDGE1:
-	case CS35L41_IRQ1_EDGE4:
-	case CS35L41_IRQ1_POL1:
-	case CS35L41_IRQ1_POL2:
-	case CS35L41_IRQ1_POL3:
-	case CS35L41_IRQ1_POL4:
-	case CS35L41_IRQ1_DB3:
 	case CS35L41_IRQ2_STATUS:
 	case CS35L41_IRQ2_STATUS1:
 	case CS35L41_IRQ2_STATUS2:
@@ -389,54 +395,7 @@ static bool cs35l41_volatile_reg(struct device *dev, unsigned int reg)
 	case CS35L41_IRQ2_RAW_STATUS2:
 	case CS35L41_IRQ2_RAW_STATUS3:
 	case CS35L41_IRQ2_RAW_STATUS4:
-	case CS35L41_IRQ2_FRC1:
-	case CS35L41_IRQ2_FRC2:
-	case CS35L41_IRQ2_FRC3:
-	case CS35L41_IRQ2_FRC4:
-	case CS35L41_IRQ2_EDGE1:
-	case CS35L41_IRQ2_EDGE4:
-	case CS35L41_IRQ2_POL1:
-	case CS35L41_IRQ2_POL2:
-	case CS35L41_IRQ2_POL3:
-	case CS35L41_IRQ2_POL4:
-	case CS35L41_IRQ2_DB3:
 	case CS35L41_GPIO_STATUS1:
-	case CS35L41_OTP_TRIM_1:
-	case CS35L41_OTP_TRIM_2:
-	case CS35L41_OTP_TRIM_3:
-	case CS35L41_OTP_TRIM_4:
-	case CS35L41_OTP_TRIM_5:
-	case CS35L41_OTP_TRIM_6:
-	case CS35L41_OTP_TRIM_7:
-	case CS35L41_OTP_TRIM_8:
-	case CS35L41_OTP_TRIM_9:
-	case CS35L41_OTP_TRIM_10:
-	case CS35L41_OTP_TRIM_11:
-	case CS35L41_OTP_TRIM_12:
-	case CS35L41_OTP_TRIM_13:
-	case CS35L41_OTP_TRIM_14:
-	case CS35L41_OTP_TRIM_15:
-	case CS35L41_OTP_TRIM_16:
-	case CS35L41_OTP_TRIM_17:
-	case CS35L41_OTP_TRIM_18:
-	case CS35L41_OTP_TRIM_19:
-	case CS35L41_OTP_TRIM_20:
-	case CS35L41_OTP_TRIM_21:
-	case CS35L41_OTP_TRIM_22:
-	case CS35L41_OTP_TRIM_23:
-	case CS35L41_OTP_TRIM_24:
-	case CS35L41_OTP_TRIM_25:
-	case CS35L41_OTP_TRIM_26:
-	case CS35L41_OTP_TRIM_27:
-	case CS35L41_OTP_TRIM_28:
-	case CS35L41_OTP_TRIM_29:
-	case CS35L41_OTP_TRIM_30:
-	case CS35L41_OTP_TRIM_31:
-	case CS35L41_OTP_TRIM_32:
-	case CS35L41_OTP_TRIM_33:
-	case CS35L41_OTP_TRIM_34:
-	case CS35L41_OTP_TRIM_35:
-	case CS35L41_OTP_TRIM_36:
 	case CS35L41_DSP_MBOX_1 ... CS35L41_DSP_VIRT2_MBOX_8:
 	case CS35L41_DSP1_XMEM_PACK_0 ... CS35L41_DSP1_XMEM_PACK_3068:
 	case CS35L41_DSP1_XMEM_UNPACK32_0 ... CS35L41_DSP1_XMEM_UNPACK32_2046:
@@ -445,7 +404,11 @@ static bool cs35l41_volatile_reg(struct device *dev, unsigned int reg)
 	case CS35L41_DSP1_YMEM_UNPACK32_0 ... CS35L41_DSP1_YMEM_UNPACK32_1022:
 	case CS35L41_DSP1_YMEM_UNPACK24_0 ... CS35L41_DSP1_YMEM_UNPACK24_2045:
 	case CS35L41_DSP1_PMEM_0 ... CS35L41_DSP1_PMEM_5114:
-	case CS35L41_DSP1_CCM_CORE_CTRL ... CS35L41_DSP1_WDT_STATUS:
+	case CS35L41_DSP1_SCRATCH1:
+	case CS35L41_DSP1_SCRATCH2:
+	case CS35L41_DSP1_SCRATCH3:
+	case CS35L41_DSP1_SCRATCH4:
+	case CS35L41_DSP1_CCM_CLK_OVERRIDE ... CS35L41_DSP1_WDT_STATUS:
 	case CS35L41_OTP_MEM0 ... CS35L41_OTP_MEM31:
 		return true;
 	default:
Signature · 1 line
2.11.0
author maintainer
#6 lore raw

PATCH 6/8 ASoC: wm_adsp: Add support for "toggle" preloaders

In reply to Charles Keepax

In the case a device can support retaining the firmware memory across low power states it is useful for the preloader widget to only power up whilst actually loading/unloading the core, as opposed to the normal operation where the widget is powered for the entire time a firmware is preloaded onto the core. Add support for this mode and a flag to enable it.

---
 sound/soc/codecs/wm_adsp.c | 14 +++++++++++---
 sound/soc/codecs/wm_adsp.h |  8 ++++++++
 2 files changed, 19 insertions(+), 3 deletions(-)
sound/soc/codecs/wm_adsp.c +11 -3
index c3112bf238666..f3672e3d1703e 100644
@@ -896,11 +896,12 @@ int wm_adsp2_preloader_put(struct snd_kcontrol *kcontrol,
 	struct wm_adsp *dsp = &dsps[mc->shift - 1];
 	char preload[32];
 
-	snprintf(preload, ARRAY_SIZE(preload), "%s Preload", dsp->cs_dsp.name);
+	if (dsp->preloaded == ucontrol->value.integer.value[0])
+		return 0;
 
-	dsp->preloaded = ucontrol->value.integer.value[0];
+	snprintf(preload, ARRAY_SIZE(preload), "%s Preload", dsp->cs_dsp.name);
 
-	if (ucontrol->value.integer.value[0])
+	if (ucontrol->value.integer.value[0] || dsp->toggle_preload)
 		snd_soc_component_force_enable_pin(component, preload);
 	else
 		snd_soc_component_disable_pin(component, preload);
@@ -909,6 +910,13 @@ int wm_adsp2_preloader_put(struct snd_kcontrol *kcontrol,
 
 	flush_work(&dsp->boot_work);
 
+	dsp->preloaded = ucontrol->value.integer.value[0];
+
+	if (dsp->toggle_preload) {
+		snd_soc_component_disable_pin(component, preload);
+		snd_soc_dapm_sync(dapm);
+	}
+
 	return 0;
 }
 EXPORT_SYMBOL_GPL(wm_adsp2_preloader_put);
sound/soc/codecs/wm_adsp.h +8 -0
index 0e2f113bd3422..7f4fabbc6ad3a 100644
@@ -41,6 +41,14 @@ struct wm_adsp {
 
 	struct list_head compr_list;
 	struct list_head buffer_list;
+
+	/*
+	 * Flag indicating the preloader widget only needs power toggled
+	 * on state change rather than held on for the duration of the
+	 * preload, useful for devices that can retain firmware memory
+	 * across power down.
+	 */
+	bool toggle_preload;
 };
 
 #define WM_ADSP1(wname, num) \
Signature · 1 line
2.11.0
author maintainer
#2 lore raw

PATCH 2/8 ASoC: cs35l41: Remove incorrect comment

In reply to Charles Keepax

The IRQ is not used for the PDN_DONE bit, this is polled during the DAPM sequence, remove the misleading comment.

---
 sound/soc/codecs/cs35l41.c | 2 --
 1 file changed, 2 deletions(-)
sound/soc/codecs/cs35l41.c +0 -2
index d9e6e84e64d0b..980294c1bcdba 100644
@@ -1338,8 +1338,6 @@ int cs35l41_probe(struct cs35l41_private *cs35l41,
 	ret = devm_request_threaded_irq(cs35l41->dev, cs35l41->irq, NULL, cs35l41_irq,
 					IRQF_ONESHOT | IRQF_SHARED | irq_pol,
 					"cs35l41", cs35l41);
-
-	/* CS35L41 needs INT for PDN_DONE */
 	if (ret != 0) {
 		dev_err(cs35l41->dev, "Failed to request IRQ: %d\n", ret);
 		goto err;
Signature · 1 line
2.11.0
author maintainer
#5 lore raw

PATCH 5/8 firmware: cs_dsp: Clear core reset for cache

In reply to Charles Keepax

If the Halo registers are kept in the register cache the HALO_CORE_RESET bit will be retained as 1 after reset is triggered in cs_dsp_halo_start_core. This will cause subsequent writes to reset the core which is not desired. Apart from this bit the rest of the register bits are cacheable, so for safety sake clear the bit to ensure the cache is consistent.

---
 drivers/firmware/cirrus/cs_dsp.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
drivers/firmware/cirrus/cs_dsp.c +10 -4
index 5af8171d6cedf..e48108e694f8d 100644
@@ -2744,10 +2744,16 @@ EXPORT_SYMBOL_GPL(cs_dsp_stop);
 
 static int cs_dsp_halo_start_core(struct cs_dsp *dsp)
 {
-	return regmap_update_bits(dsp->regmap,
-				  dsp->base + HALO_CCM_CORE_CONTROL,
-				  HALO_CORE_RESET | HALO_CORE_EN,
-				  HALO_CORE_RESET | HALO_CORE_EN);
+	int ret;
+
+	ret = regmap_update_bits(dsp->regmap, dsp->base + HALO_CCM_CORE_CONTROL,
+				 HALO_CORE_RESET | HALO_CORE_EN,
+				 HALO_CORE_RESET | HALO_CORE_EN);
+	if (ret)
+		return ret;
+
+	return regmap_update_bits(dsp->regmap, dsp->base + HALO_CCM_CORE_CONTROL,
+				  HALO_CORE_RESET, 0);
 }
 
 static void cs_dsp_halo_stop_core(struct cs_dsp *dsp)
Signature · 1 line
2.11.0
author maintainer
#1 lore raw

PATCH 1/8 ASoC: cs35l41: Add cs35l51/53 IDs

In reply to Charles Keepax

From: David Rhodes <[email protected]>

Add IDs for the CS35L51/53 variants, the functionality is shared with CS35L41.

---
 sound/soc/codecs/cs35l41-i2c.c | 2 ++
 sound/soc/codecs/cs35l41-spi.c | 2 ++
 2 files changed, 4 insertions(+)
sound/soc/codecs/cs35l41-i2c.c +2 -0
index de5c8612f0307..eb8dfb6d9c950 100644
@@ -22,6 +22,8 @@
 static const struct i2c_device_id cs35l41_id_i2c[] = {
 	{ "cs35l40", 0 },
 	{ "cs35l41", 0 },
+	{ "cs35l51", 0 },
+	{ "cs35l53", 0 },
 	{}
 };
 
sound/soc/codecs/cs35l41-spi.c +2 -0
index c157153f28d87..86bbe2fba956e 100644
@@ -20,6 +20,8 @@
 static const struct spi_device_id cs35l41_id_spi[] = {
 	{ "cs35l40", 0 },
 	{ "cs35l41", 0 },
+	{ "cs35l51", 0 },
+	{ "cs35l53", 0 },
 	{}
 };
 
Signature · 1 line
2.11.0
author maintainer
#3 lore raw

PATCH 3/8 ASoC: cs35l41: Correct DSP power down

In reply to Charles Keepax

The wm_adsp_event should be called before the early_event on power down, event stops the core running and early_event then powers down the core. Additionally, the core should only be stopped if it was actually running in the first place.

---
 sound/soc/codecs/cs35l41.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
sound/soc/codecs/cs35l41.c +8 -4
index 980294c1bcdba..05839fabf97bc 100644
@@ -181,17 +181,21 @@ static SOC_ENUM_SINGLE_DECL(pcm_sft_ramp,
 static int cs35l41_dsp_preload_ev(struct snd_soc_dapm_widget *w,
 				  struct snd_kcontrol *kcontrol, int event)
 {
+	struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
+	struct cs35l41_private *cs35l41 = snd_soc_component_get_drvdata(component);
 	int ret;
 
 	switch (event) {
 	case SND_SOC_DAPM_PRE_PMU:
 		return wm_adsp_early_event(w, kcontrol, event);
 	case SND_SOC_DAPM_PRE_PMD:
-		ret = wm_adsp_early_event(w, kcontrol, event);
-		if (ret)
-			return ret;
+		if (cs35l41->dsp.cs_dsp.running) {
+			ret = wm_adsp_event(w, kcontrol, event);
+			if (ret)
+				return ret;
+		}
 
-		return wm_adsp_event(w, kcontrol, event);
+		return wm_adsp_early_event(w, kcontrol, event);
 	default:
 		return 0;
 	}
Signature · 1 line
2.11.0
author maintainer
#7 lore raw

PATCH 7/8 ASoC: cs35l41: Update handling of test key registers

In reply to Charles Keepax

In 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.

---
 include/sound/cs35l41.h        |  2 ++
 sound/soc/codecs/cs35l41-lib.c | 65 +++++++++++++++++++++---------------------
 sound/soc/codecs/cs35l41.c     | 32 ++++++++++++---------
 3 files changed, 52 insertions(+), 47 deletions(-)
include/sound/cs35l41.h +2 -0
index 29a527457b486..56289b67b9a0e 100644
@@ -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 +32 -33

123 lines not on this page · raw message

sound/soc/codecs/cs35l41.c +18 -14
index 05839fabf97bc..e1b9fd8ee9966 100644
@@ -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

Charles Keepax

author maintainer
#0 lore raw

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.

Patches 1-6 can happily be applied straight away and are mostly bug fixes to set things up for the series specifically around getting the cache handling corrected in the driver.

Patches 7,8 specifically will cause some very minor conflicts with Lucas's currently outstanding work on the HDA version of cs35l41. Whilst things will still build, this patch adds a test key function his code will now have to call. If his patches are getting merged first I will respin this series to update his code, he is currently on holiday until the 12th of Jan, so if we want to wait for another spin of those patches I can work with him to update them at that time. Or alternatively we could just merge them all and I will do a quick fixup patch at the end, since there is no build breakage.

Thanks,
Charles

Charles Keepax (7):
ASoC: cs35l41: Remove incorrect comment
ASoC: cs35l41: Correct DSP power down
ASoC: cs35l41: Correct handling of some registers in the cache
ASoC: cs35l41: Update handling of test key registers
firmware: cs_dsp: Clear core reset for cache
ASoC: wm_adsp: Add support for "toggle" preloaders
ASoC: cs35l41: Add support for hibernate memory retention mode

David Rhodes (1):
ASoC: cs35l41: Add cs35l51/53 IDs

 drivers/firmware/cirrus/cs_dsp.c |  14 ++-
 include/sound/cs35l41.h          |   7 ++
 sound/soc/codecs/cs35l41-i2c.c   |   3 +
 sound/soc/codecs/cs35l41-lib.c   | 152 ++++++++++--------------
 sound/soc/codecs/cs35l41-spi.c   |   3 +
 sound/soc/codecs/cs35l41.c       | 246 +++++++++++++++++++++++++++++++++++----
 sound/soc/codecs/cs35l41.h       |   4 +
 sound/soc/codecs/wm_adsp.c       |  14 ++-
 sound/soc/codecs/wm_adsp.h       |   8 ++
 9 files changed, 328 insertions(+), 123 deletions(-)
Signature · 27 lines
2.11.0

Charles Keepax (7):
  ASoC: cs35l41: Remove incorrect comment
  ASoC: cs35l41: Correct DSP power down
  ASoC: cs35l41: Correct handling of some registers in the cache
  firmware: cs_dsp: Clear core reset for cache
  ASoC: wm_adsp: Add support for "toggle" preloaders
  ASoC: cs35l41: Update handling of test key registers
  ASoC: cs35l41: Add support for hibernate memory retention mode

David Rhodes (1):
  ASoC: cs35l41: Add cs35l51/53 IDs

 drivers/firmware/cirrus/cs_dsp.c |  14 ++-
 include/sound/cs35l41.h          |   7 ++
 sound/soc/codecs/cs35l41-i2c.c   |   3 +
 sound/soc/codecs/cs35l41-lib.c   | 152 ++++++++++--------------
 sound/soc/codecs/cs35l41-spi.c   |   3 +
 sound/soc/codecs/cs35l41.c       | 246 +++++++++++++++++++++++++++++++++++----
 sound/soc/codecs/cs35l41.h       |   4 +
 sound/soc/codecs/wm_adsp.c       |  14 ++-
 sound/soc/codecs/wm_adsp.h       |   8 ++
 9 files changed, 328 insertions(+), 123 deletions(-)

-- 
2.11.0
author maintainer
#8 lore raw

PATCH 8/8 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.

---
 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     | 200 ++++++++++++++++++++++++++++++++++++++++-
 sound/soc/codecs/cs35l41.h     |   4 +
 6 files changed, 213 insertions(+), 4 deletions(-)
include/sound/cs35l41.h +5 -0
index 56289b67b9a0e..bf7f9a9aeba04 100644
@@ -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
index eb8dfb6d9c950..faad5c638cb82 100644
@@ -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
index 4037831a2ca98..215f6e36260bc 100644
@@ -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
index 86bbe2fba956e..6dfd5459aa207 100644
@@ -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 +196 -4

281 lines not on this page · raw message

sound/soc/codecs/cs35l41.h +4 -0
index 26a08d58a8c34..88a3d6e3434fb 100644
@@ -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
#9 lore raw
In reply to Charles Keepax
Quoted 9 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.

Patches 1-6 can happily be applied straight away and are mostly bug fixes to set things up for the series specifically around getting the cache handling corrected in the driver.

Quoted 9 lines

Patches 7,8 specifically will cause some very minor conflicts with Lucas's currently outstanding work on the HDA version of cs35l41. Whilst things will still build, this patch adds a test key function his code will now have to call. If his patches are getting merged first I will respin this series to update his code, he is currently on holiday until the 12th of Jan, so if we want to wait for another spin of those patches I can work with him to update them at that time. Or alternatively we could just merge them all and I will do a quick fixup patch at the end, since there is no build breakage.

FWIW, the ASoC part of Lucas's patch set has been already merged in Mark's asoc tree. (HD-audio part isn't merged yet though).

Takashi

author maintainer
#10 lore raw
Quoted 12 lines · Takashi Iwai
Quoted 9 lines · Charles Keepax

Patches 7,8 specifically will cause some very minor conflicts with Lucas's currently outstanding work on the HDA version of cs35l41. Whilst things will still build, this patch adds a test key function his code will now have to call. If his patches are getting merged first I will respin this series to update his code, he is currently on holiday until the 12th of Jan, so if we want to wait for another spin of those patches I can work with him to update them at that time. Or alternatively we could just merge them all and I will do a quick fixup patch at the end, since there is no build breakage.

Quoted 3 lines

FWIW, the ASoC part of Lucas's patch set has been already merged in Mark's asoc tree. (HD-audio part isn't merged yet though).

Yeah its the HDA part that would require a small change after those last two patches to call the additional function. The series is already based on top of the merged ASoC changes.

Thanks,
Charles

#11 lore raw
Quoted 14 lines · Charles Keepax
Quoted 12 lines · Takashi Iwai
Quoted 9 lines · Charles Keepax

Patches 7,8 specifically will cause some very minor conflicts with Lucas's currently outstanding work on the HDA version of cs35l41. Whilst things will still build, this patch adds a test key function his code will now have to call. If his patches are getting merged first I will respin this series to update his code, he is currently on holiday until the 12th of Jan, so if we want to wait for another spin of those patches I can work with him to update them at that time. Or alternatively we could just merge them all and I will do a quick fixup patch at the end, since there is no build breakage.

Quoted 7 lines
Quoted 3 lines

FWIW, the ASoC part of Lucas's patch set has been already merged in Mark's asoc tree. (HD-audio part isn't merged yet though).

Yeah its the HDA part that would require a small change after those last two patches to call the additional function. The series is already based on top of the merged ASoC changes.

Ah, OK, that's what you commented in Lukas's v6 patchset, right? We can fix it up later after the merge, too.

Right now I'm waiting for the PR from Mark, then will merge v6 patches (modulo the ACPI one).

thanks,

Takashi

author maintainer
#12 lore raw
Quoted 24 lines · Takashi Iwai
Quoted 14 lines · Charles Keepax
Quoted 12 lines · Takashi Iwai
Quoted 9 lines · Charles Keepax

Patches 7,8 specifically will cause some very minor conflicts with Lucas's currently outstanding work on the HDA version of cs35l41. Whilst things will still build, this patch adds a test key function his code will now have to call. If his patches are getting merged first I will respin this series to update his code, he is currently on holiday until the 12th of Jan, so if we want to wait for another spin of those patches I can work with him to update them at that time. Or alternatively we could just merge them all and I will do a quick fixup patch at the end, since there is no build breakage.

Quoted 7 lines
Quoted 3 lines

FWIW, the ASoC part of Lucas's patch set has been already merged in Mark's asoc tree. (HD-audio part isn't merged yet though).

Yeah its the HDA part that would require a small change after those last two patches to call the additional function. The series is already based on top of the merged ASoC changes.

Quoted 5 lines

Ah, OK, that's what you commented in Lukas's v6 patchset, right? We can fix it up later after the merge, too.

Right now I'm waiting for the PR from Mark, then will merge v6 patches (modulo the ACPI one).

Yeah I suspect me just doing a small fix up patch at the end might be the simplest solution.

Thanks,
Charles

maintainer
#13 lore raw
In reply to Charles Keepax
Quoted 3 lines · Charles Keepax

Patches 7,8 specifically will cause some very minor conflicts with Lucas's currently outstanding work on the HDA version of cs35l41. Whilst things will still build, this patch adds a test key function

No they won't, an x86 allmodconfig gives this:

ERROR: modpost: "cs35l41_pm_ops" [sound/soc/codecs/snd-soc-cs35l41-i2c.ko] undefined!
ERROR: modpost: "cs35l41_pm_ops" [sound/soc/codecs/snd-soc-cs35l41-spi.ko] undefined!
ERROR: modpost: "cs35l41_test_key_lock" [sound/soc/codecs/snd-soc-cs35l41.ko] undefined!
ERROR: modpost: "cs35l41_test_key_unlock" [sound/soc/codecs/snd-soc-cs35l41.ko] undefined!

author maintainer
#14 lore raw
Quoted 6 lines · Mark Brown
Quoted 3 lines · Charles Keepax

Patches 7,8 specifically will cause some very minor conflicts with Lucas's currently outstanding work on the HDA version of cs35l41. Whilst things will still build, this patch adds a test key function

Quoted 6 lines

No they won't, an x86 allmodconfig gives this:

ERROR: modpost: "cs35l41_pm_ops" [sound/soc/codecs/snd-soc-cs35l41-i2c.ko] undefined!
ERROR: modpost: "cs35l41_pm_ops" [sound/soc/codecs/snd-soc-cs35l41-spi.ko] undefined!
ERROR: modpost: "cs35l41_test_key_lock" [sound/soc/codecs/snd-soc-cs35l41.ko] undefined!
ERROR: modpost: "cs35l41_test_key_unlock" [sound/soc/codecs/snd-soc-cs35l41.ko] undefined!

Hmm... apologies, let me look into that one.

Thanks,
Charles

maintainer
#15 lore raw
In reply to Charles Keepax
Quoted 9 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.

Patches 1-6 can happily be applied straight away and are mostly bug fixes to set things up for the series specifically around getting the cache handling corrected in the driver.

[...]

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/8] ASoC: cs35l41: Add cs35l51/53 IDs

      commit: dcf821319474edde7e85b95608a4539703a2b67d
[2/8] ASoC: cs35l41: Remove incorrect comment
      commit: 4e7c3cd87db8d9350062a25a8476f90fd1cbc4c9
[3/8] ASoC: cs35l41: Correct DSP power down
      commit: 56852cf4b2179fb90068a49538501f31c2de18ea
[4/8] ASoC: cs35l41: Correct handling of some registers in the cache
      commit: 5f2f539901b0d9bda722637521a11b7f7cf753f1
[5/8] firmware: cs_dsp: Clear core reset for cache
      commit: 7aa1cc1091e0a424e9e7711ca381ebe98b6865bc
[6/8] ASoC: wm_adsp: Add support for "toggle" preloaders
      commit: ba235634b138cd9d012dbe983e7920481211e132

[7/8] ASoC: cs35l41: Update handling of test key registers
(no commit info)
[8/8] ASoC: cs35l41: Add support for hibernate memory retention mode
(no commit info)

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