From 077576fbf1bc2340b5d5b1a4f19df4743f0c3d01 Mon Sep 17 00:00:00 2001
From: j-schambacher <joerg@hifiberry.com>
Date: Mon, 10 Feb 2025 14:58:34 +0100
Subject: [PATCH] dtoverlays: adds support for Hifiberry ADC8x to the DAC8x

Allows the usage of ADC8x stacked on top of the DAC8x.
Activates all I2S pins and uses now the dummy-dai instead
of the formerly used pcm5102 to allow the use of a
capture device, too. The simple card driver will
probe for the ADC8x and may activate the 8 channel
capture. Uses GPIO5 for detection.

Signed-off-by: j-schambacher <joerg@hifiberry.com>
---
 arch/arm/boot/dts/overlays/README                  |  3 +++
 .../boot/dts/overlays/hifiberry-dac8x-overlay.dts  | 14 ++++++++++----
 2 files changed, 13 insertions(+), 4 deletions(-)

--- a/arch/arm/boot/dts/overlays/README
+++ b/arch/arm/boot/dts/overlays/README
@@ -1900,6 +1900,9 @@ Params: <None>
 
 Name:   hifiberry-dac8x
 Info:   Configures the HifiBerry DAC8X audio cards (only on Pi5)
+        This driver also detects a stacked ADC8x and activates the
+        capture capabilities.
+        Note: for standalone use of the ADC8x activate the ADC8x module.
 Load:   dtoverlay=hifiberry-dac8x
 Params: <None>
 
--- a/arch/arm/boot/dts/overlays/hifiberry-dac8x-overlay.dts
+++ b/arch/arm/boot/dts/overlays/hifiberry-dac8x-overlay.dts
@@ -1,7 +1,10 @@
+// SPDX-License-Identifier: GPL-2.0
 // Definitions for HiFiBerry DAC8x
 /dts-v1/;
 /plugin/;
 
+#include <dt-bindings/gpio/gpio.h>
+
 / {
 	compatible = "brcm,bcm2712";
 
@@ -10,8 +13,10 @@
 		__overlay__ {
 			rp1_i2s0_dac8x: rp1_i2s0_dac8x {
 				function = "i2s0";
-				pins = "gpio18", "gpio19", "gpio21",
-				       "gpio23", "gpio25", "gpio27";
+				pins = "gpio18", "gpio19", "gpio20",
+				       "gpio21", "gpio22", "gpio23",
+				       "gpio24", "gpio25", "gpio26",
+				       "gpio27";
 				bias-disable;
 				status = "okay";
 			};
@@ -30,9 +35,9 @@
 	fragment@2 {
 		target-path = "/";
 		__overlay__ {
-			pcm5102a-codec {
+			dummy-codec {
 				#sound-dai-cells = <0>;
-				compatible = "ti,pcm5102a";
+				compatible = "snd-soc-dummy";
 				status = "okay";
 			};
 		};
@@ -43,6 +48,7 @@
 		__overlay__ {
 			compatible = "hifiberry,hifiberry-dac8x";
 			i2s-controller = <&i2s_clk_producer>;
+			hasadc-gpio = <&gpio 5 GPIO_ACTIVE_LOW>;
 			status = "okay";
 		};
 	};
