mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2 0/3] thermal/drivers/amlogic: add S4 support
@ 2026-11-06 10:19 christian.koever-draxl
  2026-11-06 10:19 ` [PATCH v2 1/3] dt-bindings: thermal: amlogic: add S4 christian.koever-draxl
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: christian.koever-draxl @ 2026-11-06 10:19 UTC (permalink / raw)
  To: glaroque, rafael, daniel.lezcano, rui.zhang, lukasz.luba, robh,
	krzk+dt, conor+dt
  Cc: linux-pm, linux-amlogic, devicetree, linux-kernel,
	Christian Stefan Kövér-Draxl

From: Christian Stefan Kövér-Draxl <ckoever@outlook.de>

The S4 temperature sensors are the G12A design with the calibration read
through the secure monitor, as on T7, so they reuse the T7 data on top of
Ronald Claveau's secure monitor calibration support. Without calibration
the CPU sensor reported about -144 degrees Celsius.

Patch 3 makes the expected first probe deferral (the secure monitor
probes later) quiet.

Changes in v2:
- Compatible renamed from amlogic,s4-cpu-thermal to amlogic,s4-thermal:
  as on T7 the sensor index is the secure monitor phandle argument, so
  one compatible covers the CPU and the DDR sensor.
- The binding takes the bus clock (ts_pll / ts_ddr) besides the
  functional clock, named, like T7; the driver reuses the T7 data.
- Patch 3: Reviewed-by from Neil.
- Link to v1: https://lore.kernel.org/r/20261025192244.209256-1-christian.koever-draxl@student.uibk.ac.at

Tool use (Documentation/process/generated-content.rst):
This work was done with the help of an AI coding assistant, Claude
(Anthropic), used through Claude Code over many sessions. It did a large
part of the hands-on work: it read the vendor kernel and the firmware
interfaces, probed registers on the board, drafted the code and the
changelogs, and ran the builds, checkpatch, dt_binding_check and the
tests on the hardware. I directed the work, reviewed every change and
the final patches, and take responsibility for them. There is no single
prompt to quote; the sessions were of the form "find out why X fails on
this board, fix it, test it on the box".

Tested on an Amediatech X98Q TV box (Amlogic S905W2, S4 family, 2 GiB),
vendor U-Boot and BL31/OP-TEE, Linux 7.3 plus this work.

Christian Stefan Kövér-Draxl (3):
  dt-bindings: thermal: amlogic: add S4
  thermal/drivers/amlogic: add S4 support
  thermal/drivers/amlogic: do not log the secure monitor deferral as an
    error

 .../devicetree/bindings/thermal/amlogic,thermal.yaml  |  5 ++++-
 drivers/thermal/amlogic_thermal.c                     | 11 +++++++----
 2 files changed, 11 insertions(+), 5 deletions(-)


base-commit: 7be4bc52fd9e0e55dc9a2e0232b89427d2c4b614
-- 
2.56.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2 1/3] dt-bindings: thermal: amlogic: add S4
  2026-11-06 10:19 [PATCH v2 0/3] thermal/drivers/amlogic: add S4 support christian.koever-draxl
@ 2026-11-06 10:19 ` christian.koever-draxl
  2026-11-06 17:20   ` Conor Dooley
  2026-11-06 10:19 ` [PATCH v2 2/3] thermal/drivers/amlogic: add S4 support christian.koever-draxl
  2026-11-06 10:19 ` [PATCH v2 3/3] thermal/drivers/amlogic: do not log the secure monitor deferral as an error christian.koever-draxl
  2 siblings, 1 reply; 5+ messages in thread
From: christian.koever-draxl @ 2026-11-06 10:19 UTC (permalink / raw)
  To: glaroque, rafael, daniel.lezcano, rui.zhang, lukasz.luba, robh,
	krzk+dt, conor+dt
  Cc: linux-pm, linux-amlogic, devicetree, linux-kernel,
	Christian Stefan Kövér-Draxl

From: Christian Stefan Kövér-Draxl <ckoever@outlook.de>

The S4 temperature sensors are the G12A design, but like on T7 their
calibration value is only available through the secure monitor: the
ao-secure register used on G12A holds unrelated data on S4. Add a
compatible for them. As on T7 the sensor index is the argument of the
secure monitor phandle, so one compatible serves the CPU and the DDR
sensor. Each sensor has a bus clock gating register access (ts_pll /
ts_ddr in the S4 peripheral clock controller) besides the functional
clock, so it takes both, named.

Signed-off-by: Christian Stefan Kövér-Draxl <ckoever@outlook.de>
---
 .../devicetree/bindings/thermal/amlogic,thermal.yaml         | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/thermal/amlogic,thermal.yaml b/Documentation/devicetree/bindings/thermal/amlogic,thermal.yaml
index e72cb39ac635..66dd572ff44b 100644
--- a/Documentation/devicetree/bindings/thermal/amlogic,thermal.yaml
+++ b/Documentation/devicetree/bindings/thermal/amlogic,thermal.yaml
@@ -23,6 +23,7 @@ properties:
           - const: amlogic,g12a-thermal
       - enum:
           - amlogic,a1-cpu-thermal
+          - amlogic,s4-thermal
           - amlogic,t7-thermal
 
   reg:
@@ -84,7 +85,9 @@ allOf:
       properties:
         compatible:
           contains:
-            const: amlogic,t7-thermal
+            enum:
+              - amlogic,s4-thermal
+              - amlogic,t7-thermal
     then:
       properties:
         clocks:
-- 
2.56.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2 2/3] thermal/drivers/amlogic: add S4 support
  2026-11-06 10:19 [PATCH v2 0/3] thermal/drivers/amlogic: add S4 support christian.koever-draxl
  2026-11-06 10:19 ` [PATCH v2 1/3] dt-bindings: thermal: amlogic: add S4 christian.koever-draxl
@ 2026-11-06 10:19 ` christian.koever-draxl
  2026-11-06 10:19 ` [PATCH v2 3/3] thermal/drivers/amlogic: do not log the secure monitor deferral as an error christian.koever-draxl
  2 siblings, 0 replies; 5+ messages in thread
From: christian.koever-draxl @ 2026-11-06 10:19 UTC (permalink / raw)
  To: glaroque, rafael, daniel.lezcano, rui.zhang, lukasz.luba, robh,
	krzk+dt, conor+dt
  Cc: linux-pm, linux-amlogic, devicetree, linux-kernel,
	Christian Stefan Kövér-Draxl

From: Christian Stefan Kövér-Draxl <ckoever@outlook.de>

The S4 CPU sensor reads its calibration through the secure monitor and
otherwise matches the T7 setup, including the separate bus and
functional clocks, so reuse the T7 data for it. The driver already
enables every clock the device tree lists.

Without the calibration the driver reported about -144 degrees Celsius
on an S905W2 board; with it the readings are plausible and CPU
throttling engages.

Signed-off-by: Christian Stefan Kövér-Draxl <ckoever@outlook.de>
---
 drivers/thermal/amlogic_thermal.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/thermal/amlogic_thermal.c b/drivers/thermal/amlogic_thermal.c
index 60728de6968a..4c107b3100c0 100644
--- a/drivers/thermal/amlogic_thermal.c
+++ b/drivers/thermal/amlogic_thermal.c
@@ -292,6 +292,10 @@ static const struct of_device_id of_amlogic_thermal_match[] = {
 		.compatible = "amlogic,a1-cpu-thermal",
 		.data = &amlogic_thermal_a1_cpu_param,
 	},
+	{
+		.compatible = "amlogic,s4-thermal",
+		.data = &amlogic_thermal_t7_param,
+	},
 	{
 		.compatible = "amlogic,t7-thermal",
 		.data = &amlogic_thermal_t7_param,
-- 
2.56.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2 3/3] thermal/drivers/amlogic: do not log the secure monitor deferral as an error
  2026-11-06 10:19 [PATCH v2 0/3] thermal/drivers/amlogic: add S4 support christian.koever-draxl
  2026-11-06 10:19 ` [PATCH v2 1/3] dt-bindings: thermal: amlogic: add S4 christian.koever-draxl
  2026-11-06 10:19 ` [PATCH v2 2/3] thermal/drivers/amlogic: add S4 support christian.koever-draxl
@ 2026-11-06 10:19 ` christian.koever-draxl
  2 siblings, 0 replies; 5+ messages in thread
From: christian.koever-draxl @ 2026-11-06 10:19 UTC (permalink / raw)
  To: glaroque, rafael, daniel.lezcano, rui.zhang, lukasz.luba, robh,
	krzk+dt, conor+dt
  Cc: linux-pm, linux-amlogic, devicetree, linux-kernel,
	Christian Stefan Kövér-Draxl, Neil Armstrong

From: Christian Stefan Kövér-Draxl <ckoever@outlook.de>

The thermal sensor usually probes before the secure monitor, so the
first attempt always defers and logs "Failed to get secure monitor
firmware" as an error on every boot, although the second attempt
succeeds. Use dev_err_probe(), which records the reason for the
deferral instead of logging it.

Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
Signed-off-by: Christian Stefan Kövér-Draxl <ckoever@outlook.de>
---
 drivers/thermal/amlogic_thermal.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/thermal/amlogic_thermal.c b/drivers/thermal/amlogic_thermal.c
index 4c107b3100c0..bbf910ba8513 100644
--- a/drivers/thermal/amlogic_thermal.c
+++ b/drivers/thermal/amlogic_thermal.c
@@ -196,10 +196,9 @@ static int amlogic_thermal_probe_sm(struct platform_device *pdev,
 
 	pdata->sm_fw = meson_sm_get(ph_args.np);
 	of_node_put(ph_args.np);
-	if (!pdata->sm_fw) {
-		dev_err(dev, "Failed to get secure monitor firmware\n");
-		return -EPROBE_DEFER;
-	}
+	if (!pdata->sm_fw)
+		return dev_err_probe(dev, -EPROBE_DEFER,
+				     "Failed to get secure monitor firmware\n");
 
 	pdata->tsensor_id = ph_args.args[0];
 
-- 
2.56.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 1/3] dt-bindings: thermal: amlogic: add S4
  2026-11-06 10:19 ` [PATCH v2 1/3] dt-bindings: thermal: amlogic: add S4 christian.koever-draxl
@ 2026-11-06 17:20   ` Conor Dooley
  0 siblings, 0 replies; 5+ messages in thread
From: Conor Dooley @ 2026-11-06 17:20 UTC (permalink / raw)
  To: christian.koever-draxl
  Cc: glaroque, rafael, daniel.lezcano, rui.zhang, lukasz.luba, robh,
	krzk+dt, conor+dt, linux-pm, linux-amlogic, devicetree,
	linux-kernel, Christian Stefan Kövér-Draxl

[-- Attachment #1: Type: text/plain, Size: 1839 bytes --]

On Fri, Nov 06, 2026 at 11:19:11AM +0100, christian.koever-draxl@student.uibk.ac.at wrote:
> From: Christian Stefan Kövér-Draxl <ckoever@outlook.de>
> 
> The S4 temperature sensors are the G12A design, but like on T7 their
> calibration value is only available through the secure monitor: the
> ao-secure register used on G12A holds unrelated data on S4. Add a
> compatible for them. As on T7 the sensor index is the argument of the
> secure monitor phandle, so one compatible serves the CPU and the DDR
> sensor. Each sensor has a bus clock gating register access (ts_pll /
> ts_ddr in the S4 peripheral clock controller) besides the functional
> clock, so it takes both, named.

Why can this not use the t7 as a fallback? Driver suggest it can.

> 
> Signed-off-by: Christian Stefan Kövér-Draxl <ckoever@outlook.de>
> ---
>  .../devicetree/bindings/thermal/amlogic,thermal.yaml         | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/Documentation/devicetree/bindings/thermal/amlogic,thermal.yaml b/Documentation/devicetree/bindings/thermal/amlogic,thermal.yaml
> index e72cb39ac635..66dd572ff44b 100644
> --- a/Documentation/devicetree/bindings/thermal/amlogic,thermal.yaml
> +++ b/Documentation/devicetree/bindings/thermal/amlogic,thermal.yaml
> @@ -23,6 +23,7 @@ properties:
>            - const: amlogic,g12a-thermal
>        - enum:
>            - amlogic,a1-cpu-thermal
> +          - amlogic,s4-thermal
>            - amlogic,t7-thermal
>  
>    reg:
> @@ -84,7 +85,9 @@ allOf:
>        properties:
>          compatible:
>            contains:
> -            const: amlogic,t7-thermal
> +            enum:
> +              - amlogic,s4-thermal
> +              - amlogic,t7-thermal
>      then:
>        properties:
>          clocks:
> -- 
> 2.56.0
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-11-06 17:21 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-06 10:19 [PATCH v2 0/3] thermal/drivers/amlogic: add S4 support christian.koever-draxl
2026-11-06 10:19 ` [PATCH v2 1/3] dt-bindings: thermal: amlogic: add S4 christian.koever-draxl
2026-11-06 17:20   ` Conor Dooley
2026-11-06 10:19 ` [PATCH v2 2/3] thermal/drivers/amlogic: add S4 support christian.koever-draxl
2026-11-06 10:19 ` [PATCH v2 3/3] thermal/drivers/amlogic: do not log the secure monitor deferral as an error christian.koever-draxl

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®