Skip to contentSkip to conversation

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

PATCH Applied Nick Xie 4 participants 8 messages Mar 25 – Mar 27

Subsystems (3)
lore
Share & tools
lore

Nick Xie

author
#0 lore raw

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

There are no known hardware differences between the SARADC on the S4 and the previous G12A generation. The S4 bindings utilize a fallback to G12A, but a dedicated driver match entry is included to ensure the correct part name is exposed to the userspace ABI.

Changes in v3:
- Patch 1: Updated the commit message to explicitly explain why the comment regarding the generic fallback was added.
- Patch 2: Retained the driver patch and updated the commit message to clarify that the dedicated match entry is kept specifically for userspace ABI naming purposes.
- Link to v2: https://lore.kernel.org/all/[email protected]/

Changes in v2:
- Addressed feedback from Krzysztof Kozlowski:
- Updated dt-bindings commit message to explain the hardware compatibility.
- Separated the S4 compatible string in the YAML bindings to ensure it correctly falls back to the specific "amlogic,meson-g12a-saradc" rather than the generic "amlogic,meson-saradc".
- Updated the S4 SoC dtsi to use the correct G12A fallback.
- Added Martin's Reviewed-by tags where appropriate.
- Link to v1: https://lore.kernel.org/all/[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         |  4 ++++
 .../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, 45 insertions(+)
Signature · 1 line
2.34.1
author
#1 lore raw

PATCH v3 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.

There are no known differences between the SARADC on S4 and the one on G12A. Therefore, it uses "amlogic,meson-g12a-saradc" as a proper specific fallback.

Also add a comment indicating that "amlogic,meson-saradc" must not be used for new devices. It's a made up compatible string that does not correspond to a specific hardware generation and is not used to match any driver. For old devices we keep it as it's part of the ABI.

---
 .../devicetree/bindings/iio/adc/amlogic,meson-saradc.yaml     | 4 ++++
 1 file changed, 4 insertions(+)
Documentation/devicetree/bindings/iio/adc/amlogic,meson-saradc.yaml +4 -0
index bb9825e7346dd..70ab4e140e71b 100644
@@ -27,7 +27,11 @@ properties:
               - amlogic,meson-gxm-saradc
               - amlogic,meson-axg-saradc
               - amlogic,meson-g12a-saradc
+          # Usage of this generic fallback is not allowed for new devices
           - const: amlogic,meson-saradc
+      - items:
+          - const: amlogic,meson-s4-saradc
+          - const: amlogic,meson-g12a-saradc
 
   reg:
     maxItems: 1
Signature · 1 line
2.34.1
Reviewed-by on v3 1/4
#2 lore raw

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

Quoted 7 lines · Nick Xie

Add the compatible string for the SARADC (Successive Approximation Register ADC) IP block found in the Amlogic Meson S4 SoC.

There are no known differences between the SARADC on S4 and the one on G12A. Therefore, it uses "amlogic,meson-g12a-saradc" as a proper specific fallback.

Quoted 6 lines

Also add a comment indicating that "amlogic,meson-saradc" must not be used for new devices. It's a made up compatible string that does not correspond to a specific hardware generation and is not used to match any driver. For old devices we keep it as it's part of the ABI.

Best regards,
Krzysztof

author
#3 lore raw

PATCH v3 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.

Although the device tree fallback mechanism could handle the match, a dedicated entry is added to ensure the userspace ABI correctly reports the specific part name ("meson-s4-saradc"). This allows userspace to accurately identify the exact device and maintains consistency across different firmware types where automatic fallback parsing might be problematic.

---
 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
#4 lore raw

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

In reply to Nick Xie

Add the SARADC (Successive Approximation Register ADC) controller node to the Meson S4 SoC dtsi.

It uses the S4-specific compatible string with a fallback to the G12A generation, as there are no known hardware differences.

---
 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..936a5c1353d15 100644
@@ -77,6 +77,20 @@ pwrc: power-controller {
 		};
 	};
 
+	saradc: adc@fe026000 {
+		compatible = "amlogic,meson-s4-saradc",
+			     "amlogic,meson-g12a-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
#5 lore raw

PATCH v3 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
maintainer Applied
#6 lore raw
In reply to Nick Xie
Quoted 9 lines · On Wed, 25 Mar 2026 15:06:14 +0800 Nick Xie <[email protected]> wrote:

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.

There are no known hardware differences between the SARADC on the S4 and the previous G12A generation. The S4 bindings utilize a fallback to G12A, but a dedicated driver match entry is included to ensure the correct part name is exposed to the userspace ABI.

Applied patches 1 and 2 to the togreg branch of iio.git.

Quoted 32 lines

Changes in v3:
- Patch 1: Updated the commit message to explicitly explain why the comment regarding the generic fallback was added.
- Patch 2: Retained the driver patch and updated the commit message to clarify that the dedicated match entry is kept specifically for userspace ABI naming purposes.
- Link to v2: https://lore.kernel.org/all/[email protected]/

Changes in v2:
- Addressed feedback from Krzysztof Kozlowski:
- Updated dt-bindings commit message to explain the hardware compatibility.
- Separated the S4 compatible string in the YAML bindings to ensure it correctly falls back to the specific "amlogic,meson-g12a-saradc" rather than the generic "amlogic,meson-saradc".
- Updated the S4 SoC dtsi to use the correct G12A fallback.
- Added Martin's Reviewed-by tags where appropriate.
- Link to v1: https://lore.kernel.org/all/[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         |  4 ++++
 .../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, 45 insertions(+)
maintainer Applied
#7 lore raw

Re: (subset) [PATCH v3 0/4] iio: adc: meson-saradc: add support for Meson S4

In reply to Nick Xie

Hi,

Quoted 10 lines · Nick Xie

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.

There are no known hardware differences between the SARADC on the S4 and the previous G12A generation. The S4 bindings utilize a fallback to G12A, but a dedicated driver match entry is included to ensure the correct part name is exposed to the userspace ABI.

[...]

Thanks, Applied to https://git.kernel.org/pub/scm/linux/kernel/git/amlogic/linux.git (v7.1/arm64-dt)

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

      https://git.kernel.org/amlogic/c/3b095e9b3674da0666aea3021167ca44097ed7fa
[4/4] arm64: dts: amlogic: meson-s4-s905y4-khadas-vim1s: add Function key support
      https://git.kernel.org/amlogic/c/97c4d4b7de6ef264fbd45300a168c2a0874d6c75

These changes has been applied on the intermediate git tree [1].

The v7.1/arm64-dt branch will then be sent via a formal Pull Request to the Linux SoC maintainers for inclusion in their intermediate git branches in order to be sent to Linus during the next merge window, or sooner if it's a set of fixes.

In the cases of fixes, those will be merged in the current release candidate kernel and as soon they appear on the Linux master branch they will be backported to the previous Stable and Long-Stable kernels [2].

The intermediate git branches are merged daily in the linux-next tree [3], people are encouraged testing these pre-release kernels and report issues on the relevant mailing-lists.

If problems are discovered on those changes, please submit a signed-off-by revert patch followed by a corrective changeset.

[1] https://git.kernel.org/pub/scm/linux/kernel/git/amlogic/linux.git
[2] https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
[3] https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git

Signature · 1 line
Neil