iio: adc: meson-saradc: add support for Meson S4
Subsystems (3)
cover iio: adc: meson-saradc: add support for Meson S4
This series adds support for the SARADC IP block found in the Amlogic Meson S4 (S905Y4) SoC and enables it for the Khadas VIM1S board to support the onboard ADC 'Function' key.
Following discussions in a previous board-enablement thread [1], a dedicated compatible string ("amlogic,meson-s4-saradc") is introduced. While the hardware currently operates perfectly using the G12A parameter set, defining an S4-specific string ensures forward compatibility should any S4-specific quirks or BL30 integration differences be discovered in the future.
[1] https://lore.kernel.org/linux-amlogic/[email protected]/
Nick Xie (4):
dt-bindings: iio: adc: amlogic,meson-saradc: add S4 compatible
iio: adc: meson-saradc: add support for Meson S4
arm64: dts: amlogic: meson-s4: add internal SARADC controller
arm64: dts: amlogic: meson-s4-s905y4-khadas-vim1s: add Function key
support
.../iio/adc/amlogic,meson-saradc.yaml | 1 + .../amlogic/meson-s4-s905y4-khadas-vim1s.dts | 19 +++++++++++++++++++ arch/arm64/boot/dts/amlogic/meson-s4.dtsi | 14 ++++++++++++++ drivers/iio/adc/meson_saradc.c | 8 ++++++++ 4 files changed, 42 insertions(+)
Signature · 1 line
2.34.1
PATCH 1/4 dt-bindings: iio: adc: amlogic,meson-saradc: add S4 compatible
Add the compatible string for the SARADC (Successive Approximation Register ADC) IP block found in the Amlogic Meson S4 SoC.
--- .../devicetree/bindings/iio/adc/amlogic,meson-saradc.yaml | 1 + 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/iio/adc/amlogic,meson-saradc.yaml +1 -0
@@ -27,6 +27,7 @@ properties: - amlogic,meson-gxm-saradc - amlogic,meson-axg-saradc - amlogic,meson-g12a-saradc + - amlogic,meson-s4-saradc - const: amlogic,meson-saradc reg:
Signature · 1 line
2.34.1
PATCH 2/4 iio: adc: meson-saradc: add support for Meson S4
In reply to Nick XieAdd support for the SARADC found on the Amlogic Meson S4 SoC. According to the documentation and current testing, it is fully compatible with the G12A parameter set, so we reuse meson_sar_adc_g12a_data for this new compatible string.
--- drivers/iio/adc/meson_saradc.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/iio/adc/meson_saradc.c +8 -0
@@ -1313,6 +1313,11 @@ static const struct meson_sar_adc_data meson_sar_adc_g12a_data = { .name = "meson-g12a-saradc", }; +static const struct meson_sar_adc_data meson_sar_adc_s4_data = { + .param = &meson_sar_adc_g12a_param, + .name ="meson-s4-saradc" , +}; +static const struct of_device_id meson_sar_adc_of_match[] = { { .compatible ="amlogic,meson8-saradc" ,
@@ -1341,6 +1346,9 @@ static const struct of_device_id meson_sar_adc_of_match[] = { }, { .compatible = "amlogic,meson-g12a-saradc", .data = &meson_sar_adc_g12a_data, + }, { + .compatible = "amlogic,meson-s4-saradc", + .data = &meson_sar_adc_s4_data, }, { } };
Signature · 1 line
2.34.1
PATCH 3/4 arm64: dts: amlogic: meson-s4: add internal SARADC controller
In reply to Nick XieAdd the SARADC controller node to the Meson S4 SoC dtsi. Uses the newly introduced S4-specific compatible string.
--- arch/arm64/boot/dts/amlogic/meson-s4.dtsi | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
arch/arm64/boot/dts/amlogic/meson-s4.dtsi +14 -0
@@ -77,6 +77,20 @@ pwrc: power-controller { }; }; + saradc: adc@fe026000 { + compatible = "amlogic,meson-s4-saradc", + "amlogic,meson-saradc"; + reg = <0x0 0xfe026000 0x0 0x48>; + #io-channel-cells = <1>; + interrupts = <GIC_SPI 181 IRQ_TYPE_EDGE_RISING>; + clocks = <&xtal>, + <&clkc_periphs CLKID_SAR_ADC>, + <&clkc_periphs CLKID_SARADC>, + <&clkc_periphs CLKID_SARADC_SEL>; + clock-names = "clkin", "core", "adc_clk", "adc_sel"; + status = "disabled"; + }; + soc { compatible = "simple-bus"; #address-cells = <2>;
Signature · 1 line
2.34.1
PATCH 4/4 arm64: dts: amlogic: meson-s4-s905y4-khadas-vim1s: add Function key support
In reply to Nick XieEnable the SARADC controller and add the adc-keys node to support the Function key found on the Khadas VIM1S board.
--- .../amlogic/meson-s4-s905y4-khadas-vim1s.dts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
arch/arm64/boot/dts/amlogic/meson-s4-s905y4-khadas-vim1s.dts +19 -0
@@ -40,6 +40,20 @@ secmon_reserved: secmon@5000000 { }; }; + adc-keys { + compatible = "adc-keys"; + io-channels = <&saradc 0>; + io-channel-names = "buttons"; + keyup-threshold-microvolt = <1710000>; + poll-interval = <100>; + + button-function { + label = "Function"; + linux,code = <KEY_FN>; + press-threshold-microvolt = <10000>; + }; + }; + emmc_pwrseq: emmc-pwrseq { compatible = "mmc-pwrseq-emmc"; reset-gpios = <&gpio GPIOB_9 GPIO_ACTIVE_LOW>;
@@ -278,6 +292,11 @@ brcmf: wifi@1 { }; }; +&saradc { + status = "okay"; + vref-supply = <&vddio_ao1v8>; +}; + &spicc0 { status = "okay"; pinctrl-names = "default";
Signature · 1 line
2.34.1
Re: [PATCH v1 1/4] dt-bindings: iio: adc: amlogic,meson-saradc: add S4 compatible
In reply to Nick XieQuoted 2 lines · Nick Xie
Add the compatible string for the SARADC (Successive Approximation Register ADC) IP block found in the Amlogic Meson S4 SoC.
... which is fully compatible with g12a?
Write proper explanations.
Quoted 11 lines
Signed-off-by Nick Xie <[email protected]>--- .../devicetree/bindings/iio/adc/amlogic,meson-saradc.yaml | 1 + 1 file changed, 1 insertion(+)Documentation/devicetree/bindings/iio/adc/amlogic,meson-saradc.yaml +0
-0
Documentation/devicetree/bindings/iio/adc/amlogic,meson-saradc.yaml properties: · line 30
Quoted 4 lines
Documentation/devicetree/bindings/iio/adc/amlogic,meson-saradc.yaml +1
-0@@ -27,6 +27,7 @@ properties: - amlogic,meson-gxm-saradc - amlogic,meson-axg-saradc - amlogic,meson-g12a-saradc + - amlogic,meson-s4-saradc
If this is compatible with other device, you need proper fallback.
Documentation/devicetree/bindings/iio/adc/amlogic,meson-saradc.yaml properties: · line 31
Quoted 1 line
Documentation/devicetree/bindings/iio/adc/amlogic,meson-saradc.yaml +0
-0- const: amlogic,meson-saradc
And this one is now kind of fake - how does this device use it?
Best regards,
Krzysztof
Re: [PATCH v1 1/4] dt-bindings: iio: adc: amlogic,meson-saradc: add S4 compatible
Quoted 26 lines · Krzysztof Kozlowski
Quoted 2 lines · Nick Xie
Add the compatible string for the SARADC (Successive Approximation Register ADC) IP block found in the Amlogic Meson S4 SoC.
... which is fully compatible with g12a?
Write proper explanations.
Quoted 11 lines
Signed-off-by Nick Xie <[email protected]>--- .../devicetree/bindings/iio/adc/amlogic,meson-saradc.yaml | 1 + 1 file changed, 1 insertion(+)Documentation/devicetree/bindings/iio/adc/amlogic,meson-saradc.yaml +0
-0Documentation/devicetree/bindings/iio/adc/amlogic,meson-saradc.yaml properties: · line 30
Quoted 4 lines
Documentation/devicetree/bindings/iio/adc/amlogic,meson-saradc.yaml +1
-0@@ -27,6 +27,7 @@ properties: - amlogic,meson-gxm-saradc - amlogic,meson-axg-saradc - amlogic,meson-g12a-saradc + - amlogic,meson-s4-saradcIf this is compatible with other device, you need proper fallback.
Quoted 3 lines
Documentation/devicetree/bindings/iio/adc/amlogic,meson-saradc.yaml properties: · line 31
Quoted 1 line
Documentation/devicetree/bindings/iio/adc/amlogic,meson-saradc.yaml +0
-0- const: amlogic,meson-saradcAnd this one is now kind of fake - how does this device use it?
I checked now - NOTHING uses it. This is completely useless fallback, don't write such schema. Add a comment that usage of this fallback is not allowed for new devices and instead create proper compatibility (look at your driver code).
Best regards,
Krzysztof
kernel test robot
build botRe: [PATCH v1 4/4] arm64: dts: amlogic: meson-s4-s905y4-khadas-vim1s: add Function key support
In reply to Nick Xiekernel test robot noticed the following build errors:
Hi Nick,
kernel test robot noticed the following build errors:
[auto build test ERROR on jic23-iio/togreg]
[also build test ERROR on robh/for-next linus/master v7.0-rc1 next-20260227] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Nick-Xie/dt-bindings-iio-adc-amlogic-meson-saradc-add-S4-compatible/20260228-150346 base: https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git togreg patch link: https://lore.kernel.org/r/20260228065840.702651-5-nick%40khadas.com patch subject: [PATCH v1 4/4] arm64: dts: amlogic: meson-s4-s905y4-khadas-vim1s: add Function key support config: arm64-randconfig-001-20260228 (https://download.01.org/0day-ci/archive/20260301/[email protected]/config) compiler: clang version 23.0.0git (https://github.com/llvm/llvm-project 9a109fbb6e184ec9bcce10615949f598f4c974a9) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260301/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
Lexical error: arch/arm64/boot/dts/amlogic/meson-s4-s905y4-khadas-vim1s.dts:50.18-24 Unexpected 'KEY_FN'
>> FATAL ERROR: Syntax error parsing input tree
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Quoted 7 lines · Nick Xie
Add support for the SARADC found on the Amlogic Meson S4 SoC. According to the documentation and current testing, it is fully compatible with the G12A parameter set, so we reuse
meson_sar_adc_g12a_datafor this new compatible string.Signed-off-by Nick Xie <[email protected]>
Re: [PATCH v1 3/4] arm64: dts: amlogic: meson-s4: add internal SARADC controller
In reply to Nick XieQuoted 5 lines · Nick Xie
Add the SARADC controller node to the Meson S4 SoC dtsi. Uses the newly introduced S4-specific compatible string.
Signed-off-by Nick Xie <[email protected]>
Martin Blumenstingl
reviewerRe: [PATCH v1 1/4] dt-bindings: iio: adc: amlogic,meson-saradc: add S4 compatible
In reply to Krzysztof KozlowskiHi Krzysztof,
Quoted 8 lines · Krzysztof Kozlowski
Quoted 2 lines · Nick Xie
Add the compatible string for the SARADC (Successive Approximation Register ADC) IP block found in the Amlogic Meson S4 SoC.
... which is fully compatible with g12a?
Write proper explanations.
Would you be fine with:
"There are no known differences between the SARADC on S4 and the one on G12A. In the past differences between SARADC on the different SoCs generations have been uncovered late, meaning that a dedicated compatible string has proven to be useful."
Do you also require Nick to add amlogic,meson-g12a-saradc as fallback compatible string for amlogic,meson-s4-saradc?
Quoted 18 lines
Quoted 11 lines
Signed-off-by Nick Xie <[email protected]>--- .../devicetree/bindings/iio/adc/amlogic,meson-saradc.yaml | 1 + 1 file changed, 1 insertion(+)Documentation/devicetree/bindings/iio/adc/amlogic,meson-saradc.yaml +0
-0Documentation/devicetree/bindings/iio/adc/amlogic,meson-saradc.yaml properties: · line 30
Quoted 4 lines
Documentation/devicetree/bindings/iio/adc/amlogic,meson-saradc.yaml +1
-0@@ -27,6 +27,7 @@ properties: - amlogic,meson-gxm-saradc - amlogic,meson-axg-saradc - amlogic,meson-g12a-saradc + - amlogic,meson-s4-saradcIf this is compatible with other device, you need proper fallback.
Quoted 3 lines
Documentation/devicetree/bindings/iio/adc/amlogic,meson-saradc.yaml properties: · line 31
Quoted 1 line
Documentation/devicetree/bindings/iio/adc/amlogic,meson-saradc.yaml +0
-0- const: amlogic,meson-saradcAnd this one is now kind of fake - how does this device use it?
As you have noticed later, it is currently not used.
Can you please confirm that my understanding of the next steps is correct:
- you're expecting Nick to omit the amlogic,meson-saradc fallback compatible string for amlogic,meson-s4-saradc
- and you would like to see amlogic,meson-saradc removed (from the bindings and .dts files that are already upstream) - I will take care of this once S4 support lands upstream
Best regards,
Martin
Martin Blumenstingl
reviewerRe: [PATCH v1 4/4] arm64: dts: amlogic: meson-s4-s905y4-khadas-vim1s: add Function key support
In reply to kernel test robotQuoted 19 lines · kernel test robot
Hi Nick,
kernel test robot noticed the following build errors:
[auto build test ERROR on jic23-iio/togreg]
[also build test ERROR on robh/for-next linus/master v7.0-rc1 next-20260227] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]url: https://github.com/intel-lab-lkp/linux/commits/Nick-Xie/dt-bindings-iio-adc-amlogic-meson-saradc-add-S4-compatible/20260228-150346 base: https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git togreg patch link: https://lore.kernel.org/r/20260228065840.702651-5-nick%40khadas.com patch subject: [PATCH v1 4/4] arm64: dts: amlogic: meson-s4-s905y4-khadas-vim1s: add Function key support config: arm64-randconfig-001-20260228 (https://download.01.org/0day-ci/archive/20260301/[email protected]/config) compiler: clang version 23.0.0git (https://github.com/llvm/llvm-project 9a109fbb6e184ec9bcce10615949f598f4c974a9) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260301/[email protected]/reproduce)
Quoted 9 lines
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/All errors (new ones prefixed by >>):
Lexical error: arch/arm64/boot/dts/amlogic/meson-s4-s905y4-khadas-vim1s.dts:50.18-24 Unexpected 'KEY_FN'Quoted 1 line
Quoted 1 line
FATAL ERROR: Syntax error parsing input tree
It turns out that this series is supposed to be applied on top of "arm64: dts: amlogic: meson-s4-khadas-vim1s: enable LEDs, Keys and Bluetooth" [0]
When applying this series on top of the other then there's no more build error.
[0] https://lore.kernel.org/linux-amlogic/[email protected]/T/#m2f4d30878fc8252f853bdb3005042c3aad97961e
Re: [PATCH v1 1/4] dt-bindings: iio: adc: amlogic,meson-saradc: add S4 compatible
In reply to Martin BlumenstinglQuoted 8 lines · Martin Blumenstingl
Hi Krzysztof,
Quoted 5 lines · Krzysztof Kozlowski
Quoted 2 lines · Nick Xie
Add the compatible string for the SARADC (Successive Approximation Register ADC) IP block found in the Amlogic Meson S4 SoC.
Quoted 8 lines
Quoted 3 lines
... which is fully compatible with g12a?
Write proper explanations.
Would you be fine with:
"There are no known differences between the SARADC on S4 and the one on G12A. In the past differences between SARADC on the different SoCs generations have been uncovered late, meaning that a dedicated compatible string has proven to be useful."
No, last sentence is redundant. You do not need to explain in the commit msg rules of bindings, because they are obvious/known. You need to explain the hardware, e.g. in this case the compatibility between devices.
Quoted 22 lines
Do you also require Nick to add amlogic,meson-g12a-saradc as fallback compatible string for amlogic,meson-s4-saradc?
Quoted 18 lines
Quoted 11 lines
Signed-off-by Nick Xie <[email protected]>--- .../devicetree/bindings/iio/adc/amlogic,meson-saradc.yaml | 1 + 1 file changed, 1 insertion(+)Documentation/devicetree/bindings/iio/adc/amlogic,meson-saradc.yaml +0
-0Documentation/devicetree/bindings/iio/adc/amlogic,meson-saradc.yaml properties: · line 30
Quoted 4 lines
Documentation/devicetree/bindings/iio/adc/amlogic,meson-saradc.yaml +1
-0@@ -27,6 +27,7 @@ properties: - amlogic,meson-gxm-saradc - amlogic,meson-axg-saradc - amlogic,meson-g12a-saradc + - amlogic,meson-s4-saradcIf this is compatible with other device, you need proper fallback.
Quoted 7 lines
Quoted 3 lines
Documentation/devicetree/bindings/iio/adc/amlogic,meson-saradc.yaml properties: · line 31
Quoted 1 line
Documentation/devicetree/bindings/iio/adc/amlogic,meson-saradc.yaml +0
-0- const: amlogic,meson-saradcAnd this one is now kind of fake - how does this device use it?
As you have noticed later, it is currently not used.
Can you please confirm that my understanding of the next steps is correct:
- you're expecting Nick to omit the amlogic,meson-saradc fallback compatible string for amlogic,meson-s4-saradc
Not omit but replace with proper fallback to specific compatible.
Quoted 3 lines
- and you would like to see amlogic,meson-saradc removed (from the bindings and .dts files that are already upstream) - I will take care of this once S4 support lands upstream
This no. It's an ABI, you cannot change it. Not worth it, either.
Best regards,
Krzysztof
Martin Blumenstingl
reviewerRe: [PATCH v1 1/4] dt-bindings: iio: adc: amlogic,meson-saradc: add S4 compatible
Hi Krzysztof,
Quoted 19 lines · Krzysztof Kozlowski
Quoted 8 lines · Martin Blumenstingl
Hi Krzysztof,
Quoted 5 lines · Krzysztof Kozlowski
Quoted 2 lines · Nick Xie
Add the compatible string for the SARADC (Successive Approximation Register ADC) IP block found in the Amlogic Meson S4 SoC.
Quoted 8 lines
Quoted 3 lines
... which is fully compatible with g12a?
Write proper explanations.
Would you be fine with:
"There are no known differences between the SARADC on S4 and the one on G12A. In the past differences between SARADC on the different SoCs generations have been uncovered late, meaning that a dedicated compatible string has proven to be useful."
Quoted 3 lines
No, last sentence is redundant. You do not need to explain in the commit msg rules of bindings, because they are obvious/known. You need to explain the hardware, e.g. in this case the compatibility between devices.
Understood, thanks.
Quoted 24 lines
Quoted 24 lines
Do you also require Nick to add amlogic,meson-g12a-saradc as fallback compatible string for amlogic,meson-s4-saradc?
Quoted 20 lines
Quoted 11 lines
Signed-off-by Nick Xie <[email protected]>--- .../devicetree/bindings/iio/adc/amlogic,meson-saradc.yaml | 1 + 1 file changed, 1 insertion(+)Documentation/devicetree/bindings/iio/adc/amlogic,meson-saradc.yaml +0
-0Documentation/devicetree/bindings/iio/adc/amlogic,meson-saradc.yaml properties: · line 30
Quoted 4 lines
Documentation/devicetree/bindings/iio/adc/amlogic,meson-saradc.yaml +1
-0@@ -27,6 +27,7 @@ properties: - amlogic,meson-gxm-saradc - amlogic,meson-axg-saradc - amlogic,meson-g12a-saradc + - amlogic,meson-s4-saradcIf this is compatible with other device, you need proper fallback.
Quoted 1 line
Documentation/devicetree/bindings/iio/adc/amlogic,meson-saradc.yaml +0
-0- const: amlogic,meson-saradc
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
And this one is now kind of fake - how does this device use it?
As you have noticed later, it is currently not used.
Can you please confirm that my understanding of the next steps is correct:
- you're expecting Nick to omit the amlogic,meson-saradc fallback compatible string for amlogic,meson-s4-saradcNot omit but replace with proper fallback to specific compatible.
So in this case we need to end up with:
compatible = "amlogic,meson-s4-saradc", "amlogic,meson-g12a-saradc" Stating that the S4 SARADC IP is compatible with the G12A SARADC IP. Any S4 specific quirks that we need (in case we ever find something) can then be managed in the driver.
Quoted 5 lines
Quoted 3 lines
- and you would like to see amlogic,meson-saradc removed (from the bindings and .dts files that are already upstream) - I will take care of this once S4 support lands upstream
This no. It's an ABI, you cannot change it. Not worth it, either.
You suggested adding a comment stating that future bindings must not use the "amlogic,meson-saradc" compatible string anymore.
Since it's part of ABI we need to keep it. So adding a comment is all I'll do.
Best regards,
Martin
Re: [PATCH v1 1/4] dt-bindings: iio: adc: amlogic,meson-saradc: add S4 compatible
Quoted 9 lines · Martin Blumenstingl
Quoted 5 lines
Quoted 3 lines
- and you would like to see amlogic,meson-saradc removed (from the bindings and .dts files that are already upstream) - I will take care of this once S4 support lands upstream
This no. It's an ABI, you cannot change it. Not worth it, either.
You suggested adding a comment stating that future bindings must not use the "amlogic,meson-saradc" compatible string anymore.
Since it's part of ABI we need to keep it. So adding a comment is all I'll do.
Yes, comment would be useful.
Best regards,
Krzysztof