* [PATCH v2 1/3] dt-bindings: iio: adc: Add GPADC for Allwinner A523
2026-05-13 4:59 [PATCH v2 0/3] Add GPADC support for A523 Michal Piekos
@ 2026-05-13 4:59 ` Michal Piekos
2026-05-13 4:59 ` [PATCH v2 2/3] iio: adc: sun20i-gpadc: add A523 gpadc support Michal Piekos
2026-05-13 4:59 ` [PATCH v2 3/3] arm64: dts: allwinner: a523: add gpadc node Michal Piekos
2 siblings, 0 replies; 6+ messages in thread
From: Michal Piekos @ 2026-05-13 4:59 UTC (permalink / raw)
To: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Chen-Yu Tsai,
Jernej Skrabec, Samuel Holland, Maksim Kiselev
Cc: linux-iio, devicetree, linux-arm-kernel, linux-sunxi,
linux-kernel, Michal Piekos
Add support for the GPADC for the Allwinner A523. It differs from the
D1/T113s/R329/T507 by having two clocks.
Signed-off-by: Michal Piekos <michal.piekos@mmpsystems.pl>
---
.../iio/adc/allwinner,sun20i-d1-gpadc.yaml | 32 +++++++++++++++++++++-
1 file changed, 31 insertions(+), 1 deletion(-)
diff --git a/Documentation/devicetree/bindings/iio/adc/allwinner,sun20i-d1-gpadc.yaml b/Documentation/devicetree/bindings/iio/adc/allwinner,sun20i-d1-gpadc.yaml
index da605a051b94..6467800d30e2 100644
--- a/Documentation/devicetree/bindings/iio/adc/allwinner,sun20i-d1-gpadc.yaml
+++ b/Documentation/devicetree/bindings/iio/adc/allwinner,sun20i-d1-gpadc.yaml
@@ -14,6 +14,7 @@ properties:
oneOf:
- enum:
- allwinner,sun20i-d1-gpadc
+ - allwinner,sun55i-a523-gpadc
- items:
- enum:
- allwinner,sun50i-h616-gpadc
@@ -29,7 +30,12 @@ properties:
const: 0
clocks:
- maxItems: 1
+ minItems: 1
+ maxItems: 2
+
+ clock-names:
+ minItems: 1
+ maxItems: 2
interrupts:
maxItems: 1
@@ -40,6 +46,30 @@ properties:
resets:
maxItems: 1
+allOf:
+ - if:
+ properties:
+ compatible:
+ enum:
+ - allwinner,sun55i-a523-gpadc
+ then:
+ properties:
+ clocks:
+ items:
+ - description: Bus clock
+ - description: Module clock
+ clock-names:
+ items:
+ - const: bus
+ - const: mod
+ required:
+ - clock-names
+ else:
+ properties:
+ clocks:
+ maxItems: 1
+ clock-names: false
+
patternProperties:
"^channel@[0-9a-f]+$":
$ref: adc.yaml
--
2.43.0
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH v2 2/3] iio: adc: sun20i-gpadc: add A523 gpadc support
2026-05-13 4:59 [PATCH v2 0/3] Add GPADC support for A523 Michal Piekos
2026-05-13 4:59 ` [PATCH v2 1/3] dt-bindings: iio: adc: Add GPADC for Allwinner A523 Michal Piekos
@ 2026-05-13 4:59 ` Michal Piekos
2026-05-13 11:44 ` Sanjay Chitroda
2026-05-13 4:59 ` [PATCH v2 3/3] arm64: dts: allwinner: a523: add gpadc node Michal Piekos
2 siblings, 1 reply; 6+ messages in thread
From: Michal Piekos @ 2026-05-13 4:59 UTC (permalink / raw)
To: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Chen-Yu Tsai,
Jernej Skrabec, Samuel Holland, Maksim Kiselev
Cc: linux-iio, devicetree, linux-arm-kernel, linux-sunxi,
linux-kernel, Michal Piekos
A523 differs from existing sun20i-gpadc-iio by having two clocks; bus
clock and module clock.
Change driver to enable all clocks.
Signed-off-by: Michal Piekos <michal.piekos@mmpsystems.pl>
---
drivers/iio/adc/sun20i-gpadc-iio.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/drivers/iio/adc/sun20i-gpadc-iio.c b/drivers/iio/adc/sun20i-gpadc-iio.c
index 861c14da75ad..3f1f07b3a385 100644
--- a/drivers/iio/adc/sun20i-gpadc-iio.c
+++ b/drivers/iio/adc/sun20i-gpadc-iio.c
@@ -180,7 +180,7 @@ static int sun20i_gpadc_probe(struct platform_device *pdev)
struct iio_dev *indio_dev;
struct sun20i_gpadc_iio *info;
struct reset_control *rst;
- struct clk *clk;
+ struct clk_bulk_data *clks;
int irq;
int ret;
@@ -205,9 +205,11 @@ static int sun20i_gpadc_probe(struct platform_device *pdev)
if (IS_ERR(info->regs))
return PTR_ERR(info->regs);
- clk = devm_clk_get_enabled(dev, NULL);
- if (IS_ERR(clk))
- return dev_err_probe(dev, PTR_ERR(clk), "failed to enable bus clock\n");
+ ret = devm_clk_bulk_get_all_enabled(dev, &clks);
+ if (ret <= 0)
+ return dev_err_probe(
+ dev, ret,
+ "failed to enable clocks or no clocks defined\n");
rst = devm_reset_control_get_exclusive(dev, NULL);
if (IS_ERR(rst))
@@ -243,6 +245,7 @@ static int sun20i_gpadc_probe(struct platform_device *pdev)
static const struct of_device_id sun20i_gpadc_of_id[] = {
{ .compatible = "allwinner,sun20i-d1-gpadc" },
+ { .compatible = "allwinner,sun55i-a523-gpadc" },
{ }
};
MODULE_DEVICE_TABLE(of, sun20i_gpadc_of_id);
--
2.43.0
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH v2 2/3] iio: adc: sun20i-gpadc: add A523 gpadc support
2026-05-13 4:59 ` [PATCH v2 2/3] iio: adc: sun20i-gpadc: add A523 gpadc support Michal Piekos
@ 2026-05-13 11:44 ` Sanjay Chitroda
2026-05-13 11:53 ` Andre Przywara
0 siblings, 1 reply; 6+ messages in thread
From: Sanjay Chitroda @ 2026-05-13 11:44 UTC (permalink / raw)
To: Michal Piekos, Jonathan Cameron, David Lechner, Nuno Sá,
Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Chen-Yu Tsai, Jernej Skrabec, Samuel Holland, Maksim Kiselev
Cc: linux-iio, devicetree, linux-arm-kernel, linux-sunxi,
linux-kernel
On 13 May 2026 10:29:43 am IST, Michal Piekos <michal.piekos@mmpsystems.pl> wrote:
>A523 differs from existing sun20i-gpadc-iio by having two clocks; bus
>clock and module clock.
>
>Change driver to enable all clocks.
>
>Signed-off-by: Michal Piekos <michal.piekos@mmpsystems.pl>
>---
> drivers/iio/adc/sun20i-gpadc-iio.c | 11 +++++++----
> 1 file changed, 7 insertions(+), 4 deletions(-)
>
>diff --git a/drivers/iio/adc/sun20i-gpadc-iio.c b/drivers/iio/adc/sun20i-gpadc-iio.c
>index 861c14da75ad..3f1f07b3a385 100644
>--- a/drivers/iio/adc/sun20i-gpadc-iio.c
>+++ b/drivers/iio/adc/sun20i-gpadc-iio.c
>@@ -180,7 +180,7 @@ static int sun20i_gpadc_probe(struct platform_device *pdev)
> struct iio_dev *indio_dev;
> struct sun20i_gpadc_iio *info;
> struct reset_control *rst;
>- struct clk *clk;
>+ struct clk_bulk_data *clks;
> int irq;
> int ret;
>
>@@ -205,9 +205,11 @@ static int sun20i_gpadc_probe(struct platform_device *pdev)
> if (IS_ERR(info->regs))
> return PTR_ERR(info->regs);
>
>- clk = devm_clk_get_enabled(dev, NULL);
>- if (IS_ERR(clk))
>- return dev_err_probe(dev, PTR_ERR(clk), "failed to enable bus clock\n");
>+ ret = devm_clk_bulk_get_all_enabled(dev, &clks);
>+ if (ret <= 0)
Thank you Michal for the change.
Have you validated the changes ?
It looks while success ret would be 0 and it would give return error.
Thanks, Sanjay
>+ return dev_err_probe(
>+ dev, ret,
>+ "failed to enable clocks or no clocks defined\n");
>
> rst = devm_reset_control_get_exclusive(dev, NULL);
> if (IS_ERR(rst))
>@@ -243,6 +245,7 @@ static int sun20i_gpadc_probe(struct platform_device *pdev)
>
> static const struct of_device_id sun20i_gpadc_of_id[] = {
> { .compatible = "allwinner,sun20i-d1-gpadc" },
>+ { .compatible = "allwinner,sun55i-a523-gpadc" },
> { }
> };
> MODULE_DEVICE_TABLE(of, sun20i_gpadc_of_id);
>
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH v2 2/3] iio: adc: sun20i-gpadc: add A523 gpadc support
2026-05-13 11:44 ` Sanjay Chitroda
@ 2026-05-13 11:53 ` Andre Przywara
0 siblings, 0 replies; 6+ messages in thread
From: Andre Przywara @ 2026-05-13 11:53 UTC (permalink / raw)
To: Sanjay Chitroda, Michal Piekos, Jonathan Cameron, David Lechner,
Nuno Sá, Andy Shevchenko, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Chen-Yu Tsai, Jernej Skrabec, Samuel Holland,
Maksim Kiselev
Cc: linux-iio, devicetree, linux-arm-kernel, linux-sunxi,
linux-kernel
Hi Sanjay,
thanks for having a look!
On 5/13/26 13:44, Sanjay Chitroda wrote:
>
>
> On 13 May 2026 10:29:43 am IST, Michal Piekos <michal.piekos@mmpsystems.pl> wrote:
>> A523 differs from existing sun20i-gpadc-iio by having two clocks; bus
>> clock and module clock.
>>
>> Change driver to enable all clocks.
>>
>> Signed-off-by: Michal Piekos <michal.piekos@mmpsystems.pl>
>> ---
>> drivers/iio/adc/sun20i-gpadc-iio.c | 11 +++++++----
>> 1 file changed, 7 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/iio/adc/sun20i-gpadc-iio.c b/drivers/iio/adc/sun20i-gpadc-iio.c
>> index 861c14da75ad..3f1f07b3a385 100644
>> --- a/drivers/iio/adc/sun20i-gpadc-iio.c
>> +++ b/drivers/iio/adc/sun20i-gpadc-iio.c
>> @@ -180,7 +180,7 @@ static int sun20i_gpadc_probe(struct platform_device *pdev)
>> struct iio_dev *indio_dev;
>> struct sun20i_gpadc_iio *info;
>> struct reset_control *rst;
>> - struct clk *clk;
>> + struct clk_bulk_data *clks;
>> int irq;
>> int ret;
>>
>> @@ -205,9 +205,11 @@ static int sun20i_gpadc_probe(struct platform_device *pdev)
>> if (IS_ERR(info->regs))
>> return PTR_ERR(info->regs);
>>
>> - clk = devm_clk_get_enabled(dev, NULL);
>> - if (IS_ERR(clk))
>> - return dev_err_probe(dev, PTR_ERR(clk), "failed to enable bus clock\n");
>> + ret = devm_clk_bulk_get_all_enabled(dev, &clks);
>> + if (ret <= 0)
>
> Thank you Michal for the change.
>
> Have you validated the changes ?
> It looks while success ret would be 0 and it would give return error.
But devm_clk_bulk_get_all_enabled() returns the number of clocks found
and enabled. And since we need at least one, I think this is correct,
and the error message below reflects that.
To me that change looks good:
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Cheers,
Andre
>
> Thanks, Sanjay
>
>
>> + return dev_err_probe(
>> + dev, ret,
>> + "failed to enable clocks or no clocks defined\n");
>>
>> rst = devm_reset_control_get_exclusive(dev, NULL);
>> if (IS_ERR(rst))
>> @@ -243,6 +245,7 @@ static int sun20i_gpadc_probe(struct platform_device *pdev)
>>
>> static const struct of_device_id sun20i_gpadc_of_id[] = {
>> { .compatible = "allwinner,sun20i-d1-gpadc" },
>> + { .compatible = "allwinner,sun55i-a523-gpadc" },
>> { }
>> };
>> MODULE_DEVICE_TABLE(of, sun20i_gpadc_of_id);
>>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2 3/3] arm64: dts: allwinner: a523: add gpadc node
2026-05-13 4:59 [PATCH v2 0/3] Add GPADC support for A523 Michal Piekos
2026-05-13 4:59 ` [PATCH v2 1/3] dt-bindings: iio: adc: Add GPADC for Allwinner A523 Michal Piekos
2026-05-13 4:59 ` [PATCH v2 2/3] iio: adc: sun20i-gpadc: add A523 gpadc support Michal Piekos
@ 2026-05-13 4:59 ` Michal Piekos
2 siblings, 0 replies; 6+ messages in thread
From: Michal Piekos @ 2026-05-13 4:59 UTC (permalink / raw)
To: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Chen-Yu Tsai,
Jernej Skrabec, Samuel Holland, Maksim Kiselev
Cc: linux-iio, devicetree, linux-arm-kernel, linux-sunxi,
linux-kernel, Michal Piekos
Describe GPADC block on Allwinner A523.
Tested on Radxa Cubie A5E:
- 2 connected channels are showing voltages in agreement with
schematics.
BOOT-SEL-ADC ~500mV
BOM-ADC ~1800mV
- 3rd channel exposed on 40pin header is showing correct voltages when
connected to known voltage source.
Signed-off-by: Michal Piekos <michal.piekos@mmpsystems.pl>
---
arch/arm64/boot/dts/allwinner/sun55i-a523.dtsi | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/arch/arm64/boot/dts/allwinner/sun55i-a523.dtsi b/arch/arm64/boot/dts/allwinner/sun55i-a523.dtsi
index 5afa8d92acbf..4e793aeccf89 100644
--- a/arch/arm64/boot/dts/allwinner/sun55i-a523.dtsi
+++ b/arch/arm64/boot/dts/allwinner/sun55i-a523.dtsi
@@ -340,6 +340,17 @@ ledc: led-controller@2008000 {
status = "disabled";
};
+ gpadc: adc@2009000 {
+ compatible = "allwinner,sun55i-a523-gpadc";
+ reg = <0x2009000 0x400>;
+ clocks = <&ccu CLK_BUS_GPADC0>, <&ccu CLK_GPADC0>;
+ clock-names = "bus", "mod";
+ resets = <&ccu RST_BUS_GPADC0>;
+ interrupts = <GIC_SPI 61 IRQ_TYPE_LEVEL_HIGH>;
+ #io-channel-cells = <1>;
+ status = "disabled";
+ };
+
wdt: watchdog@2050000 {
compatible = "allwinner,sun55i-a523-wdt";
reg = <0x2050000 0x20>;
--
2.43.0
^ permalink raw reply related [flat|nested] 6+ messages in thread