// SPDX-License-Identifier: GPL-2.0-only
/*
 * Support for CompuLab SBC-AM57x single board computer
 *
 * Copyright (C) 2015 CompuLab Ltd. - https://www.compulab.co.il/
 * Author: Dmitry Lifshitz <lifshitz@compulab.co.il>
 */

#include "am57xx-cl-som-am57x.dts"
#include "compulab-sb-som.dtsi"

/ {
	model = "CompuLab CL-SOM-AM57x on SB-SOM-AM57x";
	compatible = "compulab,sbc-am57x", "compulab,cl-som-am57x", "ti,am5728", "ti,dra742", "ti,dra74", "ti,dra7";

	aliases {
		display0 = &lcd0;
		display1 = &hdmi;
	};
};

&dra7_pmx_core {
	uart3_pins_default: uart3-default-pins {
		pinctrl-single,pins = <
			DRA7XX_CORE_IOPAD(0x3648, PIN_INPUT_SLEW | MUX_MODE0)	/* uart3_rxd */
			DRA7XX_CORE_IOPAD(0x364c, PIN_INPUT_SLEW | MUX_MODE0)	/* uart3_txd */
		>;
	};

	mmc1_pins_default: mmc1-default-pins {
		pinctrl-single,pins = <
			DRA7XX_CORE_IOPAD(0x3754, PIN_INPUT_PULLUP | MUX_MODE0) /* mmc1_clk.clk */
			DRA7XX_CORE_IOPAD(0x3758, PIN_INPUT_PULLUP | MUX_MODE0)	/* mmc1_cmd.cmd */
			DRA7XX_CORE_IOPAD(0x375c, PIN_INPUT_PULLUP | MUX_MODE0) /* mmc1_dat0.dat0 */
			DRA7XX_CORE_IOPAD(0x3760, PIN_INPUT_PULLUP | MUX_MODE0) /* mmc1_dat1.dat1 */
			DRA7XX_CORE_IOPAD(0x3764, PIN_INPUT_PULLUP | MUX_MODE0) /* mmc1_dat2.dat2 */
			DRA7XX_CORE_IOPAD(0x3768, PIN_INPUT_PULLUP | MUX_MODE0) /* mmc1_dat3.dat3 */
			DRA7XX_CORE_IOPAD(0x376c, PIN_INPUT | MUX_MODE14)	/* mmc1_sdcd.gpio6_27 */
			DRA7XX_CORE_IOPAD(0x377c, PIN_INPUT | MUX_MODE14)	/* mmc1_sdwp.gpio6_28 */
		>;
	};

	usb1_pins: usb1-pins {
		pinctrl-single,pins = <
			DRA7XX_CORE_IOPAD(0x3680, PIN_INPUT_SLEW | MUX_MODE0) /* usb1_drvvbus */
		>;
	};

	i2c5_pins_default: i2c5-default-pins {
		pinctrl-single,pins = <
			DRA7XX_CORE_IOPAD(0x36b4, PIN_INPUT| MUX_MODE10)	/* mcasp1_axr0.i2c5_sda */
			DRA7XX_CORE_IOPAD(0x36b8, PIN_INPUT| MUX_MODE10)	/* mcasp1_axr1.i2c5_scl */
		>;
	};

	lcd_pins_default: lcd-default-pins {
		pinctrl-single,pins = <
			DRA7XX_CORE_IOPAD(0x3564, PIN_OUTPUT | MUX_MODE14)      /* vin2a_vsync0.gpio4_0 */
		>;
	};

	hdmi_pins: hdmi-pins {
		pinctrl-single,pins = <
			DRA7XX_CORE_IOPAD(0x3808, PIN_INPUT | MUX_MODE1)	/* i2c2_sda.hdmi1_ddc_scl */
			DRA7XX_CORE_IOPAD(0x380c, PIN_INPUT | MUX_MODE1)	/* i2c2_scl.hdmi1_ddc_sda */
		>;
	};

	hdmi_conn_pins: hdmi-conn-pins {
		pinctrl-single,pins = <
			DRA7XX_CORE_IOPAD(0x37b8, PIN_INPUT | MUX_MODE14)	/* spi1_cs2.gpio7_12 */
		>;
	};
};

&uart3 {
	status = "okay";
	interrupts-extended = <&crossbar_mpu GIC_SPI 69 IRQ_TYPE_LEVEL_HIGH>,
			      <&dra7_pmx_core 0x3f8>;

	pinctrl-names = "default";
	pinctrl-0 = <&uart3_pins_default>;
};

&mmc1 {
	status = "okay";

	pinctrl-names = "default";
	pinctrl-0 = <&mmc1_pins_default>;

	vmmc-supply = <&ldo1_reg>;
	bus-width = <4>;
	cd-gpios = <&gpio6 27 GPIO_ACTIVE_LOW>;
	wp-gpios = <&gpio6 28 GPIO_ACTIVE_HIGH>;
};

&usb1 {
	pinctrl-names = "default";
	pinctrl-0 = <&usb1_pins>;
};

&i2c5 {
	status = "okay";
	pinctrl-names = "default";
	pinctrl-0 = <&i2c5_pins_default>;
	clock-frequency = <400000>;

	eeprom_base: atmel@54 {
		compatible = "atmel,24c08";
		reg = <0x54>;
		pagesize = <16>;
	};

	pca9555: pca9555@20 {
		compatible = "nxp,pca9555";
		reg = <0x20>;
		gpio-controller;
		#gpio-cells = <2>;
	};
};

&dss {
	status = "okay";

	vdda_video-supply = <&ldoln_reg>;

	port {
		dpi_lcd_out: endpoint {
			remote-endpoint = <&lcd_in>;
			data-lines = <24>;
		};
	};
};

&lcd0 {
	pinctrl-names = "default";
	pinctrl-0 = <&lcd_pins_default>;

	enable-gpios = <&pca9555 14 GPIO_ACTIVE_HIGH
			&gpio4 0 GPIO_ACTIVE_HIGH>;

	port {
		lcd_in: endpoint {
			remote-endpoint = <&dpi_lcd_out>;
			data-lines = <24>;
		};
	};
};

&hdmi {
	status = "okay";
	vdda-supply = <&ldo4_reg>;

	pinctrl-names = "default";
	pinctrl-0 = <&hdmi_pins>;

	port {
		hdmi_out: endpoint {
			remote-endpoint = <&hdmi_connector_in>;
			lanes = <1 0 3 2 5 4 7 6>;
		};
	};
};

&hdmi_conn {
	pinctrl-names = "default";
	pinctrl-0 = <&hdmi_conn_pins>;

	hpd-gpios = <&gpio7 12 GPIO_ACTIVE_HIGH>;

	port {
		hdmi_connector_in: endpoint {
			remote-endpoint = <&hdmi_out>;
		};
	};
};
