From 2f656dc533b65ae7f23527c3dc176efa92add105 Mon Sep 17 00:00:00 2001
From: j-schambacher <joerg@hifiberry.com>
Date: Tue, 20 Aug 2024 10:24:10 +0200
Subject: [PATCH 1229/1350] overlays: Add overlay for Hifiberry ADC

Adds the DT overlay for the HiFiBerry ADC.

Signed-off-by: j-schambacher <joerg@hifiberry.com>
---
 arch/arm/boot/dts/overlays/Makefile           |  1 +
 arch/arm/boot/dts/overlays/README             |  7 +++
 .../dts/overlays/hifiberry-adc-overlay.dts    | 45 +++++++++++++++++++
 sound/soc/bcm/Kconfig                         |  1 +
 4 files changed, 54 insertions(+)
 create mode 100644 arch/arm/boot/dts/overlays/hifiberry-adc-overlay.dts

--- a/arch/arm/boot/dts/overlays/Makefile
+++ b/arch/arm/boot/dts/overlays/Makefile
@@ -85,6 +85,7 @@ dtbo-$(CONFIG_ARCH_BCM2835) += \
 	hd44780-i2c-lcd.dtbo \
 	hd44780-lcd.dtbo \
 	hdmi-backlight-hwhack-gpio.dtbo \
+	hifiberry-adc.dtbo \
 	hifiberry-amp.dtbo \
 	hifiberry-amp100.dtbo \
 	hifiberry-amp3.dtbo \
--- a/arch/arm/boot/dts/overlays/README
+++ b/arch/arm/boot/dts/overlays/README
@@ -1771,6 +1771,13 @@ Params: gpio_pin                GPIO pin
                                 expects a high to switch it on.
 
 
+Name:   hifiberry-adc
+Info:   Configures the HifiBerry ADC audio card
+Load:   dtoverlay=hifiberry-adc,<param>=<val>
+Params: leds_off                If set to 'true' the onboard indicator LED
+                                is switched off at all times.
+
+
 Name:   hifiberry-amp
 Info:   Configures the HifiBerry Amp and Amp+ audio cards
 Load:   dtoverlay=hifiberry-amp
--- /dev/null
+++ b/arch/arm/boot/dts/overlays/hifiberry-adc-overlay.dts
@@ -0,0 +1,45 @@
+// SPDX-License-Identifier: GPL-2.0
+// Definitions for HiFiBerry ADC, no onboard clocks
+/dts-v1/;
+/plugin/;
+
+/ {
+	compatible = "brcm,bcm2835";
+
+	fragment@0 {
+		target = <&i2s_clk_producer>;
+		__overlay__ {
+			status = "okay";
+		};
+	};
+
+	fragment@1 {
+		target = <&i2c1>;
+		__overlay__ {
+			#address-cells = <1>;
+			#size-cells = <0>;
+			status = "okay";
+
+			hb_adc: pcm186x@4a {
+				#sound-dai-cells = <0>;
+				compatible = "ti,pcm1863";
+				reg = <0x4a>;
+				status = "okay";
+			};
+		};
+	};
+
+	fragment@2 {
+		target = <&sound>;
+		hifiberry_adc: __overlay__ {
+			compatible = "hifiberry,hifiberry-adc";
+			audio-codec = <&hb_adc>;
+			i2s-controller = <&i2s_clk_producer>;
+			status = "okay";
+		};
+	};
+
+	__overrides__ {
+		leds_off = <&hifiberry_adc>,"hifiberry-adc,leds_off?";
+	};
+};
--- a/sound/soc/bcm/Kconfig
+++ b/sound/soc/bcm/Kconfig
@@ -45,6 +45,7 @@ config SND_BCM2708_SOC_HIFIBERRY_ADC
         select SND_RPI_HIFIBERRY_ADC
         help
          Say Y or M if you want to add support for HifiBerry ADC.
+         Use this module for HiFiBerry's ADC-only sound cards
 
 config SND_BCM2708_SOC_HIFIBERRY_DAC
         tristate "Support for HifiBerry DAC and DAC8X"
