Skip to contentSkip to conversation

Add driver for NVIDIA Tegra30 SoC Thermal sensor

PATCH Applied Dmitry Osipenko 3 participants 17 messages Jun 16, 2021 – Sep 9, 2021

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

v4 cover Add driver for NVIDIA Tegra30 SoC Thermal sensor

Hi,

This series adds support for the thermal sensor that is found on NVIDIA Tegra30 SoC. Sensor monitors temperature and voltage of the SoC, it also emits signals to the power management and clock controllers that are performing the emergency shut down and the CPU frequency throttling when a pre-programmed temperature levels are reached.

Changelog:

v4: - Removed DIV2 CPU frequency throttling and cooling device part as was
suggested by Daniel Lezcano since we need to notify cpufreq about the updated frequency and change the thermal pressure. The thermal pressure change should co-exists with the cpufreq_cooling. This all needs some more thought, so the DIV2 mitigation will come sometime later.

- Added ack from Thierry Reding.

- Changed default TZ trips in the device-tree to the silicon temperature levels, instead of the average device levels.

v3: - No code changes. CC'ed linux-pm, which was previously missed by accident.
Not sure how much that is important for the thermal patches, but won't hurt to re-send since only DT binding was reviewed so far.

v2: - Made a very minor improvement to one error message, it now prints
number of channel at which error occurred.

- Added r-b from Rob Herring to the binding.

Dmitry Osipenko (6):
dt-bindings: thermal: Add binding for Tegra30 thermal sensor
thermal: thermal_of: Stop zone device before unregistering it thermal/drivers/tegra: Add driver for Tegra30 thermal sensor
ARM: tegra_defconfig: Enable CONFIG_TEGRA30_TSENSOR
ARM: multi_v7_defconfig: Enable CONFIG_TEGRA30_TSENSOR
ARM: tegra: Add SoC thermal sensor to Tegra30 device-trees

 .../thermal/nvidia,tegra30-tsensor.yaml       |  73 ++
 arch/arm/boot/dts/tegra30.dtsi                |  87 ++-
 arch/arm/configs/multi_v7_defconfig           |   1 +
 arch/arm/configs/tegra_defconfig              |   1 +
 drivers/thermal/tegra/Kconfig                 |   7 +
 drivers/thermal/tegra/Makefile                |   1 +
 drivers/thermal/tegra/tegra30-tsensor.c       | 673 ++++++++++++++++++
 drivers/thermal/thermal_of.c                  |   3 +
 8 files changed, 842 insertions(+), 4 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/thermal/nvidia,tegra30-tsensor.yaml
 create mode 100644 drivers/thermal/tegra/tegra30-tsensor.c
Signature · 1 line
2.30.2
#1 lore raw

PATCH v4 1/6 dt-bindings: thermal: Add binding for Tegra30 thermal sensor

All NVIDIA Tegra30 SoCs have on-chip sensors which monitor temperature and voltage of the SoC. Sensors also controls CPU x2 freq throttle and emits emergency shutdown signal. TSENSOR has has two separate channels for each sensor placed in a different parts of the SoC. Add binding for the sensor hardware.

---
 .../thermal/nvidia,tegra30-tsensor.yaml       | 73 +++++++++++++++++++
 1 file changed, 73 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/thermal/nvidia,tegra30-tsensor.yaml
Documentation/devicetree/bindings/thermal/nvidia,tegra30-tsensor.yaml new file +73 -0
new file mode 100644
index 000000000000..a35da257b070
@@ -0,0 +1,73 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/thermal/nvidia,tegra30-tsensor.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: NVIDIA Tegra30 Thermal Sensor
+
+maintainers:
+  - Dmitry Osipenko <[email protected]>
+  - Jon Hunter <[email protected]>
+  - Thierry Reding <[email protected]>
+
+description: |
+  TSENSOR provides thermal and voltage sensors which monitor temperature
+  and voltage of the chip. Sensors are placed across the die to gauge the
+  temperature of the whole chip. The TSENSOR module:
+
+    Generates an interrupt to SW to lower temperature via DVFS on reaching
+    a certain thermal/voltage threshold.
+
+    Generates a signal to the CAR to reduce CPU frequency by half on reaching
+    a certain thermal/voltage threshold.
+
+    Generates a signal to the PMC when the temperature reaches dangerously high
+    levels to reset the chip and sets a flag in the PMC.
+
+  TSENSOR has two channels which monitor two different spots of the SoC.
+
+properties:
+  compatible:
+    const: nvidia,tegra30-tsensor
+
+  reg:
+    maxItems: 1
+
+  clocks:
+    maxItems: 1
+
+  resets:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+  "#thermal-sensor-cells":
+    const: 1
+
+  assigned-clock-parents: true
+  assigned-clock-rates: true
+  assigned-clocks: true
+
+required:
+  - compatible
+  - reg
+  - clocks
+  - resets
+  - interrupts
+  - "#thermal-sensor-cells"
+
+additionalProperties: false
+
+examples:
+  - |
+    thermal-sensor@70014000 {
+      compatible = "nvidia,tegra30-tsensor";
+      reg = <0x70014000 0x500>;
+      interrupts = <0 102 4>;
+      clocks = <&clk 100>;
+      resets = <&rst 100>;
+
+      #thermal-sensor-cells = <1>;
+    };
Signature · 1 line
2.30.2
#2 lore raw

[thermal: thermal/next] dt-bindings: thermal: Add binding for Tegra30 thermal sensor

The following commit has been merged into the thermal/next branch of thermal:

The following commit has been merged into the thermal/next branch of thermal:

Commit-ID:     6380829885ccf8a5ec556ef2b3bb69f5961f9dde
Gitweb:        https://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux.git//6380829885ccf8a5ec556ef2b3bb69f5961f9dde
Author:        Dmitry Osipenko <[email protected]>
AuthorDate:    Wed, 16 Jun 2021 22:04:12 +03:00
Committer:     Daniel Lezcano <[email protected]>
CommitterDate: Fri, 18 Jun 2021 12:38:33 +02:00

dt-bindings: thermal: Add binding for Tegra30 thermal sensor

All NVIDIA Tegra30 SoCs have on-chip sensors which monitor temperature and voltage of the SoC. Sensors also controls CPU x2 freq throttle and emits emergency shutdown signal. TSENSOR has has two separate channels for each sensor placed in a different parts of the SoC. Add binding for the sensor hardware.

---
 Documentation/devicetree/bindings/thermal/nvidia,tegra30-tsensor.yaml | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 73 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/thermal/nvidia,tegra30-tsensor.yaml
Documentation/devicetree/bindings/thermal/nvidia,tegra30-tsensor.yaml new file +73 -0
new file mode 100644
index 0000000..a35da25
@@ -0,0 +1,73 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/thermal/nvidia,tegra30-tsensor.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: NVIDIA Tegra30 Thermal Sensor
+
+maintainers:
+  - Dmitry Osipenko <[email protected]>
+  - Jon Hunter <[email protected]>
+  - Thierry Reding <[email protected]>
+
+description: |
+  TSENSOR provides thermal and voltage sensors which monitor temperature
+  and voltage of the chip. Sensors are placed across the die to gauge the
+  temperature of the whole chip. The TSENSOR module:
+
+    Generates an interrupt to SW to lower temperature via DVFS on reaching
+    a certain thermal/voltage threshold.
+
+    Generates a signal to the CAR to reduce CPU frequency by half on reaching
+    a certain thermal/voltage threshold.
+
+    Generates a signal to the PMC when the temperature reaches dangerously high
+    levels to reset the chip and sets a flag in the PMC.
+
+  TSENSOR has two channels which monitor two different spots of the SoC.
+
+properties:
+  compatible:
+    const: nvidia,tegra30-tsensor
+
+  reg:
+    maxItems: 1
+
+  clocks:
+    maxItems: 1
+
+  resets:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+  "#thermal-sensor-cells":
+    const: 1
+
+  assigned-clock-parents: true
+  assigned-clock-rates: true
+  assigned-clocks: true
+
+required:
+  - compatible
+  - reg
+  - clocks
+  - resets
+  - interrupts
+  - "#thermal-sensor-cells"
+
+additionalProperties: false
+
+examples:
+  - |
+    thermal-sensor@70014000 {
+      compatible = "nvidia,tegra30-tsensor";
+      reg = <0x70014000 0x500>;
+      interrupts = <0 102 4>;
+      clocks = <&clk 100>;
+      resets = <&rst 100>;
+
+      #thermal-sensor-cells = <1>;
+    };
#3 lore raw

[thermal: thermal/next] dt-bindings: thermal: Add binding for Tegra30 thermal sensor

In reply to Dmitry Osipenko
The following commit has been merged into the thermal/next branch of thermal:

The following commit has been merged into the thermal/next branch of thermal:

Commit-ID:     1aab6b81af3c96e3181911140d2528e112335bef
Gitweb:        https://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux.git//1aab6b81af3c96e3181911140d2528e112335bef
Author:        Dmitry Osipenko <[email protected]>
AuthorDate:    Wed, 16 Jun 2021 22:04:12 +03:00
Committer:     Daniel Lezcano <[email protected]>
CommitterDate: Sun, 04 Jul 2021 18:28:04 +02:00

dt-bindings: thermal: Add binding for Tegra30 thermal sensor

All NVIDIA Tegra30 SoCs have on-chip sensors which monitor temperature and voltage of the SoC. Sensors also controls CPU x2 freq throttle and emits emergency shutdown signal. TSENSOR has has two separate channels for each sensor placed in a different parts of the SoC. Add binding for the sensor hardware.

---
 Documentation/devicetree/bindings/thermal/nvidia,tegra30-tsensor.yaml | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 73 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/thermal/nvidia,tegra30-tsensor.yaml
Documentation/devicetree/bindings/thermal/nvidia,tegra30-tsensor.yaml new file +73 -0
new file mode 100644
index 0000000..a35da25
@@ -0,0 +1,73 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/thermal/nvidia,tegra30-tsensor.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: NVIDIA Tegra30 Thermal Sensor
+
+maintainers:
+  - Dmitry Osipenko <[email protected]>
+  - Jon Hunter <[email protected]>
+  - Thierry Reding <[email protected]>
+
+description: |
+  TSENSOR provides thermal and voltage sensors which monitor temperature
+  and voltage of the chip. Sensors are placed across the die to gauge the
+  temperature of the whole chip. The TSENSOR module:
+
+    Generates an interrupt to SW to lower temperature via DVFS on reaching
+    a certain thermal/voltage threshold.
+
+    Generates a signal to the CAR to reduce CPU frequency by half on reaching
+    a certain thermal/voltage threshold.
+
+    Generates a signal to the PMC when the temperature reaches dangerously high
+    levels to reset the chip and sets a flag in the PMC.
+
+  TSENSOR has two channels which monitor two different spots of the SoC.
+
+properties:
+  compatible:
+    const: nvidia,tegra30-tsensor
+
+  reg:
+    maxItems: 1
+
+  clocks:
+    maxItems: 1
+
+  resets:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+  "#thermal-sensor-cells":
+    const: 1
+
+  assigned-clock-parents: true
+  assigned-clock-rates: true
+  assigned-clocks: true
+
+required:
+  - compatible
+  - reg
+  - clocks
+  - resets
+  - interrupts
+  - "#thermal-sensor-cells"
+
+additionalProperties: false
+
+examples:
+  - |
+    thermal-sensor@70014000 {
+      compatible = "nvidia,tegra30-tsensor";
+      reg = <0x70014000 0x500>;
+      interrupts = <0 102 4>;
+      clocks = <&clk 100>;
+      resets = <&rst 100>;
+
+      #thermal-sensor-cells = <1>;
+    };
#4 lore raw

PATCH v4 2/6 thermal: thermal_of: Stop zone device before unregistering it

In reply to Dmitry Osipenko

Zone device is enabled after thermal_zone_of_sensor_register() completion, but it's not disabled before senor is unregistered, leaving temperature polling active. This results in accessing a disabled zone device and produces a warning about this problem. Stop zone device before unregistering it in order to fix this "use-after-free" problem.

---
 drivers/thermal/thermal_of.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/thermal/thermal_of.c +3 -0
index 5b76f9a1280d..6379f26a335f 100644
@@ -559,6 +559,9 @@ void thermal_zone_of_sensor_unregister(struct device *dev,
 	if (!tz)
 		return;
 
+	/* stop temperature polling */
+	thermal_zone_device_disable(tzd);
+
 	mutex_lock(&tzd->lock);
 	tzd->ops->get_temp = NULL;
 	tzd->ops->get_trend = NULL;
Signature · 1 line
2.30.2
#5 lore raw

[thermal: thermal/next] thermal/core/thermal_of: Stop zone device before unregistering it

The following commit has been merged into the thermal/next branch of thermal:

The following commit has been merged into the thermal/next branch of thermal:

Commit-ID:     add9a126cfb59375c36e779bf739fc765219ed11
Gitweb:        https://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux.git//add9a126cfb59375c36e779bf739fc765219ed11
Author:        Dmitry Osipenko <[email protected]>
AuthorDate:    Wed, 16 Jun 2021 22:04:13 +03:00
Committer:     Daniel Lezcano <[email protected]>
CommitterDate: Fri, 18 Jun 2021 12:39:50 +02:00

thermal/core/thermal_of: Stop zone device before unregistering it

Zone device is enabled after thermal_zone_of_sensor_register() completion, but it's not disabled before senor is unregistered, leaving temperature polling active. This results in accessing a disabled zone device and produces a warning about this problem. Stop zone device before unregistering it in order to fix this "use-after-free" problem.

---
 drivers/thermal/thermal_of.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/thermal/thermal_of.c +3 -0
index 5b76f9a..6379f26 100644
@@ -559,6 +559,9 @@ void thermal_zone_of_sensor_unregister(struct device *dev,
 	if (!tz)
 		return;
 
+	/* stop temperature polling */
+	thermal_zone_device_disable(tzd);
+
 	mutex_lock(&tzd->lock);
 	tzd->ops->get_temp = NULL;
 	tzd->ops->get_trend = NULL;
#6 lore raw

[thermal: thermal/next] thermal/core/thermal_of: Stop zone device before unregistering it

In reply to Dmitry Osipenko
The following commit has been merged into the thermal/next branch of thermal:

The following commit has been merged into the thermal/next branch of thermal:

Commit-ID:     5e5c9f9a75fc4532980c2e699caf8a36070a3a2e
Gitweb:        https://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux.git//5e5c9f9a75fc4532980c2e699caf8a36070a3a2e
Author:        Dmitry Osipenko <[email protected]>
AuthorDate:    Wed, 16 Jun 2021 22:04:13 +03:00
Committer:     Daniel Lezcano <[email protected]>
CommitterDate: Sun, 04 Jul 2021 18:28:04 +02:00

thermal/core/thermal_of: Stop zone device before unregistering it

Zone device is enabled after thermal_zone_of_sensor_register() completion, but it's not disabled before senor is unregistered, leaving temperature polling active. This results in accessing a disabled zone device and produces a warning about this problem. Stop zone device before unregistering it in order to fix this "use-after-free" problem.

---
 drivers/thermal/thermal_of.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/thermal/thermal_of.c +3 -0
index 5b76f9a..6379f26 100644
@@ -559,6 +559,9 @@ void thermal_zone_of_sensor_unregister(struct device *dev,
 	if (!tz)
 		return;
 
+	/* stop temperature polling */
+	thermal_zone_device_disable(tzd);
+
 	mutex_lock(&tzd->lock);
 	tzd->ops->get_temp = NULL;
 	tzd->ops->get_trend = NULL;
#7 lore raw

PATCH v4 3/6 thermal/drivers/tegra: Add driver for Tegra30 thermal sensor

In reply to Dmitry Osipenko

All NVIDIA Tegra30 SoCs have a two-channel on-chip sensor unit which monitors temperature and voltage of the SoC. Sensors control CPU frequency throttling, which is activated by hardware once preprogrammed temperature level is breached, they also send signal to Power Management controller to perform emergency shutdown on a critical overheat of the SoC die. Add driver for the Tegra30 TSENSOR module, exposing it as a thermal sensor.

---
 drivers/thermal/tegra/Kconfig           |   7 +
 drivers/thermal/tegra/Makefile          |   1 +
 drivers/thermal/tegra/tegra30-tsensor.c | 673 ++++++++++++++++++++++++
 3 files changed, 681 insertions(+)
 create mode 100644 drivers/thermal/tegra/tegra30-tsensor.c
drivers/thermal/tegra/Kconfig +7 -0
index 46c2215867cd..019e3a2eb69e 100644
@@ -18,4 +18,11 @@ config TEGRA_BPMP_THERMAL
 	  Enable this option for support for sensing system temperature of NVIDIA
 	  Tegra systems-on-chip with the BPMP coprocessor (Tegra186).
 
+config TEGRA30_TSENSOR
+	tristate "Tegra30 Thermal Sensor"
+	depends on ARCH_TEGRA_3x_SOC || COMPILE_TEST
+	help
+	  Enable this option to support thermal management of NVIDIA Tegra30
+	  system-on-chip.
+
 endmenu
drivers/thermal/tegra/Makefile +1 -0
index 0f2b66edf0d2..eb27d194c583 100644
@@ -1,6 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0
 obj-$(CONFIG_TEGRA_SOCTHERM)		+= tegra-soctherm.o
 obj-$(CONFIG_TEGRA_BPMP_THERMAL)	+= tegra-bpmp-thermal.o
+obj-$(CONFIG_TEGRA30_TSENSOR)		+= tegra30-tsensor.o
 
 tegra-soctherm-y				:= soctherm.o soctherm-fuse.o
 tegra-soctherm-$(CONFIG_ARCH_TEGRA_124_SOC)	+= tegra124-soctherm.o
drivers/thermal/tegra/tegra30-tsensor.c new file +673 -0

673 lines not on this page · raw message

Signature · 1 line
2.30.2
#8 lore raw

[thermal: thermal/next] thermal/drivers/tegra: Add driver for Tegra30 thermal sensor

The following commit has been merged into the thermal/next branch of thermal:

The following commit has been merged into the thermal/next branch of thermal:

Commit-ID:     6b3c6646909619ecd0bcd995b838d8186d006c4d
Gitweb:        https://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux.git//6b3c6646909619ecd0bcd995b838d8186d006c4d
Author:        Dmitry Osipenko <[email protected]>
AuthorDate:    Wed, 16 Jun 2021 22:04:14 +03:00
Committer:     Daniel Lezcano <[email protected]>
CommitterDate: Fri, 18 Jun 2021 12:41:16 +02:00

thermal/drivers/tegra: Add driver for Tegra30 thermal sensor

All NVIDIA Tegra30 SoCs have a two-channel on-chip sensor unit which monitors temperature and voltage of the SoC. Sensors control CPU frequency throttling, which is activated by hardware once preprogrammed temperature level is breached, they also send signal to Power Management controller to perform emergency shutdown on a critical overheat of the SoC die. Add driver for the Tegra30 TSENSOR module, exposing it as a thermal sensor.

---
 drivers/thermal/tegra/Kconfig           |   7 +-
 drivers/thermal/tegra/Makefile          |   1 +-
 drivers/thermal/tegra/tegra30-tsensor.c | 673 +++++++++++++++++++++++-
 3 files changed, 681 insertions(+)
 create mode 100644 drivers/thermal/tegra/tegra30-tsensor.c
drivers/thermal/tegra/Kconfig +7 -0
index eca61c5..cfa41d8 100644
@@ -18,4 +18,11 @@ config TEGRA_BPMP_THERMAL
 	  Enable this option for support for sensing system temperature of NVIDIA
 	  Tegra systems-on-chip with the BPMP coprocessor (Tegra186).
 
+config TEGRA30_TSENSOR
+	tristate "Tegra30 Thermal Sensor"
+	depends on ARCH_TEGRA_3x_SOC || COMPILE_TEST
+	help
+	  Enable this option to support thermal management of NVIDIA Tegra30
+	  system-on-chip.
+
 endmenu
drivers/thermal/tegra/Makefile +1 -0
index 0f2b66e..eb27d19 100644
@@ -1,6 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0
 obj-$(CONFIG_TEGRA_SOCTHERM)		+= tegra-soctherm.o
 obj-$(CONFIG_TEGRA_BPMP_THERMAL)	+= tegra-bpmp-thermal.o
+obj-$(CONFIG_TEGRA30_TSENSOR)		+= tegra30-tsensor.o
 
 tegra-soctherm-y				:= soctherm.o soctherm-fuse.o
 tegra-soctherm-$(CONFIG_ARCH_TEGRA_124_SOC)	+= tegra124-soctherm.o
drivers/thermal/tegra/tegra30-tsensor.c new file +673 -0

673 lines not on this page · raw message

#9 lore raw

[thermal: thermal/next] thermal/drivers/tegra: Add driver for Tegra30 thermal sensor

In reply to Dmitry Osipenko
The following commit has been merged into the thermal/next branch of thermal:

The following commit has been merged into the thermal/next branch of thermal:

Commit-ID:     3747e4263ff6d6085507a32946f8236c62dd2495
Gitweb:        https://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux.git//3747e4263ff6d6085507a32946f8236c62dd2495
Author:        Dmitry Osipenko <[email protected]>
AuthorDate:    Wed, 16 Jun 2021 22:04:14 +03:00
Committer:     Daniel Lezcano <[email protected]>
CommitterDate: Sat, 14 Aug 2021 12:23:39 +02:00

thermal/drivers/tegra: Add driver for Tegra30 thermal sensor

All NVIDIA Tegra30 SoCs have a two-channel on-chip sensor unit which monitors temperature and voltage of the SoC. Sensors control CPU frequency throttling, which is activated by hardware once preprogrammed temperature level is breached, they also send signal to Power Management controller to perform emergency shutdown on a critical overheat of the SoC die. Add driver for the Tegra30 TSENSOR module, exposing it as a thermal sensor.

---
 drivers/thermal/tegra/Kconfig           |   7 +-
 drivers/thermal/tegra/Makefile          |   1 +-
 drivers/thermal/tegra/tegra30-tsensor.c | 673 +++++++++++++++++++++++-
 3 files changed, 681 insertions(+)
 create mode 100644 drivers/thermal/tegra/tegra30-tsensor.c
drivers/thermal/tegra/Kconfig +7 -0
index 46c2215..019e3a2 100644
@@ -18,4 +18,11 @@ config TEGRA_BPMP_THERMAL
 	  Enable this option for support for sensing system temperature of NVIDIA
 	  Tegra systems-on-chip with the BPMP coprocessor (Tegra186).
 
+config TEGRA30_TSENSOR
+	tristate "Tegra30 Thermal Sensor"
+	depends on ARCH_TEGRA_3x_SOC || COMPILE_TEST
+	help
+	  Enable this option to support thermal management of NVIDIA Tegra30
+	  system-on-chip.
+
 endmenu
drivers/thermal/tegra/Makefile +1 -0
index 0f2b66e..eb27d19 100644
@@ -1,6 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0
 obj-$(CONFIG_TEGRA_SOCTHERM)		+= tegra-soctherm.o
 obj-$(CONFIG_TEGRA_BPMP_THERMAL)	+= tegra-bpmp-thermal.o
+obj-$(CONFIG_TEGRA30_TSENSOR)		+= tegra30-tsensor.o
 
 tegra-soctherm-y				:= soctherm.o soctherm-fuse.o
 tegra-soctherm-$(CONFIG_ARCH_TEGRA_124_SOC)	+= tegra124-soctherm.o
drivers/thermal/tegra/tegra30-tsensor.c new file +673 -0

673 lines not on this page · raw message

#10 lore raw

PATCH v4 4/6 ARM: tegra_defconfig: Enable CONFIG_TEGRA30_TSENSOR

In reply to Dmitry Osipenko

Enable NVIDIA Tegra30 SoC thermal sensor driver in tegra_defconfig.

---
 arch/arm/configs/tegra_defconfig | 1 +
 1 file changed, 1 insertion(+)
arch/arm/configs/tegra_defconfig +1 -0
index 3d8d8af9524d..63e7f3261e6d 100644
@@ -169,6 +169,7 @@ CONFIG_THERMAL_STATISTICS=y
 CONFIG_CPU_THERMAL=y
 CONFIG_DEVFREQ_THERMAL=y
 CONFIG_TEGRA_SOCTHERM=m
+CONFIG_TEGRA30_TSENSOR=m
 CONFIG_WATCHDOG=y
 CONFIG_MAX77620_WATCHDOG=y
 CONFIG_TEGRA_WATCHDOG=y
Signature · 1 line
2.30.2
#11 lore raw

PATCH v4 5/6 ARM: multi_v7_defconfig: Enable CONFIG_TEGRA30_TSENSOR

In reply to Dmitry Osipenko

Enable NVIDIA Tegra30 SoC thermal sensor driver in multi_v7_defconfig.

---
 arch/arm/configs/multi_v7_defconfig | 1 +
 1 file changed, 1 insertion(+)
arch/arm/configs/multi_v7_defconfig +1 -0
index 52a0400fdd92..fc346f87d7f9 100644
@@ -523,6 +523,7 @@ CONFIG_BRCMSTB_THERMAL=m
 CONFIG_GENERIC_ADC_THERMAL=m
 CONFIG_ST_THERMAL_MEMMAP=y
 CONFIG_TEGRA_SOCTHERM=m
+CONFIG_TEGRA30_TSENSOR=m
 CONFIG_UNIPHIER_THERMAL=y
 CONFIG_DA9063_WATCHDOG=m
 CONFIG_XILINX_WATCHDOG=y
Signature · 1 line
2.30.2
#12 lore raw

PATCH v4 6/6 ARM: tegra: Add SoC thermal sensor to Tegra30 device-trees

In reply to Dmitry Osipenko

Add the on-chip SoC thermal sensor to Tegra30 device-trees. Now CPU temperature reporting and thermal throttling is available on all Tegra30 devices universally.

---
 arch/arm/boot/dts/tegra30.dtsi | 87 ++++++++++++++++++++++++++++++++--
 1 file changed, 83 insertions(+), 4 deletions(-)
arch/arm/boot/dts/tegra30.dtsi +83 -4
index c577c191be4b..404b6ecc9c20 100644
@@ -5,6 +5,7 @@
 #include <dt-bindings/pinctrl/pinctrl-tegra.h>
 #include <dt-bindings/interrupt-controller/arm-gic.h>
 #include <dt-bindings/soc/tegra-pmc.h>
+#include <dt-bindings/thermal/thermal.h>
 
 #include "tegra30-peripherals-opp.dtsi"
 
@@ -800,6 +801,20 @@ fuse@7000f800 {
 		reset-names = "fuse";
 	};
 
+	tsensor: tsensor@70014000 {
+		compatible = "nvidia,tegra30-tsensor";
+		reg = <0x70014000 0x500>;
+		interrupts = <GIC_SPI 102 IRQ_TYPE_LEVEL_HIGH>;
+		clocks = <&tegra_car TEGRA30_CLK_TSENSOR>;
+		resets = <&tegra_car TEGRA30_CLK_TSENSOR>;
+
+		assigned-clocks = <&tegra_car TEGRA30_CLK_TSENSOR>;
+		assigned-clock-parents = <&tegra_car TEGRA30_CLK_CLK_M>;
+		assigned-clock-rates = <500000>;
+
+		#thermal-sensor-cells = <1>;
+	};
+
 	hda@70030000 {
 		compatible = "nvidia,tegra30-hda";
 		reg = <0x70030000 0x10000>;
@@ -1062,32 +1077,36 @@ cpus {
 		#address-cells = <1>;
 		#size-cells = <0>;
 
-		cpu@0 {
+		cpu0: cpu@0 {
 			device_type = "cpu";
 			compatible = "arm,cortex-a9";
 			reg = <0>;
 			clocks = <&tegra_car TEGRA30_CLK_CCLK_G>;
+			#cooling-cells = <2>;
 		};
 
-		cpu@1 {
+		cpu1: cpu@1 {
 			device_type = "cpu";
 			compatible = "arm,cortex-a9";
 			reg = <1>;
 			clocks = <&tegra_car TEGRA30_CLK_CCLK_G>;
+			#cooling-cells = <2>;
 		};
 
-		cpu@2 {
+		cpu2: cpu@2 {
 			device_type = "cpu";
 			compatible = "arm,cortex-a9";
 			reg = <2>;
 			clocks = <&tegra_car TEGRA30_CLK_CCLK_G>;
+			#cooling-cells = <2>;
 		};
 
-		cpu@3 {
+		cpu3: cpu@3 {
 			device_type = "cpu";
 			compatible = "arm,cortex-a9";
 			reg = <3>;
 			clocks = <&tegra_car TEGRA30_CLK_CCLK_G>;
+			#cooling-cells = <2>;
 		};
 	};
 
@@ -1102,4 +1121,64 @@ pmu {
 				     <&{/cpus/cpu@2}>,
 				     <&{/cpus/cpu@3}>;
 	};
+
+	thermal-zones {
+		tsensor-channel0 {
+			polling-delay-passive = <1000>; /* milliseconds */
+			polling-delay = <5000>; /* milliseconds */
+
+			thermal-sensors = <&tsensor 0>;
+
+			trips {
+				level1_trip: dvfs-alert {
+					/* throttle at 80C until temperature drops to 79.8C */
+					temperature = <80000>;
+					hysteresis = <200>;
+					type = "passive";
+				};
+
+				level2_trip: cpu-div2-throttle {
+					/* hardware CPU x2 freq throttle at 85C */
+					temperature = <85000>;
+					hysteresis = <200>;
+					type = "hot";
+				};
+
+				level3_trip: soc-critical {
+					/* hardware shut down at 90C */
+					temperature = <90000>;
+					hysteresis = <2000>;
+					type = "critical";
+				};
+			};
+
+			cooling-maps {
+				map0 {
+					trip = <&level1_trip>;
+					cooling-device = <&cpu0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>,
+							 <&cpu1 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>,
+							 <&cpu2 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>,
+							 <&cpu3 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>,
+							 <&actmon THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
+				};
+			};
+		};
+
+		tsensor-channel1 {
+			status = "disabled";
+
+			polling-delay-passive = <1000>; /* milliseconds */
+			polling-delay = <0>; /* milliseconds */
+
+			thermal-sensors = <&tsensor 1>;
+
+			trips {
+				dvfs-alert {
+					temperature = <80000>;
+					hysteresis = <200>;
+					type = "passive";
+				};
+			};
+		};
+	};
 };
Signature · 1 line
2.30.2
#13 lore raw
In reply to Dmitry Osipenko

Hi Dmitry,

I compiled the your series and got these unresolved.

arm-linux-gnueabi-ld: drivers/thermal/tegra/soctherm-fuse.o: in function `tegra_calc_shared_calib':
soctherm-fuse.c:(.text+0x60): undefined reference to `tegra_fuse_readl'
arm-linux-gnueabi-ld: soctherm-fuse.c:(.text+0xf0): undefined reference to `tegra_fuse_readl'
arm-linux-gnueabi-ld: drivers/thermal/tegra/soctherm-fuse.o: in function `tegra_calc_tsensor_calib':
soctherm-fuse.c:(.text+0x144): undefined reference to `tegra_fuse_readl'
arm-linux-gnueabi-ld: drivers/thermal/tegra/tegra30-tsensor.o: in function `tegra_tsensor_fuse_read_spare':
tegra30-tsensor.c:(.text+0x364): undefined reference to `tegra_fuse_readl'
arm-linux-gnueabi-ld: drivers/thermal/tegra/tegra30-tsensor.o: in function `tegra_tsensor_probe':
tegra30-tsensor.c:(.text+0x874): undefined reference to `tegra_fuse_readl' arm-linux-gnueabi-ld:
drivers/thermal/tegra/tegra30-tsensor.o:tegra30-tsensor.c:(.text+0x904):
more undefined references to `tegra_fuse_readl' follow
make[1]: *** [/home/dlezcano/Work/src/linux/Makefile:1196: vmlinux] Error 1
make: *** [/home/dlezcano/Work/src/linux/Makefile:215: __sub-make] Error 2

Quoted 50 lines · Dmitry Osipenko

Hi,

This series adds support for the thermal sensor that is found on NVIDIA Tegra30 SoC. Sensor monitors temperature and voltage of the SoC, it also emits signals to the power management and clock controllers that are performing the emergency shut down and the CPU frequency throttling when a pre-programmed temperature levels are reached.

Changelog:

v4: - Removed DIV2 CPU frequency throttling and cooling device part as was
suggested by Daniel Lezcano since we need to notify cpufreq about the updated frequency and change the thermal pressure. The thermal pressure change should co-exists with the cpufreq_cooling. This all needs some more thought, so the DIV2 mitigation will come sometime later.

- Added ack from Thierry Reding.

- Changed default TZ trips in the device-tree to the silicon temperature levels, instead of the average device levels.

v3: - No code changes. CC'ed linux-pm, which was previously missed by accident.
Not sure how much that is important for the thermal patches, but won't hurt to re-send since only DT binding was reviewed so far.

v2: - Made a very minor improvement to one error message, it now prints
number of channel at which error occurred.

- Added r-b from Rob Herring to the binding.

Dmitry Osipenko (6):
dt-bindings: thermal: Add binding for Tegra30 thermal sensor
thermal: thermal_of: Stop zone device before unregistering it thermal/drivers/tegra: Add driver for Tegra30 thermal sensor
ARM: tegra_defconfig: Enable CONFIG_TEGRA30_TSENSOR
ARM: multi_v7_defconfig: Enable CONFIG_TEGRA30_TSENSOR
ARM: tegra: Add SoC thermal sensor to Tegra30 device-trees

 .../thermal/nvidia,tegra30-tsensor.yaml       |  73 ++
 arch/arm/boot/dts/tegra30.dtsi                |  87 ++-
 arch/arm/configs/multi_v7_defconfig           |   1 +
 arch/arm/configs/tegra_defconfig              |   1 +
 drivers/thermal/tegra/Kconfig                 |   7 +
 drivers/thermal/tegra/Makefile                |   1 +
 drivers/thermal/tegra/tegra30-tsensor.c       | 673 ++++++++++++++++++
 drivers/thermal/thermal_of.c                  |   3 +
 8 files changed, 842 insertions(+), 4 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/thermal/nvidia,tegra30-tsensor.yaml
 create mode 100644 drivers/thermal/tegra/tegra30-tsensor.c
Signature · 5 lines
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
#14 lore raw

21.06.2021 20:13, Daniel Lezcano пишет:

Quoted 16 lines

Hi Dmitry,

I compiled the your series and got these unresolved.

arm-linux-gnueabi-ld: drivers/thermal/tegra/soctherm-fuse.o: in function `tegra_calc_shared_calib':
soctherm-fuse.c:(.text+0x60): undefined reference to `tegra_fuse_readl'
arm-linux-gnueabi-ld: soctherm-fuse.c:(.text+0xf0): undefined reference to `tegra_fuse_readl'
arm-linux-gnueabi-ld: drivers/thermal/tegra/soctherm-fuse.o: in function `tegra_calc_tsensor_calib':
soctherm-fuse.c:(.text+0x144): undefined reference to `tegra_fuse_readl'
arm-linux-gnueabi-ld: drivers/thermal/tegra/tegra30-tsensor.o: in function `tegra_tsensor_fuse_read_spare':
tegra30-tsensor.c:(.text+0x364): undefined reference to `tegra_fuse_readl'

Quoted 8 lines

arm-linux-gnueabi-ld: drivers/thermal/tegra/tegra30-tsensor.o: in function `tegra_tsensor_probe':
tegra30-tsensor.c:(.text+0x874): undefined reference to `tegra_fuse_readl' arm-linux-gnueabi-ld:
drivers/thermal/tegra/tegra30-tsensor.o:tegra30-tsensor.c:(.text+0x904):
more undefined references to `tegra_fuse_readl' follow
make[1]: *** [/home/dlezcano/Work/src/linux/Makefile:1196: vmlinux] Error 1
make: *** [/home/dlezcano/Work/src/linux/Makefile:215: __sub-make] Error 2

The missing stub was added by [1]. I guess you could take [2] for the base since Thierry already sent out PR for 5.14, or we could defer the "thermal/drivers/tegra: Correct compile-testing of drivers" patch till the next kernel version. Please choose whatever is easier for you.

[1]
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=30b44e81772a5caa983000057ce1cd9cb4531647

[2]
https://git.kernel.org/pub/scm/linux/kernel/git/tegra/linux.git/log/?h=for-5.14/soc

#15 lore raw
Quoted 26 lines · Dmitry Osipenko

21.06.2021 20:13, Daniel Lezcano пишет:

Quoted 16 lines

Hi Dmitry,

I compiled the your series and got these unresolved.

arm-linux-gnueabi-ld: drivers/thermal/tegra/soctherm-fuse.o: in function `tegra_calc_shared_calib':
soctherm-fuse.c:(.text+0x60): undefined reference to `tegra_fuse_readl'
arm-linux-gnueabi-ld: soctherm-fuse.c:(.text+0xf0): undefined reference to `tegra_fuse_readl'
arm-linux-gnueabi-ld: drivers/thermal/tegra/soctherm-fuse.o: in function `tegra_calc_tsensor_calib':
soctherm-fuse.c:(.text+0x144): undefined reference to `tegra_fuse_readl'
arm-linux-gnueabi-ld: drivers/thermal/tegra/tegra30-tsensor.o: in function `tegra_tsensor_fuse_read_spare':
tegra30-tsensor.c:(.text+0x364): undefined reference to `tegra_fuse_readl'

Quoted 8 lines

arm-linux-gnueabi-ld: drivers/thermal/tegra/tegra30-tsensor.o: in function `tegra_tsensor_probe':
tegra30-tsensor.c:(.text+0x874): undefined reference to `tegra_fuse_readl' arm-linux-gnueabi-ld:
drivers/thermal/tegra/tegra30-tsensor.o:tegra30-tsensor.c:(.text+0x904):
more undefined references to `tegra_fuse_readl' follow
make[1]: *** [/home/dlezcano/Work/src/linux/Makefile:1196: vmlinux] Error 1
make: *** [/home/dlezcano/Work/src/linux/Makefile:215: __sub-make] Error 2

Quoted 4 lines

The missing stub was added by [1]. I guess you could take [2] for the base since Thierry already sent out PR for 5.14, or we could defer the "thermal/drivers/tegra: Correct compile-testing of drivers" patch till the next kernel version. Please choose whatever is easier for you.

I would like to prevent to have more patches floating around. As we are close the to the merge window, I think we can live with the missing stubs ATM. But in the future, provide an immutable branch with the fixes, so we can share it and prevent these issues.

-- Daniel

Signature · 5 lines
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
#16 lore raw

21.06.2021 21:16, Daniel Lezcano пишет:

Quoted 32 lines · Dmitry Osipenko
Quoted 26 lines

21.06.2021 20:13, Daniel Lezcano пишет:

Quoted 16 lines

Hi Dmitry,

I compiled the your series and got these unresolved.

arm-linux-gnueabi-ld: drivers/thermal/tegra/soctherm-fuse.o: in function `tegra_calc_shared_calib':
soctherm-fuse.c:(.text+0x60): undefined reference to `tegra_fuse_readl'
arm-linux-gnueabi-ld: soctherm-fuse.c:(.text+0xf0): undefined reference to `tegra_fuse_readl'
arm-linux-gnueabi-ld: drivers/thermal/tegra/soctherm-fuse.o: in function `tegra_calc_tsensor_calib':
soctherm-fuse.c:(.text+0x144): undefined reference to `tegra_fuse_readl'
arm-linux-gnueabi-ld: drivers/thermal/tegra/tegra30-tsensor.o: in function `tegra_tsensor_fuse_read_spare':
tegra30-tsensor.c:(.text+0x364): undefined reference to `tegra_fuse_readl'

Quoted 8 lines

arm-linux-gnueabi-ld: drivers/thermal/tegra/tegra30-tsensor.o: in function `tegra_tsensor_probe':
tegra30-tsensor.c:(.text+0x874): undefined reference to `tegra_fuse_readl' arm-linux-gnueabi-ld:
drivers/thermal/tegra/tegra30-tsensor.o:tegra30-tsensor.c:(.text+0x904):
more undefined references to `tegra_fuse_readl' follow
make[1]: *** [/home/dlezcano/Work/src/linux/Makefile:1196: vmlinux] Error 1
make: *** [/home/dlezcano/Work/src/linux/Makefile:215: __sub-make] Error 2

Quoted 4 lines

The missing stub was added by [1]. I guess you could take [2] for the base since Thierry already sent out PR for 5.14, or we could defer the "thermal/drivers/tegra: Correct compile-testing of drivers" patch till the next kernel version. Please choose whatever is easier for you.

Quoted 4 lines

I would like to prevent to have more patches floating around. As we are close the to the merge window, I think we can live with the missing stubs ATM. But in the future, provide an immutable branch with the fixes, so we can share it and prevent these issues.

Thank you! There were multiple issues like this during this kernel release. It's not easy to track all dependencies, I keep forgetting when and which patches are already applied. Hopefully nobody bisects code with COMPILE_TEST=y, so this should be a minor issue. Sorry for the inconvenience.