Add support for Allwinner GPADC on D1/T113s/R329/T507 SoCs
Subsystems (4)
v8 cover Add support for Allwinner GPADC on D1/T113s/R329/T507 SoCs
This series adds support for general purpose ADC (GPADC) on new Allwinner's SoCs, such as D1, T113s, T507 and R329. The implemented driver provides basic functionality for getting ADC channels data.
Change History:
v8:
- Added patch that changes Kconfig description for previous Allwinner GPADC
- Changed Kconfig description for this GPADC driver
- Fixed 'reg' range for gpadc node in 'sunxi-d1s-t113.dtsi'
v7:
- Fixed typo in DT bindings property
v6:
- Fixed DT bindings regexp for channel properties
- Dropped checking the max number of channels from the drivers code (This is redundant as we raly on DT bindings check)
v5:
- Fixed DT bindings properties for child nodes
v4:
- Fixed DT bindings warnings
- Used GENMASK to clear the irq register
- Minor formatting fixes
v3:
- Added DT bindings dual license, fixed property order and example formatting
- Added explanations comments for timeout and mutex
- Dropped unnecessary regmap and used readl/writel instead
- Added error message about getting channel number
- Renamed labels and variables to make them self-explanatory
v2:
- Added lastch flag to avoid addition work for already selected channel
- Added reset assertion on module remove
- Added dynamic channel allocation and dropped iio_chan_spec arrays
- Changed IIO_CHAN_INFO_SCALE type to FRACTIONAL_LOG2
- Dropped separate compatible strings and configs for T113s and R329
- Fixed includes
- Fixed Kconfig description
- Removed duplicate probe error messages
- Used FIELD_PREP for bit setup
v1:
- Initial version
Maksim Kiselev (4):
iio: adc: Kconfig change description for Allwinner GPADC
iio: adc: Add Allwinner D1/T113s/R329/T507 SoCs GPADC
dt-bindings: iio: adc: Add Allwinner D1/T113s/R329/T507 SoCs GPADC
riscv: dts: allwinner: d1: Add GPADC node
.../iio/adc/allwinner,sun20i-d1-gpadc.yaml | 91 ++++++ .../boot/dts/allwinner/sunxi-d1s-t113.dtsi | 10 + drivers/iio/adc/Kconfig | 12 +- drivers/iio/adc/Makefile | 1 + drivers/iio/adc/sun20i-gpadc-iio.c | 276 ++++++++++++++++++ 5 files changed, 389 insertions(+), 1 deletion(-) create mode 100644 Documentation/devicetree/bindings/iio/adc/allwinner,sun20i-d1-gpadc.yaml create mode 100644 drivers/iio/adc/sun20i-gpadc-iio.c
Signature · 1 line
2.39.2
PATCH v8 1/4 iio: adc: Kconfig change description for Allwinner GPADC
This patch adds SoCs names to Allwinner GPADC description to make it more informative.
--- drivers/iio/adc/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/adc/Kconfig +1 -1
@@ -1105,7 +1105,7 @@ config STMPE_ADC built-in ADC block (stmpe811). config SUN4I_GPADC - tristate "Support for the Allwinner SoCs GPADC" + tristate "Allwinner A10/A13/A31 and similar GPADCs driver" depends on IIO depends on MFD_SUN4I_GPADC || MACH_SUN8I depends on THERMAL || !THERMAL_OF
Signature · 1 line
2.39.2
Jernej Škrabec
maintainerRe: [PATCH v8 1/4] iio: adc: Kconfig change description for Allwinner GPADC
Dne ponedeljek, 19. junij 2023 ob 17:42:24 CEST je Maksim Kiselev napisal(a):
Quoted 2 lines
This patch adds SoCs names to Allwinner GPADC description to make it more informative.
Please reword to remove "This patch".
Quoted 2 lines
Fixes d1caa9905538 ("iio: adc: add support for Allwinner SoCs ADC")
I'm fine with the patch in general, but does this really warrant fixes tag?
Best regards,
Jernej
Quoted 18 lines
Signed-off-by Maksim Kiselev <[email protected]>--- drivers/iio/adc/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/iio/adc/Kconfig +1
-1@@ -1105,7 +1105,7 @@ config STMPE_ADC built-in ADC block (stmpe811). config SUN4I_GPADC - tristate "Support for the Allwinner SoCs GPADC" + tristate "Allwinner A10/A13/A31 and similar GPADCs driver" depends on IIO depends on MFD_SUN4I_GPADC || MACH_SUN8I depends on THERMAL || !THERMAL_OF
Re: [PATCH v8 1/4] iio: adc: Kconfig change description for Allwinner GPADC
Quoted 11 lines · Jernej Škrabec
Dne ponedeljek, 19. junij 2023 ob 17:42:24 CEST je Maksim Kiselev napisal(a):
Quoted 2 lines
This patch adds SoCs names to Allwinner GPADC description to make it more informative.
Please reword to remove "This patch".
Quoted 2 lines
Fixes d1caa9905538 ("iio: adc: add support for Allwinner SoCs ADC")I'm fine with the patch in general, but does this really warrant fixes tag?
No, it's some fake fix. There is no bug here.
Best regards,
Krzysztof
Jonathan Cameron
maintainerRe: [PATCH v8 1/4] iio: adc: Kconfig change description for Allwinner GPADC
Quoted 10 lines · On Wed, 12 Jul 2023 07:37:38 +0200 Krzysztof Kozlowski…
Quoted 9 lines · Jernej Škrabec
Dne ponedeljek, 19. junij 2023 ob 17:42:24 CEST je Maksim Kiselev napisal(a):
Quoted 2 lines
This patch adds SoCs names to Allwinner GPADC description to make it more informative.
Please reword to remove "This patch".
Quoted 2 lines
Fixes d1caa9905538 ("iio: adc: add support for Allwinner SoCs ADC")
Quoted 8 lines
Quoted 2 lines
I'm fine with the patch in general, but does this really warrant fixes tag?
No, it's some fake fix. There is no bug here.
Best regards,
Krzysztof
Dropped the tag.
Thanks for pointing this out.
Jonathan
PATCH v8 2/4 iio: adc: Add Allwinner D1/T113s/R329/T507 SoCs GPADC
In reply to Maksim KiselevThe General Purpose ADC (GPADC) can convert the external signal into a certain proportion of digital value, to realize the measurement of analog signal, which can be applied to power detection and key detection.
Theoretically, this ADC can support up to 16 channels. All SoCs below contain this GPADC IP. The only difference between them is the number of available channels:
T113 - 1 channel
D1 - 2 channels
R329 - 4 channels
T507 - 4 channels
--- drivers/iio/adc/Kconfig | 10 ++ drivers/iio/adc/Makefile | 1 + drivers/iio/adc/sun20i-gpadc-iio.c | 276 +++++++++++++++++++++++++++++ 3 files changed, 287 insertions(+) create mode 100644 drivers/iio/adc/sun20i-gpadc-iio.c
drivers/iio/adc/Kconfig +10 -0
@@ -1123,6 +1123,16 @@ config SUN4I_GPADC To compile this driver as a module, choose M here: the module will be called sun4i-gpadc-iio. +config SUN20I_GPADC + tristate "Allwinner D1/T113s/T507/R329 and similar GPADCs driver" + depends on ARCH_SUNXI || COMPILE_TEST + help + Say yes here to build support for Allwinner (D1, T113, T507 and R329) + SoCs GPADC. This ADC provides up to 16 channels. + + To compile this driver as a module, choose M here: the module will be + called sun20i-gpadc-iio. + config TI_ADC081C tristate "Texas Instruments ADC081C/ADC101C/ADC121C family" depends on I2C
drivers/iio/adc/Makefile +1 -0
@@ -95,6 +95,7 @@ obj-$(CONFIG_RZG2L_ADC) += rzg2l_adc.o obj-$(CONFIG_SC27XX_ADC) += sc27xx_adc.o obj-$(CONFIG_SPEAR_ADC) += spear_adc.o obj-$(CONFIG_SUN4I_GPADC) += sun4i-gpadc-iio.o +obj-$(CONFIG_SUN20I_GPADC) += sun20i-gpadc-iio.o obj-$(CONFIG_STM32_ADC_CORE) += stm32-adc-core.o obj-$(CONFIG_STM32_ADC) += stm32-adc.o obj-$(CONFIG_STM32_DFSDM_CORE) += stm32-dfsdm-core.o
drivers/iio/adc/sun20i-gpadc-iio.c new file +276 -0
276 lines not on this page · raw message
Signature · 1 line
2.39.2
PATCH v8 3/4 dt-bindings: iio: adc: Add Allwinner D1/T113s/R329/T507 SoCs GPADC
In reply to Maksim KiselevAllwinner's D1/T113s/R329/T507 SoCs have a new general purpose ADC. This ADC is the same for all of this SoCs. The only difference is the number of available channels.
--- .../iio/adc/allwinner,sun20i-d1-gpadc.yaml | 91 +++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/adc/allwinner,sun20i-d1-gpadc.yaml
Documentation/devicetree/bindings/iio/adc/allwinner,sun20i-d1-gpadc.yaml new file +91 -0
@@ -0,0 +1,91 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/adc/allwinner,sun20i-d1-gpadc.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Allwinner D1 General Purpose ADC + +maintainers: + - Maksim Kiselev <[email protected]> + +properties: + compatible: + enum: + - allwinner,sun20i-d1-gpadc + + "#io-channel-cells": + const: 1 + + "#address-cells": + const: 1 + + "#size-cells": + const: 0 + + clocks: + maxItems: 1 + + interrupts: + maxItems: 1 + + reg: + maxItems: 1 + + resets: + maxItems: 1 + +patternProperties: + "^channel@[0-9a-f]+$": + $ref: adc.yaml + type: object + description: + Represents the internal channels of the ADC. + + properties: + reg: + items: + minimum: 0 + maximum: 15 + + required: + - reg + + unevaluatedProperties: false + +required: + - "#io-channel-cells" + - clocks + - compatible + - interrupts + - reg + - resets + +additionalProperties: false + +examples: + - | + #include <dt-bindings/clock/sun20i-d1-ccu.h> + #include <dt-bindings/reset/sun20i-d1-ccu.h> + #include <dt-bindings/interrupt-controller/irq.h> + + gpadc: adc@2009000 { + compatible = "allwinner,sun20i-d1-gpadc"; + reg = <0x2009000 0x400>; + clocks = <&ccu CLK_BUS_GPADC>; + resets = <&ccu RST_BUS_GPADC>; + interrupts = <73 IRQ_TYPE_LEVEL_HIGH>; + #io-channel-cells = <1>; + + #address-cells = <1>; + #size-cells = <0>; + + channel@0 { + reg = <0>; + }; + + channel@1 { + reg = <1>; + }; + }; +...
Signature · 1 line
2.39.2
PATCH v8 4/4 riscv: dts: allwinner: d1: Add GPADC node
In reply to Maksim KiselevThis patch adds declaration of the general purpose ADC for D1 and T113s SoCs.
--- arch/riscv/boot/dts/allwinner/sunxi-d1s-t113.dtsi | 10 ++++++++++ 1 file changed, 10 insertions(+)
arch/riscv/boot/dts/allwinner/sunxi-d1s-t113.dtsi +10 -0
@@ -138,6 +138,16 @@ ccu: clock-controller@2001000 { #reset-cells = <1>; }; + gpadc: adc@2009000 { + compatible = "allwinner,sun20i-d1-gpadc"; + reg = <0x2009000 0x400>; + clocks = <&ccu CLK_BUS_GPADC>; + resets = <&ccu RST_BUS_GPADC>; + interrupts = <SOC_PERIPHERAL_IRQ(57) IRQ_TYPE_LEVEL_HIGH>; + status = "disabled"; + #io-channel-cells = <1>; + }; + dmic: dmic@2031000 { compatible = "allwinner,sun20i-d1-dmic", "allwinner,sun50i-h6-dmic";
Signature · 1 line
2.39.2
Re: [PATCH v8 4/4] riscv: dts: allwinner: d1: Add GPADC node
Dne ponedeljek, 19. junij 2023 ob 17:42:27 CEST je Maksim Kiselev napisal(a):
Quoted 4 lines
This patch adds declaration of the general purpose ADC for D1 and T113s SoCs.
Signed-off-by Maksim Kiselev <[email protected]>
Best regards,
Jernej
Quoted 10 lines
--- arch/riscv/boot/dts/allwinner/sunxi-d1s-t113.dtsi | 10 ++++++++++ 1 file changed, 10 insertions(+)(quoted diff) +0
-0
b/arch/riscv/boot/dts/allwinner/sunxi-d1s-t113.dtsiindex922e8e0e2c09..cb353d5805cb100644
arch/riscv/boot/dts/allwinner/sunxi-d1s-t113.dtsi ccu: clock-controller@2001000 { · line 146
Quoted 9 lines
arch/riscv/boot/dts/allwinner/sunxi-d1s-t113.dtsi +6
-0@@ -138,6 +138,16 @@ ccu: clock-controller@2001000 { #reset-cells = <1>; }; + gpadc: adc@2009000 { + compatible = "allwinner,sun20i-d1-gpadc"; + reg = <0x2009000 0x400>; + clocks = <&ccu CLK_BUS_GPADC>; + resets = <&ccu RST_BUS_GPADC>; + interrupts = <SOC_PERIPHERAL_IRQ(57)
IRQ_TYPE_LEVEL_HIGH>;
Quoted 7 lines
arch/riscv/boot/dts/allwinner/sunxi-d1s-t113.dtsi +4
-0+ status = "disabled"; + #io-channel-cells = <1>; + }; + dmic: dmic@2031000 { compatible = "allwinner,sun20i-d1-dmic", "allwinner,sun50i-h6-dmic";
Re: [PATCH v8 4/4] riscv: dts: allwinner: d1: Add GPADC node
In reply to Maksim KiselevDne ponedeljek, 19. junij 2023 ob 17:42:27 CEST je Maksim Kiselev napisal(a):
Quoted 4 lines
This patch adds declaration of the general purpose ADC for D1 and T113s SoCs.
Signed-off-by Maksim Kiselev <[email protected]>
Applied, thanks!
Best regards,
Jernej
Jonathan Cameron
maintainerQuoted 3 lines · On Mon, 19 Jun 2023 18:42:23 +0300 Maksim Kiselev <[email protected]> wrote:
This series adds support for general purpose ADC (GPADC) on new Allwinner's SoCs, such as D1, T113s, T507 and R329. The implemented driver provides basic functionality for getting ADC channels data.
Applied 1-3 to the togreg branch of iio.git which will initially be pushed out as testing so that 0-day can see if we missed anything. I'll also be rebasing it on rc1 once available before pushing out as togreg.
Thanks,
Jonathan
Quoted 59 lines
Change History:
v8:
- Added patch that changesKconfigdescription for previous Allwinner GPADC
- ChangedKconfigdescription for this GPADC driver
- Fixed 'reg' range for gpadc node in 'sunxi-d1s-t113.dtsi'v7:
- Fixed typo in DT bindings propertyv6:
- Fixed DT bindings regexp for channel properties
- Dropped checking the max number of channels from the drivers code (This is redundant as we raly on DT bindings check)v5:
- Fixed DT bindings properties for child nodesv4:
- Fixed DT bindings warnings
- Used GENMASK to clear the irq register
- Minor formatting fixesv3:
- Added DT bindings dual license, fixed property order and example formatting
- Added explanations comments for timeout and mutex
- Dropped unnecessary regmap and used readl/writel instead
- Added error message about getting channel number
- Renamed labels and variables to make them self-explanatoryv2:
- Added lastch flag to avoid addition work for already selected channel
- Added reset assertion on module remove
- Added dynamic channel allocation and droppediio_chan_specarrays
- ChangedIIO_CHAN_INFO_SCALEtype toFRACTIONAL_LOG2
- Dropped separate compatible strings and configs for T113s and R329
- Fixed includes
- FixedKconfigdescription
- Removed duplicate probe error messages
- UsedFIELD_PREPfor bit setupv1:
- Initial versionMaksim Kiselev (4):
iio: adc:Kconfigchange description for Allwinner GPADC
iio: adc: Add Allwinner D1/T113s/R329/T507 SoCs GPADC
dt-bindings: iio: adc: Add Allwinner D1/T113s/R329/T507 SoCs GPADC
riscv: dts: allwinner: d1: Add GPADC node.../iio/adc/allwinner,sun20i-d1-gpadc.yaml | 91 ++++++ .../boot/dts/allwinner/sunxi-d1s-t113.dtsi | 10 + drivers/iio/adc/Kconfig | 12 +- drivers/iio/adc/Makefile | 1 + drivers/iio/adc/sun20i-gpadc-iio.c | 276 ++++++++++++++++++ 5 files changed, 389 insertions(+), 1 deletion(-) create mode 100644 Documentation/devicetree/bindings/iio/adc/allwinner,sun20i-d1-gpadc.yaml create mode 100644 drivers/iio/adc/sun20i-gpadc-iio.c