// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
/*
 * Copyright 2026 Mehmet Fide
 *
 * Toradex Iris carrier board V1.1, common part for Colibri VF50 and VF61.
 *
 * The Colibri modules are pin compatible, so the carrier signals sit on the
 * same SODIMM pins as they do for the i.MX modules, whose Iris device trees
 * are already upstream. The two SODIMM pins below are taken from the Colibri
 * VFxx datasheet (102 -> PTA12 -> PORT0[5], 104 -> PTD28 -> PORT2[2]).
 *
 * An Iris V2.0 carries the same signals on the same pins, so everything here
 * works on it as well. What it adds is a regulator on SODIMM 100 that can cut
 * power to the uSD slot, which this file does not describe.
 */

/ {
	chosen {
		stdout-path = "serial0:115200n8";
	};

	reg_usbh_vbus: regulator-usbh-vbus {
		compatible = "regulator-fixed";
		pinctrl-names = "default";
		pinctrl-0 = <&pinctrl_usbh1_reg>;
		regulator-name = "VCC_USB[1-4]";
		regulator-min-microvolt = <5000000>;
		regulator-max-microvolt = <5000000>;
		gpio = <&gpio2 19 GPIO_ACTIVE_LOW>;	/* SODIMM 129, USBH_PEN */
	};
};

&gpio0 {
	/*
	 * The RS232 transceivers on the carrier are switched on by these two
	 * lines. Delete the hog to turn a transceiver off from userspace.
	 * The pin group belongs to the gpio controller rather than to iomuxc,
	 * which would depend on its own child and log a dependency cycle.
	 */
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_iris_uart1_tx_on>;

	uart1-tx-on-hog {
		gpio-hog;
		gpios = <5 GPIO_ACTIVE_HIGH>;	/* SODIMM 102 */
		output-high;
	};
};

&gpio2 {
	pinctrl-names = "default";
	/* keep the EXT_IO group from vf-colibri.dtsi alongside ours */
	pinctrl-0 = <&pinctrl_gpio_ext>, <&pinctrl_iris_uart25_tx_on>;

	uart25-tx-on-hog {
		gpio-hog;
		gpios = <2 GPIO_ACTIVE_HIGH>;	/* SODIMM 104 */
		output-high;
	};
};

&iomuxc {
	pinctrl_iris_uart1_tx_on: irisuart1txongrp {
		fsl,pins = <
			VF610_PAD_PTA12__GPIO_5		0x22ef
		>;
	};

	pinctrl_iris_uart25_tx_on: irisuart25txongrp {
		fsl,pins = <
			VF610_PAD_PTD28__GPIO_66	0x22ef
		>;
	};
};

/* Colibri SSP, on the extension connector */
&dspi1 {
	status = "okay";
};

&esdhc1 {
	status = "okay";
};

&fec1 {
	status = "okay";
};

&pwm0 {
	status = "okay";
};

&pwm1 {
	status = "okay";
};

&i2c0 {
	status = "okay";

	/* M41T0M6 real time clock on the carrier */
	rtc@68 {
		compatible = "st,m41t0";
		reg = <0x68>;
	};
};

&uart0 {
	status = "okay";
};

&uart1 {
	status = "okay";
};

&uart2 {
	status = "okay";
};

&usbdev0 {
	status = "okay";
};

&usbh1 {
	vbus-supply = <&reg_usbh_vbus>;
	status = "okay";
};