Skip to contentSkip to conversation

fix the TSHUT issue on rockchip thermal

PATCH In review Caesar Wang 5 participants 10 messages Oct 23, 2015 – Nov 19, 2015

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v4 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 v4:
- take the Doug's commit as correct decription.

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: support the sleep pinctrl state to avoid glitches
in s2r
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 v4 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 v4: None
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
#3 lore raw

PATCH v4 2/3 thermal: rockchip: support the sleep pinctrl state to avoid glitches in s2r

In reply to Caesar Wang

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.

---

Changes in v4:
- take the Doug's commit as correct decription.

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
#5 lore raw

PATCH v4 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 v4: None
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
Acked-by on v4 1/3
#2 lore raw

Re: [PATCH v4 1/3] dt-bindings: rockchip-thermal: Add the pinctrl states in this document

In reply to Caesar Wang
Quoted 16 lines · Caesar Wang

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.

Quoted 8 lines

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.

Quoted 49 lines

---

Changes in v4: None
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 -3
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>;
--

1.9.1

#6 lore raw

Re: [PATCH v4 3/3] ARM: dts: rockchip: Add the OTP gpio pinctrl

In reply to Caesar Wang

Hi,

Quoted 20 lines · 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 v4: None
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]

Quoted 7 lines

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(-)

I realized that the subject of this patch should probably contain the word rk3288, but I presume Heiko would rather add that himself than for you to spin this again. ;)

-Doug

Reviewed-by on v4 2/3
#4 lore raw

Re: [PATCH v4 2/3] thermal: rockchip: support the sleep pinctrl state to avoid glitches in s2r

In reply to Caesar Wang

Caesar,

Quoted 19 lines · Caesar Wang

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.

---

Changes in v4:
- take the Doug's commit as correct decription.

Quoted 8 lines

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(+)
maintainer
#7 lore raw

Re: [PATCH v4 3/3] ARM: dts: rockchip: Add the OTP gpio pinctrl

In reply to Doug Anderson

Am Freitag, 23. Oktober 2015, 08:25:08 schrieb Doug Anderson:

Quoted 27 lines · Caesar Wang
Quoted 26 lines

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 v4: None

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.

Quoted 8 lines
Quoted 4 lines

- As the Doug's patch to add the 'init' property.

 arch/arm/boot/dts/rk3288.dtsi | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

I realized that the subject of this patch should probably contain the word rk3288, but I presume Heiko would rather add that himself than for you to spin this again. ;)

yep :-) ... no need to respin for such an easy change.

#8 lore raw

Re: [PATCH v4 3/3] ARM: dts: rockchip: Add the OTP gpio pinctrl

Hi Heiko,

? 2015?10?25? 15:55, Heiko St?bner ??:

Quoted 28 lines

Am Freitag, 23. Oktober 2015, 08:25:08 schrieb Doug Anderson:

Quoted 27 lines · Caesar Wang
Quoted 26 lines

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 v4: None

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.

Quoted 8 lines
Quoted 7 lines
Quoted 4 lines

- As the Doug's patch to add the 'init' property.

  arch/arm/boot/dts/rk3288.dtsi | 10 ++++++++--
  1 file changed, 8 insertions(+), 2 deletions(-)

I realized that the subject of this patch should probably contain the word rk3288, but I presume Heiko would rather add that himself than for you to spin this again. ;)

yep :-) ... no need to respin for such an easy change

That's seem this patch didn't merge into your v4.5-armsoc/soc branch.:-)

I guess this patch should merge into kernel-4.4 since the Patch[1/3] / [2/3] have been merged into 4.4-rc1.:-P

Quoted 5 lines

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

Signature · 2 lines
Thanks,
Caesar
maintainer
#9 lore raw

Re: [PATCH v4 3/3] ARM: dts: rockchip: Add the OTP gpio pinctrl

Hi Caesar,

Am Donnerstag, 19. November 2015, 10:44:02 schrieb Caesar Wang:

Quoted 36 lines

? 2015?10?25? 15:55, Heiko St?bner ??:

Quoted 35 lines

Am Freitag, 23. Oktober 2015, 08:25:08 schrieb Doug Anderson:

Quoted 34 lines · Caesar Wang
Quoted 24 lines

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 v4: None

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

Quoted 6 lines

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(-)

I realized that the subject of this patch should probably contain the word rk3288, but I presume Heiko would rather add that himself than for you to spin this again. ;)

Quoted 6 lines
Quoted 1 line

yep :-) ... no need to respin for such an easy change

That's seem this patch didn't merge into your v4.5-armsoc/soc branch.:-)

I guess this patch should merge into kernel-4.4 since the Patch[1/3] / [2/3] have been merged into 4.4-rc1.:-P

thanks for the reminder :-)

It seems I didn't get a notice when the core thermal changes were merged, so this patch seems to have dropped of my radar. It is clearly a fix for a real issue, so I've added it to my fixes branch for 4.4.

Heiko