// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
/*
 * Copyright (c) 2020 Rockchip Electronics Co., Ltd.
 *
 */

#include "rk3566-evb2-lp4x-v10.dtsi"
#include "rk3568-android.dtsi"

/ {
	model = "Rockchip RK3566 EVB2 LP4X V10 Board PDM Mic Array";
	compatible = "rockchip,rk3566-evb2-lp4x-v10", "rockchip,rk3566";

	rk809_sound_micarray: rk809-sound-micarray {
		compatible = "simple-audio-card";
		simple-audio-card,format = "i2s";
		simple-audio-card,name = "rockchip,rk809-codec";
		simple-audio-card,mclk-fs = <256>;

		simple-audio-card,dai-link@0 {
			format = "i2s";
			cpu {
				sound-dai = <&i2s1_8ch>;
			};
			codec {
				sound-dai = <&rk809_codec 0>;
			};
		};
		simple-audio-card,dai-link@1 {
			format = "pdm";
			cpu {
				sound-dai = <&pdm>;
			};
			codec {
				sound-dai = <&rk809_codec 1>;
			};
		};
		simple-audio-card,dai-link@2 {
			format = "pdm";
			cpu {
				sound-dai = <&pdm>;
			};
			codec {
				sound-dai = <&es7202>;
			};
		};
	};
};

&i2c3 {
	status = "okay";

	es7202: es7202@30 {
		status = "okay";
		#sound-dai-cells = <0>;
		compatible = "ES7202_PDM_ADC_1";
		reg = <0x30>;
	};

	es7202_31: es7202@31 {
		status = "okay";
		#sound-dai-cells = <0>;
		compatible = "ES7202_PDM_ADC_2";
		reg = <0x31>;
	};
};

&i2s1_8ch {
	status = "okay";
	#sound-dai-cells = <0>;
	rockchip,clk-trcm = <1>;
	pinctrl-names = "default";
	pinctrl-0 = <&i2s1m0_sclktx
		     &i2s1m0_lrcktx
		     &i2s1m0_sdo0>;
};

&pdm {
	status = "okay";
	#sound-dai-cells = <0>;
	pinctrl-names = "default";
	pinctrl-0 = <&pdmm0_clk
			&pdmm0_clk1
			&pdmm0_sdi0
			&pdmm0_sdi1
			&pdmm0_sdi2
			&pdmm0_sdi3>;
};

&rk809_codec {
	#sound-dai-cells = <1>;
	compatible = "rockchip,rk809-codec", "rockchip,rk817-codec";
	clocks = <&cru I2S1_MCLKOUT>;
	clock-names = "mclk";
	assigned-clocks = <&cru I2S1_MCLKOUT>, <&cru I2S1_MCLK_TX_IOE>;
	assigned-clock-rates = <12288000>;
	assigned-clock-parents = <&cru I2S1_MCLKOUT_TX>, <&cru I2S1_MCLKOUT_TX>;
	pinctrl-names = "default";
	pinctrl-0 = <&i2s1m0_mclk>;
	pdmdata-out-enable;
	adc-for-loopback;
	hp-volume = <20>;
	spk-volume = <3>;
	mic-in-differential;
	status = "okay";
};

&rk809_sound {
	status = "disabled";
};

