// SPDX-License-Identifier: GPL-2.0+ OR MIT
/*
 * Copyright (C) 2024 Kontron Electronics GmbH
 */

/dts-v1/;

#include "imx93-kontron-osm-s.dtsi"

/ {
	model = "Kontron BL i.MX93 OSM-S";
	compatible = "kontron,imx93-bl-osm-s", "kontron,imx93-osm-s", "fsl,imx93";

	aliases {
		ethernet0 = &fec;
		ethernet1 = &eqos;
		gpio0 = &gpio1;
		gpio1 = &gpio2;
		i2c0 = &lpi2c1;
		i2c1 = &lpi2c2;
		mmc0 = &usdhc1;
		mmc1 = &usdhc2;
		serial0 = &lpuart1;
		serial1 = &lpuart2;
		serial2 = &lpuart3;
		serial3 = &lpuart4;
		serial4 = &lpuart5;
		serial5 = &lpuart6;
		serial6 = &lpuart7;
		spi0 = &lpspi1;
		spi1 = &lpspi2;
		spi2 = &lpspi3;
		spi3 = &lpspi4;
		spi4 = &lpspi5;
		spi5 = &lpspi6;
		spi6 = &lpspi7;
		spi7 = &lpspi8;
	};

	leds {
		compatible = "gpio-leds";

		led1 {
			label = "led1";
			gpios = <&gpio2 3 GPIO_ACTIVE_HIGH>;
			linux,default-trigger = "heartbeat";
		};
	};

	pwm-beeper {
		compatible = "pwm-beeper";
		pwms = <&tpm6 1 5000 0>;
	};

	reg_vcc_panel: regulator-vcc-panel {
		compatible = "regulator-fixed";
		pinctrl-names = "default";
		pinctrl-0 = <&pinctrl_reg_vcc_panel>;
		gpio = <&gpio2 21 GPIO_ACTIVE_HIGH>;
		enable-active-high;
		regulator-max-microvolt = <3300000>;
		regulator-min-microvolt = <3300000>;
		regulator-name = "VCC_PANEL";
	};
};

&eqos { /* Second ethernet (OSM-S ETH_B) */
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_eqos_rgmii>;
	phy-mode = "rgmii-id";
	phy-handle = <&ethphy1>;
	status = "okay";

	mdio {
		compatible = "snps,dwmac-mdio";
		#address-cells = <1>;
		#size-cells = <0>;

		ethphy1: ethernet-phy@1 {
			compatible = "ethernet-phy-id4f51.e91b";
			reg = <1>;
			reset-assert-us = <10000>;
			reset-gpios = <&gpio1 10 GPIO_ACTIVE_LOW>;
		};
	};
};

&fec { /* First ethernet (OSM-S ETH_A) */
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_enet_rgmii>;
	phy-connection-type = "rgmii-id";
	phy-handle = <&ethphy0>;
	status = "okay";

	mdio {
		#address-cells = <1>;
		#size-cells = <0>;

		ethphy0: ethernet-phy@1 {
			compatible = "ethernet-phy-id4f51.e91b";
			reg = <1>;
			reset-assert-us = <10000>;
			reset-gpios = <&gpio2 18 GPIO_ACTIVE_LOW>;
		};
	};
};

&flexcan1 {
	status = "okay";
};

&lpi2c2 {
	status = "okay";

	gpio_expander_dio: gpio@20 {
		compatible = "ti,tca6408";
		reg = <0x20>;
		gpio-controller;
		#gpio-cells = <2>;
		gpio-line-names = "DIO1_OUT","DIO1_IN", "DIO2_OUT","DIO2_IN",
				  "DIO3_OUT","DIO3_IN", "DIO4_OUT","DIO4_IN";
		interrupt-parent = <&gpio4>;
		interrupts = <28 IRQ_TYPE_EDGE_FALLING>;
		reset-gpios = <&gpio2 2 GPIO_ACTIVE_LOW>;
	};
};

&lpspi8 {
	assigned-clocks = <&clk IMX93_CLK_LPSPI8>;
	assigned-clock-parents = <&clk IMX93_CLK_SYS_PLL_PFD0_DIV2>;
	assigned-clock-rates = <100000000>;
	status = "okay";

	eeram@0 {
		compatible = "microchip,48l640";
		reg = <0>;
		spi-max-frequency = <20000000>;
	};
};

&lpuart1 {
	status = "okay";
};

&lpuart7 {
	uart-has-rtscts;
	status = "okay";
};

&lpuart6 {
	linux,rs485-enabled-at-boot-time;
	uart-has-rtscts;
	status = "okay";
};

&tpm6 {
	status = "okay";
};

&usbotg1 {
	disable-over-current;
	dr_mode = "peripheral";
	status = "okay";
};

&usbotg2 {
	#address-cells = <1>;
	#size-cells = <0>;
	disable-over-current;
	dr_mode = "host";
	status = "okay";

	usb1@1 {
		compatible = "usb424,2514";
		reg = <1>;
	};
};

&usdhc2 {
	vmmc-supply = <&reg_vdd_3v3>;
	status = "okay";
};

&iomuxc {
	pinctrl_reg_vcc_panel: regvccpanelgrp {
		fsl,pins = <
			MX93_PAD_GPIO_IO21__GPIO2_IO21		0x31e /* PWM_2 */
		>;
	};
};