bcm2835: add thermal driver
Subsystems (5)
v2 cover bcm2835: add thermal driver
From: Martin Sperl <[email protected]>
Add a thermal driver for the TSENSE device of the bcm2835 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 - reads as 0 currently)
The calibrations are (potentially) different for bcm2835, bcm2836 and bcm2837 and can get selected by the compatiblity 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
* 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)
Changelog:
V1 -> V2: renamed dt-binding documentation file
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)
added driver to multi_v7_defconfig
Martin Sperl (5):
dt: bindings: add thermal device driver for bcm2835
thermal: bcm2835: add thermal driver for bcm2835 soc
ARM: bcm2835: add thermal node to device-tree of bcm283x
ARM: bcm2835: add thermal driver to default_config
ARM: multi_v7_defconfig: bcm2835: add bcm2835-thermal driver
.../bindings/thermal/brcm,bcm2835-thermal.txt | 17 ++ arch/arm/boot/dts/bcm283x.dtsi | 6 + arch/arm/configs/bcm2835_defconfig | 2 + arch/arm/configs/multi_v7_defconfig | 1 + drivers/thermal/Kconfig | 5 + drivers/thermal/Makefile | 1 + drivers/thermal/bcm/Kconfig | 4 + drivers/thermal/bcm/Makefile | 1 + drivers/thermal/bcm/bcm2835_thermal.c | 326 +++++++++++++++++++++ 9 files changed, 363 insertions(+) create mode 100644 Documentation/devicetree/bindings/thermal/brcm,bcm2835-thermal.txt create mode 100644 drivers/thermal/bcm/Kconfig create mode 100644 drivers/thermal/bcm/Makefile create mode 100644 drivers/thermal/bcm/bcm2835_thermal.c
--
2.1.4
PATCH v2 1/5 dt: bindings: add thermal device driver for bcm2835
From: Martin Sperl <[email protected]>
Add documentation for bcm2835 SOC thermal sensor.
Changelog:
V1 -> V2: renamed file to follow naming conventions
--- .../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
@@ -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 0x7e212000 { + compatible = "brcm,bcm2835-thermal"; + reg = <0x7e212000 0x8>; + clocks = <&clocks BCM2835_CLOCK_TSENS>; +};
--
2.1.4
Rob Herring
maintainerPATCH v2 1/5 dt: bindings: add thermal device driver for bcm2835
Quoted 23 lines · kernel at martin.sperl.org
From: Martin Sperl <[email protected]>
Add documentation for bcm2835 SOC thermal sensor.
Signed-off-by Martin Sperl <[email protected]>Acked-by Eric Anholt <[email protected]>Changelog:
V1 -> V2: renamed file to follow naming conventions--- .../bindings/thermal/brcm,bcm2835-thermal.txt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 Documentation/devicetree/bindings/thermal/brcm,bcm2835-thermal.txtDocumentation/devicetree/bindings/thermal/brcm,bcm2835-thermal.txt new file +3
-0@@ -0,0 +1,17 @@ +Binding for Thermal Sensor driver for BCM2835 SoCs. + +Required parameters:
Documentation/devicetree/bindings/thermal/brcm,bcm2835-thermal.txt line 13
Quoted 10 lines
Documentation/devicetree/bindings/thermal/brcm,bcm2835-thermal.txt new file +10
-0+------------------- + +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 0x7e212000 {
Drop the '0x'. Otherwise,
Quoted 6 lines
Documentation/devicetree/bindings/thermal/brcm,bcm2835-thermal.txt new file +4
-1+ compatible = "brcm,bcm2835-thermal"; + reg = <0x7e212000 0x8>; + clocks = <&clocks BCM2835_CLOCK_TSENS>; +}; --2.1.4
PATCH v2 2/5 thermal: bcm2835: add thermal driver for bcm2835 soc
In reply to kernel at martin.sperl.orgFrom: 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)
--- drivers/thermal/Kconfig | 5 + drivers/thermal/Makefile | 1 + drivers/thermal/bcm/Kconfig | 4 + drivers/thermal/bcm/Makefile | 1 + drivers/thermal/bcm/bcm2835_thermal.c | 326 ++++++++++++++++++++++++++++++++++ 5 files changed, 337 insertions(+) create mode 100644 drivers/thermal/bcm/Kconfig create mode 100644 drivers/thermal/bcm/Makefile create mode 100644 drivers/thermal/bcm/bcm2835_thermal.c
drivers/thermal/Kconfig +5 -0
@@ -383,6 +383,11 @@ config MTK_THERMAL Enable this option if you want to have support for thermal management controller present in Mediatek SoCs +menu "Broadcom thermal drivers" +depends on ARCH_BCM || COMPILE_TEST +source "drivers/thermal/bcm/Kconfig" +endmenu + menu "Texas Instruments thermal drivers" depends on ARCH_HAS_BANDGAP || COMPILE_TEST depends on HAS_IOMEM
drivers/thermal/Makefile +1 -0
@@ -49,3 +49,4 @@ obj-$(CONFIG_ST_THERMAL) += st/ obj-$(CONFIG_TEGRA_SOCTHERM) += tegra_soctherm.o obj-$(CONFIG_HISI_THERMAL) += hisi_thermal.o obj-$(CONFIG_MTK_THERMAL) += mtk_thermal.o +obj-y += bcm/
drivers/thermal/bcm/Kconfig new file +4 -0
@@ -0,0 +1,4 @@ +config BCM2835_THERMAL + tristate "Thermal sensors on bcm2835 SoC" + help + Support for thermal sensors on Broadcom bcm2835 SoCs.
drivers/thermal/bcm/Makefile new file +1 -0
@@ -0,0 +1 @@ +obj-$(CONFIG_BCM2835_THERMAL) := bcm2835_thermal.o
drivers/thermal/bcm/bcm2835_thermal.c new file +326 -0
326 lines not on this page · raw message
Signature · 1 line
2.1.4
PATCH v2 3/5 ARM: bcm2835: add thermal node to device-tree of bcm283x
In reply to kernel at martin.sperl.orgFrom: Martin Sperl <[email protected]>
Add the node for the thermal sensor of the bcm2835-soc to the device tree.
--- arch/arm/boot/dts/bcm283x.dtsi | 6 ++++++ 1 file changed, 6 insertions(+)
arch/arm/boot/dts/bcm283x.dtsi +6 -0
@@ -153,6 +153,12 @@ status = "disabled"; }; + thermal: thermal at 0x7e212000 { + compatible = "brcm,bcm2835-thermal"; + reg = <0x7e212000 0x8>; + clocks = <&clocks BCM2835_CLOCK_TSENS>; + }; + aux: aux at 0x7e215000 { compatible = "brcm,bcm2835-aux"; #clock-cells = <1>;
Signature · 1 line
2.1.4
PATCH v2 4/5 ARM: bcm2835: add thermal driver to default_config
In reply to kernel at martin.sperl.orgFrom: 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
@@ -71,6 +71,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_FB=y
Signature · 1 line
2.1.4
PATCH v2 5/5 ARM: multi_v7_defconfig: bcm2835: add bcm2835-thermal driver
In reply to kernel at martin.sperl.orgFrom: Martin Sperl <[email protected]>
Add the thermal driver to list of compiled modules in multi_v7_defconfig.
--- arch/arm/configs/multi_v7_defconfig | 1 + 1 file changed, 1 insertion(+)
arch/arm/configs/multi_v7_defconfig +1 -0
@@ -422,6 +422,7 @@ CONFIG_CPU_THERMAL=y CONFIG_ROCKCHIP_THERMAL=y CONFIG_RCAR_THERMAL=y CONFIG_ARMADA_THERMAL=y +CONFIG_BCM2835_THERMAL=y CONFIG_DAVINCI_WATCHDOG=m CONFIG_EXYNOS_THERMAL=m CONFIG_ST_THERMAL_SYSCFG=y
Signature · 1 line
2.1.4
PATCH v2 5/5 ARM: multi_v7_defconfig: bcm2835: add bcm2835-thermal driver
Quoted 15 lines · kernel at martin.sperl.org
From: Martin Sperl <[email protected]>
Add the thermal driver to list of compiled modules in
multi_v7_defconfig.Signed-off-by Martin Sperl <[email protected]>--- arch/arm/configs/multi_v7_defconfig | 1 + 1 file changed, 1 insertion(+)arch/arm/configs/multi_v7_defconfig +0
-0
arch/arm/configs/multi_v7_defconfig CONFIG_CPU_THERMAL=y · line 425
Quoted 4 lines
arch/arm/configs/multi_v7_defconfig +1
-0@@ -422,6 +422,7 @@ CONFIG_CPU_THERMAL=y CONFIG_ROCKCHIP_THERMAL=y CONFIG_RCAR_THERMAL=y CONFIG_ARMADA_THERMAL=y +CONFIG_BCM2835_THERMAL=y
Does this need to be built into the kernel?
Signature · 1 line
Florian
PATCH v2 5/5 ARM: multi_v7_defconfig: bcm2835: add bcm2835-thermal driver
Quoted 14 lines · Florian Fainelli
Quoted 10 lines · kernel at martin.sperl.org
From: Martin Sperl <[email protected]>
Add the thermal driver to list of compiled modules in
multi_v7_defconfig.Signed-off-by Martin Sperl <[email protected]>---
arch/arm/configs/multi_v7_defconfig| 1 +1 file changed, 1 insertion(+)
Quoted 12 lines
Quoted 9 lines
arch/arm/configs/multi_v7_defconfig +0
-0@@ -422,6 +422,7 @@ CONFIG_CPU_THERMAL=y
CONFIG_ROCKCHIP_THERMAL=yCONFIG_RCAR_THERMAL=yCONFIG_ARMADA_THERMAL=y
+CONFIG_BCM2835_THERMAL=yDoes this need to be built into the kernel?
Not necessarily, but as most other drivers in this context are built in this one was added as such as well.
If the policy is different, then I can change it...