From 15450525b386406dec3a4c9c1911323f61bacc2a Mon Sep 17 00:00:00 2001 From: Chukun Pan Date: Wed, 6 Mar 2024 23:10:21 +0800 Subject: [PATCH] sunxi: backport h616 thermal sensor support Backport H616 thermal sensor support from linux-next. Tested on the Orange Pi Zero 3 (H618 SoC). Signed-off-by: Chukun Pan --- ...m-export-register-0-for-THS-on-H616.patch} | 51 ++++++-------- ...-Add-D1-T113s-THS-controller-support.patch | 47 +++++++++++++ ...i-Explain-unknown-H6-register-value.patch} | 28 ++------ ...-Extend-H6-calibration-to-support-4.patch} | 34 +++------- ...sun8i-Add-SRAM-register-access-code.patch} | 52 ++++++-------- ...Add-support-for-H616-THS-controller.patch} | 35 +++------- ...Dont-fail-probe-due-to-zone-registra.patch | 68 +++++++++++++++++++ ...r-h616-Add-thermal-sensor-and-zones.patch} | 29 ++------ 8 files changed, 190 insertions(+), 154 deletions(-) rename target/linux/sunxi/patches-6.1/{110-soc-sunxi-sram-export-register-0-for-THS-on-H616.patch => 009-v6.9-soc-sunxi-sram-export-register-0-for-THS-on-H616.patch} (61%) create mode 100644 target/linux/sunxi/patches-6.1/010-v6.8-thermal-drivers-sun8i-Add-D1-T113s-THS-controller-support.patch rename target/linux/sunxi/patches-6.1/{111-thermal-sun8i-explain-unknown-H6-register-value.patch => 011-v6.9-thermal-drivers-sun8i-Explain-unknown-H6-register-value.patch} (74%) rename target/linux/sunxi/patches-6.1/{112-thermal-sun8i-extend-H6-calibration-to-support-4-sensors.patch => 012-v6.9-thermal-drivers-sun8i-Extend-H6-calibration-to-support-4.patch} (68%) rename target/linux/sunxi/patches-6.1/{113-thermal-sun8i-add-SRAM-register-access-code.patch => 013-v6.9-thermal-drivers-sun8i-Add-SRAM-register-access-code.patch} (68%) rename target/linux/sunxi/patches-6.1/{114-thermal-sun8i-add-support-for-H616-THS-controller.patch => 014-v6.9-thermal-drivers-sun8i-Add-support-for-H616-THS-controller.patch} (55%) create mode 100644 target/linux/sunxi/patches-6.1/015-v6.9-thermal-drivers-sun8i-Dont-fail-probe-due-to-zone-registra.patch rename target/linux/sunxi/patches-6.1/{115-arm64-dts-allwinner-h616-Add-thermal-sensor-and-zones.patch => 016-v6.9-arm64-dts-allwinner-h616-Add-thermal-sensor-and-zones.patch} (73%) diff --git a/target/linux/sunxi/patches-6.1/110-soc-sunxi-sram-export-register-0-for-THS-on-H616.patch b/target/linux/sunxi/patches-6.1/009-v6.9-soc-sunxi-sram-export-register-0-for-THS-on-H616.patch similarity index 61% rename from target/linux/sunxi/patches-6.1/110-soc-sunxi-sram-export-register-0-for-THS-on-H616.patch rename to target/linux/sunxi/patches-6.1/009-v6.9-soc-sunxi-sram-export-register-0-for-THS-on-H616.patch index 5f5ef246f2..3453e2aa53 100644 --- a/target/linux/sunxi/patches-6.1/110-soc-sunxi-sram-export-register-0-for-THS-on-H616.patch +++ b/target/linux/sunxi/patches-6.1/009-v6.9-soc-sunxi-sram-export-register-0-for-THS-on-H616.patch @@ -1,47 +1,39 @@ +From 898d96c5464b69af44f6407c5de81ebc349d574b Mon Sep 17 00:00:00 2001 From: Andre Przywara -To: Vasily Khoruzhick , - Yangtao Li , Chen-Yu Tsai , - Jernej Skrabec , - Samuel Holland -Cc: "Rafael J . Wysocki" , - Daniel Lezcano , - Zhang Rui , - Lukasz Luba , - Rob Herring , - Krzysztof Kozlowski , - Conor Dooley , - Martin Botka , - Maksim Kiselev , - Bob McChesney , - linux-pm@vger.kernel.org, devicetree@vger.kernel.org, - linux-arm-kernel@lists.infradead.org, - linux-sunxi@lists.linux.dev -Subject: [PATCH v4 1/7] soc: sunxi: sram: export register 0 for THS on H616 -Date: Fri, 9 Feb 2024 14:42:15 +0000 [thread overview] -Message-ID: <20240209144221.3602382-2-andre.przywara@arm.com> (raw) -In-Reply-To: <20240209144221.3602382-1-andre.przywara@arm.com> +Date: Mon, 19 Feb 2024 15:36:33 +0000 +Subject: [PATCH] soc: sunxi: sram: export register 0 for THS on H616 The Allwinner H616 SoC contains a mysterious bit at register offset 0x0 in the SRAM control block. If bit 16 is set (the reset value), the temperature readings of the THS are way off, leading to reports about 200C, at normal ambient temperatures. Clearing this bits brings the -reported values down to reasonable ranges. +reported values down to the expected values. The BSP code clears this bit in firmware (U-Boot), and has an explicit comment about this, but offers no real explanation. +Experiments in U-Boot show that register 0x0 has no effect on the SRAM C +visibility: all tested bit settings still allow full read and write +access by the CPU to the whole of SRAM C. Only bit 24 of the register at +offset 0x4 makes all of SRAM C inaccessible by the CPU. So modelling +the THS switch functionality as an SRAM region would not reflect reality. + Since we should not rely on firmware settings, allow other code (the THS driver) to access this register, by exporting it through the already existing regmap. This mimics what we already do for the LDO control and the EMAC register. -Since this bit is in the very same register as the actual SRAM switch, -we need to change the regmap lock to the SRAM lock. Fortunately regmap -has provisions for that, so we just need to hook in there. +To avoid concurrent accesses to the same register at the same time, by +the SRAM switch code and the regmap code, use the same lock to protect +the access. The regmap subsystem allows to use an existing lock, so we +just need to hook in there. Signed-off-by: Andre Przywara +Reviewed-by: Jernej Skrabec +Signed-off-by: Daniel Lezcano +Link: https://lore.kernel.org/r/20240219153639.179814-2-andre.przywara@arm.com --- - drivers/soc/sunxi/sunxi_sram.c | 23 +++++++++++++++++++++++ - 1 file changed, 23 insertions(+) + drivers/soc/sunxi/sunxi_sram.c | 22 ++++++++++++++++++++++ + 1 file changed, 22 insertions(+) --- a/drivers/soc/sunxi/sunxi_sram.c +++ b/drivers/soc/sunxi/sunxi_sram.c @@ -73,11 +65,10 @@ Signed-off-by: Andre Przywara if (reg >= SUNXI_SRAM_EMAC_CLOCK_REG && reg < SUNXI_SRAM_EMAC_CLOCK_REG + variant->num_emac_clocks * 4) return true; -@@ -324,6 +329,21 @@ static bool sunxi_sram_regmap_accessible +@@ -324,6 +329,20 @@ static bool sunxi_sram_regmap_accessible return false; } -+ +static void sunxi_sram_lock(void *_lock) +{ + spinlock_t *lock = _lock; @@ -95,7 +86,7 @@ Signed-off-by: Andre Przywara static struct regmap_config sunxi_sram_regmap_config = { .reg_bits = 32, .val_bits = 32, -@@ -333,6 +353,9 @@ static struct regmap_config sunxi_sram_r +@@ -333,6 +352,9 @@ static struct regmap_config sunxi_sram_r /* other devices have no business accessing other registers */ .readable_reg = sunxi_sram_regmap_accessible_reg, .writeable_reg = sunxi_sram_regmap_accessible_reg, diff --git a/target/linux/sunxi/patches-6.1/010-v6.8-thermal-drivers-sun8i-Add-D1-T113s-THS-controller-support.patch b/target/linux/sunxi/patches-6.1/010-v6.8-thermal-drivers-sun8i-Add-D1-T113s-THS-controller-support.patch new file mode 100644 index 0000000000..8b19989118 --- /dev/null +++ b/target/linux/sunxi/patches-6.1/010-v6.8-thermal-drivers-sun8i-Add-D1-T113s-THS-controller-support.patch @@ -0,0 +1,47 @@ +From ebbf19e36d021f253425344b4d4b987f3b7d9be5 Mon Sep 17 00:00:00 2001 +From: Maxim Kiselev +Date: Mon, 18 Dec 2023 00:06:23 +0300 +Subject: [PATCH] thermal/drivers/sun8i: Add D1/T113s THS controller support + +This patch adds a thermal sensor controller support for the D1/T113s, +which is similar to the one on H6, but with only one sensor and +different scale and offset values. + +Signed-off-by: Maxim Kiselev +Acked-by: Jernej Skrabec +Reviewed-by: Andre Przywara +Signed-off-by: Daniel Lezcano +Link: https://lore.kernel.org/r/20231217210629.131486-3-bigunclemax@gmail.com +--- + drivers/thermal/sun8i_thermal.c | 13 +++++++++++++ + 1 file changed, 13 insertions(+) + +--- a/drivers/thermal/sun8i_thermal.c ++++ b/drivers/thermal/sun8i_thermal.c +@@ -610,6 +610,18 @@ static const struct ths_thermal_chip sun + .calc_temp = sun8i_ths_calc_temp, + }; + ++static const struct ths_thermal_chip sun20i_d1_ths = { ++ .sensor_num = 1, ++ .has_bus_clk_reset = true, ++ .offset = 188552, ++ .scale = 673, ++ .temp_data_base = SUN50I_H6_THS_TEMP_DATA, ++ .calibrate = sun50i_h6_ths_calibrate, ++ .init = sun50i_h6_thermal_init, ++ .irq_ack = sun50i_h6_irq_ack, ++ .calc_temp = sun8i_ths_calc_temp, ++}; ++ + static const struct of_device_id of_ths_match[] = { + { .compatible = "allwinner,sun8i-a83t-ths", .data = &sun8i_a83t_ths }, + { .compatible = "allwinner,sun8i-h3-ths", .data = &sun8i_h3_ths }, +@@ -618,6 +630,7 @@ static const struct of_device_id of_ths_ + { .compatible = "allwinner,sun50i-a100-ths", .data = &sun50i_a100_ths }, + { .compatible = "allwinner,sun50i-h5-ths", .data = &sun50i_h5_ths }, + { .compatible = "allwinner,sun50i-h6-ths", .data = &sun50i_h6_ths }, ++ { .compatible = "allwinner,sun20i-d1-ths", .data = &sun20i_d1_ths }, + { /* sentinel */ }, + }; + MODULE_DEVICE_TABLE(of, of_ths_match); diff --git a/target/linux/sunxi/patches-6.1/111-thermal-sun8i-explain-unknown-H6-register-value.patch b/target/linux/sunxi/patches-6.1/011-v6.9-thermal-drivers-sun8i-Explain-unknown-H6-register-value.patch similarity index 74% rename from target/linux/sunxi/patches-6.1/111-thermal-sun8i-explain-unknown-H6-register-value.patch rename to target/linux/sunxi/patches-6.1/011-v6.9-thermal-drivers-sun8i-Explain-unknown-H6-register-value.patch index 4079e8ca08..b8138a3870 100644 --- a/target/linux/sunxi/patches-6.1/111-thermal-sun8i-explain-unknown-H6-register-value.patch +++ b/target/linux/sunxi/patches-6.1/011-v6.9-thermal-drivers-sun8i-Explain-unknown-H6-register-value.patch @@ -1,25 +1,7 @@ +From 14f118aa50fe7c7c7330f56d007ecacca487cea8 Mon Sep 17 00:00:00 2001 From: Andre Przywara -To: Vasily Khoruzhick , - Yangtao Li , Chen-Yu Tsai , - Jernej Skrabec , - Samuel Holland -Cc: "Rafael J . Wysocki" , - Daniel Lezcano , - Zhang Rui , - Lukasz Luba , - Rob Herring , - Krzysztof Kozlowski , - Conor Dooley , - Martin Botka , - Maksim Kiselev , - Bob McChesney , - linux-pm@vger.kernel.org, devicetree@vger.kernel.org, - linux-arm-kernel@lists.infradead.org, - linux-sunxi@lists.linux.dev -Subject: [PATCH v4 3/7] thermal: sun8i: explain unknown H6 register value -Date: Fri, 9 Feb 2024 14:42:17 +0000 [thread overview] -Message-ID: <20240209144221.3602382-4-andre.przywara@arm.com> (raw) -In-Reply-To: <20240209144221.3602382-1-andre.przywara@arm.com> +Date: Mon, 19 Feb 2024 15:36:35 +0000 +Subject: [PATCH] thermal/drivers/sun8i: Explain unknown H6 register value So far we were ORing in some "unknown" value into the THS control register on the Allwinner H6. This part of the register is not explained @@ -35,6 +17,10 @@ according to its explanation in the H616 manual. No functional change, just a macro rename and adjustment. Signed-off-by: Andre Przywara +Reviewed-by: Jernej Skrabec +Acked-by: Vasily Khoruzhick +Signed-off-by: Daniel Lezcano +Link: https://lore.kernel.org/r/20240219153639.179814-4-andre.przywara@arm.com --- drivers/thermal/sun8i_thermal.c | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/target/linux/sunxi/patches-6.1/112-thermal-sun8i-extend-H6-calibration-to-support-4-sensors.patch b/target/linux/sunxi/patches-6.1/012-v6.9-thermal-drivers-sun8i-Extend-H6-calibration-to-support-4.patch similarity index 68% rename from target/linux/sunxi/patches-6.1/112-thermal-sun8i-extend-H6-calibration-to-support-4-sensors.patch rename to target/linux/sunxi/patches-6.1/012-v6.9-thermal-drivers-sun8i-Extend-H6-calibration-to-support-4.patch index 0a48053711..3d01a507fa 100644 --- a/target/linux/sunxi/patches-6.1/112-thermal-sun8i-extend-H6-calibration-to-support-4-sensors.patch +++ b/target/linux/sunxi/patches-6.1/012-v6.9-thermal-drivers-sun8i-Extend-H6-calibration-to-support-4.patch @@ -1,27 +1,8 @@ -From: Andre Przywara -To: Vasily Khoruzhick , - Yangtao Li , Chen-Yu Tsai , - Jernej Skrabec , - Samuel Holland -Cc: "Rafael J . Wysocki" , - Daniel Lezcano , - Zhang Rui , - Lukasz Luba , - Rob Herring , - Krzysztof Kozlowski , - Conor Dooley , - Martin Botka , - Maksim Kiselev , - Bob McChesney , - linux-pm@vger.kernel.org, devicetree@vger.kernel.org, - linux-arm-kernel@lists.infradead.org, - linux-sunxi@lists.linux.dev -Subject: [PATCH v4 4/7] thermal: sun8i: extend H6 calibration to support 4 sensors -Date: Fri, 9 Feb 2024 14:42:18 +0000 [thread overview] -Message-ID: <20240209144221.3602382-5-andre.przywara@arm.com> (raw) -In-Reply-To: <20240209144221.3602382-1-andre.przywara@arm.com> - +From 6c04a419a4c5fb18edefc44dd676fb95c7f6c55d Mon Sep 17 00:00:00 2001 From: Maksim Kiselev +Date: Mon, 19 Feb 2024 15:36:36 +0000 +Subject: [PATCH] thermal/drivers/sun8i: Extend H6 calibration to support 4 + sensors The H616 SoC resembles the H6 thermal sensor controller, with a few changes like four sensors. @@ -29,10 +10,15 @@ changes like four sensors. Extend sun50i_h6_ths_calibrate() function to support calibration of these sensors. -Signed-off-by: Maksim Kiselev Co-developed-by: Martin Botka +Signed-off-by: Martin Botka +Signed-off-by: Maksim Kiselev Reviewed-by: Andre Przywara Signed-off-by: Andre Przywara +Reviewed-by: Jernej Skrabec +Acked-by: Vasily Khoruzhick +Signed-off-by: Daniel Lezcano +Link: https://lore.kernel.org/r/20240219153639.179814-5-andre.przywara@arm.com --- drivers/thermal/sun8i_thermal.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/target/linux/sunxi/patches-6.1/113-thermal-sun8i-add-SRAM-register-access-code.patch b/target/linux/sunxi/patches-6.1/013-v6.9-thermal-drivers-sun8i-Add-SRAM-register-access-code.patch similarity index 68% rename from target/linux/sunxi/patches-6.1/113-thermal-sun8i-add-SRAM-register-access-code.patch rename to target/linux/sunxi/patches-6.1/013-v6.9-thermal-drivers-sun8i-Add-SRAM-register-access-code.patch index d392d4efaa..6db1e32cfb 100644 --- a/target/linux/sunxi/patches-6.1/113-thermal-sun8i-add-SRAM-register-access-code.patch +++ b/target/linux/sunxi/patches-6.1/013-v6.9-thermal-drivers-sun8i-Add-SRAM-register-access-code.patch @@ -1,25 +1,7 @@ +From f8b54d1120b81ed57bed96cc8e814ba08886d1e5 Mon Sep 17 00:00:00 2001 From: Andre Przywara -To: Vasily Khoruzhick , - Yangtao Li , Chen-Yu Tsai , - Jernej Skrabec , - Samuel Holland -Cc: "Rafael J . Wysocki" , - Daniel Lezcano , - Zhang Rui , - Lukasz Luba , - Rob Herring , - Krzysztof Kozlowski , - Conor Dooley , - Martin Botka , - Maksim Kiselev , - Bob McChesney , - linux-pm@vger.kernel.org, devicetree@vger.kernel.org, - linux-arm-kernel@lists.infradead.org, - linux-sunxi@lists.linux.dev -Subject: [PATCH v4 5/7] thermal: sun8i: add SRAM register access code -Date: Fri, 9 Feb 2024 14:42:19 +0000 [thread overview] -Message-ID: <20240209144221.3602382-6-andre.przywara@arm.com> (raw) -In-Reply-To: <20240209144221.3602382-1-andre.przywara@arm.com> +Date: Mon, 19 Feb 2024 15:36:37 +0000 +Subject: [PATCH] thermal/drivers/sun8i: Add SRAM register access code The Allwinner H616 SoC needs to clear a bit in one register in the SRAM controller, to report reasonable temperature values. On reset, bit 16 in @@ -34,9 +16,12 @@ the SRAM controller device via a DT phandle link, then clear just this single bit. Signed-off-by: Andre Przywara +Acked-by: Vasily Khoruzhick +Signed-off-by: Daniel Lezcano +Link: https://lore.kernel.org/r/20240219153639.179814-6-andre.przywara@arm.com --- - drivers/thermal/sun8i_thermal.c | 50 +++++++++++++++++++++++++++++++++ - 1 file changed, 50 insertions(+) + drivers/thermal/sun8i_thermal.c | 51 +++++++++++++++++++++++++++++++++ + 1 file changed, 51 insertions(+) --- a/drivers/thermal/sun8i_thermal.c +++ b/drivers/thermal/sun8i_thermal.c @@ -56,7 +41,7 @@ Signed-off-by: Andre Przywara int sensor_num; int offset; int scale; -@@ -85,6 +87,7 @@ struct ths_device { +@@ -85,12 +87,16 @@ struct ths_device { const struct ths_thermal_chip *chip; struct device *dev; struct regmap *regmap; @@ -64,7 +49,16 @@ Signed-off-by: Andre Przywara struct reset_control *reset; struct clk *bus_clk; struct clk *mod_clk; -@@ -337,6 +340,34 @@ static void sun8i_ths_reset_control_asse + struct tsensor sensor[MAX_SENSOR_NUM]; + }; + ++/* The H616 needs to have a bit 16 in the SRAM control register cleared. */ ++static const struct reg_field sun8i_ths_sram_reg_field = REG_FIELD(0x0, 16, 16); ++ + /* Temp Unit: millidegree Celsius */ + static int sun8i_ths_calc_temp(struct ths_device *tmdev, + int id, int reg) +@@ -337,6 +343,34 @@ static void sun8i_ths_reset_control_asse reset_control_assert(data); } @@ -99,13 +93,11 @@ Signed-off-by: Andre Przywara static int sun8i_ths_resource_init(struct ths_device *tmdev) { struct device *dev = tmdev->dev; -@@ -381,6 +412,21 @@ static int sun8i_ths_resource_init(struc +@@ -381,6 +415,19 @@ static int sun8i_ths_resource_init(struc if (ret) return ret; + if (tmdev->chip->needs_sram) { -+ const struct reg_field sun8i_sram_reg_field = -+ REG_FIELD(0x0, 16, 16); + struct regmap *regmap; + + regmap = sun8i_ths_get_sram_regmap(dev->of_node); @@ -113,7 +105,7 @@ Signed-off-by: Andre Przywara + return PTR_ERR(regmap); + tmdev->sram_regmap_field = devm_regmap_field_alloc(dev, + regmap, -+ sun8i_sram_reg_field); ++ sun8i_ths_sram_reg_field); + if (IS_ERR(tmdev->sram_regmap_field)) + return PTR_ERR(tmdev->sram_regmap_field); + } @@ -121,7 +113,7 @@ Signed-off-by: Andre Przywara ret = sun8i_ths_calibrate(tmdev); if (ret) return ret; -@@ -427,6 +473,10 @@ static int sun50i_h6_thermal_init(struct +@@ -427,6 +474,10 @@ static int sun50i_h6_thermal_init(struct { int val; diff --git a/target/linux/sunxi/patches-6.1/114-thermal-sun8i-add-support-for-H616-THS-controller.patch b/target/linux/sunxi/patches-6.1/014-v6.9-thermal-drivers-sun8i-Add-support-for-H616-THS-controller.patch similarity index 55% rename from target/linux/sunxi/patches-6.1/114-thermal-sun8i-add-support-for-H616-THS-controller.patch rename to target/linux/sunxi/patches-6.1/014-v6.9-thermal-drivers-sun8i-Add-support-for-H616-THS-controller.patch index 2b508eb1f2..e743d344c6 100644 --- a/target/linux/sunxi/patches-6.1/114-thermal-sun8i-add-support-for-H616-THS-controller.patch +++ b/target/linux/sunxi/patches-6.1/014-v6.9-thermal-drivers-sun8i-Add-support-for-H616-THS-controller.patch @@ -1,27 +1,7 @@ -From: Andre Przywara -To: Vasily Khoruzhick , - Yangtao Li , Chen-Yu Tsai , - Jernej Skrabec , - Samuel Holland -Cc: "Rafael J . Wysocki" , - Daniel Lezcano , - Zhang Rui , - Lukasz Luba , - Rob Herring , - Krzysztof Kozlowski , - Conor Dooley , - Martin Botka , - Maksim Kiselev , - Bob McChesney , - linux-pm@vger.kernel.org, devicetree@vger.kernel.org, - linux-arm-kernel@lists.infradead.org, - linux-sunxi@lists.linux.dev -Subject: [PATCH v4 6/7] thermal: sun8i: add support for H616 THS controller -Date: Fri, 9 Feb 2024 14:42:20 +0000 [thread overview] -Message-ID: <20240209144221.3602382-7-andre.przywara@arm.com> (raw) -In-Reply-To: <20240209144221.3602382-1-andre.przywara@arm.com> - +From e7dbfa19572a1440a2e67ef70f94ff204849a0a8 Mon Sep 17 00:00:00 2001 From: Martin Botka +Date: Mon, 19 Feb 2024 15:36:38 +0000 +Subject: [PATCH] thermal/drivers/sun8i: Add support for H616 THS controller Add support for the thermal sensor found in H616 SoCs, is the same as the H6 thermal sensor controller, but with four sensors. @@ -30,13 +10,16 @@ register cleared, so set exercise the SRAM regmap to take care of that. Signed-off-by: Martin Botka Signed-off-by: Andre Przywara +Acked-by: Vasily Khoruzhick +Signed-off-by: Daniel Lezcano +Link: https://lore.kernel.org/r/20240219153639.179814-7-andre.przywara@arm.com --- drivers/thermal/sun8i_thermal.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) --- a/drivers/thermal/sun8i_thermal.c +++ b/drivers/thermal/sun8i_thermal.c -@@ -675,6 +675,20 @@ static const struct ths_thermal_chip sun +@@ -688,6 +688,20 @@ static const struct ths_thermal_chip sun .calc_temp = sun8i_ths_calc_temp, }; @@ -57,10 +40,10 @@ Signed-off-by: Andre Przywara static const struct of_device_id of_ths_match[] = { { .compatible = "allwinner,sun8i-a83t-ths", .data = &sun8i_a83t_ths }, { .compatible = "allwinner,sun8i-h3-ths", .data = &sun8i_h3_ths }, -@@ -683,6 +697,7 @@ static const struct of_device_id of_ths_ - { .compatible = "allwinner,sun50i-a100-ths", .data = &sun50i_a100_ths }, +@@ -697,6 +711,7 @@ static const struct of_device_id of_ths_ { .compatible = "allwinner,sun50i-h5-ths", .data = &sun50i_h5_ths }, { .compatible = "allwinner,sun50i-h6-ths", .data = &sun50i_h6_ths }, + { .compatible = "allwinner,sun20i-d1-ths", .data = &sun20i_d1_ths }, + { .compatible = "allwinner,sun50i-h616-ths", .data = &sun50i_h616_ths }, { /* sentinel */ }, }; diff --git a/target/linux/sunxi/patches-6.1/015-v6.9-thermal-drivers-sun8i-Dont-fail-probe-due-to-zone-registra.patch b/target/linux/sunxi/patches-6.1/015-v6.9-thermal-drivers-sun8i-Dont-fail-probe-due-to-zone-registra.patch new file mode 100644 index 0000000000..384bf55084 --- /dev/null +++ b/target/linux/sunxi/patches-6.1/015-v6.9-thermal-drivers-sun8i-Dont-fail-probe-due-to-zone-registra.patch @@ -0,0 +1,68 @@ +From 9ac53d5532cc4bb595bbee86ccba2172ccc336c3 Mon Sep 17 00:00:00 2001 +From: Mark Brown +Date: Tue, 23 Jan 2024 23:33:07 +0000 +Subject: [PATCH] thermal/drivers/sun8i: Don't fail probe due to zone + registration failure + +Currently the sun8i thermal driver will fail to probe if any of the +thermal zones it is registering fails to register with the thermal core. +Since we currently do not define any trip points for the GPU thermal +zones on at least A64 or H5 this means that we have no thermal support +on these platforms: + +[ 1.698703] thermal_sys: Failed to find 'trips' node +[ 1.698707] thermal_sys: Failed to find trip points for thermal-sensor id=1 + +even though the main CPU thermal zone on both SoCs is fully configured. +This does not seem ideal, while we may not be able to use all the zones +it seems better to have those zones which are usable be operational. +Instead just carry on registering zones if we get any non-deferral +error, allowing use of those zones which are usable. + +This means that we also need to update the interrupt handler to not +attempt to notify the core for events on zones which we have not +registered, I didn't see an ability to mask individual interrupts and +I would expect that interrupts would still be indicated in the ISR even +if they were masked. + +Reviewed-by: Vasily Khoruzhick +Acked-by: Jernej Skrabec +Signed-off-by: Mark Brown +Signed-off-by: Daniel Lezcano +Link: https://lore.kernel.org/r/20240123-thermal-sun8i-registration-v3-1-3e5771b1bbdd@kernel.org +--- + drivers/thermal/sun8i_thermal.c | 16 ++++++++++++++-- + 1 file changed, 14 insertions(+), 2 deletions(-) + +--- a/drivers/thermal/sun8i_thermal.c ++++ b/drivers/thermal/sun8i_thermal.c +@@ -197,6 +197,9 @@ static irqreturn_t sun8i_irq_thread(int + int i; + + for_each_set_bit(i, &irq_bitmap, tmdev->chip->sensor_num) { ++ /* We allow some zones to not register. */ ++ if (IS_ERR(tmdev->sensor[i].tzd)) ++ continue; + thermal_zone_device_update(tmdev->sensor[i].tzd, + THERMAL_EVENT_UNSPECIFIED); + } +@@ -531,8 +534,17 @@ static int sun8i_ths_register(struct ths + i, + &tmdev->sensor[i], + &ths_ops); +- if (IS_ERR(tmdev->sensor[i].tzd)) +- return PTR_ERR(tmdev->sensor[i].tzd); ++ ++ /* ++ * If an individual zone fails to register for reasons ++ * other than probe deferral (eg, a bad DT) then carry ++ * on, other zones might register successfully. ++ */ ++ if (IS_ERR(tmdev->sensor[i].tzd)) { ++ if (PTR_ERR(tmdev->sensor[i].tzd) == -EPROBE_DEFER) ++ return PTR_ERR(tmdev->sensor[i].tzd); ++ continue; ++ } + + if (devm_thermal_add_hwmon_sysfs(tmdev->sensor[i].tzd)) + dev_warn(tmdev->dev, diff --git a/target/linux/sunxi/patches-6.1/115-arm64-dts-allwinner-h616-Add-thermal-sensor-and-zones.patch b/target/linux/sunxi/patches-6.1/016-v6.9-arm64-dts-allwinner-h616-Add-thermal-sensor-and-zones.patch similarity index 73% rename from target/linux/sunxi/patches-6.1/115-arm64-dts-allwinner-h616-Add-thermal-sensor-and-zones.patch rename to target/linux/sunxi/patches-6.1/016-v6.9-arm64-dts-allwinner-h616-Add-thermal-sensor-and-zones.patch index 60160c65d2..cd6542bf14 100644 --- a/target/linux/sunxi/patches-6.1/115-arm64-dts-allwinner-h616-Add-thermal-sensor-and-zones.patch +++ b/target/linux/sunxi/patches-6.1/016-v6.9-arm64-dts-allwinner-h616-Add-thermal-sensor-and-zones.patch @@ -1,27 +1,7 @@ -From: Andre Przywara -To: Vasily Khoruzhick , - Yangtao Li , Chen-Yu Tsai , - Jernej Skrabec , - Samuel Holland -Cc: "Rafael J . Wysocki" , - Daniel Lezcano , - Zhang Rui , - Lukasz Luba , - Rob Herring , - Krzysztof Kozlowski , - Conor Dooley , - Martin Botka , - Maksim Kiselev , - Bob McChesney , - linux-pm@vger.kernel.org, devicetree@vger.kernel.org, - linux-arm-kernel@lists.infradead.org, - linux-sunxi@lists.linux.dev -Subject: [PATCH v4 7/7] arm64: dts: allwinner: h616: Add thermal sensor and zones -Date: Fri, 9 Feb 2024 14:42:21 +0000 [thread overview] -Message-ID: <20240209144221.3602382-8-andre.przywara@arm.com> (raw) -In-Reply-To: <20240209144221.3602382-1-andre.przywara@arm.com> - +From f4318af40544b8e7ff5a6b667ede60e6cf808262 Mon Sep 17 00:00:00 2001 From: Martin Botka +Date: Mon, 19 Feb 2024 15:36:39 +0000 +Subject: [PATCH] arm64: dts: allwinner: h616: Add thermal sensor and zones There are four thermal sensors: - CPU @@ -33,6 +13,9 @@ Add the thermal sensor configuration and the thermal zones. Signed-off-by: Martin Botka Signed-off-by: Andre Przywara +Reviewed-by: Jernej Skrabec +Link: https://lore.kernel.org/r/20240219153639.179814-8-andre.przywara@arm.com +Signed-off-by: Jernej Skrabec --- .../arm64/boot/dts/allwinner/sun50i-h616.dtsi | 88 +++++++++++++++++++ 1 file changed, 88 insertions(+)