mirror of https://lore.kernel.org/linux-amlogic/
 help / color / mirror / Atom feed
* [PATCH v2 0/2] Add bus clock for t7-thermal sensor
@ 2026-09-23 14:37 Ronald Claveau via B4 Relay
  2026-09-23 14:37 ` [PATCH v2 1/2] dt-bindings: thermal: amlogic: describe bus clock for t7-thermal Ronald Claveau via B4 Relay
  2026-09-23 14:37 ` [PATCH v2 2/2] thermal/drivers/amlogic: switch to clk_bulk API to support multiple clocks Ronald Claveau via B4 Relay
  0 siblings, 2 replies; 4+ messages in thread
From: Ronald Claveau via B4 Relay @ 2026-09-23 14:37 UTC (permalink / raw)
  To: Guillaume La Roque, Rafael J. Wysocki, Daniel Lezcano, Zhang Rui,
	Lukasz Luba, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Neil Armstrong
  Cc: Conor Dooley, linux-pm, linux-amlogic, devicetree, linux-kernel,
	Ronald Claveau, Krzysztof Kozlowski

The t7 thermal sensor requires a bus clock, gating register access to
the sensor, in addition to the functional clock that is already
described and shared between sensors on other Amlogic SoCs.

This series first extends the devicetree binding to describe this
second clock, making it mandatory only for the t7-thermal compatible
so other SoCs are unaffected, then updates the driver to use the
clk_bulk API instead of a single struct clk, so it can transparently
handle however many clocks a given compatible declares.

`dt_binding_check DT_SCHEMA_FILES=amlogic,thermal.yaml` is ok

  CHKDT   ./Documentation/devicetree/bindings
warning: python package 'yamllint' not installed, skipping
  STYLE   ./Documentation/devicetree/bindings
  DTEX    Documentation/devicetree/bindings/thermal/amlogic,thermal.example.dts
  DTC [C] Documentation/devicetree/bindings/thermal/amlogic,thermal.example.dtb

Signed-off-by: Ronald Claveau <linux-kernel-dev@aliel.fr>
---
Changes in v2:
- PATCH 1: Fix commit message. Thanks to Krzysztof review.
- PATCH 2: Return an error when no clock provided. Thanks to sashiko's review.
- Link to v1: https://lore.kernel.org/r/20260923-fix-t7-thermal-clock-v1-0-7d4c4682f182@aliel.fr

---
Ronald Claveau (2):
      dt-bindings: thermal: amlogic: describe bus clock for t7-thermal
      thermal/drivers/amlogic: switch to clk_bulk API to support multiple clocks

 .../bindings/thermal/amlogic,thermal.yaml          | 29 ++++++++++++++++++++--
 drivers/thermal/amlogic_thermal.c                  | 14 ++++++-----
 2 files changed, 35 insertions(+), 8 deletions(-)
---
base-commit: a8c591ed6b672915e0be57843f943a2a723aff40
change-id: 20260922-fix-t7-thermal-clock-151a0bf4746e

Best regards,
-- 
Ronald Claveau <linux-kernel-dev@aliel.fr>



_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

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

* [PATCH v2 1/2] dt-bindings: thermal: amlogic: describe bus clock for t7-thermal
  2026-09-23 14:37 [PATCH v2 0/2] Add bus clock for t7-thermal sensor Ronald Claveau via B4 Relay
@ 2026-09-23 14:37 ` Ronald Claveau via B4 Relay
  2026-09-23 14:45   ` sashiko-bot
  2026-09-23 14:37 ` [PATCH v2 2/2] thermal/drivers/amlogic: switch to clk_bulk API to support multiple clocks Ronald Claveau via B4 Relay
  1 sibling, 1 reply; 4+ messages in thread
From: Ronald Claveau via B4 Relay @ 2026-09-23 14:37 UTC (permalink / raw)
  To: Guillaume La Roque, Rafael J. Wysocki, Daniel Lezcano, Zhang Rui,
	Lukasz Luba, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Neil Armstrong
  Cc: Conor Dooley, linux-pm, linux-amlogic, devicetree, linux-kernel,
	Ronald Claveau, Krzysztof Kozlowski

From: Ronald Claveau <linux-kernel-dev@aliel.fr>

The t7 thermal sensor needs a bus clock, in addition to the existing
functional clock, to gate register access to the sensor. This bus
clock is specific to each sensor, unlike the functional clock which
is shared between sensors. The current binding only describes a
single unnamed clock and therefore cannot represent this hardware
requirement, so add a second clock entry and clock-names for clarity.
Make the second clock mandatory for the t7-thermal compatible only,
via an additional if/then/else, to avoid breaking other Amlogic SoCs
that still use a single clock. Update the t7 example to match.

Fixes: b1c8ccdbd4e9 ("dt-bindings: thermal: amlogic: Add support for T7")
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
Signed-off-by: Ronald Claveau <linux-kernel-dev@aliel.fr>
---
 .../bindings/thermal/amlogic,thermal.yaml          | 29 ++++++++++++++++++++--
 1 file changed, 27 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/thermal/amlogic,thermal.yaml b/Documentation/devicetree/bindings/thermal/amlogic,thermal.yaml
index 8cfa44dcda58c..e72cb39ac635d 100644
--- a/Documentation/devicetree/bindings/thermal/amlogic,thermal.yaml
+++ b/Documentation/devicetree/bindings/thermal/amlogic,thermal.yaml
@@ -32,7 +32,15 @@ properties:
     maxItems: 1
 
   clocks:
-    maxItems: 1
+    minItems: 1
+    items:
+      - description: Bus clock, gates register access to the sensor.
+      - description: Functional clock of the temperature sensor, shared between sensors.
+
+  clock-names:
+    items:
+      - const: bus
+      - const: core
 
   power-domains:
     maxItems: 1
@@ -72,6 +80,22 @@ allOf:
     else:
       required:
         - amlogic,secure-monitor
+  - if:
+      properties:
+        compatible:
+          contains:
+            const: amlogic,t7-thermal
+    then:
+      properties:
+        clocks:
+          minItems: 2
+      required:
+        - clock-names
+    else:
+      properties:
+        clocks:
+          maxItems: 1
+        clock-names: false
 
 unevaluatedProperties: false
 
@@ -94,7 +118,8 @@ examples:
         compatible = "amlogic,t7-thermal";
         reg = <0x20000 0x50>;
         interrupts = <GIC_SPI 31 IRQ_TYPE_LEVEL_HIGH>;
-        clocks = <&clkc_periphs CLKID_TS>;
+        clocks = <&clkc_periphs CLKID_SYS_TS_A73>, <&clkc_periphs CLKID_TS>;
+        clock-names = "bus", "core";
         #thermal-sensor-cells = <0>;
         amlogic,secure-monitor = <&sm 1>;
     };

-- 
2.49.0



_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

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

* [PATCH v2 2/2] thermal/drivers/amlogic: switch to clk_bulk API to support multiple clocks
  2026-09-23 14:37 [PATCH v2 0/2] Add bus clock for t7-thermal sensor Ronald Claveau via B4 Relay
  2026-09-23 14:37 ` [PATCH v2 1/2] dt-bindings: thermal: amlogic: describe bus clock for t7-thermal Ronald Claveau via B4 Relay
@ 2026-09-23 14:37 ` Ronald Claveau via B4 Relay
  1 sibling, 0 replies; 4+ messages in thread
From: Ronald Claveau via B4 Relay @ 2026-09-23 14:37 UTC (permalink / raw)
  To: Guillaume La Roque, Rafael J. Wysocki, Daniel Lezcano, Zhang Rui,
	Lukasz Luba, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Neil Armstrong
  Cc: Conor Dooley, linux-pm, linux-amlogic, devicetree, linux-kernel,
	Ronald Claveau

From: Ronald Claveau <linux-kernel-dev@aliel.fr>

The t7-thermal variant now exposes two clocks (bus and core) in its
devicetree binding, but the driver only knows how to get and manage
a single struct clk. Using devm_clk_get() would silently ignore the
second clock, so switch to devm_clk_bulk_get_all() and the matching
clk_bulk_prepare_enable()/clk_bulk_disable_unprepare() calls. This
lets the driver transparently handle however many clocks a given
compatible declares, without needing per-variant clock-handling code,
and keeps working for existing SoCs that only have one.

Fixes: 18d65de8157c ("thermal/drivers/amlogic: Add support for secure monitor calibration readout")
Signed-off-by: Ronald Claveau <linux-kernel-dev@aliel.fr>
---
 drivers/thermal/amlogic_thermal.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/thermal/amlogic_thermal.c b/drivers/thermal/amlogic_thermal.c
index a0b530624b60c..60728de6968ac 100644
--- a/drivers/thermal/amlogic_thermal.c
+++ b/drivers/thermal/amlogic_thermal.c
@@ -100,7 +100,8 @@ struct amlogic_thermal {
 	const struct amlogic_thermal_data *data;
 	struct regmap *regmap;
 	struct regmap *sec_ao_map;
-	struct clk *clk;
+	struct clk_bulk_data *clks;
+	int num_clks;
 	struct thermal_zone_device *tzd;
 	u32 trim_info;
 	struct meson_sm_firmware *sm_fw;
@@ -142,7 +143,7 @@ static int amlogic_thermal_enable(struct amlogic_thermal *data)
 {
 	int ret;
 
-	ret = clk_prepare_enable(data->clk);
+	ret = clk_bulk_prepare_enable(data->num_clks, data->clks);
 	if (ret)
 		return ret;
 
@@ -156,7 +157,7 @@ static void amlogic_thermal_disable(struct amlogic_thermal *data)
 {
 	regmap_update_bits(data->regmap, TSENSOR_CFG_REG1,
 			   TSENSOR_CFG_REG1_ENABLE, 0);
-	clk_disable_unprepare(data->clk);
+	clk_bulk_disable_unprepare(data->num_clks, data->clks);
 }
 
 static int amlogic_thermal_get_temp(struct thermal_zone_device *tz, int *temp)
@@ -323,9 +324,10 @@ static int amlogic_thermal_probe(struct platform_device *pdev)
 	if (IS_ERR(pdata->regmap))
 		return PTR_ERR(pdata->regmap);
 
-	pdata->clk = devm_clk_get(dev, NULL);
-	if (IS_ERR(pdata->clk))
-		return dev_err_probe(dev, PTR_ERR(pdata->clk), "failed to get clock\n");
+	ret = devm_clk_bulk_get_all(dev, &pdata->clks);
+	if (ret <= 0)
+		return dev_err_probe(dev, ret ?: -ENOENT, "failed to get clocks\n");
+	pdata->num_clks = ret;
 
 	if (pdata->data->use_sm)
 		ret = amlogic_thermal_probe_sm(pdev, pdata);

-- 
2.49.0



_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

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

* Re: [PATCH v2 1/2] dt-bindings: thermal: amlogic: describe bus clock for t7-thermal
  2026-09-23 14:37 ` [PATCH v2 1/2] dt-bindings: thermal: amlogic: describe bus clock for t7-thermal Ronald Claveau via B4 Relay
@ 2026-09-23 14:45   ` sashiko-bot
  0 siblings, 0 replies; 4+ messages in thread
From: sashiko-bot @ 2026-09-23 14:45 UTC (permalink / raw)
  To: Ronald Claveau; +Cc: robh, conor+dt, linux-amlogic, devicetree, neil.armstrong

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] dt-bindings: ABI break by prepending new clock instead of appending
--

commit e4a0aa553cfc6f50abf6357d559b0af000ba1b3b
Author: Ronald Claveau <linux-kernel-dev@aliel.fr>

dt-bindings: thermal: amlogic: describe bus clock for t7-thermal

This commit updates the amlogic thermal binding to describe a new bus clock
required by the t7 thermal sensor to gate register access. It makes this
second clock mandatory for the t7-thermal compatible while keeping a single
clock for older Amlogic SoCs.

> diff --git a/Documentation/devicetree/bindings/thermal/amlogic,thermal.yaml b/Documentation/devicetree/bindings/thermal/amlogic,thermal.yaml
> --- a/Documentation/devicetree/bindings/thermal/amlogic,thermal.yaml
> +++ b/Documentation/devicetree/bindings/thermal/amlogic,thermal.yaml
> @@ -32,7 +32,15 @@ properties:
>      maxItems: 1
>  
>    clocks:
> -    maxItems: 1
> +    minItems: 1
> +    items:
> +      - description: Bus clock, gates register access to the sensor.
> +      - description: Functional clock of the temperature sensor, shared between sensors.

[Severity: High]
Does prepending the "bus" clock at index 0 break backward compatibility for
older deployed kernels?

Older driver versions use devm_clk_get() which blindly fetches the clock at
index 0:

drivers/thermal/amlogic_thermal.c:amlogic_thermal_probe()
    ...
    pdata->clk = devm_clk_get(dev, NULL);
    if (IS_ERR(pdata->clk))
    ...

If an older kernel is booted with this updated device tree, it will fetch the
"bus" clock instead of the "core" functional clock, which could cause the
thermal sensor to fail. Additionally, doesn't this misdocument the existing
functional clock for older Amlogic SoCs as a "bus" clock?

Even if the driver is later updated to use bulk clock APIs, the device tree
ABI break for existing older kernels remains. Should the new "bus" clock be
appended to the list instead, keeping "core" at index 0 and "bus" at index 1?

> +
> +  clock-names:
> +    items:
> +      - const: bus
> +      - const: core

[Severity: High]
Since this naming array matches the clocks array above, would it also need to
be reversed to "- const: core" then "- const: bus" to ensure the functional
clock remains at index 0?

[ ... ]

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260923-fix-t7-thermal-clock-v2-0-bff7a09eb487@aliel.fr?part=1

_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

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

end of thread, other threads:[~2026-09-23 14:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-23 14:37 [PATCH v2 0/2] Add bus clock for t7-thermal sensor Ronald Claveau via B4 Relay
2026-09-23 14:37 ` [PATCH v2 1/2] dt-bindings: thermal: amlogic: describe bus clock for t7-thermal Ronald Claveau via B4 Relay
2026-09-23 14:45   ` sashiko-bot
2026-09-23 14:37 ` [PATCH v2 2/2] thermal/drivers/amlogic: switch to clk_bulk API to support multiple clocks Ronald Claveau via B4 Relay

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®