Skip to contentSkip to conversation

Rockchip soc thermal driver

PATCH Superseded Caesar Wang 2 participants 8 messages Oct 29, 2014 – Oct 31, 2014

Subsystems (3)

v16 of 19 Superseded Latest is v19 →

lore
Share & tools
lore
#0 lore raw

v16 cover Rockchip soc thermal driver

This series patchs tested on rk3288 SDK board and pinky-v1,v2 board. I believe the driver can be used on the rk3288-evb board.

Add this driver, The system will shutdown when
the thermal temperture over 120C.If for some reason we are unable to shut it down in orderly fashion (kernel is stuck holding a lock or similar) then hardware will reset it.

Changes in v16:
* address comments from Dmitry Torokhov.
- add thermal->chip->control(thermal->regs, false) in remove()
- adjust TSHUT in resume().

Changes in v15:
* address comments from Dmitry Torokhov.
- enable TSHUT move into rk_tsadcv2_tshut_temp().
- drop the id argument in rk_tsadcv2_control().

Changes in v14:
* address comments from Dmitry Torokhov.
- adjust-alarm-rate-depending-on-clock.
- 0001-rockchip-thermal-do-not-register-cpufreq-cooling-dev.

Changes in v13:
- add cooling-maps for cpu-thermal.
- put tshut polarity in device tree.

Changes in v12:
* address comments from Dmitry Torokhov and Vladimir Zapolskiy.
- split-sensor-handling.
- rename-rockchip_tsadc_platform_data.

Changes in v11:
* address comments from Vladimir Zapolskiy.
- fix cpufreq_cooling_unregister() to put in correct position.
- fix "data->chn",at least can get valid Tsensor temp.

Changes in v10:
* address comments from Doug Anderson.
- fix TSHUT polarity,ensure support TSHUT.
- add the decription for rk_tsadcv2_initialize().

Changes in v9:
* address comments from Dmitry Torokhov.
- fix some style be defined
- remove some unused code.
- clk_disable_unprepare->clk_disable in suspend()

Changes in v8:
* address comments from Dmitry Torokhov and Doug Anderson.
- add three Teperture Sensors.
- support CRU and GPIO reset chip.
- rename rk3xxx-cpu-thermal.dtsi as rk3288-thermal.dtsi
- alarm-temp via set_trips() callback
- remove "reset-gpios"

Changes in v7:
- fix get data->clk=0 when in probe() function.
- fix some style code.
- modify dts,main add rk3xxx-cpu-thermal.dtsi

Changes in v6:
* address comments from Tomeu Vizoso.
- use thermal's generic framework.

Changes in v5:
* address comments from Eduardo Valentin,rui.zhang and Heiko Stubner:
- with BIT() macro
- manage clocks in suspend/resume.
- license is fixed as GPLv2.
- #include "thermal_core.h"->#include <linux/thermal.h>
- use the generic trip-points.the hw-shut-temp isn't generic trip-points.
- The method of binding and unbinding be fixed.
- The pin-name tsadc->otp_out

Changes in v4:
* address comments from Jonathan Cameron,huangtao and zhaoyifeng:
- this series thermal driver still be put in driver/thermal/
- modify the thermal driver description.

Changes in v3:(add dts configure)
* address comments from Dmitry Torokhov and Arnd Bergmann:
- fix clock-names in rockchip-thermal.txt
- remove rockchip_thermal_control() in rockchip_set_mode()
- fix some code style.
- add dts configure.

Changes in v2:
* address comments from Heiko Stubner:
- fix dt-bindings in rockchip-thermal.txt
- remove Author mark
- rename TSADC_XXX->TSADCV2_XXX,it eill ready to merge compatible other SoCs.
- fix a identation
- remove clk_set_rate(),it's no necessary.
- fix the SIMPLE_DEV_PM_OPS() function style.

Caesar Wang (5):
thermal: rockchip: add driver for thermal
dt-bindings: document Rockchip thermal
ARM: dts: add RK3288 Thermal data
ARM: dts: add main Thermal info to rk3288
ARM: dts: enable Thermal on rk3288-evb board

 .../bindings/thermal/rockchip-thermal.txt          |  45 ++
 arch/arm/boot/dts/rk3288-evb.dtsi                  |   5 +
 arch/arm/boot/dts/rk3288-thermal.dtsi              |  58 ++
 arch/arm/boot/dts/rk3288.dtsi                      |  23 +
 drivers/thermal/Kconfig                            |   9 +
 drivers/thermal/Makefile                           |   1 +
 drivers/thermal/rockchip_thermal.c                 | 628 +++++++++++++++++++++
 7 files changed, 769 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/thermal/rockchip-thermal.txt
 create mode 100644 arch/arm/boot/dts/rk3288-thermal.dtsi
 create mode 100644 drivers/thermal/rockchip_thermal.c
Signature · 1 line
1.9.1
#1 lore raw

PATCH v16 1/5 thermal: rockchip: add driver for thermal

Thermal is TS-ADC Controller module supports
user-defined mode and automatic mode.

User-defined mode refers,TSADC all the control signals entirely by software writing to register for direct control.

Automaic mode refers to the module automatically poll TSADC output, and the results were checked.If you find that the temperature High in a period of time,an interrupt is generated to the processor down-measures taken;If the temperature over a period of time High, the resulting TSHUT gave CRU module,let it reset the entire chip, or via GPIO give PMIC.

---
 drivers/thermal/Kconfig            |   9 +
 drivers/thermal/Makefile           |   1 +
 drivers/thermal/rockchip_thermal.c | 709 +++++++++++++++++++++++++++++++++++++
 3 files changed, 719 insertions(+)
 create mode 100644 drivers/thermal/rockchip_thermal.c
drivers/thermal/Kconfig +9 -0
index ef5587f..5efcf73 100644
@@ -133,6 +133,15 @@ config SPEAR_THERMAL
 	  Enable this to plug the SPEAr thermal sensor driver into the Linux
 	  thermal framework.
 
+config ROCKCHIP_THERMAL
+	tristate "Rockchip thermal driver"
+	depends on ARCH_ROCKCHIP
+	help
+	  Rockchip thermal driver provides support for Temperature sensor
+	  ADC (TS-ADC) found on Rockchip SoCs. It supports one critical
+	  trip point. Cpufreq is used as the cooling device and will throttle
+	  CPUs when the Temperature crosses the passive trip point.
+
 config RCAR_THERMAL
 	tristate "Renesas R-Car thermal driver"
 	depends on ARCH_SHMOBILE || COMPILE_TEST
drivers/thermal/Makefile +1 -0
index 31e232f..21da0a8 100644
@@ -19,6 +19,7 @@ thermal_sys-$(CONFIG_CPU_THERMAL)	+= cpu_cooling.o
 
 # platform thermal drivers
 obj-$(CONFIG_SPEAR_THERMAL)	+= spear_thermal.o
+obj-$(CONFIG_ROCKCHIP_THERMAL)	+= rockchip_thermal.o
 obj-$(CONFIG_RCAR_THERMAL)	+= rcar_thermal.o
 obj-$(CONFIG_KIRKWOOD_THERMAL)  += kirkwood_thermal.o
 obj-y				+= samsung/
drivers/thermal/rockchip_thermal.c new file +709 -0

709 lines not on this page · raw message

Signature · 1 line
1.9.1
#2 lore raw

PATCH v16 2/5 dt-bindings: document Rockchip thermal

In reply to Caesar Wang

This add the necessary binding documentation for the thermal found on Rockchip SoCs

---
 .../bindings/thermal/rockchip-thermal.txt          | 62 ++++++++++++++++++++++
 1 file changed, 62 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/thermal/rockchip-thermal.txt
Documentation/devicetree/bindings/thermal/rockchip-thermal.txt new file +62 -0
new file mode 100644
index 0000000..3061982
@@ -0,0 +1,62 @@
+* Temperature Sensor ADC (TSADC) on rockchip SoCs
+
+Required properties:
+- compatible : "rockchip,rk3288-tsadc"
+- reg : physical base address of the controller and length of memory mapped
+	region.
+- interrupts : The interrupt number to the cpu. The interrupt specifier format
+	       depends on the interrupt controller.
+- clocks : Must contain an entry for each entry in clock-names.
+- clock-names : Shall be "tsadc" for the converter-clock, and "apb_pclk" for
+		the peripheral clock.
+- #thermal-sensor-cells : Should be 1. See ./thermal.txt for a description.
+- hw-shut-temp : The hardware-controlled shutdown temperature value.
+- tsadc-tshut-mode : The hardware-controlled shutdown mode 0:CRU 1:GPIO.
+- tsadc-tshut-polarity : The hardware-controlled active polarity 0:LOW 1:HIGH.
+
+Exiample:
+tsadc: tsadc at ff280000 {
+	compatible = "rockchip,rk3288-tsadc";
+	reg = <0xff280000 0x100>;
+	interrupts = <GIC_SPI 37 IRQ_TYPE_LEVEL_HIGH>;
+	clocks = <&cru SCLK_TSADC>, <&cru PCLK_TSADC>;
+	clock-names = "tsadc", "apb_pclk";
+	pinctrl-names = "default";
+	pinctrl-0 = <&otp_out>;
+	#thermal-sensor-cells = <1>;
+	hw-shut-temp = <125000>;
+	tsadc-tshut-mode = <0>;
+	tsadc-tshut-polarity = <0>;
+};
+
+Example: referring to thermal sensors:
+thermal-zones {
+	cpu_thermal: cpu_thermal {
+		polling-delay-passive = <1000>; /* milliseconds */
+		polling-delay = <5000>; /* milliseconds */
+
+		/* sensor	ID */
+		thermal-sensors = <&tsadc	1>;
+
+		trips {
+			cpu_alert0: cpu_alert {
+				temperature = <80000>; /* millicelsius */
+				hysteresis = <2000>; /* millicelsius */
+				type = "passive";
+			};
+			cpu_crit: cpu_crit {
+				temperature = <120000>; /* millicelsius */
+				hysteresis = <2000>; /* millicelsius */
+				type = "critical";
+			};
+		};
+
+		cooling-maps {
+			map0 {
+				trip = <&cpu_alert0>;
+				cooling-device =
+					<&cpu0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
+			};
+		};
+	};
+};
Signature · 1 line
1.9.1
maintainer
#3 lore raw

Re: [PATCH v16 2/5] dt-bindings: document Rockchip thermal

Am Mittwoch, 29. Oktober 2014, 10:32:36 schrieb Caesar Wang:

Quoted 38 lines

This add the necessary binding documentation for the thermal found on Rockchip SoCs

---
 .../bindings/thermal/rockchip-thermal.txt          | 62
++++++++++++++++++++++ 1 file changed, 62 insertions(+)
 create mode 100644

Documentation/devicetree/bindings/thermal/rockchip-thermal.txt

(quoted diff) +0 -0

b/Documentation/devicetree/bindings/thermal/rockchip-thermal.txt new file mode 100644
index 0000000..3061982

Documentation/devicetree/bindings/thermal/rockchip-thermal.txt new file +7 -0
@@ -0,0 +1,62 @@
+* Temperature Sensor ADC (TSADC) on rockchip SoCs
+
+Required properties:
+- compatible : "rockchip,rk3288-tsadc"
+- reg : physical base address of the controller and length of memory mapped
+	region.
+- interrupts : The interrupt number to the cpu. The interrupt specifier

format + depends on the interrupt controller.

+- clocks : Must contain an entry for each entry in clock-names.
+- clock-names : Shall be "tsadc" for the converter-clock, and "apb_pclk"
for +		the peripheral clock.
+- #thermal-sensor-cells : Should be 1. See ./thermal.txt for a description.
+- hw-shut-temp : The hardware-controlled shutdown temperature value. +-

tsadc-tshut-mode : The hardware-controlled shutdown mode 0:CRU 1:GPIO. +- tsadc-tshut-polarity : The hardware-controlled active polarity 0:LOW 1:HIGH. +

Documentation/devicetree/bindings/thermal/rockchip-thermal.txt new file +3 -0
+Exiample:
+tsadc: tsadc at ff280000 {
+	compatible = "rockchip,rk3288-tsadc";

Documentation/devicetree/bindings/thermal/rockchip-thermal.txt line 29

Quoted 10 lines
Documentation/devicetree/bindings/thermal/rockchip-thermal.txt new file +10 -0
+	reg = <0xff280000 0x100>;
+	interrupts = <GIC_SPI 37 IRQ_TYPE_LEVEL_HIGH>;
+	clocks = <&cru SCLK_TSADC>, <&cru PCLK_TSADC>;
+	clock-names = "tsadc", "apb_pclk";
+	pinctrl-names = "default";
+	pinctrl-0 = <&otp_out>;
+	#thermal-sensor-cells = <1>;
+	hw-shut-temp = <125000>;
+	tsadc-tshut-mode = <0>;
+	tsadc-tshut-polarity = <0>;

these last 3 seem to be specific to this tsadc so should probably have a "rockchip,"-prefix

#4 lore raw

Re: [PATCH v16 2/5] dt-bindings: document Rockchip thermal

Heiko,

? 2014?10?31? 04:17, Heiko St?bner ??:

Quoted 43 lines

Am Mittwoch, 29. Oktober 2014, 10:32:36 schrieb Caesar Wang:

Quoted 42 lines

This add the necessary binding documentation for the thermal found on Rockchip SoCs

---
  .../bindings/thermal/rockchip-thermal.txt          | 62

++++++++++++++++++++++ 1 file changed, 62 insertions(+)
create mode 100644
Documentation/devicetree/bindings/thermal/rockchip-thermal.txt

(quoted diff) +0 -0

b/Documentation/devicetree/bindings/thermal/rockchip-thermal.txt new file mode 100644
index 0000000..3061982

Documentation/devicetree/bindings/thermal/rockchip-thermal.txt new file +7 -0
@@ -0,0 +1,62 @@
+* Temperature Sensor ADC (TSADC) on rockchip SoCs
+
+Required properties:
+- compatible : "rockchip,rk3288-tsadc"
+- reg : physical base address of the controller and length of memory mapped
+	region.
+- interrupts : The interrupt number to the cpu. The interrupt specifier

format + depends on the interrupt controller.

+- clocks : Must contain an entry for each entry in clock-names.
+- clock-names : Shall be "tsadc" for the converter-clock, and "apb_pclk"
for +		the peripheral clock.
+- #thermal-sensor-cells : Should be 1. See ./thermal.txt for a description.
+- hw-shut-temp : The hardware-controlled shutdown temperature value. +-

tsadc-tshut-mode : The hardware-controlled shutdown mode 0:CRU 1:GPIO. +- tsadc-tshut-polarity : The hardware-controlled active polarity 0:LOW 1:HIGH. +

Documentation/devicetree/bindings/thermal/rockchip-thermal.txt new file +7 -0
+Exiample:
+tsadc: tsadc at ff280000 {
+	compatible = "rockchip,rk3288-tsadc";
+	reg = <0xff280000 0x100>;
+	interrupts = <GIC_SPI 37 IRQ_TYPE_LEVEL_HIGH>;
+	clocks = <&cru SCLK_TSADC>, <&cru PCLK_TSADC>;
+	clock-names = "tsadc", "apb_pclk";
Quoted 8 lines

Documentation/devicetree/bindings/thermal/rockchip-thermal.txt line 29

Quoted 6 lines
Documentation/devicetree/bindings/thermal/rockchip-thermal.txt new file +6 -0
+	pinctrl-names = "default";
+	pinctrl-0 = <&otp_out>;
+	#thermal-sensor-cells = <1>;
+	hw-shut-temp = <125000>;
+	tsadc-tshut-mode = <0>;
+	tsadc-tshut-polarity = <0>;

these last 3 seem to be specific to this tsadc so should probably have a "rockchip,"-prefix

Fixed.

e.g sync to driver

rockchip,hw-shut-temp = <125000>;
rockchip,tsadc-tshut-mode = <0>;
rockchip,tsadc-tshut-polarity = <0>;

I will sent next patch v17 in 1-2 days if this series patchs haven't any problems.

Thanks.

Quoted 4 lines
Signature · 2 lines
Best regards,
Caesar
#5 lore raw

PATCH v16 3/5 ARM: dts: add RK3288 Thermal data

In reply to Caesar Wang

This patch changes a dtsi file to contain the thermal data on RK3288 and later SoCs. This data will
enable a thermal shutdown over 120C.

---
 arch/arm/boot/dts/rk3288-thermal.dtsi | 65 +++++++++++++++++++++++++++++++++++
 1 file changed, 65 insertions(+)
 create mode 100644 arch/arm/boot/dts/rk3288-thermal.dtsi
arch/arm/boot/dts/rk3288-thermal.dtsi new file +65 -0
new file mode 100644
index 0000000..2a018dc
@@ -0,0 +1,65 @@
+/*
+ * Device Tree Source for RK3288 SoC thermal
+ *
+ * Copyright (c) 2014, Fuzhou Rockchip Electronics Co., Ltd
+ *
+ * This file is licensed under the terms of the GNU General Public License
+ * version 2.  This program is licensed "as is" without any warranty of any
+ * kind, whether express or implied.
+ */
+
+#include <dt-bindings/thermal/thermal.h>
+
+reserve_thermal: reserve_thermal {
+	polling-delay-passive = <1000>; /* milliseconds */
+	polling-delay = <5000>; /* milliseconds */
+
+			/* sensor	ID */
+	thermal-sensors = <&tsadc	0>;
+
+};
+
+cpu_thermal: cpu_thermal {
+	polling-delay-passive = <1000>; /* milliseconds */
+	polling-delay = <5000>; /* milliseconds */
+
+			/* sensor	ID */
+	thermal-sensors = <&tsadc	1>;
+
+	trips {
+		cpu_alert0: cpu_alert0 {
+			temperature = <80000>; /* millicelsius */
+			hysteresis = <2000>; /* millicelsius */
+			type = "passive";
+		};
+		cpu_crit: cpu_crit {
+			temperature = <120000>; /* millicelsius */
+			hysteresis = <2000>; /* millicelsius */
+			type = "critical";
+		};
+	};
+
+	cooling-maps {
+		map0 {
+			trip = <&cpu_alert0>;
+			cooling-device =
+				<&cpu0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
+		};
+	};
+};
+
+gpu_thermal: gpu_thermal {
+	polling-delay-passive = <1000>; /* milliseconds */
+	polling-delay = <5000>; /* milliseconds */
+
+			/* sensor	ID */
+	thermal-sensors = <&tsadc	2>;
+
+	trips {
+		gpu_crit: gpu_crit {
+			temperature = <120000>; /* millicelsius */
+			hysteresis = <2000>; /* millicelsius */
+			type = "critical";
+		};
+	};
+};
Signature · 1 line
1.9.1
#6 lore raw

PATCH v16 4/5 ARM: dts: add main Thermal info to rk3288

In reply to Caesar Wang

This patch is depend on rk3288-thermal.dtsi,or it will compile error.

If for some reason we are unable to shut it down in orderly fashion (kernel is stuck holding a lock or similar), then hardware TSHUT will reset it.

If the temperature over a period of time High,over 125C the resulting TSHUT gave CRU module,let it reset the entire chip,or via GPIO give PMIC.

---
 arch/arm/boot/dts/rk3288.dtsi | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
arch/arm/boot/dts/rk3288.dtsi +25 -0
index cb18bb4..85855a6 100644
@@ -15,6 +15,7 @@
 #include <dt-bindings/interrupt-controller/arm-gic.h>
 #include <dt-bindings/pinctrl/rockchip.h>
 #include <dt-bindings/clock/rk3288-cru.h>
+#include <dt-bindings/thermal/thermal.h>
 #include "skeleton.dtsi"
 
 / {
@@ -66,6 +67,7 @@
 				 216000  900000
 				 126000  900000
 			>;
+			#cooling-cells = <2>; /* min followed by max */
 			clock-latency = <40000>;
 			clocks = <&cru ARMCLK>;
 		};
@@ -346,6 +348,23 @@
 		status = "disabled";
 	};
 
+	thermal-zones {
+		#include "rk3288-thermal.dtsi"
+	};
+
+	tsadc: tsadc at ff280000 {
+		compatible = "rockchip,rk3288-tsadc";
+		reg = <0xff280000 0x100>;
+		interrupts = <GIC_SPI 37 IRQ_TYPE_LEVEL_HIGH>;
+		clocks = <&cru SCLK_TSADC>, <&cru PCLK_TSADC>;
+		clock-names = "tsadc", "apb_pclk";
+		pinctrl-names = "default";
+		pinctrl-0 = <&otp_out>;
+		#thermal-sensor-cells = <1>;
+		hw-shut-temp = <125000>;
+		status = "disabled";
+	};
+
 	usb_host0_ehci: usb at ff500000 {
 		compatible = "generic-ehci";
 		reg = <0xff500000 0x100>;
@@ -965,6 +984,12 @@
 			};
 		};
 
+		tsadc {
+			otp_out: otp-out {
+				rockchip,pins = <0 10 RK_FUNC_1 &pcfg_pull_none>;
+			};
+		};
+
 		pwm0 {
 			pwm0_pin: pwm0-pin {
 				rockchip,pins = <7 0 RK_FUNC_1 &pcfg_pull_none>;
Signature · 1 line
1.9.1
#7 lore raw

PATCH v16 5/5 ARM: dts: enable Thermal on rk3288-evb board

In reply to Caesar Wang

when a thermal temperature over TSHUT.Default to via CRU reset the entire chip on rk3288-evb Board, TSHUT is low active on rk3288-evb board.

---
 arch/arm/boot/dts/rk3288-evb.dtsi | 6 ++++++
 1 file changed, 6 insertions(+)
arch/arm/boot/dts/rk3288-evb.dtsi +6 -0
index cb83cea..fb70523 100644
@@ -148,6 +148,12 @@
 	status = "okay";
 };
 
+&tsadc {
+	tsadc-tshut-mode = <0>; /* tshut mode 0:CRU 1:GPIO */
+	tsadc-tshut-polarity = <0>; /* tshut polarity 0:LOW 1:HIGH */
+	status = "okay";
+};
+
 &pinctrl {
 	backlight {
 		bl_en: bl-en {
Signature · 1 line
1.9.1