RZ/G3S: Backport TSU support
Subsystems (6)
cover RZ/G3S: Backport TSU support
From: Claudiu Beznea <[email protected]>
Hi,
Series backports the TSU (Thermal Sensor Unit) support for RZ/G3S.
Thank you,
Claudiu
Claudiu Beznea (7):
clk: renesas: r8a08g045: Check the source of the CPU PLL settings
clk: renesas: r9a08g045: Add clocks, resets and power domain support
for the TSU IP
dt-bindings: thermal: r9a08g045-tsu: Document the TSU unit thermal/drivers/renesas/rzg3s: Add thermal driver for the Renesas
RZ/G3S SoC
arm64: dts: renesas: r9a08g045: Add OPP table
arm64: dts: renesas: r9a08g045: Add TSU node
arm64: defconfig: Enable Renesas RZ/G3S thermal driver
.../thermal/renesas,r9a08g045-tsu.yaml | 93 ++++++ MAINTAINERS | 7 + arch/arm64/boot/dts/renesas/r9a08g045.dtsi | 77 ++++- .../boot/dts/renesas/rzg3s-smarc-som.dtsi | 4 - arch/arm64/configs/defconfig | 1 + drivers/clk/renesas/r9a08g045-cpg.c | 7 +- drivers/clk/renesas/rzg2l-cpg.c | 13 +- drivers/clk/renesas/rzg2l-cpg.h | 10 +- drivers/thermal/Kconfig | 8 + drivers/thermal/Makefile | 1 + drivers/thermal/rzg3s_thermal.c | 292 ++++++++++++++++++ 11 files changed, 502 insertions(+), 11 deletions(-) create mode 100644 Documentation/devicetree/bindings/thermal/renesas,r9a08g045-tsu.yaml create mode 100644 drivers/thermal/rzg3s_thermal.c
Signature · 1 line
2.43.0
PATCH 1/7 clk: renesas: r8a08g045: Check the source of the CPU PLL settings
From: Claudiu Beznea <[email protected]>
commit dc0f16c1b76293ac942a783e960abfd19e95fdf5 upstream.
On the RZ/G3S SoC, the CPU PLL settings can be set and retrieved through the CPG_PLL1_CLK1 and CPG_PLL1_CLK2 registers. However, these settings are applied only when CPG_PLL1_SETTING.SEL_PLL1 is set to 0. Otherwise, the CPU PLL operates at the default frequency of 1.1 GHz. Hence add support to the PLL driver for returning the 1.1 GHz frequency when the CPU PLL is configured with the default frequency.
--- drivers/clk/renesas/r9a08g045-cpg.c | 5 +++-- drivers/clk/renesas/rzg2l-cpg.c | 13 ++++++++++++- drivers/clk/renesas/rzg2l-cpg.h | 10 +++++++--- 3 files changed, 22 insertions(+), 6 deletions(-)
drivers/clk/renesas/r9a08g045-cpg.c +3 -2
@@ -50,7 +50,7 @@#define G3S_SEL_SDHI2 SEL_PLL_PACK(G3S_CPG_SDHI_DSEL, 8, 2)/* PLL 1/4/6 configuration registers macro. */ -#define G3S_PLL146_CONF (clk1, clk2) ((clk1) << 22 | (clk2) << 12) +#define G3S_PLL146_CONF (clk1, clk2, setting) ((clk1) << 22 | (clk2) << 12 | (setting))#define DEF_G3S_MUX (_name, _id, _conf, _parent_names, _mux_flags, _clk_flags) \ DEF_TYPE(_name, _id, CLK_TYPE_MUX, .conf = (_conf), \
@@ -133,7 +133,8 @@ static const struct cpg_core_clk r9a08g045_core_clks[] __initconst = {/* Internal Core Clocks */ DEF_FIXED (".osc_div1000" ,CLK_OSC_DIV1000 ,CLK_EXTAL ,1 ,1000 ), -DEF_G3S_PLL (".pll1" ,CLK_PLL1 ,CLK_EXTAL ,G3S_PLL146_CONF (0x4 ,0x8 )), +DEF_G3S_PLL (".pll1" ,CLK_PLL1 ,CLK_EXTAL ,G3S_PLL146_CONF (0x4 ,0x8 ,0x100 ), +1100000000UL ),DEF_FIXED (".pll2" ,CLK_PLL2 ,CLK_EXTAL ,200 ,3 ),DEF_FIXED (".pll3" ,CLK_PLL3 ,CLK_EXTAL ,200 ,3 ), DEF_FIXED(".pll4", CLK_PLL4, CLK_EXTAL, 100, 3),
drivers/clk/renesas/rzg2l-cpg.c +12 -1
@@ -53,6 +53,7 @@#define RZG3S_DIV_M GENMASK(25, 22)#define RZG3S_DIV_NI GENMASK(21, 13)#define RZG3S_DIV_NF GENMASK(12, 1) +#define RZG3S_SEL_PLL BIT(0)#define CLK_ON_R (reg) (reg)#define CLK_MON_R (reg) (0x180 + (reg))
@@ -62,6 +63,7 @@#define GET_REG_OFFSET (val) ((val >> 20) & 0xfff)#define GET_REG_SAMPLL_CLK1 (val) ((val >> 22) & 0xfff)#define GET_REG_SAMPLL_CLK2 (val) ((val >> 12) & 0xfff) +#define GET_REG_SAMPLL_SETTING (val) ((val) & 0xfff)#define CPG_WEN_BIT BIT(16)
@@ -954,6 +956,7 @@ rzg2l_cpg_sipll5_register(const struct cpg_core_clk *core,struct pll_clk {struct clk_hw hw; +unsigned long default_rate;unsigned int conf;unsigned int type;void __iomem *base;
@@ -991,12 +994,19 @@ static unsigned long rzg3s_cpg_pll_clk_recalc_rate(struct clk_hw *hw, {struct pll_clk *pll_clk =to_pll (hw);struct rzg2l_cpg_priv *priv = pll_clk->priv; -u32 nir, nfr, mr, pr, val; +u32 nir, nfr, mr, pr, val, setting;u64 rate;if (pll_clk->type !=CLK_TYPE_G3S_PLL )return parent_rate; + setting =GET_REG_SAMPLL_SETTING (pll_clk->conf); +if (setting) { + val =readl (priv->base + setting); +if (val &RZG3S_SEL_PLL ) +return pll_clk->default_rate; + } + val =readl (priv->base +GET_REG_SAMPLL_CLK1 (pll_clk->conf)); pr =1 <<FIELD_GET (RZG3S_DIV_P , val);
@@ -1050,6 +1060,7 @@ rzg2l_cpg_pll_clk_register(const struct cpg_core_clk *core, pll_clk->base = base; pll_clk->priv = priv; pll_clk->type = core->type; + pll_clk->default_rate = core->default_rate;return clk_register (NULL , &pll_clk->hw); }
drivers/clk/renesas/rzg2l-cpg.h +7 -3
@@ -92,7 +92,10 @@ struct cpg_core_clk {const struct clk_div_table *dtable;const u32 *mtable;const unsigned long invalid_rate; -const unsigned long max_rate; +union { +const unsigned long max_rate; +const unsigned long default_rate; + };const char *const *parent_names;notifier_fn_t notifier;u32 flag;
@@ -134,8 +137,9 @@ enum clk_types { DEF_TYPE(_name, _id, _type, .parent = _parent)#define DEF_SAMPLL (_name, _id, _parent, _conf) \ DEF_TYPE(_name, _id, CLK_TYPE_SAM_PLL, .parent = _parent, .conf = _conf) -#define DEF_G3S_PLL (_name, _id, _parent, _conf) \ - DEF_TYPE(_name, _id, CLK_TYPE_G3S_PLL, .parent = _parent, .conf = _conf) +#define DEF_G3S_PLL (_name, _id, _parent, _conf, _default_rate) \ + DEF_TYPE(_name, _id, CLK_TYPE_G3S_PLL, .parent = _parent, .conf = _conf, \ + .default_rate = _default_rate)#define DEF_INPUT (_name, _id) \ DEF_TYPE(_name, _id, CLK_TYPE_IN)#define DEF_FIXED (_name, _id, _parent, _mult, _div) \
Signature · 1 line
2.43.0
PATCH 2/7 clk: renesas: r9a08g045: Add clocks, resets and power domain support for the TSU IP
In reply to ClaudiuFrom: Claudiu Beznea <[email protected]>
commit 5599c7c4b4df440aa4a470a5b72669081413981f upstream.
Add clocks, resets and power domains for the TSU IP available on the Renesas RZ/G3S SoC.
[claudiu.beznea: drop the power domain description array as the core code
is not available in v6.1 CIP]
--- drivers/clk/renesas/r9a08g045-cpg.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/clk/renesas/r9a08g045-cpg.c +2 -0
@@ -237,6 +237,7 @@ static const struct rzg2l_mod_clk r9a08g045_mod_clks[] = {DEF_MOD ("gpio_hclk" ,R9A08G045_GPIO_HCLK ,R9A08G045_OSCCLK ,0x598 ,0 ),DEF_MOD ("adc_adclk" ,R9A08G045_ADC_ADCLK ,R9A08G045_CLK_TSU ,0x5a8 ,0 ),DEF_MOD ("adc_pclk" ,R9A08G045_ADC_PCLK ,R9A08G045_CLK_TSU ,0x5a8 ,1 ), +DEF_MOD ("tsu_pclk" ,R9A08G045_TSU_PCLK ,R9A08G045_CLK_TSU ,0x5ac ,0 ), DEF_MOD("vbat_bclk", R9A08G045_VBAT_BCLK, R9A08G045_OSCCLK, 0x614, 0), };
@@ -271,6 +272,7 @@ static const struct rzg2l_reset r9a08g045_resets[] = {DEF_RST (R9A08G045_GPIO_SPARE_RESETN ,0x898 ,2 ),DEF_RST (R9A08G045_ADC_PRESETN ,0x8a8 ,0 ),DEF_RST (R9A08G045_ADC_ADRST_N ,0x8a8 ,1 ), +DEF_RST (R9A08G045_TSU_PRESETN ,0x8ac ,0 ), DEF_RST(R9A08G045_VBAT_BRESETN, 0x914, 0), };
Signature · 1 line
2.43.0
PATCH 3/7 dt-bindings: thermal: r9a08g045-tsu: Document the TSU unit
In reply to ClaudiuFrom: Claudiu Beznea <[email protected]>
commit a3152e5c742ca2557c5cd0e5a9e6ca6b9a92df93 upstream.
The Renesas RZ/G3S SoC includes a Thermal Sensor Unit (TSU) block designed to measure the junction temperature. The temperature is measured using the RZ/G3S ADC, with a dedicated ADC channel directly connected to the TSU. Add documentation for it.
--- .../thermal/renesas,r9a08g045-tsu.yaml | 93 +++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 Documentation/devicetree/bindings/thermal/renesas,r9a08g045-tsu.yaml
Documentation/devicetree/bindings/thermal/renesas,r9a08g045-tsu.yaml new file +93 -0
@@ -0,0 +1,93 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/thermal/renesas,r9a08g045-tsu.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Renesas RZ/G3S Thermal Sensor Unit + +description: + The thermal sensor unit (TSU) measures the temperature(Tj) inside + the LSI. + +maintainers: + - Claudiu Beznea <[email protected]> + +$ref: thermal-sensor.yaml# + +properties: + compatible: + const: renesas,r9a08g045-tsu + + reg: + maxItems: 1 + + clocks: + items: + - description: TSU module clock + + power-domains: + maxItems: 1 + + resets: + items: + - description: TSU module reset + + io-channels: + items: + - description: ADC channel which reports the TSU temperature + + io-channel-names: + items: + - const: tsu + + "#thermal-sensor-cells": + const: 0 + +required: + - compatible + - reg + - clocks + - power-domains + - resets + - io-channels + - io-channel-names + - '#thermal-sensor-cells' + +additionalProperties: false + +examples: + - | + #include <dt-bindings/clock/r9a08g045-cpg.h> + + tsu: thermal@10059000 { + compatible = "renesas,r9a08g045-tsu"; + reg = <0x10059000 0x1000>; + clocks = <&cpg CPG_MOD R9A08G045_TSU_PCLK>; + resets = <&cpg R9A08G045_TSU_PRESETN>; + power-domains = <&cpg>; + #thermal-sensor-cells = <0>; + io-channels = <&adc 8>; + io-channel-names = "tsu"; + }; + + thermal-zones { + cpu-thermal { + polling-delay-passive = <250>; + polling-delay = <1000>; + thermal-sensors = <&tsu>; + + trips { + sensor_crit: sensor-crit { + temperature = <125000>; + hysteresis = <1000>; + type = "critical"; + }; + target: trip-point { + temperature = <100000>; + hysteresis = <1000>; + type = "passive"; + }; + }; + }; + };
Signature · 1 line
2.43.0
PATCH 4/7 thermal/drivers/renesas/rzg3s: Add thermal driver for the Renesas RZ/G3S SoC
In reply to ClaudiuFrom: Claudiu Beznea <[email protected]>
commit dc095b37b09e1abbdb6daf5e69dbd0cd5265087e upstream.
The Renesas RZ/G3S SoC features a Thermal Sensor Unit (TSU) that reports the junction temperature. The temperature is reported through a dedicated ADC channel. Add a driver for the Renesas RZ/G3S TSU.
[claudiu.beznea:
- fixed conflict in MAINTAINERS files as "RENESAS X9250 DIGITAL POTENTIOMETERS DRIVER" is not found in v6.1 CIP
- deleted drivers/thermal/renesas/{Kconfig, Makefile} as the renesas directory is not available in v6.1 CIP and updated instead the drivers/thermal/{Kconfig, Makfile}
- moved drivers/thermal/renesas/rzg3s_thermal.c to drivers/thermal/rzg3s_thermal.c as the renesas directory is not available in v6.1 CIP
- included "thermal_hwmon.h" instead of "../thermal_hwmon.h"
- replaced thermal_zone_device_priv(rz) with tz->devdata as thermal_zone_device_priv is not in v6.1 CIP
- used devm_reset_control_get_exclusive() + reset_control_deassert() + devm_add_action_or_reset() instead of devm_reset_control_get_exclusive_deasserted() as the latter is not available in v6.1 CIP; added rzg3s_thermal_reset_deassert() action function for this
- used thermal_add_hwmon_sysfs() + devm_add_action_or_reset() instead of devm_thermal_add_hwmon_sysfs() as the latter is not available in v6.1 CIP; added rzg3s_thermal_rem_hwmon_sysfs() for this
- added pm_runtime_mark_last_busy() as it is not embedded in pm_runtime_put_autosuspend() on v6.1 CIP]
--- MAINTAINERS | 7 + drivers/thermal/Kconfig | 8 + drivers/thermal/Makefile | 1 + drivers/thermal/rzg3s_thermal.c | 292 ++++++++++++++++++++++++++++++++ 4 files changed, 308 insertions(+) create mode 100644 drivers/thermal/rzg3s_thermal.c
MAINTAINERS +7 -0
@@ -17676,6 +17676,13 @@ S: Maintained F: Documentation/devicetree/bindings/clock/renesas,versaclock7.yaml F: drivers/clk/clk-versaclock7.c +RENESAS RZ/G3S THERMAL SENSOR UNIT DRIVER +M: Claudiu Beznea <[email protected]> +L: [email protected] +S: Maintained +F: Documentation/devicetree/bindings/thermal/renesas,r9a08g045-tsu.yaml +F: drivers/thermal/renesas/rzg3s_thermal.c + RESET CONTROLLER FRAMEWORK M: Philipp Zabel <[email protected]> S: Maintained
drivers/thermal/Kconfig +8 -0
@@ -365,6 +365,14 @@ config RZG2L_THERMAL Enable this to plug the RZ/G2L thermal sensor driver into the Linux thermal framework. +config RZG3S_THERMAL + tristate "Renesas RZ/G3S thermal driver" + depends on ARCH_R9A08G045 || COMPILE_TEST + depends on OF && IIO && RZG2L_ADC + help + Enable this to plug the RZ/G3S thermal sensor driver into the Linux + thermal framework. + config KIRKWOOD_THERMAL tristate "Temperature sensor on Marvell Kirkwood SoCs" depends on MACH_KIRKWOOD || COMPILE_TEST
drivers/thermal/Makefile +1 -0
@@ -38,6 +38,7 @@ obj-$(CONFIG_ROCKCHIP_THERMAL) += rockchip_thermal.o obj-$(CONFIG_RCAR_THERMAL) += rcar_thermal.o obj-$(CONFIG_RCAR_GEN3_THERMAL) += rcar_gen3_thermal.o obj-$(CONFIG_RZG2L_THERMAL) += rzg2l_thermal.o +obj-$(CONFIG_RZG3S_THERMAL) += rzg3s_thermal.o obj-$(CONFIG_KIRKWOOD_THERMAL) += kirkwood_thermal.o obj-y += samsung/ obj-$(CONFIG_DOVE_THERMAL) += dove_thermal.o
drivers/thermal/rzg3s_thermal.c new file +292 -0
292 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH 5/7 arm64: dts: renesas: r9a08g045: Add OPP table
In reply to ClaudiuFrom: Claudiu Beznea <[email protected]>
commit b6f4b126b2471211f35720d8e976b65044e13020 upstream.
Add OPP table for the Renesas RZ/G3S SoC.
--- arch/arm64/boot/dts/renesas/r9a08g045.dtsi | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+)
arch/arm64/boot/dts/renesas/r9a08g045.dtsi +28 -0
@@ -28,6 +28,33 @@ audio_clk2: audio2-clk { clock-frequency = <0>; }; + cluster0_opp: opp-table-0 { + compatible = "operating-points-v2"; + opp-shared; + + opp-137500000 { + opp-hz = /bits/ 64 <137500000>; + opp-microvolt = <940000>; + clock-latency-ns = <300000>; + }; + opp-275000000 { + opp-hz = /bits/ 64 <275000000>; + opp-microvolt = <940000>; + clock-latency-ns = <300000>; + }; + opp-550000000 { + opp-hz = /bits/ 64 <550000000>; + opp-microvolt = <940000>; + clock-latency-ns = <300000>; + }; + opp-1100000000 { + opp-hz = /bits/ 64 <1100000000>; + opp-microvolt = <940000>; + clock-latency-ns = <300000>; + opp-suspend; + }; + }; + cpus { #address-cells = <1>; #size-cells = <0>;
@@ -40,6 +67,7 @@ cpu0: cpu@0 { next-level-cache = <&L3_CA55>; enable-method = "psci"; clocks = <&cpg CPG_CORE R9A08G045_CLK_I>; + operating-points-v2 = <&cluster0_opp>; }; L3_CA55: cache-controller-0 {
Signature · 1 line
2.43.0
PATCH 6/7 arm64: dts: renesas: r9a08g045: Add TSU node
In reply to ClaudiuFrom: Claudiu Beznea <[email protected]>
commit ee9bfab464247edd9a3f0f65e7ed96053e4b1095 upstream.
Add TSU node along with thermal zones and keep it enabled in the SoC DTSI. The temperature reported by the TSU can only be read through channel 8 of the ADC. Therefore, enable the ADC by default.
[claudiu.beznea: fixed conflict around the i3c node as this is not yet in
v6.1 CIP]
--- arch/arm64/boot/dts/renesas/r9a08g045.dtsi | 49 ++++++++++++++++++- .../boot/dts/renesas/rzg3s-smarc-som.dtsi | 4 -- 2 files changed, 48 insertions(+), 5 deletions(-)
arch/arm64/boot/dts/renesas/r9a08g045.dtsi +48 -1
@@ -233,7 +233,6 @@ adc: adc@10058000 { #address-cells = <1>; #size-cells = <0>; #io-channel-cells = <1>; - status = "disabled"; channel@0 { reg = <0>;
@@ -272,6 +271,17 @@ channel@8 { }; }; + tsu: thermal@10059000 { + compatible = "renesas,r9a08g045-tsu"; + reg = <0 0x10059000 0 0x1000>; + clocks = <&cpg CPG_MOD R9A08G045_TSU_PCLK>; + resets = <&cpg R9A08G045_TSU_PRESETN>; + power-domains = <&cpg>; + #thermal-sensor-cells = <0>; + io-channels = <&adc 8>; + io-channel-names = "tsu"; + }; + vbattb: clock-controller@1005c000 { compatible = "renesas,r9a08g045-vbattb"; reg = <0 0x1005c000 0 0x1000>;
@@ -714,6 +724,43 @@ timer { <&gic GIC_PPI 10 IRQ_TYPE_LEVEL_LOW>; }; + thermal-zones { + cpu_thermal: cpu-thermal { + polling-delay-passive = <250>; + polling-delay = <1000>; + thermal-sensors = <&tsu>; + sustainable-power = <423>; + + cooling-maps { + map0 { + trip = <&cpu_alert0>; + cooling-device = <&cpu0 0 2>; + contribution = <1024>; + }; + }; + + trips { + cpu_crit: cpu-critical { + temperature = <110000>; + hysteresis = <1000>; + type = "critical"; + }; + + cpu_alert1: trip-point1 { + temperature = <90000>; + hysteresis = <1000>; + type = "passive"; + }; + + cpu_alert0: trip-point0 { + temperature = <85000>; + hysteresis = <1000>; + type = "passive"; + }; + }; + }; + }; + vbattb_xtal: vbattb-xtal { compatible = "fixed-clock"; #clock-cells = <0>;
arch/arm64/boot/dts/renesas/rzg3s-smarc-som.dtsi +0 -4
@@ -84,10 +84,6 @@ x3_clk: x3-clock { }; }; -&adc { - status = "okay"; -}; - #if SW_CONFIG3 == SW_ON ð0 { pinctrl-0 = <ð0_pins>;
Signature · 1 line
2.43.0
PATCH 7/7 arm64: defconfig: Enable Renesas RZ/G3S thermal driver
In reply to ClaudiuFrom: Claudiu Beznea <[email protected]>
commit 823062d153851a944e61768014d7458d609fa4ca upstream.
Enable the CONFIG_RZG3S_THERMAL flag for the RZ/G3S SoC.
--- arch/arm64/configs/defconfig | 1 + 1 file changed, 1 insertion(+)
arch/arm64/configs/defconfig +1 -0
@@ -609,6 +609,7 @@ CONFIG_ROCKCHIP_THERMAL=m CONFIG_RCAR_THERMAL=y CONFIG_RCAR_GEN3_THERMAL=y CONFIG_RZG2L_THERMAL=y +CONFIG_RZG3S_THERMAL=m CONFIG_ARMADA_THERMAL=y CONFIG_BCM2711_THERMAL=m CONFIG_BCM2835_THERMAL=m
Signature · 1 line
2.43.0
Pavel Machek
AppliedHi!
Quoted 1 line
Series backports the TSU (Thermal Sensor Unit) support for RZ/G3S.
Thank you, applied and pushed out.
Best regards,
Pavel
Signature · 1 line
In cooperation with Nabla.