From 77773aec03f65758c760ec5b43a79ad6edeb211b Mon Sep 17 00:00:00 2001
From: j-schambacher <joerg@hifiberry.com>
Date: Thu, 12 Sep 2024 16:44:12 +0200
Subject: [PATCH 1263/1350] dtoverlays: adds the definitions for the HiFiBerry
 8-channel ADC

Additions and changes for the 8 channel ADC card. This card uses only
HW-controlled devices which allows the uses of the 'dummy-dai'.
It will run only on a PI5 as it requires the designware I2S0 module.

The necessary output lanes I2S0_DI[0..3] are claimed from within the
DT overlay.

Signed-off-by: j-schambacher <joerg@hifiberry.com>
---
 arch/arm/boot/dts/overlays/Makefile           |  1 +
 arch/arm/boot/dts/overlays/README             |  6 +++
 .../dts/overlays/hifiberry-adc8x-overlay.dts  | 50 +++++++++++++++++++
 arch/arm/boot/dts/overlays/overlay_map.dts    |  4 ++
 4 files changed, 61 insertions(+)
 create mode 100644 arch/arm/boot/dts/overlays/hifiberry-adc8x-overlay.dts

--- a/arch/arm/boot/dts/overlays/Makefile
+++ b/arch/arm/boot/dts/overlays/Makefile
@@ -86,6 +86,7 @@ dtbo-$(CONFIG_ARCH_BCM2835) += \
 	hd44780-lcd.dtbo \
 	hdmi-backlight-hwhack-gpio.dtbo \
 	hifiberry-adc.dtbo \
+	hifiberry-adc8x.dtbo \
 	hifiberry-amp.dtbo \
 	hifiberry-amp100.dtbo \
 	hifiberry-amp3.dtbo \
--- a/arch/arm/boot/dts/overlays/README
+++ b/arch/arm/boot/dts/overlays/README
@@ -1778,6 +1778,12 @@ Params: leds_off                If set t
                                 is switched off at all times.
 
 
+Name:   hifiberry-adc8x
+Info:   Configures the HifiBerry ADC8X audio card (only on Pi5)
+Load:   dtoverlay=hifiberry-adc8x
+Params: <None>
+
+
 Name:   hifiberry-amp
 Info:   Configures the HifiBerry Amp and Amp+ audio cards
 Load:   dtoverlay=hifiberry-amp
--- /dev/null
+++ b/arch/arm/boot/dts/overlays/hifiberry-adc8x-overlay.dts
@@ -0,0 +1,50 @@
+// Definitions for HiFiBerry ADC8x
+/dts-v1/;
+/plugin/;
+
+/ {
+	compatible = "brcm,bcm2712";
+
+	fragment@0 {
+		target = <&gpio>;
+		__overlay__ {
+			rp1_i2s0_adc8x: rp1_i2s0_adc8x {
+				function = "i2s0";
+				pins = "gpio18", "gpio19", "gpio20",
+				       "gpio22", "gpio24", "gpio26";
+				bias-disable;
+				status = "okay";
+			};
+		};
+	};
+
+	fragment@1 {
+		target = <&i2s_clk_producer>;
+		__overlay__ {
+			pinctrl-names = "default";
+			pinctrl-0 = <&rp1_i2s0_adc8x>;
+			status = "okay";
+		};
+	};
+
+	fragment@2 {
+		target-path = "/";
+		__overlay__ {
+			dummy-codec {
+				#sound-dai-cells = <0>;
+				compatible = "snd-soc-dummy";
+				status = "okay";
+			};
+		};
+	};
+
+	fragment@3 {
+		target = <&sound>;
+		__overlay__ {
+			compatible = "hifiberry,hifiberry-adc8x";
+			i2s-controller = <&i2s_clk_producer>;
+			status = "okay";
+		};
+	};
+
+};
--- a/arch/arm/boot/dts/overlays/overlay_map.dts
+++ b/arch/arm/boot/dts/overlays/overlay_map.dts
@@ -48,6 +48,10 @@
 		bcm2712;
 	};
 
+	hifiberry-adc8x {
+		bcm2712;
+	};
+
 	hifiberry-dac8x {
 		bcm2712;
 	};
