// SPDX-License-Identifier: (GPL-2.0+ OR MIT)

#include "rk3588s-nanopi.dtsi"

/ {
	adc-keys-1 {
		compatible = "adc-keys";
		io-channels = <&saradc 1>;
		io-channel-names = "buttons";
		keyup-threshold-microvolt = <1800000>;
		poll-interval = <100>;

		button-maskrom {
			label = "Recovery";
			linux,code = <KEY_VENDOR>;
			press-threshold-microvolt = <1800>;
		};
	};

	leds {
		compatible = "gpio-leds";

		sys_led: led-0 {
			label = "sys_led";
			gpios = <&gpio1 RK_PA4 GPIO_ACTIVE_HIGH>;
			linux,default-trigger = "heartbeat";
			pinctrl-names = "default";
			pinctrl-0 = <&sys_led_pin>;
		};

		user_led: led-1 {
			label = "user_led";
			gpios = <&gpio1 RK_PA6 GPIO_ACTIVE_HIGH>;
			pinctrl-names = "default";
			pinctrl-0 = <&user_led_pin>;
		};
	};

	vcc_3v3_pcie: regulator-vcc-3v3-pcie {
		compatible = "regulator-fixed";
		enable-active-high;
		gpios = <&gpio3 RK_PC6 GPIO_ACTIVE_HIGH>;
		pinctrl-names = "default";
		pinctrl-0 = <&pcie2_2_pwren>;
		regulator-name = "vcc_3v3_pcie";
		regulator-min-microvolt = <3300000>;
		regulator-max-microvolt = <3300000>;
		vin-supply = <&vcc5v0_sys>;
	};

	vcc5v0_usb_otg0: regulator-vcc5v0-usb-otg0 {
		compatible = "regulator-fixed";
		enable-active-high;
		gpios = <&gpio3 RK_PD4 GPIO_ACTIVE_HIGH>;
		pinctrl-names = "default";
		pinctrl-0 = <&typec5v_pwren>;
		regulator-name = "vcc5v0_usb_otg0";
		regulator-min-microvolt = <5000000>;
		regulator-max-microvolt = <5000000>;
		vin-supply = <&vcc5v0_sys>;
	};

	vdd_mpcie_3v3: regulator-vdd-mpcie-3v3 {
		compatible = "regulator-fixed";
		/* Controlled by EXT_EN on RK806 */
		regulator-name = "vdd_mpcie_3v3";
		regulator-min-microvolt = <3300000>;
		regulator-max-microvolt = <3300000>;
		vin-supply = <&vcc5v0_sys>;
	};
};

&i2c7 {
	clock-frequency = <200000>;
	status = "okay";
};

&i2s0_8ch {
	pinctrl-names = "default";
	pinctrl-0 = <&i2s0_lrck
		     &i2s0_mclk
		     &i2s0_sclk
		     &i2s0_sdi0
		     &i2s0_sdo0>;
	status = "okay";
};

&pcie2x1l1 { /* M.2 E-key 2230 */
	vpcie3v3-supply = <&vdd_mpcie_3v3>;
};

&pcie2x1l2 { /* M.2 M-key 2280 */
	pinctrl-0 = <&pcie20x1_2_perstn_m0>, <&pcie20x1m0_clkreqn>, <&pcie20x1m0_waken>;
	vpcie3v3-supply = <&vcc_3v3_pcie>;
};

&pinctrl {
	gpio-leds {
		sys_led_pin: sys-led-pin {
			rockchip,pins = <1 RK_PA4 RK_FUNC_GPIO &pcfg_pull_none>;
		};

		user_led_pin: user-led-pin {
			rockchip,pins = <1 RK_PA6 RK_FUNC_GPIO &pcfg_pull_none>;
		};
	};

	headphone {
		hp_det: hp-det {
			rockchip,pins = <1 RK_PC4 RK_FUNC_GPIO &pcfg_pull_none>;
		};
	};

	pcie {
		pcie2_2_pwren: pcie2-2-pwren {
			rockchip,pins = <3 RK_PC6 RK_FUNC_GPIO &pcfg_pull_none>;
		};
	};

	usb {
		typec5v_pwren: typec5v-pwren {
			rockchip,pins = <3 RK_PD4 RK_FUNC_GPIO &pcfg_pull_none>;
		};
	};
};

&u2phy3 {
	status = "okay";
};

&u2phy3_host {
	phy-supply = <&vcc5v0_host_20>;
	status = "okay";
};

&usb_host1_ehci {
	status = "okay";
};

&usb_host1_ohci {
	status = "okay";
};