Add LVTS Thermal Architecture
Subsystems (3)
v14 cover Add LVTS Thermal Architecture
From: Balsam CHIHI <[email protected]>
The LVTS (Low Voltage Thermal Sensor) driver is capable of monitoring multiple hot points. For that, it contains 7 thermal control blocks dedicated to specific devices on the die. Each control block can handle up to 4 sensors.
The thermal controller supports several interrupts. One for the cold trip point, the hot trip point, the return to the normal trip point, and a specific programmable trip point to monitor the temperature dynamically.
The temperature measurement can be done in two ways, the immediate mode where the temperature read is instantaneous and the filtered mode where the controller uses, by configuration, an average of a set of values removing the minimum and the maximum.
Finally, it is composed of 2 finite-state machines responsible for the state of the temperature (cold, hot, hot 2 normal, hot hot), the triggering of the interrupts, and the monitoring of the temperature.
As requested, the thermal driver has been reworked to reduce the complexity of the code. At this time, the 4 little CPUs and the 4 big CPUs are supported by the thermal driver.They are described in a data structure and more devices can be added later. The calibration routine has been simplified also.
The series provide the following changes:
- Move the Mediatek drivers inside a dedicated folder as their number is increasing
- Add the DT bindings for the controller
- Add the efuse node for the mt8195
- The LVTS driver
- The thermal zones description in the DT
Changelog:
v14:
- Fix dt-binding definition :
- Change "nvmem-cells" and "nvmem-cell-names" properties of "mt8195" from "maxItems: 2" to "minItems: 2"
- Fix "mediatek,lvts-thermal.h" indentation
v13:
- Rebase on top of "thermal/linux-next" :
base-commit: a2c81dc59d41e92362ab7d41d0c15471ea50637d
- Fix coding style issues
- Remove "__init" from all functions
- Remove "lvts_ctrl_enable" and "lvts_ctrl_disable" wrappers
- Use "dev_err_probe" instead of "dev_dbg" in "lvts_probe"
- Fix subject prefix
- Add "mt8192" to dt-binding definition
- Change dt-binding license to "GPL-2.0-only OR BSD-2-Clause"
- Fix debugfs mutli-instance support
v12:
- Fix subject prefix
- Add dual licenses to dt-binding
- Rename "include/dt-bindings/thermal/mediatek-lvts.h" to "include/dt-bindings/thermal/mediatek,lvts-thermal.h"
v11:
- Rebase on top of "thermal/linux-next" :
base=0d568e144ead70189e7f16066dcb155b78ff9266
- Remove unsupported SoC (mt8192) from dt-binding definition
- Fix coding style issues :
- Move litterals to define
- Add interrupt macros
- Remove wildcard : only mt8195 is supported for now
v10:
- Rebase on top of "thermal/linux-next" : thermal-v6.3-rc1
- Rework the LVTS driver
- Add the thermal trip temperature and cooling devices for the sensors supported by the driver
v9:
- Rebase on top of 6.0.0-rc1
- Fix coding style issues
- Fix commit titles and commit messages
- Update dt-bindings :
- Add "allOf:if:then:"
- Use mt8192 as example (instead of mt8195)
- Fix dt-binding errors
- Fix DTS errors
v8:
- Fix coding style issues
- Rebase on top of next-20220803
- Add multi-instance support :
- Rewrite DT-binding and DTS :
- Add DT-binding and DTS for LVTS_v4 (MT8192 and MT8195)
- One LVTS node for each HW Domain (AP and MCU)
- One SW Instance for each HW Domain
- Add a Kconfig sub-menu entry for LVTS and LVTS_v4 SoCs
- Replace platform_get_resource by platform_get_mem_or_io to get Base Address
- Replace platform_get_resource by platform_get_irq to get Interrupt Number
- Add "lvts_" prefix to functions and structs
v7:
- Fix coding style issues
- Rewrite dt bindings
- was not accurate
- Use mt8195 for example (instead of mt8192)
- Rename mt6873 to mt8192
- Remove clock name
- Rebased on top of to series:
- patchwork.kernel.org/project/linux-mediatek/list/?series=637849
- patchwork.kernel.org/project/linux-pm/list/?series=639386
v6:
- Remove temperature aggregation (it will be added in another series)
- Update the way to read the temperature (read one sensor instead of all)
- Add support of mt8195
v5:
- Use 'git mv' for the relocated file.
v4:
- Rebase to kernel-v5.13-rc1
v3:
- change the expression in the lvts_temp_to_raw to dev_s64.
v2:
- Rebase to kernel-5.11-rc1.
- 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 an invalid number in the lvts_init.
Balsam CHIHI (6):
thermal: drivers: mediatek: Relocate driver to mediatek folder
dt-bindings: thermal: mediatek: Add LVTS thermal controllers
arm64: dts: mt8195: Add efuse node to mt8195
thermal: drivers: mediatek: Add the Low Voltage Thermal Sensor driver
arm64: dts: mediatek: mt8195: Add thermal zones and thermal nodes
arm64: dts: mediatek: mt8195: Add temperature mitigation threshold
.../thermal/mediatek,lvts-thermal.yaml | 142 ++
arch/arm64/boot/dts/mediatek/mt8195.dtsi | 272 ++++
drivers/thermal/Kconfig | 14 +-
drivers/thermal/Makefile | 2 +-
drivers/thermal/mediatek/Kconfig | 37 +
drivers/thermal/mediatek/Makefile | 2 +
.../auxadc_thermal.c} | 2 +-
drivers/thermal/mediatek/lvts_thermal.c | 1224 +++++++++++++++++
.../thermal/mediatek,lvts-thermal.h | 19 +
9 files changed, 1702 insertions(+), 12 deletions(-)
create mode 100644 Documentation/devicetree/bindings/thermal/mediatek,lvts-thermal.yaml
create mode 100644 drivers/thermal/mediatek/Kconfig
create mode 100644 drivers/thermal/mediatek/Makefile
rename drivers/thermal/{mtk_thermal.c => mediatek/auxadc_thermal.c} (99%)
create mode 100644 drivers/thermal/mediatek/lvts_thermal.c
create mode 100644 include/dt-bindings/thermal/mediatek,lvts-thermal.hbase-commit: a2c81dc59d41e92362ab7d41d0c15471ea50637d
Signature · 1 line
2.34.1
PATCH v14 1/6 thermal: drivers: mediatek: Relocate driver to mediatek folder
From: Balsam CHIHI <[email protected]>
Add MediaTek proprietary folder to upstream more thermal zone and cooler drivers, relocate the original thermal controller driver to it, and rename it as "auxadc_thermal.c" to show its purpose more clearly.
---
drivers/thermal/Kconfig | 14 ++++---------
drivers/thermal/Makefile | 2 +-
drivers/thermal/mediatek/Kconfig | 21 +++++++++++++++++++
drivers/thermal/mediatek/Makefile | 1 +
.../auxadc_thermal.c} | 2 +-
5 files changed, 28 insertions(+), 12 deletions(-)
create mode 100644 drivers/thermal/mediatek/Kconfig
create mode 100644 drivers/thermal/mediatek/Makefile
rename drivers/thermal/{mtk_thermal.c => mediatek/auxadc_thermal.c} (99%)drivers/thermal/Kconfig +4 -10
@@ -412,16 +412,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
@@ -55,7 +55,7 @@ obj-y += st/ obj-y += qcom/ obj-y += tegra/ obj-$(CONFIG_HISI_THERMAL) += hisi_thermal.o -obj-$(CONFIG_MTK_THERMAL) += mtk_thermal.o +obj-y += 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 +21 -0
@@ -0,0 +1,21 @@ +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 "AUXADC temperature sensor driver for MediaTek SoCs" + depends on HAS_IOMEM + 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) += auxadc_thermal.o
drivers/thermal/mediatek/auxadc_thermal.c renamed from drivers/thermal/mtk_thermal.c +1 -1
@@ -23,7 +23,7 @@#include <linux/reset.h> #include <linux/types.h> -#include "thermal_hwmon.h" +#include "../thermal_hwmon.h" /* AUXADC Registers */ #define AUXADC_CON1_SET_V 0x008
Signature · 1 line
2.34.1
PATCH v14 2/6 dt-bindings: thermal: mediatek: Add LVTS thermal controllers
In reply to [email protected]From: Balsam CHIHI <[email protected]>
Add LVTS thermal controllers dt-binding definition for mt8192 and mt8195.
--- .../thermal/mediatek,lvts-thermal.yaml | 142 ++++++++++++++++++ .../thermal/mediatek,lvts-thermal.h | 19 +++ 2 files changed, 161 insertions(+) create mode 100644 Documentation/devicetree/bindings/thermal/mediatek,lvts-thermal.yaml create mode 100644 include/dt-bindings/thermal/mediatek,lvts-thermal.h
Documentation/devicetree/bindings/thermal/mediatek,lvts-thermal.yaml new file +142 -0
@@ -0,0 +1,142 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/thermal/mediatek,lvts-thermal.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: MediaTek SoC Low Voltage Thermal Sensor (LVTS) + +maintainers: + - Balsam CHIHI <[email protected]> + +description: | + LVTS is a thermal management architecture composed of three subsystems, + a Sensing device - Thermal Sensing Micro Circuit Unit (TSMCU), + a Converter - Low Voltage Thermal Sensor converter (LVTS), and + a Digital controller (LVTS_CTRL). + +properties: + compatible: + enum: + - mediatek,mt8192-lvts-ap + - mediatek,mt8192-lvts-mcu + - mediatek,mt8195-lvts-ap + - mediatek,mt8195-lvts-mcu + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + clocks: + maxItems: 1 + + resets: + maxItems: 1 + description: LVTS reset for clearing temporary data on AP/MCU. + + nvmem-cells: + minItems: 1 + items: + - description: Calibration eFuse data 1 for LVTS + - description: Calibration eFuse data 2 for LVTS + + nvmem-cell-names: + minItems: 1 + items: + - const: lvts-calib-data-1 + - const: lvts-calib-data-2 + + "#thermal-sensor-cells": + const: 1 + +allOf: + - $ref: thermal-sensor.yaml# + + - if: + properties: + compatible: + contains: + enum: + - mediatek,mt8192-lvts-ap + - mediatek,mt8192-lvts-mcu + then: + properties: + nvmem-cells: + maxItems: 1 + + nvmem-cell-names: + maxItems: 1 + + - if: + properties: + compatible: + contains: + enum: + - mediatek,mt8195-lvts-ap + - mediatek,mt8195-lvts-mcu + then: + properties: + nvmem-cells: + minItems: 2 + + nvmem-cell-names: + minItems: 2 + +required: + - compatible + - reg + - interrupts + - clocks + - resets + - nvmem-cells + - nvmem-cell-names + - "#thermal-sensor-cells" + +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/arm-gic.h> + #include <dt-bindings/clock/mt8195-clk.h> + #include <dt-bindings/reset/mt8195-resets.h> + #include <dt-bindings/thermal/mediatek,lvts-thermal.h> + + soc { + #address-cells = <2>; + #size-cells = <2>; + + lvts_mcu: thermal-sensor@11278000 { + compatible = "mediatek,mt8195-lvts-mcu"; + reg = <0 0x11278000 0 0x1000>; + interrupts = <GIC_SPI 170 IRQ_TYPE_LEVEL_HIGH 0>; + clocks = <&infracfg_ao CLK_INFRA_AO_THERM>; + resets = <&infracfg_ao MT8195_INFRA_RST4_THERM_CTRL_MCU_SWRST>; + nvmem-cells = <&lvts_efuse_data1 &lvts_efuse_data2>; + nvmem-cell-names = "lvts-calib-data-1", "lvts-calib-data-2"; + #thermal-sensor-cells = <1>; + }; + }; + + thermal_zones: thermal-zones { + cpu0-thermal { + polling-delay = <1000>; + polling-delay-passive = <250>; + thermal-sensors = <&lvts_mcu MT8195_MCU_LITTLE_CPU0>; + + trips { + cpu0_alert: trip-alert { + temperature = <85000>; + hysteresis = <2000>; + type = "passive"; + }; + + cpu0_crit: trip-crit { + temperature = <100000>; + hysteresis = <2000>; + type = "critical"; + }; + }; + }; + };
include/dt-bindings/thermal/mediatek,lvts-thermal.h new file +19 -0
@@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */ +/* +* Copyright (c) 2023 MediaTek Inc. +* Author: Balsam CHIHI <[email protected]> +*/ + +#ifndef __MEDIATEK_LVTS_DT_H +#define __MEDIATEK_LVTS_DT_H + +#define MT8195_MCU_BIG_CPU0 0 +#define MT8195_MCU_BIG_CPU1 1 +#define MT8195_MCU_BIG_CPU2 2 +#define MT8195_MCU_BIG_CPU3 3 +#define MT8195_MCU_LITTLE_CPU0 4 +#define MT8195_MCU_LITTLE_CPU1 5 +#define MT8195_MCU_LITTLE_CPU2 6 +#define MT8195_MCU_LITTLE_CPU3 7 + +#endif /* __MEDIATEK_LVTS_DT_H */
Signature · 1 line
2.34.1
Re: [PATCH v14 2/6] dt-bindings: thermal: mediatek: Add LVTS thermal controllers
Quoted 4 lines · On Thu, 09 Feb 2023 11:56:24 +0100, [email protected] wrote:
From: Balsam CHIHI <[email protected]>
Add LVTS thermal controllers dt-binding definition for mt8192 and mt8195.
Quoted 8 lines
Signed-off-by Balsam CHIHI <[email protected]>--- .../thermal/mediatek,lvts-thermal.yaml | 142 ++++++++++++++++++ .../thermal/mediatek,lvts-thermal.h | 19 +++ 2 files changed, 161 insertions(+) create mode 100644 Documentation/devicetree/bindings/thermal/mediatek,lvts-thermal.yaml create mode 100644 include/dt-bindings/thermal/mediatek,lvts-thermal.h
Re: [PATCH v14 2/6] dt-bindings: thermal: mediatek: Add LVTS thermal controllers
Hi Rob,
Quoted 16 lines · Rob Herring
Quoted 4 lines · On Thu, 09 Feb 2023 11:56:24 +0100, [email protected] wrote:
From: Balsam CHIHI <[email protected]>
Add LVTS thermal controllers dt-binding definition for mt8192 and mt8195.
Quoted 8 lines
Signed-off-by Balsam CHIHI <[email protected]>--- .../thermal/mediatek,lvts-thermal.yaml | 142 ++++++++++++++++++ .../thermal/mediatek,lvts-thermal.h | 19 +++ 2 files changed, 161 insertions(+) create mode 100644 Documentation/devicetree/bindings/thermal/mediatek,lvts-thermal.yaml create mode 100644 include/dt-bindings/thermal/mediatek,lvts-thermal.h
Quoted 1 line
Reviewed-by Rob Herring <[email protected]>
Thank you for the review!
Quoted 1 line
Best Regards,
Balsam
PATCH v14 3/6 arm64: dts: mt8195: Add efuse node to mt8195
In reply to [email protected]From: Balsam CHIHI <[email protected]>
Add efuse node.
This will be required by the thermal driver to get the calibration data.
--- arch/arm64/boot/dts/mediatek/mt8195.dtsi | 6 ++++++ 1 file changed, 6 insertions(+)
arch/arm64/boot/dts/mediatek/mt8195.dtsi +6 -0
@@ -1380,6 +1380,12 @@ pciephy_glb_intr: pciephy-glb-intr@193 { dp_calibration: dp-data@1ac { reg = <0x1ac 0x10>; }; + lvts_efuse_data1: lvts1-calib@1bc { + reg = <0x1bc 0x14>; + }; + lvts_efuse_data2: lvts2-calib@1d0 { + reg = <0x1d0 0x38>; + }; }; u3phy2: t-phy@11c40000 {
Signature · 1 line
2.34.1
Matthias Brugger
maintainerRe: [PATCH v14 3/6] arm64: dts: mt8195: Add efuse node to mt8195
Quoted 10 lines · On 09/02/2023 11:56, [email protected] wrote:
From: Balsam CHIHI <[email protected]>
Add efuse node.
This will be required by the thermal driver to get the calibration data.Signed-off-by Balsam CHIHI <[email protected]>Reviewed-by Matthias Brugger <[email protected]>Reviewed-by AngeloGioacchino Del Regno <[email protected]>Signed-off-by Matthias Brugger <[email protected]>
This patch is already accepted [1], please drop it from your list.
Regards,
Matthias
[1] https://lore.kernel.org/lkml/[email protected]/
Quoted 21 lines
--- arch/arm64/boot/dts/mediatek/mt8195.dtsi | 6 ++++++ 1 file changed, 6 insertions(+)arch/arm64/boot/dts/mediatek/mt8195.dtsi +6
-0@@ -1380,6 +1380,12 @@ pciephy_glb_intr: pciephy-glb-intr@193 { dp_calibration: dp-data@1ac { reg = <0x1ac 0x10>; }; + lvts_efuse_data1: lvts1-calib@1bc { + reg = <0x1bc 0x14>; + }; + lvts_efuse_data2: lvts2-calib@1d0 { + reg = <0x1d0 0x38>; + }; }; u3phy2: t-phy@11c40000 {
Re: [PATCH v14 3/6] arm64: dts: mt8195: Add efuse node to mt8195
Hi Matthias,
Quoted 9 lines · Matthias Brugger
Quoted 5 lines · On 09/02/2023 11:56, [email protected] wrote:
From: Balsam CHIHI <[email protected]>
Add efuse node.
This will be required by the thermal driver to get the calibration data.
Quoted 7 lines
Quoted 5 lines
Signed-off-by Balsam CHIHI <[email protected]>Reviewed-by Matthias Brugger <[email protected]>Reviewed-by AngeloGioacchino Del Regno <[email protected]>Signed-off-by Matthias Brugger <[email protected]>This patch is already accepted [1], please drop it from your list.
Yes sure. I will.
Thank you.
Quoted 26 lines
Regards,
Matthias[1] https://lore.kernel.org/lkml/[email protected]/
Quoted 20 lines
--- arch/arm64/boot/dts/mediatek/mt8195.dtsi | 6 ++++++ 1 file changed, 6 insertions(+)arch/arm64/boot/dts/mediatek/mt8195.dtsi +6
-0@@ -1380,6 +1380,12 @@ pciephy_glb_intr: pciephy-glb-intr@193 { dp_calibration: dp-data@1ac { reg = <0x1ac 0x10>; }; + lvts_efuse_data1: lvts1-calib@1bc { + reg = <0x1bc 0x14>; + }; + lvts_efuse_data2: lvts2-calib@1d0 { + reg = <0x1d0 0x38>; + }; };
Quoted 1 line
arch/arm64/boot/dts/mediatek/mt8195.dtsi pciephy_glb_intr: pciephy-glb-intr@193 { · line 1391
Quoted 1 line
arch/arm64/boot/dts/mediatek/mt8195.dtsi +0
-0u3phy2: t-phy@11c40000 {
Best regards,
Balsam
PATCH v14 4/6 thermal: drivers: mediatek: Add the Low Voltage Thermal Sensor driver
In reply to [email protected]From: Balsam CHIHI <[email protected]>
The Low Voltage Thermal Sensor (LVTS) is a multiple sensors, multi controllers contained in a thermal domain.
A thermal domains can be the MCU or the AP.
Each thermal domains contain up to seven controllers, each thermal controller handle up to four thermal sensors.
The LVTS has two Finite State Machines (FSM), one to handle the functionin temperatures range like hot or cold temperature and another one to handle monitoring trip point. The FSM notifies via interrupts when a trip point is crossed.
The interrupt is managed at the thermal controller level, so when an interrupt occurs, the driver has to find out which sensor triggered such an interrupt.
The sampling of the thermal can be filtered or immediate. For the former, the LVTS measures several points and applies a low pass filter.
On MT8195 Tomato Chromebook:
--- drivers/thermal/mediatek/Kconfig | 16 + drivers/thermal/mediatek/Makefile | 1 + drivers/thermal/mediatek/lvts_thermal.c | 1224 +++++++++++++++++++++++ 3 files changed, 1241 insertions(+) create mode 100644 drivers/thermal/mediatek/lvts_thermal.c
drivers/thermal/mediatek/Kconfig +16 -0
@@ -18,4 +18,20 @@ config MTK_SOC_THERMAL This driver configures thermal controllers to collect temperature via AUXADC interface. +config MTK_LVTS_THERMAL + tristate "LVTS Thermal Driver for MediaTek SoCs" + depends on HAS_IOMEM + help + Enable this option if you want to get SoC temperature + information for supported MediaTek platforms. + This driver configures LVTS (Low Voltage Thermal Sensor) + thermal controllers to collect temperatures via ASIF + (Analog Serial Interface). + +config MTK_LVTS_THERMAL_DEBUGFS + bool "LVTS thermal debugfs" + depends on MTK_LVTS_THERMAL && DEBUG_FS + help + Enable this option to debug the internals of the device driver. + endif
drivers/thermal/mediatek/Makefile +1 -0
@@ -1 +1,2 @@ obj-$(CONFIG_MTK_SOC_THERMAL) += auxadc_thermal.o +obj-$(CONFIG_MTK_LVTS_THERMAL) += lvts_thermal.o
drivers/thermal/mediatek/lvts_thermal.c new file +1224 -0
1,224 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH v14 5/6 arm64: dts: mediatek: mt8195: Add thermal zones and thermal nodes
In reply to [email protected]From: Balsam CHIHI <[email protected]>
Add thermal zones and thermal nodes for the mt8195.
--- arch/arm64/boot/dts/mediatek/mt8195.dtsi | 129 +++++++++++++++++++++++ 1 file changed, 129 insertions(+)
arch/arm64/boot/dts/mediatek/mt8195.dtsi +129 -0
@@ -14,6 +14,7 @@ #include <dt-bindings/pinctrl/mt8195-pinfunc.h> #include <dt-bindings/power/mt8195-power.h> #include <dt-bindings/reset/mt8195-resets.h> +#include <dt-bindings/thermal/mediatek,lvts-thermal.h> / { compatible = "mediatek,mt8195";
@@ -954,6 +955,17 @@ spi0: spi@1100a000 { status = "disabled"; }; + lvts_ap: thermal-sensor@1100b000 { + compatible = "mediatek,mt8195-lvts-ap"; + reg = <0 0x1100b000 0 0x1000>; + interrupts = <GIC_SPI 169 IRQ_TYPE_LEVEL_HIGH 0>; + clocks = <&infracfg_ao CLK_INFRA_AO_THERM>; + resets = <&infracfg_ao MT8195_INFRA_RST0_THERM_CTRL_SWRST>; + nvmem-cells = <&lvts_efuse_data1 &lvts_efuse_data2>; + nvmem-cell-names = "lvts-calib-data-1", "lvts-calib-data-2"; + #thermal-sensor-cells = <1>; + }; + spi1: spi@11010000 { compatible = "mediatek,mt8195-spi", "mediatek,mt6765-spi";
@@ -1114,6 +1126,17 @@ mmc2: mmc@11250000 { status = "disabled"; }; + lvts_mcu: thermal-sensor@11278000 { + compatible = "mediatek,mt8195-lvts-mcu"; + reg = <0 0x11278000 0 0x1000>; + interrupts = <GIC_SPI 170 IRQ_TYPE_LEVEL_HIGH 0>; + clocks = <&infracfg_ao CLK_INFRA_AO_THERM>; + resets = <&infracfg_ao MT8195_INFRA_RST4_THERM_CTRL_MCU_SWRST>; + nvmem-cells = <&lvts_efuse_data1 &lvts_efuse_data2>; + nvmem-cell-names = "lvts-calib-data-1", "lvts-calib-data-2"; + #thermal-sensor-cells = <1>; + }; + xhci1: usb@11290000 { compatible = "mediatek,mt8195-xhci", "mediatek,mtk-xhci";
@@ -2387,4 +2410,110 @@ dp_tx: dp-tx@1c600000 { status = "disabled"; }; }; + + thermal_zones: thermal-zones { + cpu0-thermal { + polling-delay = <0>; + polling-delay-passive = <0>; + thermal-sensors = <&lvts_mcu MT8195_MCU_LITTLE_CPU0>; + trips { + cpu0_crit: trip-crit { + temperature = <100000>; + hysteresis = <2000>; + type = "critical"; + }; + }; + }; + + cpu1-thermal { + polling-delay = <0>; + polling-delay-passive = <0>; + thermal-sensors = <&lvts_mcu MT8195_MCU_LITTLE_CPU1>; + trips { + cpu1_crit: trip-crit { + temperature = <100000>; + hysteresis = <2000>; + type = "critical"; + }; + }; + }; + + cpu2-thermal { + polling-delay = <0>; + polling-delay-passive = <0>; + thermal-sensors = <&lvts_mcu MT8195_MCU_LITTLE_CPU2>; + trips { + cpu2_crit: trip-crit { + temperature = <100000>; + hysteresis = <2000>; + type = "critical"; + }; + }; + }; + + cpu3-thermal { + polling-delay = <0>; + polling-delay-passive = <0>; + thermal-sensors = <&lvts_mcu MT8195_MCU_LITTLE_CPU3>; + trips { + cpu3_crit: trip-crit { + temperature = <100000>; + hysteresis = <2000>; + type = "critical"; + }; + }; + }; + + cpu4-thermal { + polling-delay = <0>; + polling-delay-passive = <0>; + thermal-sensors = <&lvts_mcu MT8195_MCU_BIG_CPU0>; + trips { + cpu4_crit: trip-crit { + temperature = <100000>; + hysteresis = <2000>; + type = "critical"; + }; + }; + }; + + cpu5-thermal { + polling-delay = <0>; + polling-delay-passive = <0>; + thermal-sensors = <&lvts_mcu MT8195_MCU_BIG_CPU1>; + trips { + cpu5_crit: trip-crit { + temperature = <100000>; + hysteresis = <2000>; + type = "critical"; + }; + }; + }; + + cpu6-thermal { + polling-delay = <0>; + polling-delay-passive = <0>; + thermal-sensors = <&lvts_mcu MT8195_MCU_BIG_CPU2>; + trips { + cpu6_crit: trip-crit { + temperature = <100000>; + hysteresis = <2000>; + type = "critical"; + }; + }; + }; + + cpu7-thermal { + polling-delay = <0>; + polling-delay-passive = <0>; + thermal-sensors = <&lvts_mcu MT8195_MCU_BIG_CPU3>; + trips { + cpu7_crit: trip-crit { + temperature = <100000>; + hysteresis = <2000>; + type = "critical"; + }; + }; + }; + }; };
Signature · 1 line
2.34.1
Re: [PATCH v14 5/6] arm64: dts: mediatek: mt8195: Add thermal zones and thermal nodes
Hi Matthias, Angelo,
Would you please confirm if this patch can be applied? and, if it is the case, to which tree it will be applied?
Best regards,
Balsam
PATCH v14 6/6 arm64: dts: mediatek: mt8195: Add temperature mitigation threshold
In reply to [email protected]From: Balsam CHIHI <[email protected]>
The mt8195 SoC has several hotspots around the CPUs. Specify the targeted temperature threshold when to apply the mitigation and define the associated cooling devices.
--- arch/arm64/boot/dts/mediatek/mt8195.dtsi | 169 ++++++++++++++++++++--- 1 file changed, 153 insertions(+), 16 deletions(-)
arch/arm64/boot/dts/mediatek/mt8195.dtsi +153 -16
@@ -14,6 +14,7 @@ #include <dt-bindings/pinctrl/mt8195-pinfunc.h> #include <dt-bindings/power/mt8195-power.h> #include <dt-bindings/reset/mt8195-resets.h> +#include <dt-bindings/thermal/thermal.h> #include <dt-bindings/thermal/mediatek,lvts-thermal.h> / {
@@ -2413,107 +2414,243 @@ dp_tx: dp-tx@1c600000 { thermal_zones: thermal-zones { cpu0-thermal { - polling-delay = <0>; - polling-delay-passive = <0>; + polling-delay = <1000>; + polling-delay-passive = <250>; thermal-sensors = <&lvts_mcu MT8195_MCU_LITTLE_CPU0>; + trips { + cpu0_alert: trip-alert { + temperature = <85000>; + hysteresis = <2000>; + type = "passive"; + }; + cpu0_crit: trip-crit { temperature = <100000>; hysteresis = <2000>; type = "critical"; }; }; + + cooling-maps { + map0 { + trip = <&cpu0_alert>; + 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>; + }; + }; }; cpu1-thermal { - polling-delay = <0>; - polling-delay-passive = <0>; + polling-delay = <1000>; + polling-delay-passive = <250>; thermal-sensors = <&lvts_mcu MT8195_MCU_LITTLE_CPU1>; + trips { + cpu1_alert: trip-alert { + temperature = <85000>; + hysteresis = <2000>; + type = "passive"; + }; + cpu1_crit: trip-crit { temperature = <100000>; hysteresis = <2000>; type = "critical"; }; }; + + cooling-maps { + map0 { + trip = <&cpu1_alert>; + 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>; + }; + }; }; cpu2-thermal { - polling-delay = <0>; - polling-delay-passive = <0>; + polling-delay = <1000>; + polling-delay-passive = <250>; thermal-sensors = <&lvts_mcu MT8195_MCU_LITTLE_CPU2>; + trips { + cpu2_alert: trip-alert { + temperature = <85000>; + hysteresis = <2000>; + type = "passive"; + }; + cpu2_crit: trip-crit { temperature = <100000>; hysteresis = <2000>; type = "critical"; }; }; + + cooling-maps { + map0 { + trip = <&cpu2_alert>; + 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>; + }; + }; }; cpu3-thermal { - polling-delay = <0>; - polling-delay-passive = <0>; + polling-delay = <1000>; + polling-delay-passive = <250>; thermal-sensors = <&lvts_mcu MT8195_MCU_LITTLE_CPU3>; + trips { + cpu3_alert: trip-alert { + temperature = <85000>; + hysteresis = <2000>; + type = "passive"; + }; + cpu3_crit: trip-crit { temperature = <100000>; hysteresis = <2000>; type = "critical"; }; }; + + cooling-maps { + map0 { + trip = <&cpu3_alert>; + 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>; + }; + }; }; cpu4-thermal { - polling-delay = <0>; - polling-delay-passive = <0>; + polling-delay = <1000>; + polling-delay-passive = <250>; thermal-sensors = <&lvts_mcu MT8195_MCU_BIG_CPU0>; + trips { + cpu4_alert: trip-alert { + temperature = <85000>; + hysteresis = <2000>; + type = "passive"; + }; + cpu4_crit: trip-crit { temperature = <100000>; hysteresis = <2000>; type = "critical"; }; }; + + cooling-maps { + map0 { + trip = <&cpu4_alert>; + cooling-device = <&cpu4 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu5 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu6 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu7 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>; + }; + }; }; cpu5-thermal { - polling-delay = <0>; - polling-delay-passive = <0>; + polling-delay = <1000>; + polling-delay-passive = <250>; thermal-sensors = <&lvts_mcu MT8195_MCU_BIG_CPU1>; + trips { + cpu5_alert: trip-alert { + temperature = <85000>; + hysteresis = <2000>; + type = "passive"; + }; + cpu5_crit: trip-crit { temperature = <100000>; hysteresis = <2000>; type = "critical"; }; }; + + cooling-maps { + map0 { + trip = <&cpu5_alert>; + cooling-device = <&cpu4 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu5 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu6 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu7 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>; + }; + }; }; cpu6-thermal { - polling-delay = <0>; - polling-delay-passive = <0>; + polling-delay = <1000>; + polling-delay-passive = <250>; thermal-sensors = <&lvts_mcu MT8195_MCU_BIG_CPU2>; + trips { + cpu6_alert: trip-alert { + temperature = <85000>; + hysteresis = <2000>; + type = "passive"; + }; + cpu6_crit: trip-crit { temperature = <100000>; hysteresis = <2000>; type = "critical"; }; }; + + cooling-maps { + map0 { + trip = <&cpu6_alert>; + cooling-device = <&cpu4 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu5 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu6 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu7 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>; + }; + }; }; cpu7-thermal { - polling-delay = <0>; - polling-delay-passive = <0>; + polling-delay = <1000>; + polling-delay-passive = <250>; thermal-sensors = <&lvts_mcu MT8195_MCU_BIG_CPU3>; + trips { + cpu7_alert: trip-alert { + temperature = <85000>; + hysteresis = <2000>; + type = "passive"; + }; + cpu7_crit: trip-crit { temperature = <100000>; hysteresis = <2000>; type = "critical"; }; }; + + cooling-maps { + map0 { + trip = <&cpu7_alert>; + cooling-device = <&cpu4 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu5 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu6 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu7 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>; + }; + }; }; }; };
Signature · 1 line
2.34.1
Re: [PATCH v14 6/6] arm64: dts: mediatek: mt8195: Add temperature mitigation threshold
Hi Matthias, Angelo,
Would you please confirm if this patch can be applied? and, if it is the case, to which tree it will be applied?
Best regards,
Balsam
AngeloGioacchino Del Regno
maintainerRe: [PATCH v14 6/6] arm64: dts: mediatek: mt8195: Add temperature mitigation threshold
Il 14/02/23 15:43, Balsam CHIHI ha scritto:
Quoted 7 lines
Hi Matthias, Angelo,
Would you please confirm if this patch can be applied? and, if it is the case, to which tree it will be applied?
Best regards,
Balsam
I think it's fine to apply 5/6 and 6/6, as you're adding pre-Tjunction max temperature - this is not board specific, but rather SoC-specific. In reality it's practically the same for most SoCs, even.
Each board will define extensions (that are thermal envelope dependant) to these "please-dont-burn-my-device" initial thresholds, but that's a story for another day, and for other people anyway (including me).
Matthias, over to you!
Re: [PATCH v14 6/6] arm64: dts: mediatek: mt8195: Add temperature mitigation threshold
Hi Angelo,
Quoted 14 lines · AngeloGioacchino Del Regno
Il 14/02/23 15:43, Balsam CHIHI ha scritto:
Quoted 7 lines
Hi Matthias, Angelo,
Would you please confirm if this patch can be applied? and, if it is the case, to which tree it will be applied?
Best regards,
BalsamI think it's fine to apply 5/6 and 6/6, as you're adding pre-Tjunction max temperature - this is not board specific, but rather SoC-specific. In reality it's practically the same for most SoCs, even.
Quoted 5 lines
Each board will define extensions (that are thermal envelope dependant) to these "please-dont-burn-my-device" initial thresholds, but that's a story for another day, and for other people anyway (including me).
Matthias, over to you!
Indeed.
Thank you for your feedback!
Best regards,
Balsam
Re: [PATCH v14 6/6] arm64: dts: mediatek: mt8195: Add temperature mitigation threshold
Hi Matthias,
Is it time to apply those last two patches of the series "Add LVTS Thermal Architecture"?
[v14,6/6] arm64: dts: mediatek: mt8195: Add temperature mitigation threshold
https://lore.kernel.org/all/[email protected]/
and
[v14,5/6] arm64: dts: mediatek: mt8195: Add thermal zones and thermal nodes
https://lore.kernel.org/all/[email protected]/
Is there anything that I could do from my side, to make it possible?
Best regards,
Balsam
Matthias Brugger
maintainerRe: [PATCH v14 6/6] arm64: dts: mediatek: mt8195: Add temperature mitigation threshold
Quoted 5 lines · Balsam CHIHI
Hi Matthias,
Is it time to apply those last two patches of the series "Add LVTS Thermal Architecture"?
Quoted 8 lines
[v14,6/6] arm64: dts: mediatek: mt8195: Add temperature mitigation threshold
https://lore.kernel.org/all/[email protected]/
and
[v14,5/6] arm64: dts: mediatek: mt8195: Add thermal zones and thermal nodes
https://lore.kernel.org/all/[email protected]/Is there anything that I could do from my side, to make it possible?
Both applied now. Thanks!
Re: [PATCH v14 6/6] arm64: dts: mediatek: mt8195: Add temperature mitigation threshold
Hi Matthias,
Quoted 15 lines · Matthias Brugger
Quoted 11 lines · Balsam CHIHI
Hi Matthias,
Is it time to apply those last two patches of the series "Add LVTS Thermal Architecture"?
[v14,6/6] arm64: dts: mediatek: mt8195: Add temperature mitigation threshold
https://lore.kernel.org/all/[email protected]/
and
[v14,5/6] arm64: dts: mediatek: mt8195: Add thermal zones and thermal nodes
https://lore.kernel.org/all/[email protected]/
Quoted 4 lines
Quoted 2 lines
Is there anything that I could do from my side, to make it possible?
Both applied now. Thanks!
Great, Thank you!
Best Regards,
Balsam
Quoted 27 lines · On 09/02/2023 11:56, [email protected] wrote:
From: Balsam CHIHI <[email protected]>
The LVTS (Low Voltage Thermal Sensor) driver is capable of monitoring multiple hot points. For that, it contains 7 thermal control blocks dedicated to specific devices on the die. Each control block can handle up to 4 sensors.
The thermal controller supports several interrupts. One for the cold trip point, the hot trip point, the return to the normal trip point, and a specific programmable trip point to monitor the temperature dynamically.
The temperature measurement can be done in two ways, the immediate mode where the temperature read is instantaneous and the filtered mode where the controller uses, by configuration, an average of a set of values removing the minimum and the maximum.
Finally, it is composed of 2 finite-state machines responsible for the state of the temperature (cold, hot, hot 2 normal, hot hot), the triggering of the interrupts, and the monitoring of the temperature.
As requested, the thermal driver has been reworked to reduce the complexity of the code. At this time, the 4 little CPUs and the 4 big CPUs are supported by the thermal driver.They are described in a data structure and more devices can be added later. The calibration routine has been simplified also.
Quoted 7 lines
The series provide the following changes:
- Move the Mediatek drivers inside a dedicated folder as their number is increasing
- Add the DT bindings for the controller
- Add the efuse node for the mt8195
- The LVTS driver
- The thermal zones description in the DT
Applied patch 1,2 and 4 for v6.3
Patches 5 and 6 should go through the Mediatek tree.
Thanks!
-- 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
Hi Daniel,
Quoted 37 lines · Daniel Lezcano
Quoted 27 lines · On 09/02/2023 11:56, [email protected] wrote:
From: Balsam CHIHI <[email protected]>
The LVTS (Low Voltage Thermal Sensor) driver is capable of monitoring multiple hot points. For that, it contains 7 thermal control blocks dedicated to specific devices on the die. Each control block can handle up to 4 sensors.
The thermal controller supports several interrupts. One for the cold trip point, the hot trip point, the return to the normal trip point, and a specific programmable trip point to monitor the temperature dynamically.
The temperature measurement can be done in two ways, the immediate mode where the temperature read is instantaneous and the filtered mode where the controller uses, by configuration, an average of a set of values removing the minimum and the maximum.
Finally, it is composed of 2 finite-state machines responsible for the state of the temperature (cold, hot, hot 2 normal, hot hot), the triggering of the interrupts, and the monitoring of the temperature.
As requested, the thermal driver has been reworked to reduce the complexity of the code. At this time, the 4 little CPUs and the 4 big CPUs are supported by the thermal driver.They are described in a data structure and more devices can be added later. The calibration routine has been simplified also.
Quoted 7 lines
The series provide the following changes:
- Move the Mediatek drivers inside a dedicated folder as their number is increasing
- Add the DT bindings for the controller
- Add the efuse node for the mt8195
- The LVTS driver
- The thermal zones description in the DT
Quoted 1 line
Applied patch 1,2 and 4 for v6.3
Thank you very much!
Quoted 8 lines
Patches 5 and 6 should go through the Mediatek tree.
Thanks!
-- Daniel
Quoted 7 lines
--
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCsFollow Linaro: <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
Best regards,
Balsam