From d787ecf50d7a6ec32f8e1afcb8559600396c0f45 Mon Sep 17 00:00:00 2001
From: Ben Payne <ben@bluerocksoft.com>
Date: Tue, 13 Feb 2024 14:56:28 -0800
Subject: [PATCH 1277/1295] Add overlays needed for Interlude Audio Digital and
 Analog hats

Adding 2 new overlays for use with
Interlude Audio's Digital and Analog hats
adding descriptions for both in README
adding changes to Makefile to include both DT's
---
 arch/arm/boot/dts/overlays/Makefile           |  2 +
 arch/arm/boot/dts/overlays/README             | 12 +++
 .../interludeaudio-analog-overlay.dts         | 73 +++++++++++++++++++
 .../interludeaudio-digital-overlay.dts        | 49 +++++++++++++
 4 files changed, 136 insertions(+)
 create mode 100644 arch/arm/boot/dts/overlays/interludeaudio-analog-overlay.dts
 create mode 100644 arch/arm/boot/dts/overlays/interludeaudio-digital-overlay.dts

--- a/arch/arm/boot/dts/overlays/Makefile
+++ b/arch/arm/boot/dts/overlays/Makefile
@@ -131,6 +131,8 @@ dtbo-$(CONFIG_ARCH_BCM2835) += \
 	imx477.dtbo \
 	imx519.dtbo \
 	imx708.dtbo \
+	interludeaudio-analog.dtbo \
+	interludeaudio-digital.dtbo \
 	iqaudio-codec.dtbo \
 	iqaudio-dac.dtbo \
 	iqaudio-dacplus.dtbo \
--- a/arch/arm/boot/dts/overlays/README
+++ b/arch/arm/boot/dts/overlays/README
@@ -2708,6 +2708,18 @@ Params: rotation                Mounting
                                 450000000 (default), 447000000, 453000000.
 
 
+Name:   interludeaudio-analog
+Info:   Configures Interlude Audio Analog Hat audio card
+Load:   dtoverlay=interludeaudio-analog,<param>=<val>
+Params: gpiopin                 GPIO pin for codec reset
+
+
+Name:   interludeaudio-digital
+Info:   Configures Interlude Audio Digital Hat audio card
+Load:   dtoverlay=interludeaudio-digital
+Params: <None>
+
+
 Name:   iqaudio-codec
 Info:   Configures the IQaudio Codec audio card
 Load:   dtoverlay=iqaudio-codec
--- /dev/null
+++ b/arch/arm/boot/dts/overlays/interludeaudio-analog-overlay.dts
@@ -0,0 +1,73 @@
+// Definitions for Interlude audio analog hat
+/dts-v1/;
+/plugin/;
+
+/ {
+	compatible = "brcm,bcm2835";
+
+	fragment@0 {
+		target = <&sound>;
+		__overlay__ {
+			compatible = "simple-audio-card";
+			i2s-controller = <&i2s_clk_consumer>;
+			status = "okay";
+
+			simple-audio-card,name = "snd_IA_Analog_Hat";
+
+			simple-audio-card,widgets =
+				"Line", "Line In",
+				"Line", "Line Out";
+
+			simple-audio-card,routing =
+				"Line Out","AOUTA+",
+				"Line Out","AOUTA-",
+				"Line Out","AOUTB+",
+				"Line Out","AOUTB-",
+				"AINA","Line In",
+				"AINB","Line In";
+
+			simple-audio-card,format = "i2s";
+
+			simple-audio-card,bitclock-master = <&sound_master>;
+			simple-audio-card,frame-master = <&sound_master>;
+
+			simple-audio-card,cpu {
+				sound-dai = <&i2s>;
+				dai-tdm-slot-num = <2>;
+				dai-tdm-slot-width = <32>;
+			};
+
+			sound_master: simple-audio-card,codec {
+				sound-dai = <&cs4271>;
+				system-clock-frequency = <24576000>;
+			};
+		};
+	};
+
+	fragment@1 {
+		target = <&i2s_clk_consumer>;
+		__overlay__ {
+			status = "okay";
+		};
+	};
+
+	fragment@2 {
+		target = <&i2c1>;
+		__overlay__ {
+			#address-cells = <1>;
+			#size-cells = <0>;
+			status = "okay";
+
+			cs4271: cs4271@10 {
+				#sound-dai-cells = <0>;
+				compatible = "cirrus,cs4271";
+				reg = <0x10>;
+				status = "okay";
+				reset-gpio = <&gpio 24 0>; /* Pin 26, active high */
+			};
+		};
+	};
+	__overrides__ {
+		gpiopin = <&cs4271>,"reset-gpio:4";
+	};
+};
--- /dev/null
+++ b/arch/arm/boot/dts/overlays/interludeaudio-digital-overlay.dts
@@ -0,0 +1,49 @@
+// Definitions for Interlude Audio Digital Hat
+/dts-v1/;
+/plugin/;
+
+/ {
+	compatible = "brcm,bcm2835";
+
+	fragment@0 {
+		target = <&i2s_clk_consumer>;
+		__overlay__ {
+			status = "okay";
+		};
+	};
+
+	fragment@1 {
+		target = <&i2c1>;
+		__overlay__ {
+			#address-cells = <1>;
+			#size-cells = <0>;
+			status = "okay";
+
+			wm8804@3b {
+				#sound-dai-cells = <0>;
+				compatible = "wlf,wm8804";
+				reg = <0x3b>;
+				PVDD-supply = <&vdd_3v3_reg>;
+				DVDD-supply = <&vdd_3v3_reg>;
+				status = "okay";
+			};
+		};
+	};
+
+
+	fragment@2 {
+		target = <&sound>;
+		__overlay__ {
+			compatible = "interludeaudio,interludeaudio-digital";
+			i2s-controller = <&i2s_clk_consumer>;
+			status = "okay";
+			clock44-gpio = <&gpio 22 0>;
+			clock48-gpio = <&gpio 27 0>;
+			led1-gpio = <&gpio 13 0>;
+			led2-gpio = <&gpio 12 0>;
+			led3-gpio = <&gpio 6 0>;
+			reset-gpio = <&gpio 23 0>;
+		};
+	};
+
+};
