// SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
/*
 * Device Tree file for Cirrus Logic EDB9302 board based on EP9302 SoC
 */
/dts-v1/;
#include "ep93xx.dtsi"

/ {
	#address-cells = <1>;
	#size-cells = <1>;
	compatible = "cirrus,edb9302", "cirrus,ep9301";
	model = "cirrus,edb9302";

	chosen {
	};

	memory@0 {
		device_type = "memory";
		/* should be set from ATAGS */
		reg = <0x0000000 0x800000>,
		      <0x1000000 0x800000>,
		      <0x4000000 0x800000>,
		      <0x5000000 0x800000>;
	};

	sound {
		compatible = "audio-graph-card2";
		label = "EDB93XX";
		links = <&i2s_port>;
	};

	leds {
		compatible = "gpio-leds";
		led-0 {
			label = "grled";
			gpios = <&gpio4 0 GPIO_ACTIVE_HIGH>;
			linux,default-trigger = "heartbeat";
			function = LED_FUNCTION_HEARTBEAT;
		};

		led-1 {
			label = "rdled";
			gpios = <&gpio4 1 GPIO_ACTIVE_HIGH>;
			function = LED_FUNCTION_FAULT;
		};
	};
};

&adc {
	status = "okay";
};

&ebi {
	flash@60000000 {
		compatible = "cfi-flash";
		reg = <0x60000000 0x1000000>;
		bank-width = <2>;
	};
};

&eth0 {
	phy-handle = <&phy0>;
};

&gpio0 {
	gpio-ranges = <&syscon 0 153 1>,
		      <&syscon 1 152 1>,
		      <&syscon 2 151 1>,
		      <&syscon 3 148 1>,
		      <&syscon 4 147 1>,
		      <&syscon 5 146 1>,
		      <&syscon 6 145 1>,
		      <&syscon 7 144 1>;
};

&gpio1 {
	gpio-ranges = <&syscon 0 143 1>,
		      <&syscon 1 142 1>,
		      <&syscon 2 141 1>,
		      <&syscon 3 140 1>,
		      <&syscon 4 165 1>,
		      <&syscon 5 164 1>,
		      <&syscon 6 163 1>,
		      <&syscon 7 160 1>;
};

&gpio2 {
	gpio-ranges = <&syscon 0 115 1>;
};

/* edb9302 doesn't have GPIO Port D present */
&gpio3 {
	status = "disabled";
};

&gpio4 {
	gpio-ranges = <&syscon 0 97 2>;
};

&gpio5 {
	gpio-ranges = <&syscon 1 170 1>,
		      <&syscon 2 169 1>,
		      <&syscon 3 168 1>;
};

&gpio6 {
	gpio-ranges = <&syscon 0 87 2>;
};

&gpio7 {
	gpio-ranges = <&syscon 2 199 4>;
};

&i2s {
	pinctrl-names = "default";
	pinctrl-0 = <&i2s_on_ac97_pins>;
	status = "okay";
	i2s_port: port {
		i2s_ep: endpoint {
			system-clock-direction-out;
			frame-master;
			bitclock-master;
			mclk-fs = <256>;
			dai-format = "i2s";
			convert-channels = <2>;
			convert-sample-format = "s32_le";
			remote-endpoint = <&codec_ep>;
		};
	};
};

&mdio0 {
	phy0: ethernet-phy@1 {
		reg = <1>;
		device_type = "ethernet-phy";
	};
};

&spi0 {
	cs-gpios = <&gpio0 6 GPIO_ACTIVE_LOW
		    &gpio0 7 GPIO_ACTIVE_LOW>;
	dmas = <&dma1 10 2>, <&dma1 10 1>;
	dma-names = "rx", "tx";
	status = "okay";

	cs4271: codec@0 {
		compatible = "cirrus,cs4271";
		reg = <0>;
		#sound-dai-cells = <0>;
		spi-max-frequency = <6000000>;
		spi-cpol;
		spi-cpha;
		reset-gpios = <&gpio0 1 GPIO_ACTIVE_LOW>;
		port {
			codec_ep: endpoint {
				remote-endpoint = <&i2s_ep>;
			};
		};
	};

	at25f1024: eeprom@1 {
		compatible = "atmel,at25";
		reg = <1>;
		address-width = <8>;
		size = <0x20000>;
		pagesize = <256>;
		spi-max-frequency = <20000000>;
	};
};

&uart0 {
	status = "okay";
};

&uart1 {
	status = "okay";
};

&usb0 {
	status = "okay";
};
