mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2 0/3] iio: adc: aspeed: Fix SCU lookup for multi-SCU AST2700
@ 2026-10-01  9:50 Billy Tsai
  2026-10-01  9:50 ` [PATCH v2 1/3] dt-bindings: iio: adc: Add syscon property for multi-SCU SoCs Billy Tsai
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Billy Tsai @ 2026-10-01  9:50 UTC (permalink / raw)
  To: Jonathan Cameron, David Lechner, Nuno Sá,
	Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Joel Stanley, Andrew Jeffery, Ryan Chen
  Cc: linux-iio, devicetree, linux-arm-kernel, linux-aspeed,
	linux-kernel, Billy Tsai, Jonathan Cameron

The ADC's reference-voltage trimming data lives in a SCU register. The
driver has always located that SCU with a global, name-based
device-tree search, which works as long as a platform only has a
single node named "syscon". AST2700 splits its SCU into two
instances, syscon0 and syscon1, that share that same node name and
differ only by label and unit address, so the lookup always resolves
to syscon0 even when the ADC's trimming data lives in syscon1.

This series adds an explicit "aspeed,trim-syscon" phandle property so multi-SCU
platforms can point the ADC at the right SCU, keeps the existing
global lookup as a fallback for single-SCU platforms and already
deployed device trees, and wires the new property up on AST2700.

Patch summary:
1. dt-bindings: iio: adc: Add syscon property for multi-SCU SoCs
2. iio: adc: aspeed: Use syscon phandle for trimming data when available
3. arm64: dts: aspeed: Add syscon phandle to AST2700 ADC nodes

Assisted-by: Claude:claude-sonnet-5
Signed-off-by: Billy Tsai <billy_tsai@aspeedtech.com>
---
Changes in v2:
- Rename the new property to "aspeed,trim-syscon": a bare "syscon" is
  not a generic property per writing-bindings.rst, so follow its
  vendor,type-syscon convention
- Reword the property's description to state its purpose instead of
  restating the schema's required condition in prose
- Drop the extra AST2700 example added for the one new property
- Link to v1: https://lore.kernel.org/r/20261001-ast27xx-adc-upstream-v1-0-5ace57533418@aspeedtech.com

---
Billy Tsai (3):
      dt-bindings: iio: adc: Add syscon property for multi-SCU SoCs
      iio: adc: aspeed: Use syscon phandle for trimming data when available
      arm64: dts: aspeed: Add syscon phandle to AST2700 ADC nodes

 .../bindings/iio/adc/aspeed,ast2600-adc.yaml         | 17 +++++++++++++++++
 arch/arm64/boot/dts/aspeed/aspeed-g7-soc1.dtsi       |  2 ++
 drivers/iio/adc/aspeed_adc.c                         | 20 ++++++++++++++------
 3 files changed, 33 insertions(+), 6 deletions(-)
---
base-commit: a3b3580713f3ac5a32dc2874ee546828977a1d68
change-id: 20261001-ast27xx-adc-upstream-34b3d9e8e27b

Best regards,
-- 
Billy Tsai <billy_tsai@aspeedtech.com>


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

* [PATCH v2 1/3] dt-bindings: iio: adc: Add syscon property for multi-SCU SoCs
  2026-10-01  9:50 [PATCH v2 0/3] iio: adc: aspeed: Fix SCU lookup for multi-SCU AST2700 Billy Tsai
@ 2026-10-01  9:50 ` Billy Tsai
  2026-10-02  9:03   ` Krzysztof Kozlowski
  2026-10-01  9:50 ` [PATCH v2 2/3] iio: adc: aspeed: Use syscon phandle for trimming data when available Billy Tsai
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 8+ messages in thread
From: Billy Tsai @ 2026-10-01  9:50 UTC (permalink / raw)
  To: Jonathan Cameron, David Lechner, Nuno Sá,
	Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Joel Stanley, Andrew Jeffery, Ryan Chen
  Cc: linux-iio, devicetree, linux-arm-kernel, linux-aspeed,
	linux-kernel, Billy Tsai, Jonathan Cameron

The ADC's reference-voltage trimming data lives in a System Control
Unit (SCU) register. SoCs with a single SCU instance let the driver
locate it without any additional information, but SoCs such as AST2700
that expose more than one SCU node need an explicit phandle to
disambiguate which one holds the trimming data.

Add an "aspeed,trim-syscon" phandle property, and require it for the
AST2700 compatibles since they are the first multi-SCU SoCs supported
by this driver.

Signed-off-by: Billy Tsai <billy_tsai@aspeedtech.com>
Assisted-by: Claude:claude-sonnet-5
---
 .../devicetree/bindings/iio/adc/aspeed,ast2600-adc.yaml | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/Documentation/devicetree/bindings/iio/adc/aspeed,ast2600-adc.yaml b/Documentation/devicetree/bindings/iio/adc/aspeed,ast2600-adc.yaml
index 249101b55cf4e..140d7034e2196 100644
--- a/Documentation/devicetree/bindings/iio/adc/aspeed,ast2600-adc.yaml
+++ b/Documentation/devicetree/bindings/iio/adc/aspeed,ast2600-adc.yaml
@@ -67,6 +67,11 @@ properties:
     description:
       Inform the driver that last channel will be used to sensor battery.
 
+  aspeed,trim-syscon:
+    $ref: /schemas/types.yaml#/definitions/phandle
+    description:
+      Phandle to the SCU holding the ADC's reference-voltage trimming data.
+
 required:
   - compatible
   - reg
@@ -74,6 +79,18 @@ required:
   - resets
   - "#io-channel-cells"
 
+allOf:
+  - if:
+      properties:
+        compatible:
+          contains:
+            enum:
+              - aspeed,ast2700-adc0
+              - aspeed,ast2700-adc1
+    then:
+      required:
+        - aspeed,trim-syscon
+
 additionalProperties: false
 
 examples:

-- 
2.34.1


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

* [PATCH v2 2/3] iio: adc: aspeed: Use syscon phandle for trimming data when available
  2026-10-01  9:50 [PATCH v2 0/3] iio: adc: aspeed: Fix SCU lookup for multi-SCU AST2700 Billy Tsai
  2026-10-01  9:50 ` [PATCH v2 1/3] dt-bindings: iio: adc: Add syscon property for multi-SCU SoCs Billy Tsai
@ 2026-10-01  9:50 ` Billy Tsai
  2026-10-02  8:34   ` Andy Shevchenko
  2026-10-01  9:50 ` [PATCH v2 3/3] arm64: dts: aspeed: Add syscon phandle to AST2700 ADC nodes Billy Tsai
  2026-10-02  9:23 ` [PATCH v2 0/3] iio: adc: aspeed: Fix SCU lookup for multi-SCU AST2700 Andy Shevchenko
  3 siblings, 1 reply; 8+ messages in thread
From: Billy Tsai @ 2026-10-01  9:50 UTC (permalink / raw)
  To: Jonathan Cameron, David Lechner, Nuno Sá,
	Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Joel Stanley, Andrew Jeffery, Ryan Chen
  Cc: linux-iio, devicetree, linux-arm-kernel, linux-aspeed,
	linux-kernel, Billy Tsai, Jonathan Cameron

aspeed_adc_set_trim_data() locates the SCU holding the ADC's
reference-voltage trimming data with of_find_node_by_name(NULL,
"syscon"), a global search that matches the first device-tree node
named "syscon" regardless of which SCU instance it actually is.

On AST2700, which splits its SCU into "syscon0" (soc0) and "syscon1"
(soc1), both nodes share the same node name "syscon" and only differ
by label and unit address, so the lookup always resolves to syscon0
even though the ADC's trimming data lives in syscon1.

Use the new "aspeed,trim-syscon" phandle property when present to look
up the correct regmap directly, falling back to the old global by-name
search when the property is absent so existing device trees keep
working.

Fixes: 9d8b88ffb773 ("iio: adc: aspeed: Add AST2700 ADC support")
Signed-off-by: Billy Tsai <billy_tsai@aspeedtech.com>
Assisted-by: Claude:claude-sonnet-5
---
 drivers/iio/adc/aspeed_adc.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/drivers/iio/adc/aspeed_adc.c b/drivers/iio/adc/aspeed_adc.c
index 6169ce28261e..bc7b576b9d6d 100644
--- a/drivers/iio/adc/aspeed_adc.c
+++ b/drivers/iio/adc/aspeed_adc.c
@@ -206,13 +206,21 @@ static int aspeed_adc_set_trim_data(struct iio_dev *indio_dev)
 	u32 scu_otp, trimming_val;
 	struct aspeed_adc_data *data = iio_priv(indio_dev);
 
-	syscon = of_find_node_by_name(NULL, "syscon");
-	if (syscon == NULL) {
-		dev_warn(data->dev, "Couldn't find syscon node\n");
-		return -EOPNOTSUPP;
+	scu = syscon_regmap_lookup_by_phandle_optional(data->dev->of_node, "aspeed,trim-syscon");
+	if (!scu) {
+		/*
+		 * No "aspeed,trim-syscon" phandle: either a single-SCU SoC, or a DTB
+		 * predating the property. Fall back to the old global
+		 * by-name lookup for backward compatibility.
+		 */
+		syscon = of_find_node_by_name(NULL, "syscon");
+		if (syscon == NULL) {
+			dev_warn(data->dev, "Couldn't find syscon node\n");
+			return -EOPNOTSUPP;
+		}
+		scu = syscon_node_to_regmap(syscon);
+		of_node_put(syscon);
 	}
-	scu = syscon_node_to_regmap(syscon);
-	of_node_put(syscon);
 	if (IS_ERR(scu)) {
 		dev_warn(data->dev, "Failed to get syscon regmap\n");
 		return -EOPNOTSUPP;

-- 
2.34.1


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

* [PATCH v2 3/3] arm64: dts: aspeed: Add syscon phandle to AST2700 ADC nodes
  2026-10-01  9:50 [PATCH v2 0/3] iio: adc: aspeed: Fix SCU lookup for multi-SCU AST2700 Billy Tsai
  2026-10-01  9:50 ` [PATCH v2 1/3] dt-bindings: iio: adc: Add syscon property for multi-SCU SoCs Billy Tsai
  2026-10-01  9:50 ` [PATCH v2 2/3] iio: adc: aspeed: Use syscon phandle for trimming data when available Billy Tsai
@ 2026-10-01  9:50 ` Billy Tsai
  2026-10-02  9:23 ` [PATCH v2 0/3] iio: adc: aspeed: Fix SCU lookup for multi-SCU AST2700 Andy Shevchenko
  3 siblings, 0 replies; 8+ messages in thread
From: Billy Tsai @ 2026-10-01  9:50 UTC (permalink / raw)
  To: Jonathan Cameron, David Lechner, Nuno Sá,
	Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Joel Stanley, Andrew Jeffery, Ryan Chen
  Cc: linux-iio, devicetree, linux-arm-kernel, linux-aspeed,
	linux-kernel, Billy Tsai, Jonathan Cameron

Point the ADC nodes at their own syscon1 so the driver can correctly
locate the reference-voltage trimming data on AST2700, where syscon0
and syscon1 share the same device-tree node name and would otherwise
resolve to the wrong SCU.

Signed-off-by: Billy Tsai <billy_tsai@aspeedtech.com>
Assisted-by: Claude:claude-sonnet-5
---
 arch/arm64/boot/dts/aspeed/aspeed-g7-soc1.dtsi | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm64/boot/dts/aspeed/aspeed-g7-soc1.dtsi b/arch/arm64/boot/dts/aspeed/aspeed-g7-soc1.dtsi
index bc990f79e693..053673cc4b8e 100644
--- a/arch/arm64/boot/dts/aspeed/aspeed-g7-soc1.dtsi
+++ b/arch/arm64/boot/dts/aspeed/aspeed-g7-soc1.dtsi
@@ -246,6 +246,7 @@ adc0: adc@14c00000 {
 		clocks = <&syscon1 SCU1_CLK_AHB>;
 		resets = <&syscon1 SCU1_RESET_ADC>;
 		interrupts-extended = <&intc1 80>;
+		aspeed,trim-syscon = <&syscon1>;
 		#io-channel-cells = <1>;
 		status = "disabled";
 	};
@@ -256,6 +257,7 @@ adc1: adc@14c00100 {
 		clocks = <&syscon1 SCU1_CLK_AHB>;
 		resets = <&syscon1 SCU1_RESET_ADC>;
 		interrupts-extended = <&intc1 80>;
+		aspeed,trim-syscon = <&syscon1>;
 		#io-channel-cells = <1>;
 		status = "disabled";
 	};

-- 
2.34.1


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

* Re: [PATCH v2 2/3] iio: adc: aspeed: Use syscon phandle for trimming data when available
  2026-10-01  9:50 ` [PATCH v2 2/3] iio: adc: aspeed: Use syscon phandle for trimming data when available Billy Tsai
@ 2026-10-02  8:34   ` Andy Shevchenko
  0 siblings, 0 replies; 8+ messages in thread
From: Andy Shevchenko @ 2026-10-02  8:34 UTC (permalink / raw)
  To: Billy Tsai
  Cc: Jonathan Cameron, David Lechner, Nuno Sá,
	Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Joel Stanley, Andrew Jeffery, Ryan Chen, linux-iio, devicetree,
	linux-arm-kernel, linux-aspeed, linux-kernel

On Thu, Oct 01, 2026 at 05:50:37PM +0800, Billy Tsai wrote:
> aspeed_adc_set_trim_data() locates the SCU holding the ADC's
> reference-voltage trimming data with of_find_node_by_name(NULL,
> "syscon"), a global search that matches the first device-tree node
> named "syscon" regardless of which SCU instance it actually is.
> 
> On AST2700, which splits its SCU into "syscon0" (soc0) and "syscon1"
> (soc1), both nodes share the same node name "syscon" and only differ
> by label and unit address, so the lookup always resolves to syscon0
> even though the ADC's trimming data lives in syscon1.
> 
> Use the new "aspeed,trim-syscon" phandle property when present to look
> up the correct regmap directly, falling back to the old global by-name
> search when the property is absent so existing device trees keep
> working.

...

> -	syscon = of_find_node_by_name(NULL, "syscon");
> -	if (syscon == NULL) {
> -		dev_warn(data->dev, "Couldn't find syscon node\n");
> -		return -EOPNOTSUPP;
> +	scu = syscon_regmap_lookup_by_phandle_optional(data->dev->of_node, "aspeed,trim-syscon");

Do not dereference of_node, use dev_of_node(), it will help in the future
if we want to reorganise firmware nodes in the struct device.

> +	if (!scu) {
> +		/*
> +		 * No "aspeed,trim-syscon" phandle: either a single-SCU SoC, or a DTB
> +		 * predating the property. Fall back to the old global
> +		 * by-name lookup for backward compatibility.
> +		 */

So, why not doing

	struct device_node *np;
	const char *propname;
	...
	np = dev_of_node(data->dev);
	propname = "aspeed,trim-syscon";
	if (of_property_present(np, propname)) {
		scu = syscon_regmap_lookup_by_phandle(np, propname);
		...
	}
	...

?

> +		syscon = of_find_node_by_name(NULL, "syscon");
> +		if (syscon == NULL) {
> +			dev_warn(data->dev, "Couldn't find syscon node\n");
> +			return -EOPNOTSUPP;
> +		}
> +		scu = syscon_node_to_regmap(syscon);
> +		of_node_put(syscon);
>  	}
> -	scu = syscon_node_to_regmap(syscon);
> -	of_node_put(syscon);
>  	if (IS_ERR(scu)) {
>  		dev_warn(data->dev, "Failed to get syscon regmap\n");
>  		return -EOPNOTSUPP;

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH v2 1/3] dt-bindings: iio: adc: Add syscon property for multi-SCU SoCs
  2026-10-01  9:50 ` [PATCH v2 1/3] dt-bindings: iio: adc: Add syscon property for multi-SCU SoCs Billy Tsai
@ 2026-10-02  9:03   ` Krzysztof Kozlowski
  2026-10-02  9:15     ` Joshua Crofts
  0 siblings, 1 reply; 8+ messages in thread
From: Krzysztof Kozlowski @ 2026-10-02  9:03 UTC (permalink / raw)
  To: Billy Tsai
  Cc: Jonathan Cameron, David Lechner, Nuno Sá,
	Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Joel Stanley, Andrew Jeffery, Ryan Chen, linux-iio, devicetree,
	linux-arm-kernel, linux-aspeed, linux-kernel

On Thu, Oct 01, 2026 at 05:50:36PM +0800, Billy Tsai wrote:
> The ADC's reference-voltage trimming data lives in a System Control
> Unit (SCU) register. SoCs with a single SCU instance let the driver
> locate it without any additional information, but SoCs such as AST2700
> that expose more than one SCU node need an explicit phandle to
> disambiguate which one holds the trimming data.
> 
> Add an "aspeed,trim-syscon" phandle property, and require it for the
> AST2700 compatibles since they are the first multi-SCU SoCs supported
> by this driver.
> 
> Signed-off-by: Billy Tsai <billy_tsai@aspeedtech.com>
> Assisted-by: Claude:claude-sonnet-5

Your SoB is the last one.

With this fixed:

Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>

Best regards,
Krzysztof


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

* Re: [PATCH v2 1/3] dt-bindings: iio: adc: Add syscon property for multi-SCU SoCs
  2026-10-02  9:03   ` Krzysztof Kozlowski
@ 2026-10-02  9:15     ` Joshua Crofts
  0 siblings, 0 replies; 8+ messages in thread
From: Joshua Crofts @ 2026-10-02  9:15 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: Billy Tsai, Jonathan Cameron, David Lechner, Nuno Sá,
	Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Joel Stanley, Andrew Jeffery, Ryan Chen, linux-iio, devicetree,
	linux-arm-kernel, linux-aspeed, linux-kernel

On Fri, 2 Oct 2026 11:03:33 +0200
Krzysztof Kozlowski <krzk@kernel.org> wrote:

> On Thu, Oct 01, 2026 at 05:50:36PM +0800, Billy Tsai wrote:
> > The ADC's reference-voltage trimming data lives in a System Control
> > Unit (SCU) register. SoCs with a single SCU instance let the driver
> > locate it without any additional information, but SoCs such as AST2700
> > that expose more than one SCU node need an explicit phandle to
> > disambiguate which one holds the trimming data.
> > 
> > Add an "aspeed,trim-syscon" phandle property, and require it for the
> > AST2700 compatibles since they are the first multi-SCU SoCs supported
> > by this driver.
> > 
> > Signed-off-by: Billy Tsai <billy_tsai@aspeedtech.com>
> > Assisted-by: Claude:claude-sonnet-5  
> 
> Your SoB is the last one.
> 

And the Assisted-by should have just "LLM" instead of "Claude:claude-sonnet-5".

-- 
Kind regards,
Joshua Crofts

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

* Re: [PATCH v2 0/3] iio: adc: aspeed: Fix SCU lookup for multi-SCU AST2700
  2026-10-01  9:50 [PATCH v2 0/3] iio: adc: aspeed: Fix SCU lookup for multi-SCU AST2700 Billy Tsai
                   ` (2 preceding siblings ...)
  2026-10-01  9:50 ` [PATCH v2 3/3] arm64: dts: aspeed: Add syscon phandle to AST2700 ADC nodes Billy Tsai
@ 2026-10-02  9:23 ` Andy Shevchenko
  3 siblings, 0 replies; 8+ messages in thread
From: Andy Shevchenko @ 2026-10-02  9:23 UTC (permalink / raw)
  To: Billy Tsai
  Cc: Jonathan Cameron, David Lechner, Nuno Sá,
	Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Joel Stanley, Andrew Jeffery, Ryan Chen, linux-iio, devicetree,
	linux-arm-kernel, linux-aspeed, linux-kernel

On Thu, Oct 01, 2026 at 05:50:35PM +0800, Billy Tsai wrote:
> The ADC's reference-voltage trimming data lives in a SCU register. The
> driver has always located that SCU with a global, name-based
> device-tree search, which works as long as a platform only has a
> single node named "syscon". AST2700 splits its SCU into two
> instances, syscon0 and syscon1, that share that same node name and
> differ only by label and unit address, so the lookup always resolves
> to syscon0 even when the ADC's trimming data lives in syscon1.
> 
> This series adds an explicit "aspeed,trim-syscon" phandle property so multi-SCU
> platforms can point the ADC at the right SCU, keeps the existing
> global lookup as a fallback for single-SCU platforms and already
> deployed device trees, and wires the new property up on AST2700.
> 
> Patch summary:
> 1. dt-bindings: iio: adc: Add syscon property for multi-SCU SoCs
> 2. iio: adc: aspeed: Use syscon phandle for trimming data when available
> 3. arm64: dts: aspeed: Add syscon phandle to AST2700 ADC nodes
> 
> Assisted-by: Claude:claude-sonnet-5

Assisted-by: LLM
(as documented)

-- 
With Best Regards,
Andy Shevchenko



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

end of thread, other threads:[~2026-10-02  9:23 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-01  9:50 [PATCH v2 0/3] iio: adc: aspeed: Fix SCU lookup for multi-SCU AST2700 Billy Tsai
2026-10-01  9:50 ` [PATCH v2 1/3] dt-bindings: iio: adc: Add syscon property for multi-SCU SoCs Billy Tsai
2026-10-02  9:03   ` Krzysztof Kozlowski
2026-10-02  9:15     ` Joshua Crofts
2026-10-01  9:50 ` [PATCH v2 2/3] iio: adc: aspeed: Use syscon phandle for trimming data when available Billy Tsai
2026-10-02  8:34   ` Andy Shevchenko
2026-10-01  9:50 ` [PATCH v2 3/3] arm64: dts: aspeed: Add syscon phandle to AST2700 ADC nodes Billy Tsai
2026-10-02  9:23 ` [PATCH v2 0/3] iio: adc: aspeed: Fix SCU lookup for multi-SCU AST2700 Andy Shevchenko

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®