Skip to contentSkip to conversation

clk: qcom: gdsc: Keep RETAIN_FF bit set if gdsc is already on

PATCH Applied Stephen Boyd 3 participants 4 messages Oct 17, 2020 – Oct 20, 2020

Subsystems (3)
lore
Share & tools
lore

Stephen Boyd

author maintainer
#0 lore raw

PATCH 1/1 clk: qcom: gdsc: Keep RETAIN_FF bit set if gdsc is already on

If the GDSC is enabled out of boot but doesn't have the retain ff bit set we will get confusing results where the registers that are powered by the GDSC lose their contents on the first power off of the GDSC but thereafter they retain their contents. This is because gdsc_init() fails to make sure the RETAIN_FF bit is set when it probes the GDSC the first time and thus powering off the GDSC causes the register contents to be reset. We do set the RETAIN_FF bit the next time we power on the GDSC, see gdsc_enable(), so that subsequent GDSC power off's don't lose register contents state.

Forcibly set the bit at device probe time so that the kernel's assumed view of the GDSC is consistent with the state of the hardware. This fixes a problem where the audio PLL doesn't work on sc7180 when the bootloader leaves the lpass_core_hm GDSC enabled at boot (e.g. to make a noise) but critically doesn't set the RETAIN_FF bit.

Cc Douglas Anderson <[email protected]>
Cc Taniya Das <[email protected]>
Cc Rajendra Nayak <[email protected]>
Fixes 173722995cdb ("clk: qcom: gdsc: Add support to enable retention of GSDCR")
---
 drivers/clk/qcom/gdsc.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/clk/qcom/gdsc.c +8 -0
index bfc4ac02f9ea..af26e0695b86 100644
@@ -358,6 +358,14 @@ static int gdsc_init(struct gdsc *sc)
 	if ((sc->flags & VOTABLE) && on)
 		gdsc_enable(&sc->pd);
 
+	/*
+	 * Make sure the retain bit is set if the GDSC is already on, otherwise
+	 * we end up turning off the GDSC and destroying all the register
+	 * contents that we thought we were saving.
+	 */
+	if ((sc->flags & RETAIN_FF_ENABLE) && on)
+		gdsc_retain_ff_on(sc);
+
 	/* If ALWAYS_ON GDSCs are not ON, turn them ON */
 	if (sc->flags & ALWAYS_ON) {
 		if (!on)

base-commit: 9ff9b0d392ea08090cd1780fb196f36dbb586529

Signature · 1 line
https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git/
Reviewed-by on v1 1/1
#1 lore raw
Quoted 47 lines · Stephen Boyd

If the GDSC is enabled out of boot but doesn't have the retain ff bit set we will get confusing results where the registers that are powered by the GDSC lose their contents on the first power off of the GDSC but thereafter they retain their contents. This is because gdsc_init() fails to make sure the RETAIN_FF bit is set when it probes the GDSC the first time and thus powering off the GDSC causes the register contents to be reset. We do set the RETAIN_FF bit the next time we power on the GDSC, see gdsc_enable(), so that subsequent GDSC power off's don't lose register contents state.

Forcibly set the bit at device probe time so that the kernel's assumed view of the GDSC is consistent with the state of the hardware. This fixes a problem where the audio PLL doesn't work on sc7180 when the bootloader leaves the lpass_core_hm GDSC enabled at boot (e.g. to make a noise) but critically doesn't set the RETAIN_FF bit.

Cc Douglas Anderson <[email protected]>
Cc Taniya Das <[email protected]>
Cc Rajendra Nayak <[email protected]>
Fixes 173722995cdb ("clk: qcom: gdsc: Add support to enable retention of GSDCR")
---
  drivers/clk/qcom/gdsc.c | 8 ++++++++
  1 file changed, 8 insertions(+)
drivers/clk/qcom/gdsc.c +8 -0
index bfc4ac02f9ea..af26e0695b86 100644
@@ -358,6 +358,14 @@ static int gdsc_init(struct gdsc *sc)
  	if ((sc->flags & VOTABLE) && on)
  		gdsc_enable(&sc->pd);
 
+	/*
+	 * Make sure the retain bit is set if the GDSC is already on, otherwise
+	 * we end up turning off the GDSC and destroying all the register
+	 * contents that we thought we were saving.
+	 */
+	if ((sc->flags & RETAIN_FF_ENABLE) && on)
+		gdsc_retain_ff_on(sc);
+
  	/* If ALWAYS_ON GDSCs are not ON, turn them ON */
  	if (sc->flags & ALWAYS_ON) {
  		if (!on)

base-commit: 9ff9b0d392ea08090cd1780fb196f36dbb586529

Signature · 4 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation.

--
Reviewed-by Tested-by on v1 1/1
#2 lore raw
In reply to Stephen Boyd

Hi,

Quoted 17 lines · Stephen Boyd

If the GDSC is enabled out of boot but doesn't have the retain ff bit set we will get confusing results where the registers that are powered by the GDSC lose their contents on the first power off of the GDSC but thereafter they retain their contents. This is because gdsc_init() fails to make sure the RETAIN_FF bit is set when it probes the GDSC the first time and thus powering off the GDSC causes the register contents to be reset. We do set the RETAIN_FF bit the next time we power on the GDSC, see gdsc_enable(), so that subsequent GDSC power off's don't lose register contents state.

Forcibly set the bit at device probe time so that the kernel's assumed view of the GDSC is consistent with the state of the hardware. This fixes a problem where the audio PLL doesn't work on sc7180 when the bootloader leaves the lpass_core_hm GDSC enabled at boot (e.g. to make a noise) but critically doesn't set the RETAIN_FF bit.

Quoted 8 lines
Cc Douglas Anderson <[email protected]>
Cc Taniya Das <[email protected]>
Cc Rajendra Nayak <[email protected]>
Fixes 173722995cdb ("clk: qcom: gdsc: Add support to enable retention of GSDCR")
---
 drivers/clk/qcom/gdsc.c | 8 ++++++++
 1 file changed, 8 insertions(+)
author maintainer Applied
#3 lore raw
In reply to Stephen Boyd

Quoting Stephen Boyd (2020-10-16 19:01:37)

Quoted 16 lines

If the GDSC is enabled out of boot but doesn't have the retain ff bit set we will get confusing results where the registers that are powered by the GDSC lose their contents on the first power off of the GDSC but thereafter they retain their contents. This is because gdsc_init() fails to make sure the RETAIN_FF bit is set when it probes the GDSC the first time and thus powering off the GDSC causes the register contents to be reset. We do set the RETAIN_FF bit the next time we power on the GDSC, see gdsc_enable(), so that subsequent GDSC power off's don't lose register contents state.

Forcibly set the bit at device probe time so that the kernel's assumed view of the GDSC is consistent with the state of the hardware. This fixes a problem where the audio PLL doesn't work on sc7180 when the bootloader leaves the lpass_core_hm GDSC enabled at boot (e.g. to make a noise) but critically doesn't set the RETAIN_FF bit.

Quoted 6 lines
Cc Douglas Anderson <[email protected]>
Cc Taniya Das <[email protected]>
Cc Rajendra Nayak <[email protected]>
Fixes 173722995cdb ("clk: qcom: gdsc: Add support to enable retention of GSDCR")

---

Applied to clk-next