mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/3] iio: adc: aspeed: Fix SCU lookup for multi-SCU AST2700
@ 2026-10-01  3:28 Billy Tsai
  2026-10-01  3:28 ` [PATCH 1/3] dt-bindings: iio: adc: Add syscon property for multi-SCU SoCs Billy Tsai
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Billy Tsai @ 2026-10-01  3:28 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 "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>
---
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       | 28 ++++++++++++++++++++++
 arch/arm64/boot/dts/aspeed/aspeed-g7-soc1.dtsi     |  2 ++
 drivers/iio/adc/aspeed_adc.c                       | 20 +++++++++++-----
 3 files changed, 44 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] 6+ messages in thread

* [PATCH 1/3] dt-bindings: iio: adc: Add syscon property for multi-SCU SoCs
  2026-10-01  3:28 [PATCH 0/3] iio: adc: aspeed: Fix SCU lookup for multi-SCU AST2700 Billy Tsai
@ 2026-10-01  3:28 ` Billy Tsai
  2026-10-01  5:56   ` Krzysztof Kozlowski
  2026-10-01  3:28 ` [PATCH 2/3] iio: adc: aspeed: Use syscon phandle for trimming data when available Billy Tsai
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 6+ messages in thread
From: Billy Tsai @ 2026-10-01  3:28 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 optional "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
---
 .../bindings/iio/adc/aspeed,ast2600-adc.yaml       | 28 ++++++++++++++++++++++
 1 file changed, 28 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..0d6b10450cfa8 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.
 
+  syscon:
+    $ref: /schemas/types.yaml#/definitions/phandle
+    description:
+      Required on SoCs with more than one SCU instance (e.g. AST2700).
+
 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:
+        - syscon
+
 additionalProperties: false
 
 examples:
@@ -95,4 +112,15 @@ examples:
         #io-channel-cells = <1>;
         aspeed,int-vref-microvolt = <2500000>;
     };
+  - |
+    #include <dt-bindings/clock/aspeed,ast2700-scu.h>
+    #include <dt-bindings/reset/aspeed,ast2700-scu.h>
+    adc0: adc@14c00000 {
+        compatible = "aspeed,ast2700-adc0";
+        reg = <0x14c00000 0x100>;
+        clocks = <&syscon1 SCU1_CLK_AHB>;
+        resets = <&syscon1 SCU1_RESET_ADC>;
+        syscon = <&syscon1>;
+        #io-channel-cells = <1>;
+    };
 ...

-- 
2.34.1


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

* [PATCH 2/3] iio: adc: aspeed: Use syscon phandle for trimming data when available
  2026-10-01  3:28 [PATCH 0/3] iio: adc: aspeed: Fix SCU lookup for multi-SCU AST2700 Billy Tsai
  2026-10-01  3:28 ` [PATCH 1/3] dt-bindings: iio: adc: Add syscon property for multi-SCU SoCs Billy Tsai
@ 2026-10-01  3:28 ` Billy Tsai
  2026-10-01  3:28 ` [PATCH 3/3] arm64: dts: aspeed: Add syscon phandle to AST2700 ADC nodes Billy Tsai
  2026-10-01  7:18 ` [PATCH 0/3] iio: adc: aspeed: Fix SCU lookup for multi-SCU AST2700 Joshua Crofts
  3 siblings, 0 replies; 6+ messages in thread
From: Billy Tsai @ 2026-10-01  3:28 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 "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..d195bc3e155f 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, "syscon");
+	if (!scu) {
+		/*
+		 * No "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] 6+ messages in thread

* [PATCH 3/3] arm64: dts: aspeed: Add syscon phandle to AST2700 ADC nodes
  2026-10-01  3:28 [PATCH 0/3] iio: adc: aspeed: Fix SCU lookup for multi-SCU AST2700 Billy Tsai
  2026-10-01  3:28 ` [PATCH 1/3] dt-bindings: iio: adc: Add syscon property for multi-SCU SoCs Billy Tsai
  2026-10-01  3:28 ` [PATCH 2/3] iio: adc: aspeed: Use syscon phandle for trimming data when available Billy Tsai
@ 2026-10-01  3:28 ` Billy Tsai
  2026-10-01  7:18 ` [PATCH 0/3] iio: adc: aspeed: Fix SCU lookup for multi-SCU AST2700 Joshua Crofts
  3 siblings, 0 replies; 6+ messages in thread
From: Billy Tsai @ 2026-10-01  3:28 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..cd25fa191806 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>;
+		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>;
+		syscon = <&syscon1>;
 		#io-channel-cells = <1>;
 		status = "disabled";
 	};

-- 
2.34.1


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

* Re: [PATCH 1/3] dt-bindings: iio: adc: Add syscon property for multi-SCU SoCs
  2026-10-01  3:28 ` [PATCH 1/3] dt-bindings: iio: adc: Add syscon property for multi-SCU SoCs Billy Tsai
@ 2026-10-01  5:56   ` Krzysztof Kozlowski
  0 siblings, 0 replies; 6+ messages in thread
From: Krzysztof Kozlowski @ 2026-10-01  5:56 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 11:28:44AM +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 optional "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
> ---
>  .../bindings/iio/adc/aspeed,ast2600-adc.yaml       | 28 ++++++++++++++++++++++
>  1 file changed, 28 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..0d6b10450cfa8 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.
>  
> +  syscon:

Missing vendor and descriptive name. Please read writing bindings.

> +    $ref: /schemas/types.yaml#/definitions/phandle
> +    description:
> +      Required on SoCs with more than one SCU instance (e.g. AST2700).

Describe the purpose, not open code schema.

> +
>  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:
> +        - syscon
> +
>  additionalProperties: false
>  
>  examples:
> @@ -95,4 +112,15 @@ examples:
>          #io-channel-cells = <1>;
>          aspeed,int-vref-microvolt = <2500000>;
>      };
> +  - |
> +    #include <dt-bindings/clock/aspeed,ast2700-scu.h>
> +    #include <dt-bindings/reset/aspeed,ast2700-scu.h>

No need for a new exmaple for one new property.

Best regards,
Krzysztof


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

* Re: [PATCH 0/3] iio: adc: aspeed: Fix SCU lookup for multi-SCU AST2700
  2026-10-01  3:28 [PATCH 0/3] iio: adc: aspeed: Fix SCU lookup for multi-SCU AST2700 Billy Tsai
                   ` (2 preceding siblings ...)
  2026-10-01  3:28 ` [PATCH 3/3] arm64: dts: aspeed: Add syscon phandle to AST2700 ADC nodes Billy Tsai
@ 2026-10-01  7:18 ` Joshua Crofts
  3 siblings, 0 replies; 6+ messages in thread
From: Joshua Crofts @ 2026-10-01  7:18 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, 1 Oct 2026 11:28:43 +0800
Billy Tsai <billy_tsai@aspeedtech.com> 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 "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

All Assisted-by tags in your series should be changed to "Assisted-by: LLM"

> Signed-off-by: Billy Tsai <billy_tsai@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       | 28 ++++++++++++++++++++++
>  arch/arm64/boot/dts/aspeed/aspeed-g7-soc1.dtsi     |  2 ++
>  drivers/iio/adc/aspeed_adc.c                       | 20 +++++++++++-----
>  3 files changed, 44 insertions(+), 6 deletions(-)
> ---
> base-commit: a3b3580713f3ac5a32dc2874ee546828977a1d68
> change-id: 20261001-ast27xx-adc-upstream-34b3d9e8e27b
> 
> Best regards,



-- 
Kind regards,
Joshua Crofts

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

end of thread, other threads:[~2026-10-01  7:18 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-01  3:28 [PATCH 0/3] iio: adc: aspeed: Fix SCU lookup for multi-SCU AST2700 Billy Tsai
2026-10-01  3:28 ` [PATCH 1/3] dt-bindings: iio: adc: Add syscon property for multi-SCU SoCs Billy Tsai
2026-10-01  5:56   ` Krzysztof Kozlowski
2026-10-01  3:28 ` [PATCH 2/3] iio: adc: aspeed: Use syscon phandle for trimming data when available Billy Tsai
2026-10-01  3:28 ` [PATCH 3/3] arm64: dts: aspeed: Add syscon phandle to AST2700 ADC nodes Billy Tsai
2026-10-01  7:18 ` [PATCH 0/3] iio: adc: aspeed: Fix SCU lookup for multi-SCU AST2700 Joshua Crofts

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®