From 99e6cb05eaa2b133d9a2b7cb031fef2c19577cc1 Mon Sep 17 00:00:00 2001
From: j-schambacher <joerg@hifiberry.com>
Date: Wed, 28 Feb 2024 11:34:05 +0100
Subject: [PATCH 0916/1085] Overlays: Add definitions for HiFiBerry 8 channel
 DAC8X

Dedicated overlay claiming all 4 data lanes of the designware
I2S0 module to drive 4x PCM5102. THe devices share BCLK and
LRCLK, therefore all outputs will always run at the same
samplerate and format.

Compatible only with PI5!

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-dac8x-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-dac8x-overlay.dts

--- a/arch/arm/boot/dts/overlays/Makefile
+++ b/arch/arm/boot/dts/overlays/Makefile
@@ -89,6 +89,7 @@ dtbo-$(CONFIG_ARCH_BCM2835) += \
 	hifiberry-amp3.dtbo \
 	hifiberry-amp4pro.dtbo \
 	hifiberry-dac.dtbo \
+	hifiberry-dac8x.dtbo \
 	hifiberry-dacplus.dtbo \
 	hifiberry-dacplusadc.dtbo \
 	hifiberry-dacplusadcpro.dtbo \
--- a/arch/arm/boot/dts/overlays/README
+++ b/arch/arm/boot/dts/overlays/README
@@ -1778,6 +1778,12 @@ Load:   dtoverlay=hifiberry-dac
 Params: <None>
 
 
+Name:   hifiberry-dac8x
+Info:   Configures the HifiBerry DAC8X audio cards (only on PI5)
+Load:   dtoverlay=hifiberry-dac8x
+Params: <None>
+
+
 Name:   hifiberry-dacplus
 Info:   Configures the HifiBerry DAC+ audio card
 Load:   dtoverlay=hifiberry-dacplus,<param>=<val>
--- /dev/null
+++ b/arch/arm/boot/dts/overlays/hifiberry-dac8x-overlay.dts
@@ -0,0 +1,50 @@
+// Definitions for HiFiBerry DAC8x
+/dts-v1/;
+/plugin/;
+
+/ {
+	compatible = "brcm,bcm2712";
+
+	fragment@0 {
+		target = <&gpio>;
+		__overlay__ {
+			rp1_i2s0_dac8x: rp1_i2s0_dac8x {
+				function = "i2s0";
+				pins = "gpio18", "gpio19", "gpio21",
+				       "gpio23", "gpio25", "gpio27";
+				bias-disable;
+				status = "okay";
+			};
+		};
+	};
+
+	fragment@1 {
+		target = <&i2s_clk_producer>;
+		__overlay__ {
+			pinctrl-names = "default";
+			pinctrl-0 = <&rp1_i2s0_dac8x>;
+			status = "okay";
+		};
+	};
+
+	fragment@2 {
+		target-path = "/";
+		__overlay__ {
+			pcm5102a-codec {
+				#sound-dai-cells = <0>;
+				compatible = "ti,pcm5102a";
+				status = "okay";
+			};
+		};
+	};
+
+	fragment@3 {
+		target = <&sound>;
+		__overlay__ {
+			compatible = "hifiberry,hifiberry-dac8x";
+			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-dac8x {
+		bcm2712;
+	};
+
 	highperi {
 		bcm2711;
 	};