Skip to contentSkip to conversation

fix the TSHUT issue on rockchip thermal

PATCH Superseded Caesar Wang 4 participants 7 messages Oct 23, 2015

Subsystems (3)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v3 cover fix the TSHUT issue on rockchip thermal

Thank you all for providing inputs and comments on previous versions of this patchset.
Especially thanks to the (Doug, Rob....).

We need the OTP pin is gpio state before resetting the TSADC controller, since the tshut polarity will generate a high signal.

Says:
The TSHUT temperature is setting more than 80 degree, the default tshut polarity is HIGH.

If T > 80C, the OTP output the High Signal.
If T < 80C, the OTP output the Low Signal.

On the moment, the TSADC controller is reset, the tshut polarity will be Low in a short period of time.

So:
If T < 80C, the OTP output the High Signal.
If T > 80C, the OTP output the Low Signal.

In some cases, the OTP pin is connected to the PMIC, maybe the PMIC can accept the reset response time to avoid this issue.

In other words, the system will be always reboot if we make the OTP pin is connected the others IC to control the power.

This series patchs are depend on Doug's patch.(https://patchwork.kernel.org/patch/7454311/)

This series patchs are based on the Linus master branch.

518cd44 ARM: dts: rockchip: Add the OTP gpio pinctrl
83e0bab dt-bindings: Add the "init" pinctrl in this document
150426c drivers/pinctrl: Add the concept of an "init" state
ce1fad2 Merge branch 'keys-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs
1099f86 Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
911b79c KEYS: Don't permit request_key() to construct a new keyring
37850e3 net: bcmgenet: Fix early link interrupt enabling
afc050d Merge tag 'wireless-drivers-for-davem-2015-10-17' of git://git.kernel.org/pub/scm/linux/kernel/git/kvalo/wireless-drivers
e277de5 tunnels: Don't require remote endpoint or ID during creation.
740dbc2 openvswitch: Scrub skb between namespaces
....

Tested on box board.

Changes in v3:
- Add the pictrl states decription in document.
- Add the pinctrl state for in the suspend/resume.
- Add the "sleep" pinctrl as the gpio state in PATCH[3/3]

Changes in v2:
- Add the 'init' pinctrl more decription in commit.
- Fix the subject to make more obvious in PATCH[1/2]
- Resend this patch v2 since fix the subject to be specific.
- Add some commits for more obvious in PATCH[2/2]

Changes in v1:
- As the Doug comments, add the 'init' property to sync document.
- As the Doug comments, drop the thermal driver patchs since we can with pinctrl changing to work.
- As the Doug's patch to add the 'init' property.

Caesar Wang (3):
dt-bindings: rockchip-thermal: Add the pinctrl states in this document
thermal: rockchip: ensure the otp states before resetting the
controller
ARM: dts: rockchip: Add the OTP gpio pinctrl

 .../devicetree/bindings/thermal/rockchip-thermal.txt          | 11 +++++++++--
 arch/arm/boot/dts/rk3288.dtsi                                 | 10 ++++++++--
 drivers/thermal/rockchip_thermal.c                            |  4 ++++
 3 files changed, 21 insertions(+), 4 deletions(-)
Signature · 1 line
1.9.1
#1 lore raw

PATCH v3 1/3 dt-bindings: rockchip-thermal: Add the pinctrl states in this document

The "init" pinctrl is defined we'll set
pinctrl to this state before probe and then "default" after probe. Add the "init" and "sleep" pinctrl as the OTP gpio state, since we need switch the pin to gpio state before the TSADC controller is reset.

AFAIK, the TSADC controller is reset, the tshut polarity will be a *low* signal in a short period of time for some devices.

Says:
The TSADC get the temperature on rockchip thermal.

If T(current temperature) < (setting temperature), the OTP output the *high* signal.
If T(current temperature) > (setting temperature), the OTP output the *low* Signal.

In some cases, the OTP pin is connected to the PMIC, maybe the PMIC can accept the reset response time to avoid this issue.

In other words, the system will be always reboot if we make the OTP pin is connected the others IC to control the power.

---

Changes in v3:
- Add the pictrl states decription in document.

Changes in v2:
- Add the 'init' pinctrl more decription in commit.
- Fix the subject to make more obvious in PATCH[1/2]
- Resend this patch v2 since fix the subject to be specific.

Changes in v1:
- As the Doug comments, add the 'init' property to sync document.

 .../devicetree/bindings/thermal/rockchip-thermal.txt          | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/thermal/rockchip-thermal.txt +9 -2
index ef802de..b38200d 100644
@@ -12,6 +12,11 @@ Required properties:
 - resets : Must contain an entry for each entry in reset-names.
 	   See ../reset/reset.txt for details.
 - reset-names : Must include the name "tsadc-apb".
+- pinctrl-names : The pin control state names;
+- pinctrl-0 : The "init" pinctrl state, it will be set before device probe.
+- pinctrl-1 : The "default" pinctrl state, it will be set after reset the
+	      TSADC controller.
+- pinctrl-2 : The "sleep" pinctrl state, it will be in for suspend.
 - #thermal-sensor-cells : Should be 1. See ./thermal.txt for a description.
 - rockchip,hw-tshut-temp : The hardware-controlled shutdown temperature value.
 - rockchip,hw-tshut-mode : The hardware-controlled shutdown mode 0:CRU 1:GPIO.
@@ -27,8 +32,10 @@ tsadc: tsadc at ff280000 {
 	clock-names = "tsadc", "apb_pclk";
 	resets = <&cru SRST_TSADC>;
 	reset-names = "tsadc-apb";
-	pinctrl-names = "default";
-	pinctrl-0 = <&otp_out>;
+	pinctrl-names = "init", "default", "sleep";
+	pinctrl-0 = <&otp_gpio>;
+	pinctrl-1 = <&otp_out>;
+	pinctrl-2 = <&otp_gpio>;
 	#thermal-sensor-cells = <1>;
 	rockchip,hw-tshut-temp = <95000>;
 	rockchip,hw-tshut-mode = <0>;
Signature · 1 line
1.9.1
#2 lore raw

PATCH v3 2/3 thermal: rockchip: ensure the otp states before resetting the controller

In reply to Caesar Wang

We need the OTP pin is gpio state before resetting the TSADC controller, since the tshut polarity will generate a high signal.

Says:
The TSHUT temperature is setting more than 80 degree, the default tshut polarity is high.

If T > 80C, the OTP output the high signal.
If T < 80C, the OTP output the low signal.

On the moment, the tshut polarity will be low in a short period of time if the TSADC controller is reset.

So:
If T < 80C, the OTP output the High Signal.
If T > 80C, the OTP output the Low Signal.

In some cases, the OTP pin is connected to the PMIC, maybe the PMIC can accept the reset response time to avoid this issue.
In other words, the system will be always reboot if we
make the OTP pin is connected the others IC to control the power.

---

Changes in v3:
- Add the pinctrl state for in the suspend/resume.

Changes in v2: None
Changes in v1: None

 drivers/thermal/rockchip_thermal.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/thermal/rockchip_thermal.c +4 -0
index c89ffb2..3b8fbda 100644
@@ -642,6 +642,8 @@ static int __maybe_unused rockchip_thermal_suspend(struct device *dev)
 	clk_disable(thermal->pclk);
 	clk_disable(thermal->clk);
 
+	pinctrl_pm_select_sleep_state(dev);
+
 	return 0;
 }
 
@@ -678,6 +680,8 @@ static int __maybe_unused rockchip_thermal_resume(struct device *dev)
 	for (i = 0; i < ARRAY_SIZE(thermal->sensors); i++)
 		rockchip_thermal_toggle_sensor(&thermal->sensors[i], true);
 
+	pinctrl_pm_select_default_state(dev);
+
 	return 0;
 }
 
Signature · 1 line
1.9.1
#6 lore raw

PATCH v3 3/3 ARM: dts: rockchip: Add the OTP gpio pinctrl

In reply to Caesar Wang

Add the "init" anf "sleep" pinctrl as the OTP gpio state.
We need the OTP pin is gpio state before resetting the TSADC controller, since the tshut polarity will generate a high signal.

"init" pinctrl property is defined by Doug's Patch[0].

Patch[0]:
https://patchwork.kernel.org/patch/7454311/

---

Changes in v3:
- Add the "sleep" pinctrl as the gpio state in PATCH[3/3]

Changes in v2:
- Add some commits for more obvious in PATCH[2/2]

Changes in v1:
- As the Doug comments, drop the thermal driver patchs since we can with pinctrl changing to work.
- As the Doug's patch to add the 'init' property.

 arch/arm/boot/dts/rk3288.dtsi | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
arch/arm/boot/dts/rk3288.dtsi +8 -2
index 906e938..13ff09a 100644
@@ -447,8 +447,10 @@
 		clock-names = "tsadc", "apb_pclk";
 		resets = <&cru SRST_TSADC>;
 		reset-names = "tsadc-apb";
-		pinctrl-names = "default";
-		pinctrl-0 = <&otp_out>;
+		pinctrl-names = "init", "default", "sleep";
+		pinctrl-0 = <&otp_gpio>;
+		pinctrl-1 = <&otp_out>;
+		pinctrl-2 = <&otp_gpio>;
 		#thermal-sensor-cells = <1>;
 		rockchip,hw-tshut-temp = <95000>;
 		status = "disabled";
@@ -1273,6 +1275,10 @@
 		};
 
 		tsadc {
+			otp_gpio: otp-gpio {
+				rockchip,pins = <0 10 RK_FUNC_GPIO &pcfg_pull_none>;
+			};
+
 			otp_out: otp-out {
 				rockchip,pins = <0 10 RK_FUNC_1 &pcfg_pull_none>;
 			};
Signature · 1 line
1.9.1
#3 lore raw

Re: [PATCH v3 2/3] thermal: rockchip: ensure the otp states before resetting the controller

In reply to Caesar Wang

Caesar,

Quoted 49 lines · Caesar Wang

We need the OTP pin is gpio state before resetting the TSADC controller, since the tshut polarity will generate a high signal.

Says:
The TSHUT temperature is setting more than 80 degree, the default tshut polarity is high.

If T > 80C, the OTP output the high signal.
If T < 80C, the OTP output the low signal.

On the moment, the tshut polarity will be low in a short period of time if the TSADC controller is reset.

So:
If T < 80C, the OTP output the High Signal.
If T > 80C, the OTP output the Low Signal.

In some cases, the OTP pin is connected to the PMIC, maybe the PMIC can accept the reset response time to avoid this issue.
In other words, the system will be always reboot if we
make the OTP pin is connected the others IC to control the power.

---

Changes in v3:
- Add the pinctrl state for in the suspend/resume.

Changes in v2: None
Changes in v1: None

 drivers/thermal/rockchip_thermal.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/thermal/rockchip_thermal.c +2 -0
index c89ffb2..3b8fbda 100644
@@ -642,6 +642,8 @@ static int __maybe_unused rockchip_thermal_suspend(struct device *dev)
        clk_disable(thermal->pclk);
        clk_disable(thermal->clk);
 
+       pinctrl_pm_select_sleep_state(dev);
+
        return 0;
 }
 

drivers/thermal/rockchip_thermal.c static int __maybe_unused rockchip_thermal_resume(struct device *dev) · line 686

Quoted 7 lines
drivers/thermal/rockchip_thermal.c +2 -0
@@ -678,6 +680,8 @@ static int __maybe_unused rockchip_thermal_resume(struct device *dev)
        for (i = 0; i < ARRAY_SIZE(thermal->sensors); i++)
                rockchip_thermal_toggle_sensor(&thermal->sensors[i], true);
 
+       pinctrl_pm_select_default_state(dev);
+
        return 0;
 }

The patch looks totally fine, but the description is a little confusing. Reading this patch it's all about adding support for the "sleep" state in the tsadc driver, but nothing in the description talks about that. I'd expect something like:

thermal: rockchip: support the sleep pinctrl state to avoid glitches in s2r

When we come out of system suspend state (S3) the tsadc will have been reset and back at its default state. While reprogramming the tsadc it's possible that we'll glitch the output and unintentionally cause the "over temperature" GPIO to be asserted. Since the over temperature GPIO is often hooked up to something that will cause a reboot or shutdown in hardware, this glitch can be catastrophic on some boards.

We'll add support for selecting the "sleep" pinctrl state at suspend time. Boards can use this to effectively disable the tsadc at suspend time and avoid glitches when the system is resumed.

---

Note that although this pinctrl approach is fine IMHO, I am left wondering whether we could just change the tsadc init sequence to avoid the glitch. I can't easily test myself, but if we can program the temperatures before re-enabling the tsadc would it avoid the problem too? Like could we just swap things like:

                thermal->chip->set_tshut_temp(id, thermal->regs,
                                              thermal->hw_shut_temp);
                thermal->chip->set_tshut_mode(id, thermal->regs,
                                              thermal->tshut_mode);

Does that help?

-Doug

#4 lore raw

Re: [PATCH v3 2/3] thermal: rockchip: ensure the otp states before resetting the controller

? 2015?10?23? 12:04, Doug Anderson ??:

Quoted 74 lines

Caesar,

Quoted 49 lines · Caesar Wang

We need the OTP pin is gpio state before resetting the TSADC controller, since the tshut polarity will generate a high signal.

Says:
The TSHUT temperature is setting more than 80 degree, the default tshut polarity is high.

If T > 80C, the OTP output the high signal.
If T < 80C, the OTP output the low signal.

On the moment, the tshut polarity will be low in a short period of time if the TSADC controller is reset.

So:
If T < 80C, the OTP output the High Signal.
If T > 80C, the OTP output the Low Signal.

In some cases, the OTP pin is connected to the PMIC, maybe the PMIC can accept the reset response time to avoid this issue.
In other words, the system will be always reboot if we
make the OTP pin is connected the others IC to control the power.

---

Changes in v3:
- Add the pinctrl state for in the suspend/resume.

Changes in v2: None
Changes in v1: None

  drivers/thermal/rockchip_thermal.c | 4 ++++
  1 file changed, 4 insertions(+)
drivers/thermal/rockchip_thermal.c +2 -0
index c89ffb2..3b8fbda 100644
@@ -642,6 +642,8 @@ static int __maybe_unused rockchip_thermal_suspend(struct device *dev)
         clk_disable(thermal->pclk);
         clk_disable(thermal->clk);
 
+       pinctrl_pm_select_sleep_state(dev);
+
         return 0;
  }
 

drivers/thermal/rockchip_thermal.c static int __maybe_unused rockchip_thermal_resume(struct device *dev) · line 686

Quoted 7 lines
drivers/thermal/rockchip_thermal.c +2 -0
@@ -678,6 +680,8 @@ static int __maybe_unused rockchip_thermal_resume(struct device *dev)
         for (i = 0; i < ARRAY_SIZE(thermal->sensors); i++)
                 rockchip_thermal_toggle_sensor(&thermal->sensors[i], true);
 
+       pinctrl_pm_select_default_state(dev);
+
         return 0;
  }

The patch looks totally fine, but the description is a little confusing. Reading this patch it's all about adding support for the "sleep" state in the tsadc driver, but nothing in the description talks about that. I'd expect something like:

thermal: rockchip: support the sleep pinctrl state to avoid glitches in s2r

When we come out of system suspend state (S3) the tsadc will have been reset and back at its default state. While reprogramming the tsadc it's possible that we'll glitch the output and unintentionally cause the "over temperature" GPIO to be asserted. Since the over temperature GPIO is often hooked up to something that will cause a reboot or shutdown in hardware, this glitch can be catastrophic on some boards.

Quoted 3 lines

We'll add support for selecting the "sleep" pinctrl state at suspend time. Boards can use this to effectively disable the tsadc at suspend time and avoid glitches when the system is resumed.

Thanks Doug to take your time reviewing this series patchs. The commit is very good for this patch.

Quoted 8 lines

---

Note that although this pinctrl approach is fine IMHO, I am left wondering whether we could just change the tsadc init sequence to avoid the glitch. I can't easily test myself, but if we can program the temperatures before re-enabling the tsadc would it avoid the problem too?

It's the chip behaviour, the glitches is aways occured by reset controller. The best way need change to the gpio state before reset the controller.

Quoted 9 lines

Like could we just swap things like:

                 thermal->chip->set_tshut_temp(id, thermal->regs,
                                               thermal->hw_shut_temp);
                 thermal->chip->set_tshut_mode(id, thermal->regs,
                                               thermal->tshut_mode);

Does that help?

It didn't work on box board.

Quoted 8 lines

-Doug

_______________________________________________
Linux-rockchip mailing list
Linux-rockchip at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

#5 lore raw

Re: [PATCH v3 2/3] thermal: rockchip: ensure the otp states before resetting the controller

In reply to Doug Anderson

? 2015?10?23? 12:04, Doug Anderson ??:

Quoted 74 lines

Caesar,

Quoted 49 lines · Caesar Wang

We need the OTP pin is gpio state before resetting the TSADC controller, since the tshut polarity will generate a high signal.

Says:
The TSHUT temperature is setting more than 80 degree, the default tshut polarity is high.

If T > 80C, the OTP output the high signal.
If T < 80C, the OTP output the low signal.

On the moment, the tshut polarity will be low in a short period of time if the TSADC controller is reset.

So:
If T < 80C, the OTP output the High Signal.
If T > 80C, the OTP output the Low Signal.

In some cases, the OTP pin is connected to the PMIC, maybe the PMIC can accept the reset response time to avoid this issue.
In other words, the system will be always reboot if we
make the OTP pin is connected the others IC to control the power.

---

Changes in v3:
- Add the pinctrl state for in the suspend/resume.

Changes in v2: None
Changes in v1: None

  drivers/thermal/rockchip_thermal.c | 4 ++++
  1 file changed, 4 insertions(+)
drivers/thermal/rockchip_thermal.c +2 -0
index c89ffb2..3b8fbda 100644
@@ -642,6 +642,8 @@ static int __maybe_unused rockchip_thermal_suspend(struct device *dev)
         clk_disable(thermal->pclk);
         clk_disable(thermal->clk);
 
+       pinctrl_pm_select_sleep_state(dev);
+
         return 0;
  }
 

drivers/thermal/rockchip_thermal.c static int __maybe_unused rockchip_thermal_resume(struct device *dev) · line 686

Quoted 7 lines
drivers/thermal/rockchip_thermal.c +2 -0
@@ -678,6 +680,8 @@ static int __maybe_unused rockchip_thermal_resume(struct device *dev)
         for (i = 0; i < ARRAY_SIZE(thermal->sensors); i++)
                 rockchip_thermal_toggle_sensor(&thermal->sensors[i], true);
 
+       pinctrl_pm_select_default_state(dev);
+
         return 0;
  }

The patch looks totally fine, but the description is a little confusing. Reading this patch it's all about adding support for the "sleep" state in the tsadc driver, but nothing in the description talks about that. I'd expect something like:

thermal: rockchip: support the sleep pinctrl state to avoid glitches in s2r

When we come out of system suspend state (S3) the tsadc will have been reset and back at its default state. While reprogramming the tsadc it's possible that we'll glitch the output and unintentionally cause the "over temperature" GPIO to be asserted. Since the over temperature GPIO is often hooked up to something that will cause a reboot or shutdown in hardware, this glitch can be catastrophic on some boards.

Quoted 3 lines

We'll add support for selecting the "sleep" pinctrl state at suspend time. Boards can use this to effectively disable the tsadc at suspend time and avoid glitches when the system is resumed.

Thanks Doug to take your time reviewing this series patchs. The commit is very good for this patch.

Quoted 8 lines

---

Note that although this pinctrl approach is fine IMHO, I am left wondering whether we could just change the tsadc init sequence to avoid the glitch. I can't easily test myself, but if we can program the temperatures before re-enabling the tsadc would it avoid the problem too?

It's the chip behaviour, the glitches is aways occured by reset controller. The best way need change to the gpio state before reset the controller.

Quoted 9 lines

Like could we just swap things like:

                 thermal->chip->set_tshut_temp(id, thermal->regs,
                                               thermal->hw_shut_temp);
                 thermal->chip->set_tshut_mode(id, thermal->regs,
                                               thermal->tshut_mode);

Does that help?

It didn't work on box board.

Quoted 8 lines

-Doug

_______________________________________________
Linux-rockchip mailing list
Linux-rockchip at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

Signature · 2 lines
Thanks,
Caesar