thermal: mediatek: Add LVTS architecture thermal controller
Subsystems (3)
v5 cover thermal: mediatek: Add LVTS architecture thermal controller
This patch move thermal files related to Mediatek to the mediatek folder. And introduce the new architecture LVTS (low pressure thermal sensor) driver to report the highest temperature in the SoC and record the highest temperature sensor, each sensor as a hot zone.
The LVTS body is divided into two parts, the LVTS controller and the LVTS device. The LVTS controller can connect up to 4 LVTS devices, and each LVTS device can connect up to 7 TSMCUs.
The architecture will be the first to be used on mt6873 and mt8192.
Change in v5:
- Use 'git mv' for the relocated file.
Change in v4:
- Rebase to kernel-v5.13-rc1
- Resend
Change in v3:
- [2/3]
- change the expression in the lvts_temp_to_raw to dev_s64.
Change in v2:
- Rebase to kernel-5.11-rc1.
- [2/3]
- sort headers
- remove initial value 0 of msr_raw in the lvts_temp_to_raw.
- disconstruct the api of lvts_read_tc_msr_raw.
- add the initial value max_temp = 0 and compare e.q. in the lvts_read_all_tc_temperature.
- add the return with invalid number in the lvts_init.
This patch depends on [1].
[1]https://patchwork.kernel.org/project/linux-mediatek/patch/[email protected]/
Michael Kao (3):
thermal: mediatek: Relocate driver to mediatek folder
thermal: mediatek: Add LVTS drivers for SoC theraml zones
dt-bindings: thermal: Add binding document for mt6873 thermal
controller
.../thermal/mediatek-thermal-lvts.yaml | 81 ++
drivers/thermal/Kconfig | 14 +-
drivers/thermal/Makefile | 2 +-
drivers/thermal/mediatek/Kconfig | 33 +
drivers/thermal/mediatek/Makefile | 2 +
.../{mtk_thermal.c => mediatek/soc_temp.c} | 0
drivers/thermal/mediatek/soc_temp_lvts.c | 1287 +++++++++++++++++
drivers/thermal/mediatek/soc_temp_lvts.h | 312 ++++
8 files changed, 1720 insertions(+), 11 deletions(-)
create mode 100644 Documentation/devicetree/bindings/thermal/mediatek-thermal-lvts.yaml
create mode 100644 drivers/thermal/mediatek/Kconfig
create mode 100644 drivers/thermal/mediatek/Makefile
rename drivers/thermal/{mtk_thermal.c => mediatek/soc_temp.c} (100%)
create mode 100644 drivers/thermal/mediatek/soc_temp_lvts.c
create mode 100644 drivers/thermal/mediatek/soc_temp_lvts.hSignature · 1 line
2.18.0
PATCH v5 1/3 thermal: mediatek: Relocate driver to mediatek folder
From: Michael Kao <[email protected]>
Add Mediatek proprietary folder to upstream more thermal zone and cooler drivers. Relocate the original thermal controller driver to it and rename as soc_temp.c to show its purpose more clearly.
---
drivers/thermal/Kconfig | 14 ++++-------
drivers/thermal/Makefile | 2 +-
drivers/thermal/mediatek/Kconfig | 23 +++++++++++++++++++
drivers/thermal/mediatek/Makefile | 1 +
.../{mtk_thermal.c => mediatek/soc_temp.c} | 0
5 files changed, 29 insertions(+), 11 deletions(-)
create mode 100644 drivers/thermal/mediatek/Kconfig
create mode 100644 drivers/thermal/mediatek/Makefile
rename drivers/thermal/{mtk_thermal.c => mediatek/soc_temp.c} (100%)drivers/thermal/Kconfig +4 -10
@@ -401,16 +401,10 @@ config DA9062_THERMAL zone. Compatible with the DA9062 and DA9061 PMICs. -config MTK_THERMAL - tristate "Temperature sensor driver for mediatek SoCs" - depends on ARCH_MEDIATEK || COMPILE_TEST - depends on HAS_IOMEM - depends on NVMEM || NVMEM=n - depends on RESET_CONTROLLER - default y - help - Enable this option if you want to have support for thermal management - controller present in Mediatek SoCs +menu "Mediatek thermal drivers" +depends on ARCH_MEDIATEK || COMPILE_TEST +source "drivers/thermal/mediatek/Kconfig" +endmenu config AMLOGIC_THERMAL tristate "Amlogic Thermal Support"
drivers/thermal/Makefile +1 -1
@@ -54,7 +54,7 @@ obj-y += st/ obj-$(CONFIG_QCOM_TSENS) += qcom/ obj-y += tegra/ obj-$(CONFIG_HISI_THERMAL) += hisi_thermal.o -obj-$(CONFIG_MTK_THERMAL) += mtk_thermal.o +obj-$(CONFIG_MTK_THERMAL) += mediatek/ obj-$(CONFIG_GENERIC_ADC_THERMAL) += thermal-generic-adc.o obj-$(CONFIG_UNIPHIER_THERMAL) += uniphier_thermal.o obj-$(CONFIG_AMLOGIC_THERMAL) += amlogic_thermal.o
drivers/thermal/mediatek/Kconfig new file +23 -0
@@ -0,0 +1,23 @@ +config MTK_THERMAL + tristate "Mediatek thermal drivers" + depends on THERMAL_OF + help + This is the option for Mediatek thermal software + solutions. Please enable corresponding options to + get temperature information from thermal sensors or + turn on throttle mechaisms for thermal mitigation. + +if MTK_THERMAL + +config MTK_SOC_THERMAL + tristate "Temperature sensor driver for mediatek SoCs" + depends on HAS_IOMEM + depends on NVMEM + depends on RESET_CONTROLLER + help + Enable this option if you want to get SoC temperature + information for Mediatek platforms. This driver + configures thermal controllers to collect temperature + via AUXADC interface. + +endif
drivers/thermal/mediatek/Makefile new file +1 -0
@@ -0,0 +1 @@ +obj-$(CONFIG_MTK_SOC_THERMAL) += soc_temp.o
drivers/thermal/mediatek/soc_temp.c renamed from drivers/thermal/mtk_thermal.c +0 -0
Signature · 1 line
2.18.0
Re: [PATCH v5 1/3] thermal: mediatek: Relocate driver to mediatek folder
Quoted 8 lines · Ben Tseng
From: Michael Kao <[email protected]>
Add Mediatek proprietary folder to upstream more thermal zone and cooler drivers. Relocate the original thermal controller driver to it and rename as
soc_temp.cto show its purpose more clearly.Signed-off-by Michael Kao <[email protected]>Signed-off-by Ben Tseng <[email protected]>
Quoted 90 lines
--- drivers/thermal/Kconfig | 14 ++++------- drivers/thermal/Makefile | 2 +- drivers/thermal/mediatek/Kconfig | 23 +++++++++++++++++++ drivers/thermal/mediatek/Makefile | 1 + .../{mtk_thermal.c => mediatek/soc_temp.c} | 0 5 files changed, 29 insertions(+), 11 deletions(-) create mode 100644 drivers/thermal/mediatek/Kconfig create mode 100644 drivers/thermal/mediatek/Makefile rename drivers/thermal/{mtk_thermal.c => mediatek/soc_temp.c} (100%)drivers/thermal/Kconfig +4
-10@@ -401,16 +401,10 @@ config DA9062_THERMAL zone. Compatible with the DA9062 and DA9061 PMICs. -config MTK_THERMAL - tristate "Temperature sensor driver for mediatek SoCs" - depends on ARCH_MEDIATEK || COMPILE_TEST - depends on HAS_IOMEM - depends on NVMEM || NVMEM=n - depends on RESET_CONTROLLER - default y - help - Enable this option if you want to have support for thermal management - controller present in Mediatek SoCs +menu "Mediatek thermal drivers" +depends on ARCH_MEDIATEK || COMPILE_TEST +source "drivers/thermal/mediatek/Kconfig" +endmenu config AMLOGIC_THERMAL tristate "Amlogic Thermal Support"drivers/thermal/Makefile +1
-1@@ -54,7 +54,7 @@ obj-y += st/ obj-$(CONFIG_QCOM_TSENS) += qcom/ obj-y += tegra/ obj-$(CONFIG_HISI_THERMAL) += hisi_thermal.o -obj-$(CONFIG_MTK_THERMAL) += mtk_thermal.o +obj-$(CONFIG_MTK_THERMAL) += mediatek/ obj-$(CONFIG_GENERIC_ADC_THERMAL) += thermal-generic-adc.o obj-$(CONFIG_UNIPHIER_THERMAL) += uniphier_thermal.o obj-$(CONFIG_AMLOGIC_THERMAL) += amlogic_thermal.odrivers/thermal/mediatek/Kconfig new file +23
-0@@ -0,0 +1,23 @@ +config MTK_THERMAL + tristate "Mediatek thermal drivers" + depends on THERMAL_OF + help + This is the option for Mediatek thermal software + solutions. Please enable corresponding options to + get temperature information from thermal sensors or + turn on throttle mechaisms for thermal mitigation. + +if MTK_THERMAL + +config MTK_SOC_THERMAL + tristate "Temperature sensor driver for mediatek SoCs" + depends on HAS_IOMEM + depends on NVMEM + depends on RESET_CONTROLLER + help + Enable this option if you want to get SoC temperature + information for Mediatek platforms. This driver + configures thermal controllers to collect temperature + via AUXADC interface. + +endifdrivers/thermal/mediatek/Makefile new file +1
-0@@ -0,0 +1 @@ +obj-$(CONFIG_MTK_SOC_THERMAL) += soc_temp.odrivers/thermal/mediatek/soc_temp.c renamed from drivers/thermal/mtk_thermal.c +0
-0
PATCH v5 2/3 thermal: mediatek: Add LVTS drivers for SoC theraml zones
In reply to Ben TsengFrom: Michael Kao <[email protected]>
Add a LVTS (Low voltage thermal sensor) driver to report junction temperatures in Mediatek SoC and register the maximum temperature of sensors and each sensor as a thermal zone.
--- drivers/thermal/mediatek/Kconfig | 10 + drivers/thermal/mediatek/Makefile | 1 + drivers/thermal/mediatek/soc_temp_lvts.c | 1287 ++++++++++++++++++++++ drivers/thermal/mediatek/soc_temp_lvts.h | 312 ++++++ 4 files changed, 1610 insertions(+) create mode 100644 drivers/thermal/mediatek/soc_temp_lvts.c create mode 100644 drivers/thermal/mediatek/soc_temp_lvts.h
drivers/thermal/mediatek/Kconfig +10 -0
@@ -20,4 +20,14 @@ config MTK_SOC_THERMAL configures thermal controllers to collect temperature via AUXADC interface. +config MTK_SOC_THERMAL_LVTS + tristate "LVTS (Low voltage thermal sensor) driver for Mediatek SoCs" + depends on HAS_IOMEM + depends on NVMEM + depends on RESET_TI_SYSCON + help + Enable this option if you want to get SoC temperature + information for Mediatek platforms. This driver + configures LVTS thermal controllers to collect temperatures + via Analog Serial Interface(ASIF). endif
drivers/thermal/mediatek/Makefile +1 -0
@@ -1 +1,2 @@ obj-$(CONFIG_MTK_SOC_THERMAL) += soc_temp.o +obj-$(CONFIG_MTK_SOC_THERMAL_LVTS) += soc_temp_lvts.o
drivers/thermal/mediatek/soc_temp_lvts.c new file +1287 -0
1,287 lines not on this page · raw message
drivers/thermal/mediatek/soc_temp_lvts.h new file +312 -0
312 lines not on this page · raw message
Signature · 1 line
2.18.0
Re: [PATCH v5 2/3] thermal: mediatek: Add LVTS drivers for SoC theraml zones
Quoted 5 lines · Ben Tseng
From: Michael Kao <[email protected]>
Add a LVTS (Low voltage thermal sensor) driver to report junction temperatures in Mediatek SoC and register the maximum temperature of sensors and each sensor as a thermal zone.
I think we already talked about that. We don't want a thermal sensor driver to aggregate the temperatures but create some kindof virtual sensor with a property (min, max, avg, ...) which is usable by anyone.
[ ... ]
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
Re: [PATCH v5 2/3] thermal: mediatek: Add LVTS drivers for SoC theraml zones
Quoted 7 lines · Daniel Lezcano
Quoted 5 lines · Ben Tseng
From: Michael Kao <[email protected]>
Add a LVTS (Low voltage thermal sensor) driver to report junction temperatures in Mediatek SoC and register the maximum temperature of sensors and each sensor as a thermal zone.
Quoted 9 lines
I think we already talked about that. We don't want a thermal sensor driver to aggregate the temperatures but create some kindof virtual sensor with a property (min, max, avg, ...) which is usable by anyone.
[ ... ]
Dear Daniel,
Sorry for the late reply.
After survey ,I'm not sure whether the patch[1] is the architecture of virtual thermal sensor which you commented.
Or, is there any existing framework on mainline already support virtual sensor?
Could you help to provide reference to us?
Thank you so much.
[1]
https://patchwork.kernel.org/project/linux-pm/patch/[email protected]/
BRs
Ben
Re: [PATCH v5 2/3] thermal: mediatek: Add LVTS drivers for SoC theraml zones
Hi Ben,
Quoted 13 lines · Ben Tseng
Quoted 12 lines · Daniel Lezcano
Quoted 5 lines · Ben Tseng
From: Michael Kao <[email protected]>
Add a LVTS (Low voltage thermal sensor) driver to report junction temperatures in Mediatek SoC and register the maximum temperature of sensors and each sensor as a thermal zone.
I think we already talked about that. We don't want a thermal sensor driver to aggregate the temperatures but create some kindof virtual sensor with a property (min, max, avg, ...) which is usable by anyone.
Quoted 8 lines
Quoted 4 lines
[ ... ]
Dear Daniel,
Sorry for the late reply.
sorry too, missed to answer. Another thread pointed to this one and I figured out I forgot to answer.
Quoted 2 lines
After survey ,I'm not sure whether the patch[1] is the architecture of virtual thermal sensor which you commented.
Ah, yes that is kind of what it would be requested but really generic so anyone can use it.
Quoted 2 lines
Or, is there any existing framework on mainline already support virtual sensor?
No unfortunately, it is not done [yet].
Quoted 1 line
Could you help to provide reference to us?
Ok, we had this discussion several times on the mailing list and at the different events like the Linux Plumbers conference. But I was not able to find out a pointer.
Basically the idea is simple, we don't want drivers doing weird things in their get_temp callback. This callback must return the temperature associated to a physical sensor in a 1:1 manner.
However, some people want to define a thermal zone but with an aggregation of different sensors.
At this point, we are unsure how to do that.
Having a virtual sensor would be more adequate as it won't impact anything except the DT for a configuration. And we can make it to evolve without having to change all the thermal framework internals.
From a DT point of view, a virtual sensor device cuold have phandles to the different sensors and let's say a property telling what do to (avg, min, max, ...). The thermal zone will point to the virtual device.
In the driver itself, the get_temp will just call get_temp of all the sensors and do the operation specified in the property.
With that, the drivers stay consistent and we have the flexibility to do whatever we want.
Does it make sense ?
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
AngeloGioacchino Del Regno
maintainerRe: [PATCH v5 2/3] thermal: mediatek: Add LVTS drivers for SoC theraml zones
In reply to Ben TsengIl 17/06/21 13:47, Ben Tseng ha scritto:
Quoted 9 lines
From: Michael Kao <[email protected]>
Add a LVTS (Low voltage thermal sensor) driver to report junction temperatures in Mediatek SoC and register the maximum temperature of sensors and each sensor as a thermal zone.
Signed-off-by Yu-Chia Chang <[email protected]>Signed-off-by Michael Kao <[email protected]>Signed-off-by Ben Tseng <[email protected]>
Hello Ben,
are you still interested in upstreaming this driver?
Having thermal sensors is pretty much important to avoid damaging the hardware, and MT8195 is being actively upstreamed right now. Reading thermals is a must.
Regards,
Angelo
_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek
PATCH v5 3/3 dt-bindings: thermal: Add binding document for mt6873 thermal controller
In reply to Ben TsengFrom: Michael Kao <[email protected]>
This patch adds binding document for mt6873 thermal controller.
---
This patch depends on [1].
[1] https://patchwork.kernel.org/project/linux-mediatek/patch/[email protected]/
---
Feature: Thermal Management
Change-Id: Ibe06c699c6edc870aaee95170c3f182d1889472d
--- .../thermal/mediatek-thermal-lvts.yaml | 81 +++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 Documentation/devicetree/bindings/thermal/mediatek-thermal-lvts.yaml
Documentation/devicetree/bindings/thermal/mediatek-thermal-lvts.yaml new file +81 -0
@@ -0,0 +1,81 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/thermal/mediatek-thermal-lvts.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Mediatek SoC LVTS thermal controller (DTS) binding + +maintainers: + - Yu-Chia Chang <[email protected]> + - Ben Tseng <[email protected]> + +properties: + compatible: + const: mediatek,mt6873-lvts + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + clocks: + maxItems: 1 + + clock-names: + items: + - const: lvts_clk + + "#thermal-sensor-cells": + const: 0 + +required: + - "#thermal-sensor-cells" + - compatible + - reg + - interrupts + - clocks + - clock-names + +additionalProperties: false + +examples: + - | + #include <dt-bindings/thermal/thermal.h> + #include <dt-bindings/interrupt-controller/arm-gic.h> + #include <dt-bindings/clock/mt8192-clk.h> + dts: lvts@1100b000 { + compatible = "mediatek,mt6873-lvts"; + reg = <0x1100b000 0x1000>; + clocks = <&infracfg CLK_INFRA_THERM>; + clock-names = "lvts_clk"; + #thermal-sensor-cells = <0>; + interrupts = <GIC_SPI 147 IRQ_TYPE_LEVEL_HIGH>; + }; + + thermal-zones { + cpu_thermal: cpu-thermal { + polling-delay-passive = <0>; + polling-delay = <0>; + + thermal-sensors = <&dts>; + trips { + cpu_alert1: cpu-alert1 { + temperature = <85000>; + hysteresis = <0>; + type = "passive"; + }; + + cpu_crit: cpu-crit { + temperature = <120000>; + hysteresis = <0>; + type = "critical"; + }; + }; + + cooling-maps { + }; + }; + }; +...
Signature · 1 line
2.18.0
Rob Herring
maintainerRe: [PATCH v5 3/3] dt-bindings: thermal: Add binding document for mt6873 thermal controller
Quoted 43 lines · Ben Tseng
From: Michael Kao <[email protected]>
This patch adds binding document for mt6873 thermal controller.
Signed-off-by Michael Kao <[email protected]>Signed-off-by Ben Tseng <[email protected]>---
This patch depends on [1].[1] https://patchwork.kernel.org/project/linux-mediatek/patch/[email protected]/
---
Feature: Thermal ManagementChange-Id: Ibe06c699c6edc870aaee95170c3f182d1889472d
--- .../thermal/mediatek-thermal-lvts.yaml | 81 +++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 Documentation/devicetree/bindings/thermal/mediatek-thermal-lvts.yamlDocumentation/devicetree/bindings/thermal/mediatek-thermal-lvts.yaml new file +18
-0@@ -0,0 +1,81 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/thermal/mediatek-thermal-lvts.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Mediatek SoC LVTS thermal controller (DTS) binding + +maintainers: + - Yu-Chia Chang <[email protected]> + - Ben Tseng <[email protected]> + +properties: + compatible: + const: mediatek,mt6873-lvts + + reg: + maxItems: 1
Documentation/devicetree/bindings/thermal/mediatek-thermal-lvts.yaml line 28
Quoted 10 lines
Documentation/devicetree/bindings/thermal/mediatek-thermal-lvts.yaml new file +10
-0+ + interrupts: + maxItems: 1 + + clocks: + maxItems: 1 + + clock-names: + items: + - const: lvts_clk
Not really a useful name. I'd just drop 'clock-names'.
Quoted 10 lines
Documentation/devicetree/bindings/thermal/mediatek-thermal-lvts.yaml new file +10
-0+ + "#thermal-sensor-cells": + const: 0 + +required: + - "#thermal-sensor-cells" + - compatible + - reg + - interrupts + - clocks
Documentation/devicetree/bindings/thermal/mediatek-thermal-lvts.yaml line 48
Quoted 10 lines
Documentation/devicetree/bindings/thermal/mediatek-thermal-lvts.yaml new file +10
-0+ - clock-names + +additionalProperties: false + +examples: + - | + #include <dt-bindings/thermal/thermal.h> + #include <dt-bindings/interrupt-controller/arm-gic.h> + #include <dt-bindings/clock/mt8192-clk.h> + dts: lvts@1100b000 {
thermal-sensor@...
Quoted 37 lines
Documentation/devicetree/bindings/thermal/mediatek-thermal-lvts.yaml new file +33
-0+ compatible = "mediatek,mt6873-lvts"; + reg = <0x1100b000 0x1000>; + clocks = <&infracfg CLK_INFRA_THERM>; + clock-names = "lvts_clk"; + #thermal-sensor-cells = <0>; + interrupts = <GIC_SPI 147 IRQ_TYPE_LEVEL_HIGH>; + }; + + thermal-zones { + cpu_thermal: cpu-thermal { + polling-delay-passive = <0>; + polling-delay = <0>; + + thermal-sensors = <&dts>; + trips { + cpu_alert1: cpu-alert1 { + temperature = <85000>; + hysteresis = <0>; + type = "passive"; + }; + + cpu_crit: cpu-crit { + temperature = <120000>; + hysteresis = <0>; + type = "critical"; + }; + }; + + cooling-maps { + }; + }; + }; +...Signature · 1 line
2.18.0