// SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
/*
 * Copyright 2025 Josua Mayer <josua@solid-run.com>
 */

/ {
	aliases {
		/* this board does not use second phy / ethernet on SoM */
		/delete-property/ ethernet1;
	};

	leds {
		compatible = "gpio-leds";

		led-0 {
			color = <LED_COLOR_ID_GREEN>;
			default-state = "on";
			gpios = <&pinctrl RZG2L_GPIO(0, 1) GPIO_ACTIVE_LOW>;
			label = "D30";
		};

		led-1 {
			color = <LED_COLOR_ID_GREEN>;
			default-state = "on";
			gpios = <&pinctrl RZG2L_GPIO(47, 2) GPIO_ACTIVE_LOW>;
			label = "D31";
		};

		led-2 {
			color = <LED_COLOR_ID_GREEN>;
			default-state = "on";
			gpios = <&pinctrl RZG2L_GPIO(47, 1) GPIO_ACTIVE_LOW>;
			label = "D32";
		};

		led-3 {
			color = <LED_COLOR_ID_GREEN>;
			default-state = "on";
			gpios = <&pinctrl RZG2L_GPIO(48, 2) GPIO_ACTIVE_LOW>;
			label = "D33";
		};

		led-4 {
			color = <LED_COLOR_ID_GREEN>;
			default-state = "on";
			gpios = <&pinctrl RZG2L_GPIO(7, 2) GPIO_ACTIVE_LOW>;
			label = "D34";
		};
	};

	rfkill-mpcie {
		/* rfkill-gpio inverts internally */
		shutdown-gpios = <&pinctrl RZG2L_GPIO(14, 1) GPIO_ACTIVE_HIGH>;
		label = "mpcie radio";
		/*
		 * The mpcie connector only has USB,
		 * therefore this rfkill is for cellular radios only.
		 */
		radio-type = "wwan";
		compatible = "rfkill-gpio";
	};
};

&eth1 {
	/* this board does not use second phy / ethernet on SoM */
	status = "disabled";
};

&gpt {
	/* mikrobus header pwm pin is pwm channel 6 */
	pinctrl-0 = <&mikro_pwm_pins>;
	pinctrl-names = "default";
	status = "okay";
};

&hdmi {
	interrupts-extended = <&pinctrl RZG2L_GPIO(9, 1) IRQ_TYPE_EDGE_FALLING>;
	pd-gpios = <&pinctrl RZG2L_GPIO(3, 0) GPIO_ACTIVE_LOW>;
};

&hub_2_0 {
	reset-gpios = <&pinctrl RZG2L_GPIO(39, 1) GPIO_ACTIVE_LOW>;
};

&pinctrl {
	mpcie_rst_hog: mpcie-reset-hog {
		gpios = <RZG2L_GPIO(42, 2) GPIO_ACTIVE_LOW>;
		gpio-hog;
		line-name = "mpcie-reset";
		output-low;
	};

	mikro_pwm_pins: pinctrl-mikro-pwm-grp {
		pinmux = <RZG2L_PORT_PINMUX(41, 0, 4)>; /* GTIOC3A */
	};

	mikro_uart_pins: pinctrl-mikro-uart-grp {
		pinmux = <RZG2L_PORT_PINMUX(40, 1, 1)>, /* SCIF1_RXD */
			 <RZG2L_PORT_PINMUX(40, 0, 1)>; /* SCIF1_TXD */
	};

	usb0_vbus_pins: usb0-vbus {
		pinmux = <RZG2L_PORT_PINMUX(4, 0, 1)>; /* USB0_VBUSEN */
	};

	usb1_vbus_pins: usb1-vbus {
		pinmux = <RZG2L_PORT_PINMUX(42, 0, 1)>; /* USB1_VBUSEN */
	};
};

&usb2_phy1 {
	pinctrl-0 = <&usb1_vbus_pins>;
	pinctrl-names = "default";
};

&vmmc {
	gpios = <&pinctrl RZG2L_GPIO(4, 1) GPIO_ACTIVE_LOW>;
};

&vmpcie {
	gpios = <&pinctrl RZG2L_GPIO(17, 0) GPIO_ACTIVE_HIGH>;
};