Skip to contentSkip to conversation

iio: adc: meson-saradc: add support for Meson S4

PATCH Superseded Nick Xie 4 participants 15 messages Feb 28 – Mar 3

Subsystems (3)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Nick Xie

author
#0 lore raw

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
author
#1 lore raw

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
index bb9825e7346dd..5496a0dc714aa 100644
@@ -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
#2 lore raw

Re: [PATCH v1 1/4] dt-bindings: iio: adc: amlogic,meson-saradc: add S4 compatible

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
---
 .../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
index bb9825e7346dd..5496a0dc714aa 100644

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

#3 lore raw

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
---
 .../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
index bb9825e7346dd..5496a0dc714aa 100644

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.

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-saradc

And 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

#4 lore raw

Re: [PATCH v1 1/4] dt-bindings: iio: adc: amlogic,meson-saradc: add S4 compatible

In reply to Krzysztof Kozlowski

Hi 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
---
 .../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
index bb9825e7346dd..5496a0dc714aa 100644

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.

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-saradc

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-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

#5 lore raw

Re: [PATCH v1 1/4] dt-bindings: iio: adc: amlogic,meson-saradc: add S4 compatible

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."

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
---
 .../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
index bb9825e7346dd..5496a0dc714aa 100644

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.

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-saradc

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-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

#6 lore raw

Re: [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
---
 .../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
index bb9825e7346dd..5496a0dc714aa 100644

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.

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-saradc

Not 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

#7 lore raw

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

author
#8 lore raw

PATCH 2/4 iio: adc: meson-saradc: add support for Meson S4

In reply to 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_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
index 47cd350498a0d..3ac48b7842c4f 100644
@@ -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
author
#10 lore raw

PATCH 3/4 arm64: dts: amlogic: meson-s4: add internal SARADC controller

In reply to Nick Xie

Add 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
index 4a3e9ad82d280..a1c0ef91d7cfb 100644
@@ -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
author
#12 lore raw

PATCH 4/4 arm64: dts: amlogic: meson-s4-s905y4-khadas-vim1s: add Function key support

In reply to Nick Xie

Enable 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
index 664d64a267f2d..792ab45c4c944 100644
@@ -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
#13 lore raw

Re: [PATCH v1 4/4] arm64: dts: amlogic: meson-s4-s905y4-khadas-vim1s: add Function key support

kernel 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
#14 lore raw

Re: [PATCH v1 4/4] arm64: dts: amlogic: meson-s4-s905y4-khadas-vim1s: add Function key support

Quoted 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