From 58e6a45fb77833acc3fdaf0460ed3407f22dee63 Mon Sep 17 00:00:00 2001
From: pifi-bz <73530753+pifi-bz@users.noreply.github.com>
Date: Fri, 19 Feb 2021 13:14:32 +0200
Subject: [PATCH] DAC overlays  (#4154)

Adding overlays for PiFi DAC Zero and PiFi DAC HD.

Signed-off-by: David Knell <david.knell@gmail.com>
---
 arch/arm/boot/dts/overlays/Makefile           |  2 +
 arch/arm/boot/dts/overlays/README             | 12 +++++
 .../boot/dts/overlays/pifi-dac-hd-overlay.dts | 49 +++++++++++++++++++
 .../dts/overlays/pifi-dac-zero-overlay.dts    | 49 +++++++++++++++++++
 4 files changed, 112 insertions(+)
 create mode 100644 arch/arm/boot/dts/overlays/pifi-dac-hd-overlay.dts
 create mode 100644 arch/arm/boot/dts/overlays/pifi-dac-zero-overlay.dts

--- a/arch/arm/boot/dts/overlays/Makefile
+++ b/arch/arm/boot/dts/overlays/Makefile
@@ -130,6 +130,8 @@ dtbo-$(CONFIG_ARCH_BCM2835) += \
 	pibell.dtbo \
 	pifacedigital.dtbo \
 	pifi-40.dtbo \
+	pifi-dac-hd.dtbo \
+	pifi-dac-zero.dtbo \
 	pifi-mini-210.dtbo \
 	piglow.dtbo \
 	piscreen.dtbo \
--- a/arch/arm/boot/dts/overlays/README
+++ b/arch/arm/boot/dts/overlays/README
@@ -2131,6 +2131,18 @@ Load:   dtoverlay=pifi-40
 Params: <None>
 
 
+Name:   pifi-dac-hd
+Info:   Configures the PiFi DAC HD
+Load:   dtoverlay=pifi-dac-hd
+Params: <None>
+
+
+Name:   pifi-dac-zero
+Info:   Configures the PiFi DAC Zero
+Load:   dtoverlay=pifi-dac-zero
+Params: <None>
+
+
 Name:   pifi-mini-210
 Info:   Configures the PiFi Mini stereo amplifier
 Load:   dtoverlay=pifi-mini-210
--- /dev/null
+++ b/arch/arm/boot/dts/overlays/pifi-dac-hd-overlay.dts
@@ -0,0 +1,49 @@
+// Overlay for PiFi-DAC-HD
+/dts-v1/;
+/plugin/;
+
+/ {
+	compatible = "brcm,bcm2835";
+
+	fragment@0 {
+		target = <&i2s>;
+		__overlay__ {
+			status = "okay";
+		};
+	};
+
+	fragment@1 {
+		target = <&i2c1>;
+		__overlay__ {
+			status = "okay";
+			#address-cells = <1>;
+			#size-cells =<0>;
+
+			pcm5142: pcm5142@4c {
+				#sound-dai-cells = <0>;
+				compatible = "ti,pcm5142";
+				reg = <0x4c>;
+				status = "okay";
+			};
+		};
+	};
+
+	fragment@2 {
+		target = <&sound>;
+		__overlay__ {
+			compatible = "simple-audio-card";
+			simple-audio-card,name = "PiFi-DAC-HD";
+			status = "okay";
+
+			simple-audio-card,dai-link@1 {
+				format = "i2s";
+				cpu {
+					sound-dai = <&i2s>;
+				};
+				codec {
+					sound-dai = <&pcm5142>;
+				};
+			};
+		};
+	};
+};
--- /dev/null
+++ b/arch/arm/boot/dts/overlays/pifi-dac-zero-overlay.dts
@@ -0,0 +1,49 @@
+// Overlay for PiFi-DAC-Zero
+/dts-v1/;
+/plugin/;
+
+/ {
+	compatible = "brcm,bcm2835";
+
+	fragment@0 {
+		target = <&sound>;
+		__overlay__ {
+			compatible = "simple-audio-card";
+			simple-audio-card,name = "PiFi-DAC-Zero";
+			status = "okay";
+
+			simple-audio-card,dai-link@1 {
+				format = "i2s";
+
+				cpu {
+					sound-dai = <&i2s>;
+					dai-tdm-slot-num = <2>;
+					dai-tdm-slot-width = <32>;
+				};
+
+				codec {
+					sound-dai = <&codec_out>;
+				};
+			};
+		};
+	};
+
+	fragment@1 {
+		target-path = "/";
+		__overlay__ {
+			codec_out: pcm5102a-codec {
+				#sound-dai-cells = <0>;
+				compatible = "ti,pcm5102a";
+				status = "okay";
+			};
+		};
+	};
+
+	fragment@2 {
+		target = <&i2s>;
+		__overlay__ {
+			#sound-dai-cells = <0>;
+			status = "okay";
+		};
+	};
+};
