Add LVTS architecture thermal
Subsystems (3)
cover Add LVTS architecture thermal
From: Balsam CHIHI <[email protected]>
This series moves thermal files related to MediaTek to the mediatek folder. And introduce the new architecture LVTS (low voltage 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 mt8192 and mt8195.
Changelog:
Changes in v8.1 :
- 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
Changes in 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:
- https://patchwork.kernel.org/project/linux-mediatek/list/?series=637849
- https://patchwork.kernel.org/project/linux-pm/list/?series=639386
Changes in 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
Changes in v5 :
- Use 'git mv' for the relocated file.
Changes in v4 :
- Rebase to kernel-v5.13-rc1
- Resend
Changes in v3 :
- change the expression in the lvts_temp_to_raw to dev_s64.
Changes in 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.
Alexandre Bailon (2):
dt-bindings: thermal: Add binding document for LVTS thermal
controllers
arm64: dts: mt8195: Add efuse node to mt8195
Balsam CHIHI (1):
arm64: dts: mt8192: Add thermal zone
Michael Kao (3):
thermal: mediatek: Relocate driver to mediatek folder
thermal: mediatek: Add LVTS driver for mt8192 thermal zones
thermal: mediatek: Add thermal zone settings for mt8195
Tinghan Shen (1):
arm64: dts: mt8195: Add thermal zone
.../thermal/mediatek,lvts-thermal.yaml | 77 ++
arch/arm64/boot/dts/mediatek/mt8192.dtsi | 113 ++-
arch/arm64/boot/dts/mediatek/mt8195.dtsi | 125 ++-
drivers/thermal/Kconfig | 14 +-
drivers/thermal/Makefile | 2 +-
drivers/thermal/mediatek/Kconfig | 47 +
drivers/thermal/mediatek/Makefile | 3 +
drivers/thermal/mediatek/lvts_thermal.c | 855 ++++++++++++++++++
drivers/thermal/mediatek/lvts_thermal.h | 377 ++++++++
drivers/thermal/mediatek/lvts_v4.c | 464 ++++++++++
.../mtxxxx_thermal.c} | 2 +-
11 files changed, 2065 insertions(+), 14 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
create mode 100644 drivers/thermal/mediatek/lvts_thermal.c
create mode 100644 drivers/thermal/mediatek/lvts_thermal.h
create mode 100644 drivers/thermal/mediatek/lvts_v4.c
rename drivers/thermal/{mtk_thermal.c => mediatek/mtxxxx_thermal.c} (99%)Signature · 1 line
2.34.1
PATCH 1/7 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 it as "mtxxxx_thermal.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 +
.../mtxxxx_thermal.c} | 2 +-
5 files changed, 30 insertions(+), 12 deletions(-)
create mode 100644 drivers/thermal/mediatek/Kconfig
create mode 100644 drivers/thermal/mediatek/Makefile
rename drivers/thermal/{mtk_thermal.c => mediatek/mtxxxx_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-$(CONFIG_QCOM_TSENS) += 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 +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) += mtxxxx_thermal.o
drivers/thermal/mediatek/mtxxxx_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
Re: [PATCH v8.1, 1/7] thermal: mediatek: Relocate driver to mediatek folder
Hi Balsam,
Quoted 19 lines · On Thu, Aug 04, 2022 at 03:09:06PM +0200, [email protected] wrote:
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 it as "
mtxxxx_thermal.c" to show its purpose more clearly.Signed-off-by Michael Kao <[email protected]>Signed-off-by Ben Tseng <[email protected]>Signed-off-by Balsam CHIHI <[email protected]>--- drivers/thermal/Kconfig | 14 ++++------- drivers/thermal/Makefile | 2 +- drivers/thermal/mediatek/Kconfig | 23 +++++++++++++++++++ drivers/thermal/mediatek/Makefile | 1 + .../mtxxxx_thermal.c} | 2 +- 5 files changed, 30 insertions(+), 12 deletions(-) create mode 100644 drivers/thermal/mediatek/Kconfig create mode 100644 drivers/thermal/mediatek/Makefile rename drivers/thermal/{mtk_thermal.c => mediatek/mtxxxx_thermal.c} (99%)
[..]
drivers/thermal/mediatek/mtxxxx_thermal.c
Quoted 5 lines
drivers/thermal/mediatek/Makefile new file +1
-0@@ -0,0 +1 @@ +obj-$(CONFIG_MTK_SOC_THERMAL) += mtxxxx_thermal.odrivers/thermal/mediatek/mtxxxx_thermal.c renamed from drivers/thermal/mtk_thermal.c +0
-0
When Daniel suggested using a more SoC explicit name like 'mtxxx_thermal' [1] the xxxx was supposed to be substituted for the actual SoC (family) that makes use of this driver :-).
From the compatibles looks like we have mt8173, mt2701, mt2712, mt7622, mt8183. So it doesn't look like it's a single SoC family... What about calling it auxadc_thermal?
Thanks,
Nícolas
[1] https://lore.kernel.org/linux-mediatek/[email protected]/
Quoted 19 lines
similarity index 99%
rename fromdrivers/thermal/mtk_thermal.crename todrivers/thermal/mediatek/mtxxxx_thermal.cindexede94eadddda..60924f8f98e9100644drivers/thermal/mediatek/mtxxxx_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 0x008Signature · 1 line
2.34.1
Re: [PATCH v8.1, 1/7] thermal: mediatek: Relocate driver to mediatek folder
Quoted 34 lines · Nícolas F. R. A. Prado
Hi Balsam,
Quoted 19 lines · On Thu, Aug 04, 2022 at 03:09:06PM +0200, [email protected] wrote:
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 it as "
mtxxxx_thermal.c" to show its purpose more clearly.Signed-off-by Michael Kao <[email protected]>Signed-off-by Ben Tseng <[email protected]>Signed-off-by Balsam CHIHI <[email protected]>--- drivers/thermal/Kconfig | 14 ++++------- drivers/thermal/Makefile | 2 +- drivers/thermal/mediatek/Kconfig | 23 +++++++++++++++++++ drivers/thermal/mediatek/Makefile | 1 + .../mtxxxx_thermal.c} | 2 +- 5 files changed, 30 insertions(+), 12 deletions(-) create mode 100644 drivers/thermal/mediatek/Kconfig create mode 100644 drivers/thermal/mediatek/Makefile rename drivers/thermal/{mtk_thermal.c => mediatek/mtxxxx_thermal.c} (99%)[..]
drivers/thermal/mediatek/mtxxxx_thermal.c
Quoted 5 lines
drivers/thermal/mediatek/Makefile new file +1
-0@@ -0,0 +1 @@ +obj-$(CONFIG_MTK_SOC_THERMAL) += mtxxxx_thermal.odrivers/thermal/mediatek/mtxxxx_thermal.c renamed from drivers/thermal/mtk_thermal.c +0
-0When Daniel suggested using a more SoC explicit name like '
mtxxx_thermal' [1] the xxxx was supposed to be substituted for the actual SoC (family) that makes use of this driver :-).
Quoted 6 lines
From the compatibles looks like we have mt8173, mt2701, mt2712, mt7622, mt8183. So it doesn't look like it's a single SoC family... What about calling it
auxadc_thermal?Thanks,
Nícolas
Hello Nícolas,
"auxadc_thermal.c" makes more sense, since we have "lvts_thermal.c". Thank you for the suggestion. I will take it.
Best regards,
Balsam
Quoted 22 lines
[1] https://lore.kernel.org/linux-mediatek/[email protected]/
Quoted 19 lines
similarity index 99%
rename fromdrivers/thermal/mtk_thermal.crename todrivers/thermal/mediatek/mtxxxx_thermal.cindexede94eadddda..60924f8f98e9100644drivers/thermal/mediatek/mtxxxx_thermal.c renamed from drivers/thermal/mtk_thermal.c +1
-2@@ -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 --2.34.1
PATCH 2/7 dt-bindings: thermal: Add binding document for LVTS thermal controllers
In reply to [email protected]From: Alexandre Bailon <[email protected]>
This patch adds dt-binding documents for mt8192 and mt8195 thermal controllers.
--- .../thermal/mediatek,lvts-thermal.yaml | 77 +++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 Documentation/devicetree/bindings/thermal/mediatek,lvts-thermal.yaml
Documentation/devicetree/bindings/thermal/mediatek,lvts-thermal.yaml new file +77 -0
@@ -0,0 +1,77 @@ +# 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 LVTS thermal controller + +maintainers: + - Yu-Chia Chang <[email protected]> + - Ben Tseng <[email protected]> + +properties: + compatible: + enum: + - mediatek,mt8192-lvts-ap + - mediatek,mt8192-lvts-mcu + - mediatek,mt8195-lvts-ap + - mediatek,mt8195-lvts-mcu + + "#thermal-sensor-cells": + const: 1 + + reg: + maxItems: 2 + + interrupts: + maxItems: 1 + + clocks: + maxItems: 1 + + resets: + items: + - description: SW reset HW AP/MCU domain to clean temporary data on HW initialization/resume. + + nvmem-cells: + items: + - description: LVTS calibration data 1 for thermal sensors + - description: LVTS calibration data 2 for thermal sensors + + nvmem-cell-names: + items: + - const: lvts_calib_data1 + - const: lvts_calib_data2 + +required: + - compatible + - '#thermal-sensor-cells' + - reg + - interrupts + - clocks + - resets + - nvmem-cells + - nvmem-cell-names + +additionalProperties: false + +examples: + - | + #include <dt-bindings/thermal/thermal.h> + #include <dt-bindings/interrupt-controller/arm-gic.h> + #include <dt-bindings/clock/mt8195-clk.h> + #include <dt-bindings/reset/mt8195-resets.h> + + lvtsmcu: thermal-sensor@11278000 { + compatible = "mediatek,mt8195-lvts-mcu"; + #thermal-sensor-cells = <1>; + reg = <0 0x11278000 0 0x400>; + 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_data1", "lvts_calib_data2"; + }; + +...
Signature · 1 line
2.34.1
Re: [PATCH v8.1, 2/7] dt-bindings: thermal: Add binding document for LVTS thermal controllers
Quoted 3 lines · On 04/08/2022 15:09, [email protected] wrote:
From: Alexandre Bailon <[email protected]>
This patch adds dt-binding documents for mt8192 and mt8195 thermal controllers.
Do not use "This commit/patch".
https://elixir.bootlin.com/linux/v5.17.1/source/Documentation/process/submitting-patches.rst#L95
Quoted 3 lines
Signed-off-by Alexandre Bailon <[email protected]>Signed-off-by Balsam CHIHI <[email protected]>
Please rebase your patches on recent Linux kernel (or next).
Quoted 13 lines
--- .../thermal/mediatek,lvts-thermal.yaml | 77 +++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 Documentation/devicetree/bindings/thermal/mediatek,lvts-thermal.yamlDocumentation/devicetree/bindings/thermal/mediatek,lvts-thermal.yaml new file +2
-0@@ -0,0 +1,77 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2
Documentation/devicetree/bindings/thermal/mediatek,lvts-thermal.yaml line 12
Quoted 10 lines
Documentation/devicetree/bindings/thermal/mediatek,lvts-thermal.yaml new file +10
-0+--- +$id: http://devicetree.org/schemas/thermal/mediatek,lvts-thermal.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: MediaTek SoC LVTS thermal controller + +maintainers: + - Yu-Chia Chang <[email protected]> + - Ben Tseng <[email protected]> +
Any reason why not referencing thermal-sensor.yaml?
Documentation/devicetree/bindings/thermal/mediatek,lvts-thermal.yaml line 25
Quoted 13 lines
Documentation/devicetree/bindings/thermal/mediatek,lvts-thermal.yaml new file +13
-0+properties: + compatible: + enum: + - mediatek,mt8192-lvts-ap + - mediatek,mt8192-lvts-mcu + - mediatek,mt8195-lvts-ap + - mediatek,mt8195-lvts-mcu + + "#thermal-sensor-cells": + const: 1 + + reg: + maxItems: 2
You need to describe the items (like nvmem-cells).
Quoted 31 lines
Documentation/devicetree/bindings/thermal/mediatek,lvts-thermal.yaml new file +31
-0+ + interrupts: + maxItems: 1 + + clocks: + maxItems: 1 + + resets: + items: + - description: SW reset HW AP/MCU domain to clean temporary data on HW initialization/resume. + + nvmem-cells: + items: + - description: LVTS calibration data 1 for thermal sensors + - description: LVTS calibration data 2 for thermal sensors + + nvmem-cell-names: + items: + - const: lvts_calib_data1 + - const: lvts_calib_data2 + +required: + - compatible + - '#thermal-sensor-cells' + - reg + - interrupts + - clocks + - resets + - nvmem-cells + - nvmem-cell-names +
Documentation/devicetree/bindings/thermal/mediatek,lvts-thermal.yaml line 66
Quoted 10 lines
Documentation/devicetree/bindings/thermal/mediatek,lvts-thermal.yaml new file +10
-0+additionalProperties: false + +examples: + - | + #include <dt-bindings/thermal/thermal.h> + #include <dt-bindings/interrupt-controller/arm-gic.h> + #include <dt-bindings/clock/mt8195-clk.h> + #include <dt-bindings/reset/mt8195-resets.h> + + lvtsmcu: thermal-sensor@11278000 {
Mixed-up indentation.
Best regards,
Krzysztof
Rob Herring
maintainerRe: [PATCH v8.1, 2/7] dt-bindings: thermal: Add binding document for LVTS thermal controllers
In reply to [email protected]Quoted 11 lines · On Thu, 04 Aug 2022 15:09:07 +0200, [email protected] wrote:
From: Alexandre Bailon <[email protected]>
This patch adds dt-binding documents for mt8192 and mt8195 thermal controllers.
Signed-off-by Alexandre Bailon <[email protected]>Signed-off-by Balsam CHIHI <[email protected]>--- .../thermal/mediatek,lvts-thermal.yaml | 77 +++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 Documentation/devicetree/bindings/thermal/mediatek,lvts-thermal.yaml
My bot found errors running 'make DT_CHECKER_FLAGS=-m dt_binding_check' on your patch (DT_CHECKER_FLAGS is new in v5.13):
yamllint warnings/errors:
dtschema/dtc warnings/errors:
Error: Documentation/devicetree/bindings/thermal/mediatek,lvts-thermal.example.dts:32.36-37 syntax error FATAL ERROR: Unable to parse input tree
make[1]: *** [scripts/Makefile.lib:383: Documentation/devicetree/bindings/thermal/mediatek,lvts-thermal.example.dtb] Error 1 make[1]: *** Waiting for unfinished jobs....
make: *** [Makefile:1404: dt_binding_check] Error 2
doc reference errors (make refcheckdocs):
See https://patchwork.ozlabs.org/patch/
This check can fail if there are any dependencies. The base for a patch series is generally the most recent rc1.
If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:
pip3 install dtschema --upgrade
Please check and re-submit.
Re: [PATCH v8.1, 2/7] dt-bindings: thermal: Add binding document for LVTS thermal controllers
In reply to [email protected]Quoted 16 lines · On Thu, Aug 04, 2022 at 03:09:07PM +0200, [email protected] wrote:
From: Alexandre Bailon <[email protected]>
This patch adds dt-binding documents for mt8192 and mt8195 thermal controllers.
Signed-off-by Alexandre Bailon <[email protected]>Signed-off-by Balsam CHIHI <[email protected]>--- .../thermal/mediatek,lvts-thermal.yaml | 77 +++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 Documentation/devicetree/bindings/thermal/mediatek,lvts-thermal.yamlDocumentation/devicetree/bindings/thermal/mediatek,lvts-thermal.yaml new file +0
-0
[..]
Quoted 1 line
+ nvmem-cells:
minItems: 1
since mt8192 only has one of them.
Documentation/devicetree/bindings/thermal/mediatek,lvts-thermal.yaml line 42
Quoted 5 lines
Documentation/devicetree/bindings/thermal/mediatek,lvts-thermal.yaml new file +5
-0+ items: + - description: LVTS calibration data 1 for thermal sensors + - description: LVTS calibration data 2 for thermal sensors + + nvmem-cell-names:
Ditto.
Thanks,
Nícolas
Quoted 3 lines
Documentation/devicetree/bindings/thermal/mediatek,lvts-thermal.yaml new file +3
-0+ items: + - const: lvts_calib_data1 + - const: lvts_calib_data2
[..]
Re: [PATCH v8.1, 2/7] dt-bindings: thermal: Add binding document for LVTS thermal controllers
Quoted 11 lines · Nícolas F. R. A. Prado
Quoted 5 lines
Documentation/devicetree/bindings/thermal/mediatek,lvts-thermal.yaml new file +0
-0[..]
Quoted 1 line
+ nvmem-cells:
minItems: 1
since mt8192 only has one of them.
Then add allOf:if:then: which will constrain it per variant/compatible.
Best regards,
Krzysztof
PATCH 3/7 arm64: dts: mt8192: Add thermal zone
In reply to [email protected]From: Balsam CHIHI <[email protected]>
This adds the thermal zone for the mt8192.
--- arch/arm64/boot/dts/mediatek/mt8192.dtsi | 113 ++++++++++++++++++++++- 1 file changed, 112 insertions(+), 1 deletion(-)
arch/arm64/boot/dts/mediatek/mt8192.dtsi +112 -1
@@ -1,6 +1,6 @@ // SPDX-License-Identifier: (GPL-2.0 OR MIT) /* - * Copyright (C) 2020 MediaTek Inc. + * Copyright (C) 2022 MediaTek Inc. * Author: Seiya Wang <[email protected]> */
@@ -12,6 +12,7 @@ #include <dt-bindings/pinctrl/mt8192-pinfunc.h> #include <dt-bindings/phy/phy.h> #include <dt-bindings/power/mt8192-power.h> +#include <dt-bindings/reset/mt8192-resets.h> / { compatible = "mediatek,mt8192";
@@ -599,6 +600,28 @@ spi0: spi@1100a000 { status = "disabled"; }; + lvts_ap: thermal-sensor@1100b000 { + compatible = "mediatek,mt8192-lvts-ap"; + #thermal-sensor-cells = <1>; + reg = <0 0x1100b000 0 0x1000>; + interrupts = <GIC_SPI 169 IRQ_TYPE_LEVEL_HIGH 0>; + clocks = <&infracfg CLK_INFRA_THERM>; + resets = <&infracfg MT8192_INFRA_RST0_THERM_CTRL_SWRST>; + nvmem-cells = <&lvts_e_data1>; + nvmem-cell-names = "lvts_calib_data1"; + }; + + lvts_mcu: thermal-sensor@11278000 { + compatible = "mediatek,mt8192-lvts-mcu"; + #thermal-sensor-cells = <1>; + reg = <0 0x11278000 0 0x1000>; + interrupts = <GIC_SPI 170 IRQ_TYPE_LEVEL_HIGH 0>; + clocks = <&infracfg CLK_INFRA_THERM>; + resets = <&infracfg MT8192_INFRA_RST4_THERM_CTRL_MCU_SWRST>; + nvmem-cells = <&lvts_e_data1>; + nvmem-cell-names = "lvts_calib_data1"; + }; + spi1: spi@11010000 { compatible = "mediatek,mt8192-spi", "mediatek,mt6765-spi";
@@ -1457,4 +1480,92 @@ larb2: larb@1f002000 { power-domains = <&spm MT8192_POWER_DOMAIN_MDP>; }; }; + + thermal_zones: thermal-zones { + cpu-big1-thermal { + polling-delay = <0>; + polling-delay-passive = <0>; + thermal-sensors = <&lvts_mcu 0>; + }; + cpu-big2-thermal { + polling-delay = <0>; + polling-delay-passive = <0>; + thermal-sensors = <&lvts_mcu 1>; + }; + cpu-big3-thermal { + polling-delay = <0>; + polling-delay-passive = <0>; + thermal-sensors = <&lvts_mcu 2>; + }; + cpu-big4-thermal { + polling-delay = <0>; + polling-delay-passive = <0>; + thermal-sensors = <&lvts_mcu 3>; + }; + cpu-little1-thermal { + polling-delay = <0>; + polling-delay-passive = <0>; + thermal-sensors = <&lvts_mcu 4>; + }; + cpu-little2-thermal { + polling-delay = <0>; + polling-delay-passive = <0>; + thermal-sensors = <&lvts_mcu 5>; + }; + cpu-little3-thermal { + polling-delay = <0>; + polling-delay-passive = <0>; + thermal-sensors = <&lvts_mcu 6>; + }; + cpu-little4-thermal { + polling-delay = <0>; + polling-delay-passive = <0>; + thermal-sensors = <&lvts_mcu 7>; + }; + vpu1-thermal { + polling-delay = <0>; + polling-delay-passive = <0>; + thermal-sensors = <&lvts_ap 0>; + }; + vpu2-thermal { + polling-delay = <0>; + polling-delay-passive = <0>; + thermal-sensors = <&lvts_ap 1>; + }; + gpu1-thermal { + polling-delay = <0>; + polling-delay-passive = <0>; + thermal-sensors = <&lvts_ap 2>; + }; + gpu2-thermal { + polling-delay = <0>; + polling-delay-passive = <0>; + thermal-sensors = <&lvts_ap 3>; + }; + vdec-thermal { + polling-delay = <0>; + polling-delay-passive = <0>; + thermal-sensors = <&lvts_ap 4>; + }; + img-thermal { + polling-delay = <0>; + polling-delay-passive = <0>; + thermal-sensors = <&lvts_ap 5>; + }; + infra-thermal { + polling-delay = <0>; + polling-delay-passive = <0>; + thermal-sensors = <&lvts_ap 6>; + }; + cam1-thermal { + polling-delay = <0>; + polling-delay-passive = <0>; + thermal-sensors = <&lvts_ap 7>; + }; + cam2-thermal { + polling-delay = <0>; + polling-delay-passive = <0>; + thermal-sensors = <&lvts_ap 8>; + }; + }; };
Signature · 1 line
2.34.1
Re: [PATCH v8.1, 3/7] arm64: dts: mt8192: Add thermal zone
Quoted 14 lines · On 04/08/2022 15:09, [email protected] wrote:
From: Balsam CHIHI <[email protected]>
This adds the thermal zone for the mt8192.
Signed-off-by Balsam CHIHI <[email protected]>--- arch/arm64/boot/dts/mediatek/mt8192.dtsi | 113 ++++++++++++++++++++++- 1 file changed, 112 insertions(+), 1 deletion(-)arch/arm64/boot/dts/mediatek/mt8192.dtsi +0
-0
arch/arm64/boot/dts/mediatek/mt8192.dtsi line 3
Quoted 4 lines
arch/arm64/boot/dts/mediatek/mt8192.dtsi +1
-1@@ -1,6 +1,6 @@ // SPDX-License-Identifier: (GPL-2.0 OR MIT) /* - * Copyright (C) 2020 MediaTek Inc. + * Copyright (C) 2022 MediaTek Inc.
This is unexpected, so it needs careful explanation.
Quoted 41 lines
arch/arm64/boot/dts/mediatek/mt8192.dtsi +23
-0* Author: Seiya Wang <[email protected]> */@@ -12,6 +12,7 @@ #include <dt-bindings/pinctrl/mt8192-pinfunc.h> #include <dt-bindings/phy/phy.h> #include <dt-bindings/power/mt8192-power.h> +#include <dt-bindings/reset/mt8192-resets.h> / { compatible = "mediatek,mt8192";@@ -599,6 +600,28 @@ spi0: spi@1100a000 { status = "disabled"; }; + lvts_ap: thermal-sensor@1100b000 { + compatible = "mediatek,mt8192-lvts-ap"; + #thermal-sensor-cells = <1>; + reg = <0 0x1100b000 0 0x1000>; + interrupts = <GIC_SPI 169 IRQ_TYPE_LEVEL_HIGH 0>; + clocks = <&infracfg CLK_INFRA_THERM>; + resets = <&infracfg MT8192_INFRA_RST0_THERM_CTRL_SWRST>; + nvmem-cells = <&lvts_e_data1>; + nvmem-cell-names = "lvts_calib_data1"; + }; + + lvts_mcu: thermal-sensor@11278000 { + compatible = "mediatek,mt8192-lvts-mcu"; + #thermal-sensor-cells = <1>; + reg = <0 0x11278000 0 0x1000>; + interrupts = <GIC_SPI 170 IRQ_TYPE_LEVEL_HIGH 0>; + clocks = <&infracfg CLK_INFRA_THERM>; + resets = <&infracfg MT8192_INFRA_RST4_THERM_CTRL_MCU_SWRST>; + nvmem-cells = <&lvts_e_data1>; + nvmem-cell-names = "lvts_calib_data1"; + }; + spi1: spi@11010000 { compatible = "mediatek,mt8192-spi", "mediatek,mt6765-spi";
arch/arm64/boot/dts/mediatek/mt8192.dtsi larb2: larb@1f002000 { · line 1485
Quoted 6 lines
arch/arm64/boot/dts/mediatek/mt8192.dtsi +3
-0@@ -1457,4 +1480,92 @@ larb2: larb@1f002000 { power-domains = <&spm MT8192_POWER_DOMAIN_MDP>; }; }; + + thermal_zones: thermal-zones { + cpu-big1-thermal {
Names look not matching DT schema.
Best regards,
Krzysztof
Re: [PATCH v8.1, 3/7] arm64: dts: mt8192: Add thermal zone
In reply to [email protected]Quoted 13 lines · On Thu, Aug 04, 2022 at 03:09:08PM +0200, [email protected] wrote:
From: Balsam CHIHI <[email protected]>
This adds the thermal zone for the mt8192.
Signed-off-by Balsam CHIHI <[email protected]>--- arch/arm64/boot/dts/mediatek/mt8192.dtsi | 113 ++++++++++++++++++++++- 1 file changed, 112 insertions(+), 1 deletion(-)arch/arm64/boot/dts/mediatek/mt8192.dtsi +0
-0
[..]
arch/arm64/boot/dts/mediatek/mt8192.dtsi larb2: larb@1f002000 { · line 1545
Quoted 1 line
arch/arm64/boot/dts/mediatek/mt8192.dtsi +1
-0+ vdec-thermal {
infra-thermal
arch/arm64/boot/dts/mediatek/mt8192.dtsi larb2: larb@1f002000 { · line 1550
Quoted 5 lines
arch/arm64/boot/dts/mediatek/mt8192.dtsi +5
-0+ polling-delay = <0>; + polling-delay-passive = <0>; + thermal-sensors = <&lvts_ap 4>; + }; + img-thermal {
cam-thermal
arch/arm64/boot/dts/mediatek/mt8192.dtsi larb2: larb@1f002000 { · line 1555
Quoted 5 lines
arch/arm64/boot/dts/mediatek/mt8192.dtsi +5
-0+ polling-delay = <0>; + polling-delay-passive = <0>; + thermal-sensors = <&lvts_ap 5>; + }; + infra-thermal {
md1-thermal
arch/arm64/boot/dts/mediatek/mt8192.dtsi larb2: larb@1f002000 { · line 1560
Quoted 5 lines
arch/arm64/boot/dts/mediatek/mt8192.dtsi +5
-0+ polling-delay = <0>; + polling-delay-passive = <0>; + thermal-sensors = <&lvts_ap 6>; + }; + cam1-thermal {
md2-thermal
arch/arm64/boot/dts/mediatek/mt8192.dtsi larb2: larb@1f002000 { · line 1565
Quoted 5 lines
arch/arm64/boot/dts/mediatek/mt8192.dtsi +5
-0+ polling-delay = <0>; + polling-delay-passive = <0>; + thermal-sensors = <&lvts_ap 7>; + }; + cam2-thermal {
md3-thermal
Thanks,
Nícolas
Quoted 10 lines
arch/arm64/boot/dts/mediatek/mt8192.dtsi +5
-0+ polling-delay = <0>; + polling-delay-passive = <0>; + thermal-sensors = <&lvts_ap 8>; + }; + }; };Signature · 1 line
2.34.1
PATCH 4/7 thermal: mediatek: Add LVTS driver for mt8192 thermal zones
In reply to [email protected]From: Michael Kao <[email protected]>
Add a LVTS V4 (Low Voltage Thermal Sensor) driver to report junction temperatures in MediaTek SoC mt8192 and register the maximum temperature of sensors and each sensor as a thermal zone.
--- drivers/thermal/mediatek/Kconfig | 24 + drivers/thermal/mediatek/Makefile | 2 + drivers/thermal/mediatek/lvts_thermal.c | 855 ++++++++++++++++++++++++ drivers/thermal/mediatek/lvts_thermal.h | 376 +++++++++++ drivers/thermal/mediatek/lvts_v4.c | 241 +++++++ 5 files changed, 1498 insertions(+) create mode 100644 drivers/thermal/mediatek/lvts_thermal.c create mode 100644 drivers/thermal/mediatek/lvts_thermal.h create mode 100644 drivers/thermal/mediatek/lvts_v4.c
drivers/thermal/mediatek/Kconfig +24 -0
@@ -20,4 +20,28 @@ config MTK_SOC_THERMAL configures thermal controllers to collect temperature via AUXADC interface. +config MTK_LVTS_THERMAL + tristate "LVTS (Low Voltage Thermal 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 + LVTS (Low Voltage Thermal Sensor) thermal controllers to + collect temperatures via ASIF (Analog Serial Interface). + +if MTK_LVTS_THERMAL + +config MTK_LVTS_V4 + tristate "LVTS V4 Thermal 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 LVTS V4. + +endif + endif
drivers/thermal/mediatek/Makefile +2 -0
@@ -1 +1,3 @@ obj-$(CONFIG_MTK_SOC_THERMAL) += mtxxxx_thermal.o +obj-$(CONFIG_MTK_LVTS_THERMAL) += lvts_thermal.o +obj-$(CONFIG_MTK_LVTS_V4) += lvts_v4.o
drivers/thermal/mediatek/lvts_thermal.c new file +855 -0
855 lines not on this page · raw message
drivers/thermal/mediatek/lvts_thermal.h new file +376 -0
376 lines not on this page · raw message
drivers/thermal/mediatek/lvts_v4.c new file +241 -0
241 lines not on this page · raw message
Signature · 1 line
2.34.1
Re: [PATCH v8.1, 4/7] thermal: mediatek: Add LVTS driver for mt8192 thermal zones
Hi--
Quoted 16 lines · On 8/4/22 06:09, [email protected] wrote:
drivers/thermal/mediatek/Kconfig +8
-0@@ -20,4 +20,28 @@ config MTK_SOC_THERMAL configures thermal controllers to collect temperature via AUXADC interface. +config MTK_LVTS_THERMAL + tristate "LVTS (Low Voltage Thermal 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
drivers/thermal/mediatek/Kconfig config MTK_SOC_THERMAL · line 40
Quoted 10 lines
drivers/thermal/mediatek/Kconfig +10
-0+ LVTS (Low Voltage Thermal Sensor) thermal controllers to + collect temperatures via ASIF (Analog Serial Interface). + +if MTK_LVTS_THERMAL + +config MTK_LVTS_V4 + tristate "LVTS V4 Thermal Driver for MediaTek SoCs" + depends on HAS_IOMEM + depends on NVMEM + depends on RESET_CONTROLLER
You shouldn't need to repeat all of these "depends on" lines since this Kconfig symbol depends on MTK_LVTS_THERMAL, which already depends on these 3 items.
Have you seen any issue that this is supposed to fix?
drivers/thermal/mediatek/Kconfig config MTK_SOC_THERMAL · line 45
Quoted 5 lines
drivers/thermal/mediatek/Kconfig +5
-0+ help + Enable this option if you want to get SoC temperature + information for LVTS V4. + +endif
thanks.
Signature · 1 line
~Randy
Re: [PATCH v8.1, 4/7] thermal: mediatek: Add LVTS driver for mt8192 thermal zones
In reply to [email protected]Quoted 11 lines · On Thu, Aug 04, 2022 at 03:09:09PM +0200, [email protected] wrote:
From: Michael Kao <[email protected]>
Add a LVTS V4 (Low Voltage Thermal Sensor) driver to report junction temperatures in MediaTek SoC mt8192 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]>Signed-off-by Alexandre Bailon <[email protected]>Signed-off-by Balsam CHIHI <[email protected]>
You should have a Co-developed-by tag for each person that wrote the code [1].
Quoted 1 line
---
[..]
Quoted 2 lines
drivers/thermal/mediatek/lvts_thermal.c new file +0
-0
[..]
Quoted 2 lines
drivers/thermal/mediatek/lvts_thermal.c new file +2
-0+static int prepare_calibration_data (struct lvts_data *lvts_data) +{
[..]
drivers/thermal/mediatek/lvts_thermal.c line 433
Quoted 6 lines
drivers/thermal/mediatek/lvts_thermal.c new file +6
-0+ lvts_data->coeff.golden_temp = cal_data->golden_temp; +dev_dbg (dev,"golden_temp = %d\n" , cal_data->golden_temp); + offset =snprintf (buffer,sizeof (buffer),"[lvts_cal] num:g_count:g_count_rc " ); +for (i =0 ; i < lvts_data->num_sensor; i++) + offset +=snprintf (buffer + offset,sizeof (buffer) - offset,"%d:%d:%d " , + i, cal_data->count_r[i], cal_data->count_rc[i]);
Like Angelo already mentioned [2], you're not using this string for anything, so just remove the code.
[2] https://lore.kernel.org/linux-mediatek/[email protected]/
Quoted 3 lines
drivers/thermal/mediatek/lvts_thermal.c new file +3
-0+ +return 0 ; +}
[..]
Quoted 2 lines
drivers/thermal/mediatek/lvts_thermal.c new file +2
-0+int lvts_device_read_count_rc_n_v4 (struct lvts_data *lvts_data) +{
[..]
drivers/thermal/mediatek/lvts_thermal.c line 735
Quoted 4 lines
drivers/thermal/mediatek/lvts_thermal.c new file +4
-0+ offset =snprintf (buffer,sizeof (buffer),"[COUNT_RC_NOW] " ); +for (i =0 ; i < lvts_data->num_sensor; i++) + offset +=snprintf (buffer + offset,sizeof (buffer) - offset,"%d:%d " , i, + cal_data->count_rc_now[i]);
Again, just formatting a string and throwing it away, please just drop the code.
Quoted 3 lines
drivers/thermal/mediatek/lvts_thermal.c new file +3
-0+ +return 0 ; +}
[..]
drivers/thermal/mediatek/lvts_thermal.c line 850
Quoted 12 lines
drivers/thermal/mediatek/lvts_thermal.c new file +12
-0+int lvts_resume (struct platform_device *pdev) +{ +struct lvts_data *lvts_data; +int ret; + + lvts_data = (struct lvts_data *)platform_get_drvdata (pdev); + ret =lvts_init (lvts_data); +if (ret) +return ret; + +return 0 ; +}
You have a bug in your resume path somewhere. I get this error during resume on mt8192-asurada-spherion:
<1>[ 237.487428] Unable to handle kernel write to read-only memory at virtual address ffffc15096e491c0 <1>[ 237.496663] Mem abort info: <1>[ 237.499794] ESR = 0x000000009600004e <1>[ 237.504334] EC = 0x25: DABT (current EL), IL = 32 bits <1>[ 237.509982] SET = 0, FnV = 0 <1>[ 237.513444] EA = 0, S1PTW = 0 <1>[ 237.516911] FSC = 0x0e: level 2 permission fault <1>[ 237.522041] Data abort info: <1>[ 237.525263] ISV = 0, ISS = 0x0000004e <1>[ 237.529458] CM = 0, WnR = 1 <1>[ 237.532739] swapper pgtable: 4k pages, 48-bit VAs, pgdp=0000000041782000 <1>[ 237.539754] [ffffc15096e491c0] pgd=100000023ffff003, p4d=100000023ffff003, pud=100000023fffe003, pmd=0060000041200f81 <0>[ 237.550821] Internal error: Oops: 9600004e [#1] PREEMPT SMP <4>[ 237.556669] Modules linked in: af_alg mtk_vcodec_dec_hw snd_soc_hdmi_codec panel_edp mtk_vcodec_dec v4l2_vp9 v4l2_h264 mtk_vcodec_enc btusb mtk_vcodec_common btrtl videobuf2_dma_contig uvcvideo btintel videobuf2_vmalloc mtk_vpu btmtk videobuf2_memops v4l2_mem2mem mt7921e btbcm cdc_ether usbnet videobuf2_v4l2 mt7921_common bluetooth crct10dif_ce videobuf2_common r8152 mt76_connac_lib videodev ecdh_generic ecc mc mt76 mac80211 sbs_battery cros_usbpd_charger cros_usbpd_logger cros_ec_chardev libarc4 pwm_cros_ec anx7625 snd_soc_rt5682_i2c elan_i2c snd_soc_rt5682 cros_ec_typec snd_soc_rl6231 drm_dp_aux_bus typec drm_display_helper panfrost mediatek_drm drm_cma_helper rtc_mt6397 drm_shmem_helper phy_mtk_mipi_dsi_drv gpu_sched mt8192_mt6359_rt1015_rt5682 drm_kms_helper pwm_mtk_disp pwm_bl snd_soc_rt1015p snd_soc_mt8192_afe snd_soc_dmic snd_soc_mtk_common cfg80211 rfkill drm fuse backlight ip_tables x_tables ipv6 <4>[ 237.637538] CPU: 1 PID: 533 Comm: bash Tainted: G W 5.19.0-rc8-next-20220725+ #254 <4>[ 237.646781] Hardware name: Google Spherion (rev0 - 3) (DT) <4>[ 237.652539] pstate: 60400009 (nZCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--) <4>[ 237.659778] pc : lvts_device_enable_and_init+0xdc/0xf0 <4>[ 237.665198] lr : lvts_device_enable_and_init+0xc8/0xf0 <4>[ 237.670609] sp : ffff8000098eb9b0 <4>[ 237.674188] x29: ffff8000098eb9b0 x28: 0000000000000000 x27: 0000000000000003 <4>[ 237.681609] x26: ffff41b141151010 x25: ffffc15097260c50 x24: 0000000000000000 <4>[ 237.689028] x23: 0000000000000038 x22: 0000000000000001 x21: 000000008502fc00 <4>[ 237.696448] x20: ffffc15096e49188 x19: 0000000000000003 x18: 0000000000000000 <4>[ 237.703867] x17: 0000000000000001 x16: ffffc15095cc9838 x15: 00000000000001ca <4>[ 237.711287] x14: 0000000000000002 x13: 0000000000000000 x12: 000000000000045d <4>[ 237.718706] x11: 0000000000000000 x10: 00000000000027d0 x9 : ffffc15095d81d18 <4>[ 237.726126] x8 : ffffc150974eb008 x7 : ffff41b15fdc2f80 x6 : ffffc15095ce58c0 <4>[ 237.733545] x5 : 0000000000000000 x4 : ffff8000098eb6f0 x3 : 0000000000000000 <4>[ 237.740963] x2 : 7ec5fa8849bae900 x1 : 7ec5fa8849bae900 x0 : 0000000000000014 <4>[ 237.748383] Call trace: <4>[ 237.751091] lvts_device_enable_and_init+0xdc/0xf0 <4>[ 237.756155] lvts_init+0x180/0x520 <4>[ 237.759824] lvts_resume+0x1c/0x78 <4>[ 237.763494] platform_pm_resume+0x5c/0x80 <4>[ 237.767777] dpm_run_callback+0x80/0x2e8 <4>[ 237.771972] device_resume+0x90/0x1c0 <4>[ 237.775904] dpm_resume+0x110/0x470 <4>[ 237.779663] dpm_resume_end+0x20/0x38 <4>[ 237.783596] suspend_devices_and_enter+0x1e4/0xb90 <4>[ 237.788662] pm_suspend+0x270/0x318 <4>[ 237.792419] state_store+0x94/0x120 <4>[ 237.796176] kobj_attr_store+0x18/0x30 <4>[ 237.800198] sysfs_kf_write+0x54/0x80 <4>[ 237.804131] kernfs_fop_write_iter+0x128/0x1c0 <4>[ 237.808845] vfs_write+0x39c/0x510 <4>[ 237.812517] ksys_write+0x74/0x100 <4>[ 237.816187] __arm64_sys_write+0x24/0x30 <4>[ 237.820380] invoke_syscall+0x4c/0x110 <4>[ 237.824401] el0_svc_common.constprop.0+0x68/0x128 <4>[ 237.829464] do_el0_svc+0x34/0xc0 <4>[ 237.833048] el0_svc+0x4c/0xc0 <4>[ 237.836371] el0t_64_sync_handler+0xb8/0xc0 <4>[ 237.840824] el0t_64_sync+0x18c/0x190 <0>[ 237.844759] Code: 11000673 6b13001f 54fffaa8 52800280 (b9003a80) <4>[ 237.851129] ---[ end trace 0000000000000000 ]---
Thanks,
Nícolas
Re: [PATCH v8.1, 4/7] thermal: mediatek: Add LVTS driver for mt8192 thermal zones
In reply to [email protected]Hi Balsam,
another thing.
On Thu, Aug 04, 2022 at 03:09:09PM +0200, [email protected] wrote:
[..]
Quoted 2 lines
drivers/thermal/mediatek/lvts_thermal.h new file +0
-0
[..]
Quoted 1 line
+#define
ONE_SAMPLE(lvts_data->counting_window_us+ 2 *BUS_ACCESS_US)
This macro is still using a hardcoded variable.
drivers/thermal/mediatek/lvts_thermal.h line 217
Quoted 5 lines
drivers/thermal/mediatek/lvts_thermal.h new file +5
-0+#define NUM_OF_SAMPLE (tc_id) ((lvts_data->tc[tc_id].hw_filter < LVTS_FILTER_2) ? \ + 1 : ((lvts_data->tc[tc_id].hw_filter > LVTS_FILTER_16_OF_18) ? \ + 1 : ((lvts_data->tc[tc_id].hw_filter == LVTS_FILTER_16_OF_18) ? \ + 18 : ((lvts_data->tc[tc_id].hw_filter == LVTS_FILTER_8_OF_10) ? \ + 10 : (lvts_data->tc[tc_id].hw_filter * 2)))))
Ditto.
drivers/thermal/mediatek/lvts_thermal.h line 226
Quoted 9 lines
drivers/thermal/mediatek/lvts_thermal.h new file +9
-0+ +#define PERIOD_UNIT_US (tc_id) ((lvts_data->tc[tc_id].tc_speed->period_unit * 256 * \ + CLOCK_26MHZ_CYCLE_NS) / 1000) +#define FILTER_INT_US (tc_id) (lvts_data->tc[tc_id].tc_speed->filter_interval_delay * \ + PERIOD_UNIT_US(tc_id)) +#define SENSOR_INT_US (tc_id) (lvts_data->tc[tc_id].tc_speed->sensor_interval_delay * \ + PERIOD_UNIT_US(tc_id)) +#define GROUP_INT_US (tc_id) (lvts_data->tc[tc_id].tc_speed->group_interval_delay * \ + PERIOD_UNIT_US(tc_id))
All of these too.
Quoted 1 line
+#define
SENSOR_LATENCY_US(tc_id)((NUM_OF_SAMPLE(tc_id)- 1) *FILTER_INT_US(tc_id)+ \
[..]
Quoted 1 line
+#define
DEVICE_READ(CK26M_ACTIVE(lvts_data)|DEVICE_ACCESS)
And this.
Quoted 1 line
+#define
DEVICE_WRITE(CK26M_ACTIVE(lvts_data)|DEVICE_ACCESS|WRITE_ACCESS)
And this.
drivers/thermal/mediatek/lvts_thermal.h line 239
Quoted 3 lines
drivers/thermal/mediatek/lvts_thermal.h new file +3
-0+#define RESET_ALL_DEVICES (DEVICE_WRITE | RG_TSFM_RST << 8 | 0xFF) +#define READ_DEVICE_REG (reg_id) (DEVICE_READ | (reg_id) << 8 | 0x00) +#define READ_BACK_DEVICE_ID (CK26M_ACTIVE(lvts_data) | DEVICE_ACCESS | BROADCAST_ID_UPDATE | \
And finally this one.
I might've have missed some, so please double-check and remove any lingering hardcoded variable in macros.
Thanks,
Nícolas
Quoted 1 line
drivers/thermal/mediatek/lvts_thermal.h new file +1
-0+ RG_DID_LVTS << 8)
[..]
PATCH 5/7 arm64: dts: mt8195: Add efuse node to mt8195
In reply to [email protected]From: Alexandre Bailon <[email protected]>
This adds the efuse node. This will be required by the thermal driver to get the calibration data.
--- arch/arm64/boot/dts/mediatek/mt8195.dtsi | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
arch/arm64/boot/dts/mediatek/mt8195.dtsi +13 -1
@@ -1,6 +1,6 @@ // SPDX-License-Identifier: (GPL-2.0 OR MIT) /* - * Copyright (c) 2021 MediaTek Inc. + * Copyright (c) 2022 MediaTek Inc. * Author: Seiya Wang <[email protected]> */
@@ -733,6 +733,18 @@ u2_intr_p3: usb2-intr-p3@189,2 { reg = <0x189 0x2>; bits = <7 5>; }; + + lvts_efuse_data1: lvts1-calib@1bc { + reg = <0x1bc 0x14>; + }; + + lvts_efuse_data2: lvts2-calib@1d0 { + reg = <0x1d0 0x38>; + }; + + svs_calibration: calib@580 { + reg = <0x580 0x64>; + }; }; u3phy2: t-phy@11c40000 {
Signature · 1 line
2.34.1
Re: [PATCH v8.1, 5/7] arm64: dts: mt8195: Add efuse node to mt8195
Quoted 16 lines · On 04/08/2022 15:09, [email protected] wrote:
From: Alexandre Bailon <[email protected]>
This adds the efuse node. This will be required by the thermal driver to get the calibration data.
Signed-off-by Alexandre Bailon <[email protected]>Signed-off-by Balsam CHIHI <[email protected]>--- arch/arm64/boot/dts/mediatek/mt8195.dtsi | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)arch/arm64/boot/dts/mediatek/mt8195.dtsi +0
-0
arch/arm64/boot/dts/mediatek/mt8195.dtsi line 3
Quoted 4 lines
arch/arm64/boot/dts/mediatek/mt8195.dtsi +1
-1@@ -1,6 +1,6 @@ // SPDX-License-Identifier: (GPL-2.0 OR MIT) /* - * Copyright (c) 2021 MediaTek Inc. + * Copyright (c) 2022 MediaTek Inc.
Why changing first copyright release date? This was not explained in commit msg.
Best regards,
Krzysztof
Re: [PATCH v8.1, 5/7] arm64: dts: mt8195: Add efuse node to mt8195
Quoted 28 lines · Krzysztof Kozlowski
Quoted 16 lines · On 04/08/2022 15:09, [email protected] wrote:
From: Alexandre Bailon <[email protected]>
This adds the efuse node. This will be required by the thermal driver to get the calibration data.
Signed-off-by Alexandre Bailon <[email protected]>Signed-off-by Balsam CHIHI <[email protected]>--- arch/arm64/boot/dts/mediatek/mt8195.dtsi | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)arch/arm64/boot/dts/mediatek/mt8195.dtsi +0
-0arch/arm64/boot/dts/mediatek/mt8195.dtsi line 3
Quoted 4 lines
arch/arm64/boot/dts/mediatek/mt8195.dtsi +1
-1@@ -1,6 +1,6 @@ // SPDX-License-Identifier: (GPL-2.0 OR MIT) /* - * Copyright (c) 2021 MediaTek Inc. + * Copyright (c) 2022 MediaTek Inc.Why changing first copyright release date? This was not explained in commit msg.
Quoted 2 lines
Best regards,
Krzysztof
Hello Krzysztof,
I will drop this change from this commit. There is no reason for that. Thank you for the review.
Best regards,
Balsam
PATCH 6/7 arm64: dts: mt8195: Add thermal zone
In reply to [email protected]From: Tinghan Shen <[email protected]>
This adds the thermal zone for the mt8195.
--- arch/arm64/boot/dts/mediatek/mt8195.dtsi | 111 +++++++++++++++++++++++ 1 file changed, 111 insertions(+)
arch/arm64/boot/dts/mediatek/mt8195.dtsi +111 -0
@@ -10,6 +10,7 @@ #include <dt-bindings/interrupt-controller/irq.h> #include <dt-bindings/phy/phy.h> #include <dt-bindings/pinctrl/mt8195-pinfunc.h> +#include <dt-bindings/reset/mt8195-resets.h> / { compatible = "mediatek,mt8195";
@@ -452,6 +453,28 @@ spi0: spi@1100a000 { status = "disabled"; }; + lvts_ap: thermal-sensor@1100b000 { + compatible = "mediatek,mt8195-lvts-ap"; + #thermal-sensor-cells = <1>; + 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_data1", "lvts_calib_data2"; + }; + + lvts_mcu: thermal-sensor@11278000 { + compatible = "mediatek,mt8195-lvts-mcu"; + #thermal-sensor-cells = <1>; + 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_data1", "lvts_calib_data2"; + }; + spi1: spi@11010000 { compatible = "mediatek,mt8195-spi", "mediatek,mt6765-spi";
@@ -1106,4 +1129,92 @@ vencsys_core1: clock-controller@1b000000 { #clock-cells = <1>; }; }; + + thermal_zones: thermal-zones { + cpu-big1-thermal { + polling-delay = <0>; + polling-delay-passive = <0>; + thermal-sensors = <&lvts_mcu 0>; + }; + cpu-big2-thermal { + polling-delay = <0>; + polling-delay-passive = <0>; + thermal-sensors = <&lvts_mcu 1>; + }; + cpu-big3-thermal { + polling-delay = <0>; + polling-delay-passive = <0>; + thermal-sensors = <&lvts_mcu 2>; + }; + cpu-big4-thermal { + polling-delay = <0>; + polling-delay-passive = <0>; + thermal-sensors = <&lvts_mcu 3>; + }; + cpu-little1-thermal { + polling-delay = <0>; + polling-delay-passive = <0>; + thermal-sensors = <&lvts_mcu 4>; + }; + cpu-little2-thermal { + polling-delay = <0>; + polling-delay-passive = <0>; + thermal-sensors = <&lvts_mcu 5>; + }; + cpu-little3-thermal { + polling-delay = <0>; + polling-delay-passive = <0>; + thermal-sensors = <&lvts_mcu 6>; + }; + cpu-little4-thermal { + polling-delay = <0>; + polling-delay-passive = <0>; + thermal-sensors = <&lvts_mcu 7>; + }; + vpu1-thermal { + polling-delay = <0>; + polling-delay-passive = <0>; + thermal-sensors = <&lvts_ap 0>; + }; + vpu2-thermal { + polling-delay = <0>; + polling-delay-passive = <0>; + thermal-sensors = <&lvts_ap 1>; + }; + gpu1-thermal { + polling-delay = <0>; + polling-delay-passive = <0>; + thermal-sensors = <&lvts_ap 2>; + }; + gpu2-thermal { + polling-delay = <0>; + polling-delay-passive = <0>; + thermal-sensors = <&lvts_ap 3>; + }; + vdec-thermal { + polling-delay = <0>; + polling-delay-passive = <0>; + thermal-sensors = <&lvts_ap 4>; + }; + img-thermal { + polling-delay = <0>; + polling-delay-passive = <0>; + thermal-sensors = <&lvts_ap 5>; + }; + infra-thermal { + polling-delay = <0>; + polling-delay-passive = <0>; + thermal-sensors = <&lvts_ap 6>; + }; + cam1-thermal { + polling-delay = <0>; + polling-delay-passive = <0>; + thermal-sensors = <&lvts_ap 7>; + }; + cam2-thermal { + polling-delay = <0>; + polling-delay-passive = <0>; + thermal-sensors = <&lvts_ap 8>; + }; + }; };
Signature · 1 line
2.34.1
Re: [PATCH v8.1, 6/7] arm64: dts: mt8195: Add thermal zone
Quoted 54 lines · On 04/08/2022 15:09, [email protected] wrote:
From: Tinghan Shen <[email protected]>
This adds the thermal zone for the mt8195.
Signed-off-by Tinghan Shen <[email protected]>Signed-off-by Ben Tseng <[email protected]>Signed-off-by Alexandre Bailon <[email protected]>Signed-off-by Balsam CHIHI <[email protected]>--- arch/arm64/boot/dts/mediatek/mt8195.dtsi | 111 +++++++++++++++++++++++ 1 file changed, 111 insertions(+)arch/arm64/boot/dts/mediatek/mt8195.dtsi +23
-0@@ -10,6 +10,7 @@ #include <dt-bindings/interrupt-controller/irq.h> #include <dt-bindings/phy/phy.h> #include <dt-bindings/pinctrl/mt8195-pinfunc.h> +#include <dt-bindings/reset/mt8195-resets.h> / { compatible = "mediatek,mt8195";@@ -452,6 +453,28 @@ spi0: spi@1100a000 { status = "disabled"; }; + lvts_ap: thermal-sensor@1100b000 { + compatible = "mediatek,mt8195-lvts-ap"; + #thermal-sensor-cells = <1>; + 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_data1", "lvts_calib_data2"; + }; + + lvts_mcu: thermal-sensor@11278000 { + compatible = "mediatek,mt8195-lvts-mcu"; + #thermal-sensor-cells = <1>; + 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_data1", "lvts_calib_data2"; + }; + spi1: spi@11010000 { compatible = "mediatek,mt8195-spi", "mediatek,mt6765-spi";
arch/arm64/boot/dts/mediatek/mt8195.dtsi vencsys_core1: clock-controller@1b000000 { · line 1134
Quoted 6 lines
arch/arm64/boot/dts/mediatek/mt8195.dtsi +3
-0@@ -1106,4 +1129,92 @@ vencsys_core1: clock-controller@1b000000 { #clock-cells = <1>; }; }; + + thermal_zones: thermal-zones { + cpu-big1-thermal {
Does this pass dtbs_check?
Best regards,
Krzysztof
PATCH 7/7 thermal: mediatek: Add thermal zone settings for mt8195
In reply to [email protected]From: Michael Kao <[email protected]>
Add thermal zone settings for mt8195
--- drivers/thermal/mediatek/lvts_thermal.h | 1 + drivers/thermal/mediatek/lvts_v4.c | 223 ++++++++++++++++++++++++ 2 files changed, 224 insertions(+)
drivers/thermal/mediatek/lvts_thermal.h +1 -0
@@ -16,6 +16,7 @@#define FEATURE_DEVICE_AUTO_RCK BIT(0)#define NUM_EFUSE_ADDR 22#define NUM_EFUSE_BLOCK_MT8192 1 +#define NUM_EFUSE_BLOCK_MT8195 2#define DEFAULT_GOLDEN_TEMP 50#define DEFAULT_CUONT_R 35000#define DEFAULT_CUONT_RC 2750
drivers/thermal/mediatek/lvts_v4.c +223 -0
256 lines not on this page · raw message
Signature · 1 line
2.34.1
Quoted 10 lines · On Thu, Aug 04, 2022 at 03:09:05PM +0200, [email protected] wrote:
From: Balsam CHIHI <[email protected]>
This series moves thermal files related to MediaTek to the mediatek folder. And introduce the new architecture LVTS (low voltage 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.
Quoted 4 lines
The architecture will be the first to be used on mt8192 and mt8195.
Changelog:
Changes in v8.1 :
Please use whole numbers, no need to make this more confusing, v9 would've been just fine :-).
Thanks,
Nícolas