// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
/*
 * Copyright (c) Toradex
 *
 * Common dtsi for Verdin iMX95 SoM on development carrier board
 *
 * https://www.toradex.com/computer-on-modules/verdin-arm-family/nxp-imx95
 * https://www.toradex.com/products/carrier-board/verdin-development-board-kit
 */

/ {
	aliases {
		eeprom1 = &carrier_eeprom;
	};

	sound {
		compatible = "simple-audio-card";
		simple-audio-card,bitclock-master = <&codec_dai>;
		simple-audio-card,format = "i2s";
		simple-audio-card,frame-master = <&codec_dai>;
		simple-audio-card,mclk-fs = <256>;
		simple-audio-card,name = "verdin-nau8822";
		simple-audio-card,routing =
			"Headphones", "LHP",
			"Headphones", "RHP",
			"Speaker", "LSPK",
			"Speaker", "RSPK",
			"Line Out", "AUXOUT1",
			"Line Out", "AUXOUT2",
			"LAUX", "Line In",
			"RAUX", "Line In",
			"LMICP", "Mic In",
			"RMICP", "Mic In";
		simple-audio-card,widgets =
			"Headphones", "Headphones",
			"Line Out", "Line Out",
			"Speaker", "Speaker",
			"Microphone", "Mic In",
			"Line", "Line In";

		codec_dai: simple-audio-card,codec {
			clocks = <&scmi_clk IMX95_CLK_SAI3>;
			sound-dai = <&nau8822_1a>;
		};

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

/* Verdin ADC_1, ADC_2, ADC_3 and ADC_4 */
&adc1 {
	status = "okay";
};

/* Verdin ETH_1 (On-module PHY) */
&enetc_port0 {
	status = "okay";
};

/* Verdin ETH_2_RGMII */
&enetc_port1 {
	phy-handle = <&ethphy2>;
	phy-mode = "rgmii-id";
	status = "okay";
};

/* Verdin QSPI_1 */
&flexspi1 {
	status = "okay";
};

&gpio1 {
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_ctrl_sleep_moci>;
};

&gpio2 {
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_gpio1>,
		    <&pinctrl_gpio2>,
		    <&pinctrl_gpio3>;
};

&gpio3 {
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_gpio6>;
};

&gpio4 {
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_gpio5>;
};

&gpio5 {
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_gpio4>;
};

/* Verdin I2C_3_HDMI */
&i3c2 {
	status = "okay";
};

/* Verdin I2C_2_DSI */
&lpi2c3 {
	status = "okay";
};

/* Verdin I2C_1 */
&lpi2c4 {
	status = "okay";

	nau8822_1a: audio-codec@1a {
		compatible = "nuvoton,nau8822";
		reg = <0x1a>;
		pinctrl-names = "default";
		pinctrl-0 = <&pinctrl_sai3_mclk>;
		#sound-dai-cells = <0>;
	};

	carrier_gpio_expander: gpio@21 {
		compatible = "nxp,pcal6416";
		reg = <0x21>;
		#gpio-cells = <2>;
		gpio-controller;
	};

	/* Current measurement into module VCC */
	hwmon@40 {
		compatible = "ti,ina219";
		reg = <0x40>;
		shunt-resistor = <10000>;
	};

	temperature-sensor@4f {
		compatible = "ti,tmp75c";
		reg = <0x4f>;
	};

	carrier_eeprom: eeprom@57 {
		compatible = "st,24c02", "atmel,24c02";
		reg = <0x57>;
		pagesize = <16>;
	};
};

/* Verdin I2C_4_CSI */
&lpi2c5 {
	status = "okay";
};

/* Verdin UART_3, used as the Linux console */
&lpuart1 {
	status = "okay";
};

/* Verdin UART_4 */
&lpuart2 {
	status = "okay";
};

/* Verdin UART_1, connector X50 through RS485 transceiver */
&lpuart7 {
	rs485-rts-active-low;
	rs485-rx-during-tx;
	linux,rs485-enabled-at-boot-time;

	status = "okay";
};

/* Verdin UART_2 */
&lpuart8 {
	status = "okay";
};

&netc_emdio {
	ethphy2: ethernet-phy@7 {
		compatible = "ethernet-phy-ieee802.3-c22";
		reg = <7>;
		pinctrl-names = "default";
		pinctrl-0 = <&pinctrl_eth2_rgmii_int>;
		interrupt-parent = <&gpio1>;
		interrupts = <12 IRQ_TYPE_LEVEL_LOW>;
		micrel,led-mode = <0>;
	};
};

/* Verdin PCIE_1 */
&pcie0 {
	status = "okay";
};

/* Verdin I2S_1 */
&sai3 {
	status = "okay";
};

/* Verdin PWM_1 */
&tpm4 {
	status = "okay";
};

/* Verdin PWM_2 */
&tpm5 {
	status = "okay";
};

/* Verdin PWM_3_DSI */
&tpm6 {
	status = "okay";
};

/* Verdin USB_1 */
&usb2 {
	status = "okay";
};

/* Verdin USB_2 */
&usb3 {
	fsl,permanently-attached;

	status = "okay";
};

&usb3_phy {
	status = "okay";
};

/* Verdin SD_1 */
&usdhc2 {
	status = "okay";
};

/* Verdin CTRL_WAKE1_MICO# */
&verdin_gpio_keys {
	status = "okay";
};
