@@ -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;
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(-)