From 63f4efd396406bcfea7f72c4ba883a9acf0e039c Mon Sep 17 00:00:00 2001
From: "chipdip.lab" <43340836+chipdipru@users.noreply.github.com>
Date: Fri, 9 Jul 2021 16:00:22 +0300
Subject: [PATCH] overlays: Add overlay for Chipdip I2S master DAC

Signed-off-by: Evgenij Sapunov <evgenij.sapunov@chipdip.ru>
---
 arch/arm/boot/dts/overlays/Makefile           |  1 +
 arch/arm/boot/dts/overlays/README             |  6 +++
 .../chipdip-i2s-master-dac-overlay.dts        | 53 +++++++++++++++++++
 3 files changed, 60 insertions(+)
 create mode 100644 arch/arm/boot/dts/overlays/chipdip-i2s-master-dac-overlay.dts

--- a/arch/arm/boot/dts/overlays/Makefile
+++ b/arch/arm/boot/dts/overlays/Makefile
@@ -30,6 +30,7 @@ dtbo-$(CONFIG_ARCH_BCM2835) += \
 	audiosense-pi.dtbo \
 	audremap.dtbo \
 	balena-fin.dtbo \
+	chipdip-i2s-master-dac.dtbo \
 	cma.dtbo \
 	dht11.dtbo \
 	dionaudio-loco.dtbo \
--- a/arch/arm/boot/dts/overlays/README
+++ b/arch/arm/boot/dts/overlays/README
@@ -622,6 +622,12 @@ Info:   This overlay is now deprecated -
 Load:   <Deprecated>
 
 
+Name:   chipdip-i2s-master-dac
+Info:   Configures Raspberry PI to work as I2S slave with BCLK=64Fs.
+Load:   dtoverlay=chipdip-i2s-master-dac
+Params: <None>
+
+
 Name:   cma
 Info:   Set custom CMA sizes, only use if you know what you are doing, might
         clash with other overlays like vc4-fkms-v3d and vc4-kms-v3d.
--- /dev/null
+++ b/arch/arm/boot/dts/overlays/chipdip-i2s-master-dac-overlay.dts
@@ -0,0 +1,53 @@
+/*
+ * Device Tree overlay for ChipDip I2S master DAC
+ */
+
+/dts-v1/;
+/plugin/;
+
+/ {
+    compatible = "brcm,bcm2835";
+    fragment@0 {
+        target = <&sound>;
+        __overlay__ {
+            compatible = "simple-audio-card";
+            simple-audio-card,name = "ChipDip I2S master DAC";
+            status="okay";
+            playback_link: simple-audio-card,dai-link@0 {
+                format = "i2s";
+		bitclock-master = <&p_codec_dai>;
+                frame-master = <&p_codec_dai>;
+                p_cpu_dai: cpu {
+                        sound-dai = <&i2s>;
+			dai-tdm-slot-num = <2>;
+			dai-tdm-slot-width = <32>;
+				};
+
+                p_codec_dai: codec {
+                        sound-dai = <&codec_out>;
+                };
+            };
+        };
+    }; 
+
+    fragment@1 {
+        target-path = "/";
+        __overlay__ {
+            codec_out: spdif-transmitter {
+                #address-cells = <0>;
+                #size-cells = <0>;
+                #sound-dai-cells = <0>;
+                compatible = "linux,spdif-dit";
+                status = "okay";
+            };
+        };
+    };
+ 
+    fragment@2 {
+        target = <&i2s>;
+        __overlay__ {
+            #sound-dai-cells = <0>;
+            status = "okay";
+        };
+    };
+}; 
