* [PATCH v3 1/3] dt-bindings: iio: adc: Add syscon property for multi-SCU SoCs
2026-10-05 10:22 [PATCH v3 0/3] iio: adc: aspeed: Fix SCU lookup for multi-SCU AST2700 Billy Tsai
@ 2026-10-05 10:22 ` Billy Tsai
2026-10-05 10:22 ` [PATCH v3 2/3] iio: adc: aspeed: Use syscon phandle for trimming data when available Billy Tsai
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: Billy Tsai @ 2026-10-05 10:22 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, Krzysztof Kozlowski
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.
Assisted-by: LLM
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
Signed-off-by: Billy Tsai <billy_tsai@aspeedtech.com>
---
.../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] 6+ messages in thread* [PATCH v3 2/3] iio: adc: aspeed: Use syscon phandle for trimming data when available
2026-10-05 10:22 [PATCH v3 0/3] iio: adc: aspeed: Fix SCU lookup for multi-SCU AST2700 Billy Tsai
2026-10-05 10:22 ` [PATCH v3 1/3] dt-bindings: iio: adc: Add syscon property for multi-SCU SoCs Billy Tsai
@ 2026-10-05 10:22 ` Billy Tsai
2026-10-05 10:22 ` [PATCH v3 3/3] arm64: dts: aspeed: Add syscon phandle to AST2700 ADC nodes Billy Tsai
2026-10-18 22:56 ` [PATCH v3 0/3] iio: adc: aspeed: Fix SCU lookup for multi-SCU AST2700 Jonathan Cameron
3 siblings, 0 replies; 6+ messages in thread
From: Billy Tsai @ 2026-10-05 10:22 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")
Assisted-by: LLM
Signed-off-by: Billy Tsai <billy_tsai@aspeedtech.com>
---
drivers/iio/adc/aspeed_adc.c | 25 ++++++++++++++++++-------
1 file changed, 18 insertions(+), 7 deletions(-)
diff --git a/drivers/iio/adc/aspeed_adc.c b/drivers/iio/adc/aspeed_adc.c
index 6169ce28261e..a31ba7b0efc1 100644
--- a/drivers/iio/adc/aspeed_adc.c
+++ b/drivers/iio/adc/aspeed_adc.c
@@ -201,18 +201,29 @@ static const struct iio_chan_spec aspeed_adc_iio_bat_channels[] = {
static int aspeed_adc_set_trim_data(struct iio_dev *indio_dev)
{
- struct device_node *syscon;
+ struct device_node *np, *syscon;
struct regmap *scu;
u32 scu_otp, trimming_val;
struct aspeed_adc_data *data = iio_priv(indio_dev);
+ const char *propname = "aspeed,trim-syscon";
- syscon = of_find_node_by_name(NULL, "syscon");
- if (syscon == NULL) {
- dev_warn(data->dev, "Couldn't find syscon node\n");
- return -EOPNOTSUPP;
+ np = dev_of_node(data->dev);
+ if (of_property_present(np, propname)) {
+ scu = syscon_regmap_lookup_by_phandle(np, propname);
+ } else {
+ /*
+ * 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) {
+ 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 v3 3/3] arm64: dts: aspeed: Add syscon phandle to AST2700 ADC nodes
2026-10-05 10:22 [PATCH v3 0/3] iio: adc: aspeed: Fix SCU lookup for multi-SCU AST2700 Billy Tsai
2026-10-05 10:22 ` [PATCH v3 1/3] dt-bindings: iio: adc: Add syscon property for multi-SCU SoCs Billy Tsai
2026-10-05 10:22 ` [PATCH v3 2/3] iio: adc: aspeed: Use syscon phandle for trimming data when available Billy Tsai
@ 2026-10-05 10:22 ` Billy Tsai
2026-10-18 22:56 ` [PATCH v3 0/3] iio: adc: aspeed: Fix SCU lookup for multi-SCU AST2700 Jonathan Cameron
3 siblings, 0 replies; 6+ messages in thread
From: Billy Tsai @ 2026-10-05 10:22 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.
Assisted-by: LLM
Signed-off-by: Billy Tsai <billy_tsai@aspeedtech.com>
---
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] 6+ messages in thread* Re: [PATCH v3 0/3] iio: adc: aspeed: Fix SCU lookup for multi-SCU AST2700
2026-10-05 10:22 [PATCH v3 0/3] iio: adc: aspeed: Fix SCU lookup for multi-SCU AST2700 Billy Tsai
` (2 preceding siblings ...)
2026-10-05 10:22 ` [PATCH v3 3/3] arm64: dts: aspeed: Add syscon phandle to AST2700 ADC nodes Billy Tsai
@ 2026-10-18 22:56 ` Jonathan Cameron
2026-10-21 1:51 ` 回覆: " Billy Tsai
3 siblings, 1 reply; 6+ messages in thread
From: Jonathan Cameron @ 2026-10-18 22:56 UTC (permalink / raw)
To: Billy Tsai
Cc: 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,
Krzysztof Kozlowski
On Mon, 5 Oct 2026 18:22:52 +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.
For now I've applied 1 and 2 to the testing branch of iio.git.
Whilst it is a fix, there is little point in rushing it unless
patch 3 also goes and that one isn't tagged as a fix..
If you want me to move it over to the fixes-togreg branch and
get it in asap, then reply to this to say so.
Thanks,
Jonathan
>
> 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: LLM
> Signed-off-by: Billy Tsai <billy_tsai@aspeedtech.com>
> ---
> Changes in v3:
> - Switch the LLM attribution trailer to "Assisted-by: LLM", the format
> required by Documentation/process/coding-assistants.rst, instead of
> naming the specific tool/model
> - Move each patch's Signed-off-by to be the last trailer, after
> Assisted-by
> - In patch 2, use dev_of_node() instead of dereferencing
> data->dev->of_node, and check the new property with
> of_property_present() before calling the non-optional
> syscon_regmap_lookup_by_phandle()
> - Link to v2: https://lore.kernel.org/r/20261001-ast27xx-adc-upstream-v2-0-2f9c15cc0064@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 | 25 ++++++++++++++++------
> 3 files changed, 37 insertions(+), 7 deletions(-)
> ---
> base-commit: a3b3580713f3ac5a32dc2874ee546828977a1d68
> change-id: 20261001-ast27xx-adc-upstream-34b3d9e8e27b
>
> Best regards,
^ permalink raw reply [flat|nested] 6+ messages in thread* 回覆: [PATCH v3 0/3] iio: adc: aspeed: Fix SCU lookup for multi-SCU AST2700
2026-10-18 22:56 ` [PATCH v3 0/3] iio: adc: aspeed: Fix SCU lookup for multi-SCU AST2700 Jonathan Cameron
@ 2026-10-21 1:51 ` Billy Tsai
0 siblings, 0 replies; 6+ messages in thread
From: Billy Tsai @ 2026-10-21 1:51 UTC (permalink / raw)
To: Jonathan Cameron
Cc: 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,
Krzysztof Kozlowski
> > 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.
> For now I've applied 1 and 2 to the testing branch of iio.git.
> Whilst it is a fix, there is little point in rushing it unless
> patch 3 also goes and that one isn't tagged as a fix..
> If you want me to move it over to the fixes-togreg branch and
> get it in asap, then reply to this to say so.
Patches 1 and 2 only add the mechanism; they don't change behaviour on
AST2700 by themselves. The driver falls back to the old global
by-name syscon lookup whenever the new "aspeed,trim-syscon" property
is absent, and patch 3 is what actually sets that property on
AST2700's dts. Without patch 3, 1 and 2 land but AST2700 keeps reading
the wrong SCU exactly as before.
So yes, please move 1 and 2 to fixes-togreg, and I'd like patch 3 to
go with them. I'll resend it on its own with a Fixes tag pointing at
the commit that added these ADC nodes, since it's the piece that
makes the fix actually take effect on hardware.
Thanks
Billy Tsai
^ permalink raw reply [flat|nested] 6+ messages in thread