From e83ebb02f24f527df4916309cdb0b8a3f7d07a79 Mon Sep 17 00:00:00 2001
From: "chipdip.lab" <43340836+chipdipru@users.noreply.github.com>
Date: Mon, 26 Jul 2021 14:43:11 +0300
Subject: [PATCH] overlays: Update and rename chipdip-i2s-master-dac

Simple card fragment removed, GPIO fragment added.

Signed-off-by: Evgenij Sapunov <evgenij.sapunov@chipdip.ru>
---
 arch/arm/boot/dts/overlays/Makefile           |  2 +-
 arch/arm/boot/dts/overlays/README             |  6 +--
 .../boot/dts/overlays/chipdip-dac-overlay.dts | 46 ++++++++++++++++
 .../chipdip-i2s-master-dac-overlay.dts        | 53 -------------------
 4 files changed, 50 insertions(+), 57 deletions(-)
 create mode 100644 arch/arm/boot/dts/overlays/chipdip-dac-overlay.dts
 delete 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
@@ -31,7 +31,7 @@ dtbo-$(CONFIG_ARCH_BCM2835) += \
 	audremap.dtbo \
 	balena-fin.dtbo \
 	cap1106.dtbo \
-	chipdip-i2s-master-dac.dtbo \
+	chipdip-dac.dtbo \
 	cma.dtbo \
 	dht11.dtbo \
 	dionaudio-loco.dtbo \
--- a/arch/arm/boot/dts/overlays/README
+++ b/arch/arm/boot/dts/overlays/README
@@ -628,9 +628,9 @@ Load:   dtoverlay=cap1106,<param>=<val>
 Params: int_pin                 GPIO pin for interrupt signal (default 23)
 
 
-Name:   chipdip-i2s-master-dac
-Info:   Configures Raspberry PI to work as I2S slave with BCLK=64Fs.
-Load:   dtoverlay=chipdip-i2s-master-dac
+Name:   chipdip-dac
+Info:   Configures Chip Dip audio cards.
+Load:   dtoverlay=chipdip-dac
 Params: <None>
 
 
--- /dev/null
+++ b/arch/arm/boot/dts/overlays/chipdip-dac-overlay.dts
@@ -0,0 +1,46 @@
+/*
+ * Device Tree overlay for ChipDip DAC
+ */
+
+/dts-v1/;
+/plugin/;
+
+/ {
+	compatible = "brcm,bcm2835";
+
+	fragment@0 {
+		target = <&i2s>;
+		__overlay__ {
+			status = "okay";
+		};
+	};
+
+	fragment@1 {
+		target-path = "/";
+		__overlay__ {
+			spdif-transmitter {
+				#address-cells = <0>;
+				#size-cells = <0>;
+				#sound-dai-cells = <0>;
+				compatible = "linux,spdif-dit";
+				status = "okay";
+			};
+		};
+	};
+
+	fragment@2 {
+		target = <&sound>;
+		__overlay__ {
+			compatible = "chipdip,chipdip-dac";
+			i2s-controller = <&i2s>;
+			sr0-gpios = <&gpio 5 0>;
+			sr1-gpios = <&gpio 6 0>;
+			sr2-gpios = <&gpio 12 0>;
+			res0-gpios = <&gpio 24 0>;
+			res1-gpios = <&gpio 27 0>;
+			mute-gpios = <&gpio 4 0>;
+			sdwn-gpios = <&gpio 13 0>;
+			status = "okay";
+		};
+	};
+};
--- a/arch/arm/boot/dts/overlays/chipdip-i2s-master-dac-overlay.dts
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * 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";
-        };
-    };
-}; 
