/dts-v1/;
/plugin/;

#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/pinctrl/rockchip.h>

/*
 * Device tree overlay to disabled internal analog codec for
 * rk3328 boards and enable external i2s, binding it to a
 * pcm5102-based DAC.
 * Tested on rock-pi E, but should be suitable for other
 * similar boards
 */

&{/} {

	pcm5102: pcm510x {
		#sound-dai-cells = <0>;
		compatible = "ti,pcm5102a";
		pcm510x,format = "i2s";
		status = "okay";
	};

	i2s_sound: i2s-sound {
		compatible = "simple-audio-card";
		simple-audio-card,format = "i2s";
		simple-audio-card,mclk-fs = <256>;
		simple-audio-card,name = "I2S";
		status = "okay";

		simple-audio-card,cpu {
			sound-dai = <&i2s1>;
		};

		simple-audio-card,codec {
			sound-dai = <&pcm5102>;
		};
	};

};

&analog_sound {
	status = "disabled";
};

&codec {
	status = "disabled";
};

&i2s1_mclk {
	rockchip,pins = <2 RK_PB7 1 &pcfg_pull_down>;
};

&i2s1_sclk {
	rockchip,pins = <2 RK_PC2 1 &pcfg_pull_down>;
};

&i2s1_lrckrx {
	rockchip,pins = <2 RK_PC0 1 &pcfg_pull_up>;
};

&i2s1_lrcktx {
	rockchip,pins = <2 RK_PC1 1 &pcfg_pull_up>;
};

&i2s1_sdi {
	rockchip,pins = <2 RK_PC3 1 &pcfg_pull_up>;
};

&i2s1_sdo {
	rockchip,pins = <2 RK_PC7 1 &pcfg_pull_up>;
};

&i2s1_sdio1 {
	rockchip,pins = <2 RK_PC4 1 &pcfg_pull_up>;
};

&i2s1_sdio2 {
	rockchip,pins = <2 RK_PC5 1 &pcfg_pull_up>;
};

&i2s1_sdio3 {
	rockchip,pins = <2 RK_PC6 1 &pcfg_pull_up>;
};

&i2s1_sleep {
	rockchip,pins =
	<2 RK_PB7 RK_FUNC_GPIO &pcfg_input_high>,
	<2 RK_PC0 RK_FUNC_GPIO &pcfg_input_high>,
	<2 RK_PC1 RK_FUNC_GPIO &pcfg_input_high>,
	<2 RK_PC2 RK_FUNC_GPIO &pcfg_input_high>,
	<2 RK_PC3 RK_FUNC_GPIO &pcfg_input_high>,
	<2 RK_PC4 RK_FUNC_GPIO &pcfg_input_high>,
	<2 RK_PC5 RK_FUNC_GPIO &pcfg_input_high>,
	<2 RK_PC6 RK_FUNC_GPIO &pcfg_input_high>,
	<2 RK_PC7 RK_FUNC_GPIO &pcfg_input_high>;
};

&i2s1 {
	status = "okay";
	pinctrl-names = "default";
	pinctrl-0 = <&i2s1_mclk>, <&i2s1_sclk>, <&i2s1_lrckrx>, <&i2s1_lrcktx>, <&i2s1_sdi>, <&i2s1_sdo>, <&i2s1_sdio1>, <&i2s1_sdio2>;
	rockchip,playback-channels = <8>;
};
