Skip to contentSkip to conversation

thermal: bcm2835: add thermal driver

PATCH Superseded kernel at martin.sperl.org 4 participants 15 messages Sep 21, 2016 – Nov 2, 2016

Subsystems (5)

v7 of 9 Superseded Latest is v9 →

lore
Share & tools
lore
#0 lore raw

v7 cover thermal: bcm2835: add thermal driver

From: Martin Sperl <[email protected]>

Add a thermal driver for the TSENSE device of the bcm2835/6/7 SOC.

If the firmware enables the HW, then the configuration is not touched. In case the firmware has not enabled the device, then we try to set it up correctly (which unfortunately can not get tested).

It exposes temperature and a critical trip point (using a hardcoded default of 80C or the temperature configured in the control register by the firmware, which reads as 407C currently)

The calibrations are (potentially) different for bcm2835, bcm2836 and bcm2837 and can get selected by the compatible property in the device tree.

The driver also exposes the registers via debugfs.

Possible future enhancements:
* the device has the ability to trigger interrupts on reaching the programmed critical temperature.
I have no knowledge which interrupt could be responsible for this on the ARM side, so if we get to know which irq it is we can implement that.
Instead the driver right now implements polling in 1 second intervals
* the device can also reset the HW after the trip point
has been reached (also with some delay, so that corrective actions can get taken) - this is currently not enabled by the firmware, but could.
* we could define more trip points for THERMAL_TRIP_HOT
* make the trip point limits modifiable (ops.set_trip_temp)

Note:
No support for 32-bit arm bcm2837, as there is no arch/arm/boot/dts/bcm2836.dtsi upstream as of now. 64-bit arm support is not tested

Changelog:
V1 -> V2: renamed dt-binding documentation file
added specific settings depending on compatible added trip point based on register
setting up ctrl-register if HW is not enabled by firmware
as per recommendation of Eric (untested)
check that clock frequency is in range
(1.9 - 5MHz - as per comment in clk-bcm2835.c)
added driver to multi_v7_defconfig
V2 -> V3: made a module in multi_v7_defconfig
fixed typo in dt-binding document
V3 -> V4: moved driver back to thermal (not using bcm sub-directory)
set polling interval to 1second (was 0ms, so interrupt driven)
V4 -> V5: use correct compatiblity for different soc versions in dt
support ARM64 for bcm2837 in devicetree and defconfig
V5 -> V6: incorporated changes recommended by Stefan Wahren V6 -> V7: removed depends on ARCH_BCM2836 || ARCH_BCM2837 in Kconfig

Martin Sperl (6):
dt: bindings: add thermal device driver for bcm2835
thermal: bcm2835: add thermal driver for bcm2835 soc
ARM: bcm2835: dts: add thermal node to device-tree of bcm283x
ARM64: bcm2835: dts: add thermal node to device-tree of bcm2837
ARM: bcm2835: add thermal driver to default_config
ARM64: bcm2835: add thermal driver to default_config

 .../bindings/thermal/brcm,bcm2835-thermal.txt      |  17 ++
 arch/arm/boot/dts/bcm2835.dtsi                     |   6 +
 arch/arm/boot/dts/bcm2836.dtsi                     |   6 +
 arch/arm/boot/dts/bcm283x.dtsi                     |   7 +
 arch/arm/configs/bcm2835_defconfig                 |   2 +
 arch/arm64/boot/dts/broadcom/bcm2837.dtsi          |   6 +
 arch/arm64/configs/defconfig                       |   1 +
 drivers/thermal/Kconfig                            |   8 +
 drivers/thermal/Makefile                           |   1 +
 drivers/thermal/bcm2835_thermal.c                  | 340 +++++++++++++++++++++
 10 files changed, 394 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/thermal/brcm,bcm2835-thermal.txt
 create mode 100644 drivers/thermal/bcm2835_thermal.c

--
2.1.4

#1 lore raw

PATCH v7 1/6 dt: bindings: add thermal device driver for bcm2835

From: Martin Sperl <[email protected]>

Add dt-binding documentation for bcm2835 SOC thermal sensor.

Changelog:
V1 -> V2: renamed file to follow naming conventions V2 -> V3: removed 0x in node name

---
 .../bindings/thermal/brcm,bcm2835-thermal.txt           | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/thermal/brcm,bcm2835-thermal.txt
Documentation/devicetree/bindings/thermal/brcm,bcm2835-thermal.txt new file +17 -0
new file mode 100644
index 0000000..474531d
@@ -0,0 +1,17 @@
+Binding for Thermal Sensor driver for BCM2835 SoCs.
+
+Required parameters:
+-------------------
+
+compatible: 	should be one of: "brcm,bcm2835-thermal",
+		"brcm,bcm2836-thermal" or "brcm,bcm2837-thermal"
+reg:		Address range of the thermal registers.
+clocks: 	Phandle of the clock used by the thermal sensor.
+
+Example:
+
+thermal: thermal at 7e212000 {
+	compatible = "brcm,bcm2835-thermal";
+	reg = <0x7e212000 0x8>;
+	clocks = <&clocks BCM2835_CLOCK_TSENS>;
+};
Signature · 1 line
2.1.4
#2 lore raw

PATCH v7 2/6 thermal: bcm2835: add thermal driver for bcm2835 soc

In reply to kernel at martin.sperl.org

From: Martin Sperl <[email protected]>

Add basic thermal driver for bcm2835 SOC.

This driver currently relies on the firmware setting up the tsense HW block and does not set it up itself.

ChangeLog:
V1 -> V2: added specific settings depending on compatiblity
added trip point based on register
setting up ctrl-register if HW is not enabled by firmware
as per recommendation of Eric (untested)
check that clock frequency is in range
(1.9 - 5MHz - as per comment in clk-bcm2835.c)
V2 -> V4: moved back to thermal (not using bcm sub-directory)
set polling interval to 1second (was 0ms, so interrupt driven)
V5 -> V6: added correct depends in KConfig
removed defined default for RESET_DELAY
removed obvious comments
clarify HW setup comments if not set up by FW already move clk_prepare_enable to an earlier stage and add error handling clarify warning when TS-clock runs out of recommended range clk_disable_unprepare added in bcm2835_thermal_remove added comment on recommended temperature ranges for SOC
V6 -> V7: removed depends on ARCH_BCM2836 || ARCH_BCM2837 in Kconfig

---
 drivers/thermal/Kconfig           |   8 +
 drivers/thermal/Makefile          |   1 +
 drivers/thermal/bcm2835_thermal.c | 340 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 349 insertions(+)
 create mode 100644 drivers/thermal/bcm2835_thermal.c
drivers/thermal/Kconfig +8 -0
index 2d702ca..1bc8b14 100644
@@ -399,4 +399,12 @@ config GENERIC_ADC_THERMAL
 	  to this driver. This driver reports the temperature by reading ADC
 	  channel and converts it to temperature based on lookup table.
 
+config BCM2835_THERMAL
+	tristate "Thermal sensors on bcm2835 SoC"
+	depends on ARCH_BCM2835 || COMPILE_TEST
+	depends on HAS_IOMEM
+	depends on OF
+	help
+	  Support for thermal sensors on Broadcom bcm2835 SoCs.
+
 endif
drivers/thermal/Makefile +1 -0
index 10b07c1..c26343e 100644
@@ -51,3 +51,4 @@ obj-$(CONFIG_TEGRA_SOCTHERM)	+= tegra/
 obj-$(CONFIG_HISI_THERMAL)     += hisi_thermal.o
 obj-$(CONFIG_MTK_THERMAL)	+= mtk_thermal.o
 obj-$(CONFIG_GENERIC_ADC_THERMAL)	+= thermal-generic-adc.o
+obj-$(CONFIG_BCM2835_THERMAL)	+= bcm2835_thermal.o
drivers/thermal/bcm2835_thermal.c new file +340 -0

340 lines not on this page · raw message

Signature · 1 line
2.1.4
#3 lore raw

PATCH v7 2/6 thermal: bcm2835: add thermal driver for bcm2835 soc

Quoted 10 lines · kernel at martin.sperl.org

From: Martin Sperl <[email protected]>

Add basic thermal driver for bcm2835 SOC.

This driver currently relies on the firmware setting up the tsense HW block and does not set it up itself.

What's the status of merging this one? I'd like to merge the other
patches.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 800 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20160928/23e2792a/attachment.sig>

#4 lore raw

PATCH v7 2/6 thermal: bcm2835: add thermal driver for bcm2835 soc

Quoted 13 lines

Eric Anholt <[email protected]> hat am 28. September 2016 um 23:10 geschrieben:

Quoted 7 lines · kernel at martin.sperl.org

From: Martin Sperl <[email protected]>

Add basic thermal driver for bcm2835 SOC.

This driver currently relies on the firmware setting up the tsense HW block and does not set it up itself.

Quoted 6 lines
Quoted 3 lines

What's the status of merging this one? I'd like to merge the other patches.

gently ping ...

#5 lore raw

PATCH v7 2/6 thermal: bcm2835: add thermal driver for bcm2835 soc

In reply to Eric Anholt

Hi Martin,

Am 28.09.2016 um 23:10 schrieb Eric Anholt:

Quoted 6 lines
Quoted 4 lines · kernel at martin.sperl.org

From: Martin Sperl <[email protected]>

Add basic thermal driver for bcm2835 SOC.

Quoted 8 lines
Quoted 6 lines

This driver currently relies on the firmware setting up the tsense HW block and does not set it up itself.

What's the status of merging this one? I'd like to merge the other patches.

i think it's necessary to rebase the whole series. Maybe we could get it into 4.10.

Stefan

#6 lore raw

PATCH v7 2/6 thermal: bcm2835: add thermal driver for bcm2835 soc

Quoted 12 lines · Stefan Wahren

Hi Martin,

Am 28.09.2016 um 23:10 schrieb Eric Anholt:

Quoted 9 lines
Quoted 7 lines · kernel at martin.sperl.org

From: Martin Sperl <[email protected]>

Add basic thermal driver for bcm2835 SOC.

This driver currently relies on the firmware setting up the tsense HW block and does not set it up itself.

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

What's the status of merging this one? I'd like to merge the other patches.

i think it's necessary to rebase the whole series. Maybe we could get it into 4.10.

Why would it need to be rebased? The status, as far as I know, is that
we're still waiting for the subsystem maintainer to respond.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 800 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20161024/5f37774f/attachment.sig>

#7 lore raw

PATCH v7 2/6 thermal: bcm2835: add thermal driver for bcm2835 soc

Quoted 20 lines

Eric Anholt <[email protected]> hat am 24. Oktober 2016 um 18:38 geschrieben:

Quoted 15 lines · Stefan Wahren

Hi Martin,

Am 28.09.2016 um 23:10 schrieb Eric Anholt:

Quoted 12 lines
Quoted 10 lines · kernel at martin.sperl.org

From: Martin Sperl <[email protected]>

Add basic thermal driver for bcm2835 SOC.

This driver currently relies on the firmware setting up the tsense HW block and does not set it up itself.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

What's the status of merging this one? I'd like to merge the other patches.

i think it's necessary to rebase the whole series. Maybe we could get it into 4.10.

Why would it need to be rebased? The status, as far as I know, is that we're still waiting for the subsystem maintainer to respond.

Since at least this patch won't apply anymore, but feedback from maintainer is still good :-)

Sorry for this impatience, but i'm afraid that we possibly miss 4.10.

reviewer
#8 lore raw

PATCH v7 2/6 thermal: bcm2835: add thermal driver for bcm2835 soc

Quoted 31 lines · Stefan Wahren
Quoted 31 lines

Eric Anholt <[email protected]> hat am 24. Oktober 2016 um 18:38 geschrieben:

Quoted 24 lines · Stefan Wahren

Hi Martin,

Am 28.09.2016 um 23:10 schrieb Eric Anholt:

Quoted 11 lines
Quoted 8 lines · kernel at martin.sperl.org

From: Martin Sperl <[email protected]>

Add basic thermal driver for bcm2835 SOC.

This driver currently relies on the firmware setting up the tsense HW block and does not set it up itself.

Quoted 6 lines
Quoted 3 lines

What's the status of merging this one???I'd like to merge the other
patches.

i think it's necessary to rebase the whole series. Maybe we could get it
into 4.10.

Quoted 8 lines
Quoted 3 lines

Why would it need to be rebased???The status, as far as I know, is that
we're still waiting for the subsystem maintainer to respond.

Since at least this patch won't apply anymore, but feedback from maintainer is
still good :-)

Sorry for this impatience, but i'm afraid that we possibly miss 4.10.

Eduardo,

any comments on this patchset?

thanks,
rui

#9 lore raw

PATCH v7 2/6 thermal: bcm2835: add thermal driver for bcm2835 soc

Quoted 39 lines · Zhang Rui
Quoted 38 lines · Stefan Wahren
Quoted 28 lines

Eric Anholt <[email protected]> hat am 24. Oktober 2016 um 18:38 geschrieben:

Quoted 21 lines · Stefan Wahren

Hi Martin,

Am 28.09.2016 um 23:10 schrieb Eric Anholt:

Quoted 17 lines
Quoted 11 lines · kernel at martin.sperl.org

From: Martin Sperl <[email protected]>

Add basic thermal driver for bcm2835 SOC.

This driver currently relies on the firmware setting up the tsense HW block and does not set it up itself.

What's the status of merging this one???I'd like to merge the other
patches.

Quoted 6 lines
Quoted 3 lines

i think it's necessary to rebase the whole series. Maybe we could get it
into 4.10.

Why would it need to be rebased???The status, as far as I know, is that
we're still waiting for the subsystem maintainer to respond.

Since at least this patch won't apply anymore, but feedback from maintainer is
still good :-)

Quoted 5 lines
Quoted 1 line

Sorry for this impatience, but i'm afraid that we possibly miss 4.10.

Eduardo,

any comments on this patchset?

It's been a month on v7 of this patch. Can we please merge it?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 800 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20161031/4847b7b1/attachment.sig>

#10 lore raw

PATCH v7 2/6 thermal: bcm2835: add thermal driver for bcm2835 soc

In reply to Eric Anholt
Quoted 12 lines · Eric Anholt
Quoted 4 lines · Stefan Wahren

Hi Martin,

i think it's necessary to rebase the whole series. Maybe we could get it into 4.10.

Why would it need to be rebased? The status, as far as I know, is that we're still waiting for the subsystem maintainer to respond.

Sending out a rebased version 8 (specifically needed for patch 2 and 6).

Martin

#11 lore raw

PATCH v7 3/6 ARM: bcm2835: dts: add thermal node to device-tree of bcm283x

In reply to kernel at martin.sperl.org

From: Martin Sperl <[email protected]>

Add the node for the thermal sensor of the bcm2835-soc to the device tree.

Changelog:
V1 -> V5: generic settings is shared in bcm283x.dtsi, but disabled
moved the compatible string to the SOC specific dtsi
for arm and arm64
V5 -> V6: fix remove 0x prefix from thermal at 0x7e212000

Note: there is no arm/boot/dts/bcm2837.dtsi as of now,
so the 32-bit rpi3 dt is not modified.

---
 arch/arm/boot/dts/bcm2835.dtsi | 6 ++++++
 arch/arm/boot/dts/bcm2836.dtsi | 6 ++++++
 arch/arm/boot/dts/bcm283x.dtsi | 7 +++++++
 3 files changed, 19 insertions(+)
arch/arm/boot/dts/bcm2835.dtsi +6 -0
index a78759e..0890d97 100644
@@ -23,3 +23,9 @@
 		};
 	};
 };
+
+/* enable thermal sensor with the correct compatible property set */
+&thermal {
+	compatible = "brcm,bcm2835-thermal";
+	status = "okay";
+};
arch/arm/boot/dts/bcm2836.dtsi +6 -0
index 9d0651d..519a44f 100644
@@ -76,3 +76,9 @@
 	interrupt-parent = <&local_intc>;
 	interrupts = <8>;
 };
+
+/* enable thermal sensor with the correct compatible property set */
+&thermal {
+	compatible = "brcm,bcm2836-thermal";
+	status = "okay";
+};
arch/arm/boot/dts/bcm283x.dtsi +7 -0
index b982522..d9acf21 100644
@@ -186,6 +186,13 @@
 			interrupts = <2 14>; /* pwa1 */
 		};
 
+		thermal: thermal at 7e212000 {
+			compatible = "brcm,bcm2835-thermal";
+			reg = <0x7e212000 0x8>;
+			clocks = <&clocks BCM2835_CLOCK_TSENS>;
+			status = "disabled";
+		};
+
 		aux: aux at 0x7e215000 {
 			compatible = "brcm,bcm2835-aux";
 			#clock-cells = <1>;
Signature · 1 line
2.1.4
#12 lore raw

PATCH v7 4/6 ARM64: bcm2835: dts: add thermal node to device-tree of bcm2837

In reply to kernel at martin.sperl.org

From: Martin Sperl <[email protected]>

Add the node for the thermal sensor of the bcm2837-soc to the device tree.

---
 arch/arm64/boot/dts/broadcom/bcm2837.dtsi | 6 ++++++
 1 file changed, 6 insertions(+)
arch/arm64/boot/dts/broadcom/bcm2837.dtsi +6 -0
index f2a31d0..2b0cfc7 100644
@@ -74,3 +74,9 @@
 	interrupt-parent = <&local_intc>;
 	interrupts = <8>;
 };
+
+/* enable thermal sensor with the correct compatible property set */
+&thermal {
+	compatible = "brcm,bcm2837-thermal";
+	status = "okay";
+};
Signature · 1 line
2.1.4
#13 lore raw

PATCH v7 5/6 ARM: bcm2835: add thermal driver to default_config

In reply to kernel at martin.sperl.org

From: Martin Sperl <[email protected]>

Add the thermal driver to list of compiled modules in the default config for bcm2835.

---
 arch/arm/configs/bcm2835_defconfig | 2 ++
 1 file changed, 2 insertions(+)
arch/arm/configs/bcm2835_defconfig +2 -0
index 79de828..4b89f4e 100644
@@ -73,6 +73,8 @@ CONFIG_SPI_BCM2835=y
 CONFIG_SPI_BCM2835AUX=y
 CONFIG_GPIO_SYSFS=y
 # CONFIG_HWMON is not set
+CONFIG_THERMAL=y
+CONFIG_BCM2835_THERMAL=y
 CONFIG_WATCHDOG=y
 CONFIG_BCM2835_WDT=y
 CONFIG_DRM=y
Signature · 1 line
2.1.4
#14 lore raw

PATCH v7 6/6 ARM64: bcm2835: add thermal driver to default_config

In reply to kernel at martin.sperl.org

From: Martin Sperl <[email protected]>

Add the thermal driver for bcm2837 to list of compiled modules in the default config.

---
 arch/arm64/configs/defconfig | 1 +
 1 file changed, 1 insertion(+)
arch/arm64/configs/defconfig +1 -0
index eadf485..372f981 100644
@@ -252,6 +252,7 @@ CONFIG_SENSORS_INA2XX=m
 CONFIG_SENSORS_ARM_SCPI=y
 CONFIG_THERMAL=y
 CONFIG_THERMAL_EMULATION=y
+CONFIG_BCM2835_THERMAL=y
 CONFIG_EXYNOS_THERMAL=y
 CONFIG_WATCHDOG=y
 CONFIG_RENESAS_WDT=y
Signature · 1 line
2.1.4