Skip to contentSkip to conversation

Add support of New Amlogic temperature sensor for G12 SoCs

PATCH Superseded Guillaume La Roque 3 participants 12 messages Jul 31, 2019

Subsystems (4)

v1 of 7 Superseded Latest is v7 →

lore
Share & tools
lore

Guillaume La Roque

author maintainer
#0 lore raw

cover Add support of New Amlogic temperature sensor for G12 SoCs

This patchs series add support of New Amlogic temperature sensor and minimal thermal zone for SEI510 and ODROID-N2 boards.

First implementation was doing on IIO[1] but after comments i move on thermal framework. Formulas and calibration values come from amlogic.

Dependencies :
- patch 3: depends on Neil's patchs :
- missing dwc2 phy-names[1]
- rework on G12 DT[2]

[1] https://lore.kernel.org/linux-amlogic/[email protected]/
[2] https://lore.kernel.org/linux-amlogic/[email protected]/
[3] https://lore.kernel.org/linux-amlogic/[email protected]/

Guillaume La Roque (6):
dt-bindings: thermal: Add DT bindings documentation for Amlogic
Thermal
thermal: amlogic: Add thermal driver to support G12 SoCs
arm64: dts: amlogic: g12: add temperature sensor
arm64: dts: meson: sei510: Add minimal thermal zone
arm64: dts: amlogic: odroid-n2: add minimal thermal zone
MAINTAINERS: add entry for Amlogic Thermal driver

 .../bindings/thermal/amlogic,thermal.yaml     |  58 +++
 MAINTAINERS                                   |   9 +
 .../boot/dts/amlogic/meson-g12-common.dtsi    |  22 ++
 .../boot/dts/amlogic/meson-g12a-sei510.dts    |  13 +
 .../boot/dts/amlogic/meson-g12b-odroid-n2.dts |  13 +
 drivers/thermal/Kconfig                       |  12 +-
 drivers/thermal/Makefile                      |   1 +
 drivers/thermal/amlogic_thermal.c             | 335 ++++++++++++++++++
 8 files changed, 462 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/thermal/amlogic,thermal.yaml
 create mode 100644 drivers/thermal/amlogic_thermal.c
Signature · 1 line
2.17.1
author maintainer
#1 lore raw

PATCH 1/6 dt-bindings: thermal: Add DT bindings documentation for Amlogic Thermal

Adding the devicetree binding documentation for the Amlogic temperature sensor found in the Amlogic Meson G12 SoCs.
the G12A and G12B SoCs are supported.

---
 .../bindings/thermal/amlogic,thermal.yaml     | 58 +++++++++++++++++++
 1 file changed, 58 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/thermal/amlogic,thermal.yaml
Documentation/devicetree/bindings/thermal/amlogic,thermal.yaml new file +58 -0
new file mode 100644
index 000000000000..1e2fe84da13d
@@ -0,0 +1,58 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/thermal/amlogic,thermal.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Amlogic Thermal Driver
+
+maintainers:
+  - Guillaume La Roque <[email protected]>
+
+description: Amlogic Thermal driver
+
+properties:
+  compatible:
+    oneOf:
+      - items:
+          - enum:
+              - amlogic,g12-cpu-thermal
+              - amlogic,g12-ddr-thermal
+          - enum:
+              - amlogic,g12-thermal
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+  clocks:
+    maxItems: 1
+
+  amlogic,ao-secure:
+    description: phandle to the ao-secure syscon
+    allOf:
+     - $ref: /schemas/types.yaml#/definitions/uint32
+
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - clocks
+  - amlogic,ao-secure
+
+examples:
+  - |
+        cpu_temp: temperature-sensor@ff634800 {
+                compatible = "amlogic,g12-cpu-thermal",
+                             "amlogic,g12-thermal";
+                reg = <0x0 0xff634800 0x0 0x50>;
+                interrupts = <0x0 0x24 0x0>;
+                clocks = <&clk 164>;
+                status = "okay";
+                #thermal-sensor-cells = <1>;
+                amlogic,ao-secure = <&sec_AO>;
+        };
+...
\ No newline at end of file
Signature · 1 line
2.17.1
#2 lore raw

Re: [PATCH 1/6] dt-bindings: thermal: Add DT bindings documentation for Amlogic Thermal

Quoted 28 lines · Guillaume La Roque

Adding the devicetree binding documentation for the Amlogic temperature sensor found in the Amlogic Meson G12 SoCs.
the G12A and G12B SoCs are supported.

---
 .../bindings/thermal/amlogic,thermal.yaml     | 58 +++++++++++++++++++
 1 file changed, 58 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/thermal/amlogic,thermal.yaml
Documentation/devicetree/bindings/thermal/amlogic,thermal.yaml new file +12 -0
new file mode 100644
index 000000000000..1e2fe84da13d
@@ -0,0 +1,58 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/thermal/amlogic,thermal.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Amlogic Thermal Driver
+
+maintainers:
+  - Guillaume La Roque <[email protected]>
+
+description: Amlogic Thermal driver

Documentation/devicetree/bindings/thermal/amlogic,thermal.yaml line 22

Quoted 10 lines
Documentation/devicetree/bindings/thermal/amlogic,thermal.yaml new file +10 -0
+
+properties:
+  compatible:
+    oneOf:
+      - items:
+          - enum:
+              - amlogic,g12-cpu-thermal
+              - amlogic,g12-ddr-thermal
+          - enum:
+              - amlogic,g12-thermal

Shouldn't be :
compatible:
items:
- enum:
- amlogic,g12-cpu-thermal
- amlogic,g12-ddr-thermal
- const:
- amlogic,g12-thermal

instead ?

Quoted 38 lines
Documentation/devicetree/bindings/thermal/amlogic,thermal.yaml new file +36 -0
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+  clocks:
+    maxItems: 1
+
+  amlogic,ao-secure:
+    description: phandle to the ao-secure syscon
+    allOf:
+     - $ref: /schemas/types.yaml#/definitions/uint32
+
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - clocks
+  - amlogic,ao-secure
+
+examples:
+  - |
+        cpu_temp: temperature-sensor@ff634800 {
+                compatible = "amlogic,g12-cpu-thermal",
+                             "amlogic,g12-thermal";
+                reg = <0x0 0xff634800 0x0 0x50>;
+                interrupts = <0x0 0x24 0x0>;
+                clocks = <&clk 164>;
+                status = "okay";
+                #thermal-sensor-cells = <1>;
+                amlogic,ao-secure = <&sec_AO>;
+        };
+...
\ No newline at end of file
maintainer
#3 lore raw

Re: [PATCH 1/6] dt-bindings: thermal: Add DT bindings documentation for Amlogic Thermal

Quoted 50 lines · Neil Armstrong
Quoted 28 lines · Guillaume La Roque

Adding the devicetree binding documentation for the Amlogic temperature sensor found in the Amlogic Meson G12 SoCs.
the G12A and G12B SoCs are supported.

---
 .../bindings/thermal/amlogic,thermal.yaml     | 58 +++++++++++++++++++
 1 file changed, 58 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/thermal/amlogic,thermal.yaml
Documentation/devicetree/bindings/thermal/amlogic,thermal.yaml new file +12 -0
new file mode 100644
index 000000000000..1e2fe84da13d
@@ -0,0 +1,58 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/thermal/amlogic,thermal.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Amlogic Thermal Driver
+
+maintainers:
+  - Guillaume La Roque <[email protected]>
+
+description: Amlogic Thermal driver

Documentation/devicetree/bindings/thermal/amlogic,thermal.yaml line 22

Quoted 10 lines
Documentation/devicetree/bindings/thermal/amlogic,thermal.yaml new file +10 -0
+
+properties:
+  compatible:
+    oneOf:
+      - items:
+          - enum:
+              - amlogic,g12-cpu-thermal
+              - amlogic,g12-ddr-thermal
+          - enum:
+              - amlogic,g12-thermal

Shouldn't be :
compatible:
items:
- enum:
- amlogic,g12-cpu-thermal
- amlogic,g12-ddr-thermal
- const:
- amlogic,g12-thermal

Quoted 1 line

instead ?

Yes, except 'const' is a string, not list value.

Quoted 15 lines
Quoted 5 lines
Documentation/devicetree/bindings/thermal/amlogic,thermal.yaml new file +4 -0
+
+  reg:
+    maxItems: 1
+

Documentation/devicetree/bindings/thermal/amlogic,thermal.yaml line 36

Quoted 10 lines
Documentation/devicetree/bindings/thermal/amlogic,thermal.yaml new file +10 -0
+  interrupts:
+    maxItems: 1
+
+  clocks:
+    maxItems: 1
+
+  amlogic,ao-secure:
+    description: phandle to the ao-secure syscon
+    allOf:
+     - $ref: /schemas/types.yaml#/definitions/uint32

phandle, not uint32

Quoted 15 lines
Quoted 15 lines
Documentation/devicetree/bindings/thermal/amlogic,thermal.yaml new file +15 -0
+
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - clocks
+  - amlogic,ao-secure
+
+examples:
+  - |
+        cpu_temp: temperature-sensor@ff634800 {
+                compatible = "amlogic,g12-cpu-thermal",
+                             "amlogic,g12-thermal";
+                reg = <0x0 0xff634800 0x0 0x50>;
Quoted 8 lines

Documentation/devicetree/bindings/thermal/amlogic,thermal.yaml line 58

Quoted 8 lines
Documentation/devicetree/bindings/thermal/amlogic,thermal.yaml new file +7 -0
+                interrupts = <0x0 0x24 0x0>;
+                clocks = <&clk 164>;
+                status = "okay";
+                #thermal-sensor-cells = <1>;
+                amlogic,ao-secure = <&sec_AO>;
+        };
+...
\ No newline at end of file

Fix this.

Quoted 2 lines
Quoted 1 line
author maintainer
#4 lore raw

PATCH 2/6 thermal: amlogic: Add thermal driver to support G12 SoCs

In reply to Guillaume La Roque
---
 drivers/thermal/Kconfig           |  12 +-
 drivers/thermal/Makefile          |   1 +
 drivers/thermal/amlogic_thermal.c | 335 ++++++++++++++++++++++++++++++
 3 files changed, 347 insertions(+), 1 deletion(-)
 create mode 100644 drivers/thermal/amlogic_thermal.c
drivers/thermal/Kconfig +11 -1
index 9966364a6deb..2332ef1bfafc 100644
@@ -1,4 +1,3 @@
-# SPDX-License-Identifier: GPL-2.0-only
 #
 # Generic thermal sysfs drivers configuration
 #
@@ -348,6 +347,17 @@ config MTK_THERMAL
 	  Enable this option if you want to have support for thermal management
 	  controller present in Mediatek SoCs
 
+config AMLOGIC_THERMAL
+	tristate "Amlogic Thermal Support"
+	default ARCH_MESON
+	depends on OF && ARCH_MESON
+	help
+	  If you say yes here you get support for Amlogic Thermal
+	  for G12 SoC Family.
+
+	  This driver can also be built as a module. If so, the module will
+	  be called amlogic_thermal.
+
 menu "Intel thermal drivers"
 depends on X86 || X86_INTEL_QUARK || COMPILE_TEST
 source "drivers/thermal/intel/Kconfig"
drivers/thermal/Makefile +1 -0
index 74a37c7f847a..baeb70bf0568 100644
@@ -54,3 +54,4 @@ obj-$(CONFIG_MTK_THERMAL)	+= mtk_thermal.o
 obj-$(CONFIG_GENERIC_ADC_THERMAL)	+= thermal-generic-adc.o
 obj-$(CONFIG_ZX2967_THERMAL)	+= zx2967_thermal.o
 obj-$(CONFIG_UNIPHIER_THERMAL)	+= uniphier_thermal.o
+obj-$(CONFIG_AMLOGIC_THERMAL)     += amlogic_thermal.o
drivers/thermal/amlogic_thermal.c new file +335 -0

335 lines not on this page · raw message

Signature · 1 line
2.17.1
#5 lore raw

Re: [PATCH 2/6] thermal: amlogic: Add thermal driver to support G12 SoCs

Quoted 13 lines · Guillaume La Roque
---
 drivers/thermal/Kconfig           |  12 +-
 drivers/thermal/Makefile          |   1 +
 drivers/thermal/amlogic_thermal.c | 335 ++++++++++++++++++++++++++++++
 3 files changed, 347 insertions(+), 1 deletion(-)
 create mode 100644 drivers/thermal/amlogic_thermal.c
drivers/thermal/Kconfig +0 -0
index 9966364a6deb..2332ef1bfafc 100644

drivers/thermal/Kconfig line 1

Quoted 1 line
drivers/thermal/Kconfig +0 -1
@@ -1,4 +1,3 @@
-# SPDX-License-Identifier: GPL-2.0-only

|\ typo ?

Quoted 21 lines
drivers/thermal/Kconfig +11 -0
 #
 # Generic thermal sysfs drivers configuration
 #
@@ -348,6 +347,17 @@ config MTK_THERMAL
 	  Enable this option if you want to have support for thermal management
 	  controller present in Mediatek SoCs
 
+config AMLOGIC_THERMAL
+	tristate "Amlogic Thermal Support"
+	default ARCH_MESON
+	depends on OF && ARCH_MESON
+	help
+	  If you say yes here you get support for Amlogic Thermal
+	  for G12 SoC Family.
+
+	  This driver can also be built as a module. If so, the module will
+	  be called amlogic_thermal.
+
 menu "Intel thermal drivers"
 depends on X86 || X86_INTEL_QUARK || COMPILE_TEST
 source "drivers/thermal/intel/Kconfig"

[...]

author maintainer
#6 lore raw

PATCH 3/6 arm64: dts: amlogic: g12: add temperature sensor

In reply to Guillaume La Roque

Add cpu and ddr temperature sensors for G12 Socs

---
 .../boot/dts/amlogic/meson-g12-common.dtsi    | 22 +++++++++++++++++++
 1 file changed, 22 insertions(+)
arch/arm64/boot/dts/amlogic/meson-g12-common.dtsi +22 -0
index 06e186ca41e3..e10aba5c9270 100644
@@ -1353,6 +1353,28 @@
 				};
 			};
 
+			cpu_temp: temperature-sensor@34800 {
+				compatible = "amlogic,g12-cpu-thermal",
+					     "amlogic,g12-thermal";
+				reg = <0x0 0x34800 0x0 0x50>;
+				interrupts = <GIC_SPI 35 IRQ_TYPE_EDGE_RISING>;
+				clocks = <&clkc CLKID_TS>;
+				status = "okay";
+				#thermal-sensor-cells = <1>;
+				amlogic,ao-secure = <&sec_AO>;
+			};
+
+			ddr_temp: temperature-sensor@34c00 {
+				compatible = "amlogic,g12-ddr-thermal",
+					     "amlogic,g12-thermal";
+				reg = <0x0 0x34c00 0x0 0x50>;
+				interrupts = <GIC_SPI 36 IRQ_TYPE_EDGE_RISING>;
+				clocks = <&clkc CLKID_TS>;
+				status = "okay";
+				#thermal-sensor-cells = <1>;
+				amlogic,ao-secure = <&sec_AO>;
+			};
+
 			usb2_phy0: phy@36000 {
 				compatible = "amlogic,g12a-usb2-phy";
 				reg = <0x0 0x36000 0x0 0x2000>;
Signature · 1 line
2.17.1
author maintainer
#7 lore raw

PATCH 4/6 arm64: dts: meson: sei510: Add minimal thermal zone

In reply to Guillaume La Roque

Add minimal thermal zone for DDR and CPU sensor

---
 arch/arm64/boot/dts/amlogic/meson-g12a-sei510.dts | 13 +++++++++++++
 1 file changed, 13 insertions(+)
arch/arm64/boot/dts/amlogic/meson-g12a-sei510.dts +13 -0
index c7a87368850b..79ae514e238d 100644
@@ -33,6 +33,19 @@
 		ethernet0 = &ethmac;
 	};
 
+	thermal-zones {
+		soc_thermal {
+			polling-delay = <1000>;
+			polling-delay-passive = <100>;
+			thermal-sensors = <&cpu_temp 0>;
+		};
+		ddr_thermal {
+			polling-delay = <1000>;
+			polling-delay-passive = <100>;
+			thermal-sensors = <&ddr_temp 1>;
+		};
+	};
+
 	mono_dac: audio-codec-0 {
 		compatible = "maxim,max98357a";
 		#sound-dai-cells = <0>;
Signature · 1 line
2.17.1
#8 lore raw

Re: [PATCH 4/6] arm64: dts: meson: sei510: Add minimal thermal zone

Quoted 12 lines · Guillaume La Roque

Add minimal thermal zone for DDR and CPU sensor

---
 arch/arm64/boot/dts/amlogic/meson-g12a-sei510.dts | 13 +++++++++++++
 1 file changed, 13 insertions(+)
arch/arm64/boot/dts/amlogic/meson-g12a-sei510.dts +0 -0
index c7a87368850b..79ae514e238d 100644

arch/arm64/boot/dts/amlogic/meson-g12a-sei510.dts line 40

Quoted 8 lines
arch/arm64/boot/dts/amlogic/meson-g12a-sei510.dts +5 -0
@@ -33,6 +33,19 @@
 		ethernet0 = &ethmac;
 	};
 
+	thermal-zones {
+		soc_thermal {
+			polling-delay = <1000>;
+			polling-delay-ptripsassive = <100>;
+			thermal-sensors = <&cpu_temp 0>;

Seems the trips & cooling-maps are required as described in thermal.txt

For the soc_thermal zone it's esy to add a cooling map with the CPU and cooling devices, but for the ddr_thermal, no idea if we can use the CPUs within 2 cooling maps.

arch/arm64/boot/dts/amlogic/meson-g12a-sei510.dts line 41

Quoted 1 line
arch/arm64/boot/dts/amlogic/meson-g12a-sei510.dts +1 -0
+		};

I would add a blank line between the zones, same for other files.

Quoted 11 lines
arch/arm64/boot/dts/amlogic/meson-g12a-sei510.dts +7 -0
+		ddr_thermal {
+			polling-delay = <1000>;
+			polling-delay-passive = <100>;
+			thermal-sensors = <&ddr_temp 1>;
+		};
+	};
+
 	mono_dac: audio-codec-0 {
 		compatible = "maxim,max98357a";
 		#sound-dai-cells = <0>;
author maintainer
#9 lore raw

PATCH 5/6 arm64: dts: amlogic: odroid-n2: add minimal thermal zone

In reply to Guillaume La Roque

Add minimal thermal zone for DDR and CPU sensor

---
 .../arm64/boot/dts/amlogic/meson-g12b-odroid-n2.dts | 13 +++++++++++++
 1 file changed, 13 insertions(+)
arch/arm64/boot/dts/amlogic/meson-g12b-odroid-n2.dts +13 -0
index 81780ffcc7f0..4bd8d6d0c972 100644
@@ -20,6 +20,19 @@
 		ethernet0 = &ethmac;
 	};
 
+	thermal-zones {
+		soc_thermal {
+			polling-delay = <1000>;
+			polling-delay-passive = <100>;
+			thermal-sensors = <&cpu_temp 0>;
+		};
+		ddr_thermal {
+			polling-delay = <1000>;
+			polling-delay-passive = <100>;
+			thermal-sensors = <&ddr_temp 1>;
+		};
+	};
+
 	chosen {
 		stdout-path = "serial0:115200n8";
 	};
Signature · 1 line
2.17.1
author maintainer
#10 lore raw

PATCH 6/6 MAINTAINERS: add entry for Amlogic Thermal driver

In reply to Guillaume La Roque

Add myself as maintainer for Amlogic Thermal driver.

---
 MAINTAINERS | 9 +++++++++
 1 file changed, 9 insertions(+)
MAINTAINERS +9 -0
index fb2b12f75c37..299f27d11058 100644
@@ -15910,6 +15910,15 @@ F:	Documentation/driver-api/thermal/cpu-cooling-api.rst
 F:	drivers/thermal/cpu_cooling.c
 F:	include/linux/cpu_cooling.h
 
+THERMAL DRIVER FOR AMLOGIC SOCS
+M:	Guillaume La Roque <[email protected]>
+L:	[email protected]
+L:	[email protected]
+W:	http://linux-meson.com/
+S:	Supported
+F:	drivers/thermal/amlogic_thermal.c
+F:	Documentation/devicetree/bindings/thermal/amlogic,thermal.yaml
+
 THINKPAD ACPI EXTRAS DRIVER
 M:	Henrique de Moraes Holschuh <[email protected]>
 L:	[email protected]
Signature · 1 line
2.17.1
Reviewed-by on v1 6/6
#11 lore raw

Re: [PATCH 6/6] MAINTAINERS: add entry for Amlogic Thermal driver

Quoted 18 lines · Guillaume La Roque

Add myself as maintainer for Amlogic Thermal driver.

---
 MAINTAINERS | 9 +++++++++
 1 file changed, 9 insertions(+)
MAINTAINERS +2 -0
index fb2b12f75c37..299f27d11058 100644
@@ -15910,6 +15910,15 @@ F:	Documentation/driver-api/thermal/cpu-cooling-api.rst
 F:	drivers/thermal/cpu_cooling.c
 F:	include/linux/cpu_cooling.h
 
+THERMAL DRIVER FOR AMLOGIC SOCS
+M:	Guillaume La Roque <[email protected]>

MAINTAINERS F: Documentation/driver-api/thermal/cpu-cooling-api.rst · line 15924

Quoted 10 lines
MAINTAINERS +7 -0
+L:	[email protected]
+L:	[email protected]
+W:	http://linux-meson.com/
+S:	Supported
+F:	drivers/thermal/amlogic_thermal.c
+F:	Documentation/devicetree/bindings/thermal/amlogic,thermal.yaml
+
 THINKPAD ACPI EXTRAS DRIVER
 M:	Henrique de Moraes Holschuh <[email protected]>
 L:	[email protected]