// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
/*
 * Copyright (c) 2022 AmadeusGhost <amadeus@jmu.edu.cn>
 */

/dts-v1/;
#include "rk3568-mrkaio-m68s.dtsi"

/ {
	model = "EZPRO Mrkaio M68S";
	compatible = "ezpro,mrkaio-m68s", "rockchip,rk3568";

	aliases {
		ethernet0 = &gmac0;
		ethernet1 = &gmac1;

		led-boot = &power_led;
		led-failsafe = &power_led;
		led-running = &power_led;
		led-upgrade = &power_led;
	};

	gpio-leds {
		compatible = "gpio-leds";
		pinctrl-names = "default";
		pinctrl-0 = <&power_led_pin>, <&sata_led_pin>;

		power_led: led-power {
			label = "red:power";
			gpios = <&gpio4 RK_PC4 GPIO_ACTIVE_HIGH>;
		};

		led-sata {
			label = "blue:sata";
			gpios = <&gpio0 RK_PC2 GPIO_ACTIVE_HIGH>;
			linux,default-trigger = "disk-activity";
		};
	};

	switch_otg: switch-otg-regulator {
		compatible = "regulator-fixed";
		gpio = <&gpio0 RK_PD6 GPIO_ACTIVE_LOW>;
		pinctrl-names = "default";
		pinctrl-0 = <&usb_otg_switch_en>;
		regulator-name = "switch_otg";
		regulator-always-on;
	};

	vcc5v0_ahci: vcc5v0-ahci-regulator {
		compatible = "regulator-fixed";
		enable-active-high;
		gpio = <&gpio0 RK_PB6 GPIO_ACTIVE_HIGH>;
		pinctrl-names = "default";
		pinctrl-0 = <&sata_pwr_en>;
		regulator-always-on;
		regulator-boot-on;
		regulator-min-microvolt = <5000000>;
		regulator-max-microvolt = <5000000>;
		regulator-name = "vcc5v0_ahci";
	};
};

&gmac0 {
	assigned-clocks = <&cru SCLK_GMAC0_RX_TX>, <&cru SCLK_GMAC0>;
	assigned-clock-parents = <&cru SCLK_GMAC0_RGMII_SPEED>;
	assigned-clock-rates = <0>, <125000000>;
	clock_in_out = "output";
	phy-mode = "rgmii-id";
	pinctrl-names = "default";
	pinctrl-0 = <&gmac0_miim
		     &gmac0_tx_bus2
		     &gmac0_rx_bus2
		     &gmac0_rgmii_clk
		     &gmac0_rgmii_bus>;
	snps,reset-gpio = <&gpio3 RK_PA6 GPIO_ACTIVE_LOW>;
	snps,reset-active-low;
	/* Reset time is 20ms, 100ms for rtl8211f */
	snps,reset-delays-us = <0 20000 100000>;
	tx_delay = <0x3c>;
	rx_delay = <0x2f>;
	phy-handle = <&rgmii_phy0>;
	status = "okay";
};

&gmac1 {
	assigned-clocks = <&cru SCLK_GMAC1_RX_TX>, <&cru SCLK_GMAC1>;
	assigned-clock-parents = <&cru SCLK_GMAC1_RGMII_SPEED>;
	assigned-clock-rates = <0>, <125000000>;
	clock_in_out = "output";
	phy-mode = "rgmii-id";
	pinctrl-names = "default";
	pinctrl-0 = <&gmac1m1_miim
		     &gmac1m1_tx_bus2
		     &gmac1m1_rx_bus2
		     &gmac1m1_rgmii_clk
		     &gmac1m1_rgmii_bus>;
	snps,reset-gpio = <&gpio3 RK_PA7 GPIO_ACTIVE_LOW>;
	snps,reset-active-low;
	/* Reset time is 20ms, 100ms for rtl8211f */
	snps,reset-delays-us = <0 20000 100000>;
	tx_delay = <0x42>;
	rx_delay = <0x28>;
	phy-handle = <&rgmii_phy1>;
	status = "okay";
};

&mdio0 {
	rgmii_phy0: ethernet-phy@0 {
		compatible = "ethernet-phy-ieee802.3-c22";
		reg = <0>;
	};
};

&mdio1 {
	rgmii_phy1: ethernet-phy@0 {
		compatible = "ethernet-phy-ieee802.3-c22";
		reg = <0>;
	};
};

&pinctrl {
	leds {
		power_led_pin: power-led-pin {
			rockchip,pins = <4 RK_PC4 RK_FUNC_GPIO &pcfg_pull_none>;
		};

		sata_led_pin: sata-led-pin {
			rockchip,pins = <0 RK_PC2 RK_FUNC_GPIO &pcfg_pull_none>;
		};
	};

	sata {
		sata_pwr_en: sata-pwr-en {
			rockchip,pins = <0 RK_PB6 RK_FUNC_GPIO &pcfg_pull_none>;
		};
	};

	usb {
		vcc5v0_usb_host_en: vcc5v0-usb-host-en {
			rockchip,pins = <0 RK_PA5 RK_FUNC_GPIO &pcfg_pull_none>;
		};

		vcc5v0_usb_otg_en: vcc5v0-usb-otg-en {
			rockchip,pins = <0 RK_PA6 RK_FUNC_GPIO &pcfg_pull_none>;
		};

		usb_otg_switch_en: usb-otg-switch-en {
			rockchip,pins = <0 RK_PD6 RK_FUNC_GPIO &pcfg_pull_none>;
		};
	};
};

&sata2 {
	target-supply = <&vcc5v0_ahci>;
	status = "okay";
};
