// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
/*
 * Copyright (c) 2023 Theobroma Systems Design und Consulting GmbH
 */

/dts-v1/;
#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/input/input.h>
#include <dt-bindings/leds/common.h>
#include <dt-bindings/pinctrl/rockchip.h>
#include <dt-bindings/soc/rockchip,vop2.h>
#include <dt-bindings/usb/pd.h>
#include "rk8xx.h"
#include "rk3588.dtsi"

/ {
	model = "Theobroma Systems RK3588-SBC Jaguar";
	compatible = "tsd,rk3588-jaguar", "rockchip,rk3588";

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

		/* Can be controlled through SW2 but also GPIO1 on CP2102 on P20 */
		button-bios-disable {
			label = "BIOS_DISABLE";
			linux,code = <KEY_VENDOR>;
			press-threshold-microvolt = <0>;
		};
	};

	aliases {
		ethernet0 = &gmac0;
		i2c10 = &i2c10;
		mmc0 = &sdhci;
		mmc1 = &sdmmc;
		rtc0 = &rtc_twi;
	};

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

	/* DCIN is 12-24V but standard is 12V */
	dc_12v: regulator-dc-12v {
		compatible = "regulator-fixed";
		regulator-name = "dc_12v";
		regulator-always-on;
		regulator-boot-on;
		regulator-min-microvolt = <12000000>;
		regulator-max-microvolt = <12000000>;
	};

	emmc_pwrseq: emmc-pwrseq {
		compatible = "mmc-pwrseq-emmc";
		pinctrl-0 = <&emmc_reset>;
		pinctrl-names = "default";
		reset-gpios = <&gpio2 RK_PA3 GPIO_ACTIVE_HIGH>;
	};

	hdmi-con {
		compatible = "hdmi-connector";
		type = "a";

		port {
			hdmi_con_in: endpoint {
				remote-endpoint = <&hdmi0_out_con>;
			};
		};
	};

	leds {
		compatible = "gpio-leds";
		pinctrl-names = "default";
		pinctrl-0 = <&led1_pin>;

		/* LED1 on PCB */
		led-1 {
			gpios = <&gpio1 RK_PD4 GPIO_ACTIVE_HIGH>;
			function = LED_FUNCTION_HEARTBEAT;
			linux,default-trigger = "heartbeat";
			color = <LED_COLOR_ID_AMBER>;
		};
	};

	/* 100MHz PCIe reference clock from PI6C557-05BLE */
	pcie_refclk: pcie-clock-generator {
		compatible = "gated-fixed-clock";
		#clock-cells = <0>;
		clock-frequency = <100000000>;
		clock-output-names = "pcie-refclk-clock";
		enable-gpios = <&gpio0 RK_PC6 GPIO_ACTIVE_LOW>; /* PCIE30X4_CLKREQN_M0 */
		pinctrl-names = "default";
		pinctrl-0 = <&pcie30x4_clkreqn_m0>;
		vdd-supply = <&vcca_3v3_s0>;
	};

	pps {
		compatible = "pps-gpio";
		gpios = <&gpio0 RK_PD5 GPIO_ACTIVE_HIGH>;
	};

	vcc_1v1_nldo_s3: regulator-vcc-1v1-nldo-s3 {
		compatible = "regulator-fixed";
		regulator-name = "vcc_1v1_nldo_s3";
		regulator-always-on;
		regulator-boot-on;
		regulator-min-microvolt = <1100000>;
		regulator-max-microvolt = <1100000>;
		vin-supply = <&vcc5v0_sys>;
	};

	vcc_1v2_s3: regulator-vcc-1v2-s3 {
		compatible = "regulator-fixed";
		regulator-name = "vcc_1v2_s3";
		regulator-always-on;
		regulator-boot-on;
		regulator-min-microvolt = <1200000>;
		regulator-max-microvolt = <1200000>;
		vin-supply = <&vcc5v0_sys>;
	};

	/* Exposed on P14 and P15 */
	vcc_2v8_s3: regulator-vcc-2v8-s3 {
		compatible = "regulator-fixed";
		regulator-name = "vcc_2v8_s3";
		regulator-always-on;
		regulator-boot-on;
		regulator-min-microvolt = <2800000>;
		regulator-max-microvolt = <2800000>;
		vin-supply = <&vcc_3v3_s3>;
	};

	vcc_5v0_usb_a: regulator-vcc-5v0-usb-a {
		compatible = "regulator-fixed";
		regulator-name = "usb_a_vcc";
		regulator-min-microvolt = <5000000>;
		regulator-max-microvolt = <5000000>;
		vin-supply = <&vcc5v0_sys>;
		gpio = <&gpio1 RK_PB4 GPIO_ACTIVE_HIGH>;
		enable-active-high;
	};

	vcc_5v0_usb_c1: regulator-vcc-5v0-usb-c1 {
		compatible = "regulator-fixed";
		regulator-name = "5v_usbc1";
		regulator-min-microvolt = <5000000>;
		regulator-max-microvolt = <5000000>;
		vin-supply = <&vcc5v0_usb>;
		gpio = <&gpio4 RK_PB5 GPIO_ACTIVE_HIGH>;
		enable-active-high;
	};

	vcc_5v0_usb_c2: regulator-vcc-5v0-usb-c2 {
		compatible = "regulator-fixed";
		regulator-name = "5v_usbc2";
		regulator-min-microvolt = <5000000>;
		regulator-max-microvolt = <5000000>;
		vin-supply = <&vcc5v0_usb>;
		gpio = <&gpio4 RK_PB6 GPIO_ACTIVE_HIGH>;
		enable-active-high;
	};

	vcc3v3_mdot2: regulator-vcc3v3-mdot2 {
		compatible = "regulator-fixed";
		regulator-name = "vcc3v3_mdot2";
		regulator-always-on;
		regulator-boot-on;
		regulator-min-microvolt = <3300000>;
		regulator-max-microvolt = <3300000>;
		vin-supply = <&dc_12v>;
	};

	vcc5v0_sys: regulator-vcc5v0-sys {
		compatible = "regulator-fixed";
		regulator-name = "vcc5v0_sys";
		regulator-always-on;
		regulator-boot-on;
		regulator-min-microvolt = <5000000>;
		regulator-max-microvolt = <5000000>;
		vin-supply = <&dc_12v>;
	};

	vcc5v0_usb: regulator-vcc5v0-usb {
		compatible = "regulator-fixed";
		regulator-name = "vcc5v0_usb";
		regulator-always-on;
		regulator-boot-on;
		regulator-min-microvolt = <5000000>;
		regulator-max-microvolt = <5000000>;
		vin-supply = <&vcc5v0_sys>;
	};
};

&can0 {
	assigned-clocks = <&cru CLK_CAN0>;
	assigned-clock-rates = <300000000>;
	status = "okay";
};

&can1 {
	assigned-clocks = <&cru CLK_CAN1>;
	assigned-clock-rates = <300000000>;
};

&can2 {
	assigned-clocks = <&cru CLK_CAN2>;
	assigned-clock-rates = <300000000>;
};

&combphy1_ps {
	status = "okay";
};

&cpu_b0 {
	cpu-supply = <&vdd_cpu_big0_s0>;
};

&cpu_b1 {
	cpu-supply = <&vdd_cpu_big0_s0>;
};

&cpu_b2 {
	cpu-supply = <&vdd_cpu_big1_s0>;
};

&cpu_b3 {
	cpu-supply = <&vdd_cpu_big1_s0>;
};

&cpu_l0 {
	cpu-supply = <&vdd_cpu_lit_s0>;
};

&cpu_l1 {
	cpu-supply = <&vdd_cpu_lit_s0>;
};

&cpu_l2 {
	cpu-supply = <&vdd_cpu_lit_s0>;
};

&cpu_l3 {
	cpu-supply = <&vdd_cpu_lit_s0>;
};

&gmac0 {
	clock_in_out = "output";
	phy-handle = <&rgmii_phy>;
	phy-mode = "rgmii";
	phy-supply = <&vcc_1v2_s3>;
	pinctrl-names = "default";
	pinctrl-0 = <&gmac0_miim
		     &gmac0_rx_bus2
		     &gmac0_tx_bus2
		     &gmac0_rgmii_clk
		     &gmac0_rgmii_bus
		     &eth0_pins
		     &eth_reset>;
	tx_delay = <0x10>;
	rx_delay = <0x10>;
	snps,reset-gpio = <&gpio4 RK_PC3 GPIO_ACTIVE_LOW>;
	snps,reset-active-low;
	snps,reset-delays-us = <0 10000 100000>;

	status = "okay";
};

&gpio1 {
	mdot2e-w-disable1-n-hog {
		gpios = <RK_PB1 GPIO_ACTIVE_LOW>;
		output-low;
		line-name = "m.2 E-key W_DISABLE1#";
		gpio-hog;
	};
};

&gpio4 {
	mdot2e-w-disable2-n-hog {
		gpios = <RK_PC1 GPIO_ACTIVE_LOW>;
		output-low;
		line-name = "m.2 E-key W_DISABLE2#";
		gpio-hog;
	};
};

&gpu {
	mali-supply = <&vdd_gpu_s0>;
	status = "okay";
};

&hdmi0 {
	/* No CEC on Jaguar */
	frl-enable-gpios = <&gpio0 RK_PD3 GPIO_ACTIVE_LOW>;
	pinctrl-0 = <&hdmim0_tx0_hpd &hdmim0_tx0_scl &hdmim0_tx0_sda
		     &hdmi0_tx_on_h>;
	pinctrl-names = "default";
	status = "okay";
};

&hdmi0_in {
	hdmi0_in_vp0: endpoint {
		remote-endpoint = <&vp0_out_hdmi0>;
	};
};

&hdmi0_out {
	hdmi0_out_con: endpoint {
		remote-endpoint = <&hdmi_con_in>;
	};
};

&hdmi0_sound {
	status = "okay";
};

&hdptxphy0 {
	status = "okay";
};

&i2c0 {
	pinctrl-0 = <&i2c0m2_xfer>;
	pinctrl-names = "default";
	status = "okay";

	fan@18 {
		compatible = "tsd,mule", "ti,amc6821";
		reg = <0x18>;

		i2c-mux {
			compatible = "tsd,mule-i2c-mux";
			#address-cells = <1>;
			#size-cells = <0>;

			i2c10: i2c@0 {
				reg = <0x0>;
				#address-cells = <1>;
				#size-cells = <0>;

				rtc_twi: rtc@6f {
					compatible = "isil,isl1208";
					reg = <0x6f>;
				};
			};
		};
	};

	typec-portc@22 {
		compatible = "fcs,fusb302";
		reg = <0x22>;
		interrupt-parent = <&gpio4>;
		interrupts = <RK_PA3 IRQ_TYPE_LEVEL_LOW>;
		pinctrl-names = "default";
		pinctrl-0 = <&cc_int1>;
		vbus-supply = <&vcc_5v0_usb_c1>;

		connector {
			compatible = "usb-c-connector";
			data-role = "dual";
			label = "USBC-1 P11";
			power-role = "source";
			self-powered;
			source-pdos =
				<PDO_FIXED(5000, 1500, PDO_FIXED_DATA_SWAP | PDO_FIXED_USB_COMM)>;
			vbus-supply = <&vcc_5v0_usb_c1>;

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

				port@0 {
					reg = <0>;

					usbc0_hs: endpoint {
						remote-endpoint = <&usb_host0_xhci_drd_sw>;
					};
				};

				port@1 {
					reg = <1>;

					usbc0_ss: endpoint {
						remote-endpoint = <&usbdp_phy0_typec_ss>;
					};
				};

				port@2 {
					reg = <2>;

					usbc0_sbu: endpoint {
						remote-endpoint = <&usbdp_phy0_typec_sbu>;
					};
				};
			};
		};
	};

	vdd_npu_s0: regulator@42 {
		compatible = "rockchip,rk8602";
		reg = <0x42>;
		fcs,suspend-voltage-selector = <1>;
		regulator-name = "vdd_npu_s0";
		regulator-boot-on;
		regulator-min-microvolt = <550000>;
		regulator-max-microvolt = <950000>;
		regulator-ramp-delay = <2300>;
		vin-supply = <&vcc5v0_sys>;

		regulator-state-mem {
			regulator-off-in-suspend;
		};
	};

	vdd_cpu_big1_s0: regulator@43 {
		compatible = "rockchip,rk8603", "rockchip,rk8602";
		reg = <0x43>;
		fcs,suspend-voltage-selector = <1>;
		regulator-name = "vdd_cpu_big1_s0";
		regulator-always-on;
		regulator-boot-on;
		regulator-min-microvolt = <550000>;
		regulator-max-microvolt = <1050000>;
		regulator-ramp-delay = <2300>;
		vin-supply = <&vcc5v0_sys>;

		regulator-state-mem {
			regulator-off-in-suspend;
		};
	};
};

&i2c1 {
	pinctrl-0 = <&i2c1m4_xfer>;
	pinctrl-names = "default";
};

&i2c6 {
	pinctrl-0 = <&i2c6m4_xfer>;
	pinctrl-names = "default";
};

&i2c7 {
	status = "okay";

	/* SE050 Secure Element at 0x48; GPIO1_A4 for enable pin */

	/* Also on 0x55 */
	eeprom@54 {
		compatible = "st,24c04", "atmel,24c04";
		reg = <0x54>;
		pagesize = <16>;
		vcc-supply = <&vcc_3v3_s3>;
	};
};

&i2c8 {
	pinctrl-0 = <&i2c8m2_xfer>;
	pinctrl-names = "default";
	status = "okay";

	typec-portc@22 {
		compatible = "fcs,fusb302";
		reg = <0x22>;
		interrupt-parent = <&gpio4>;
		interrupts = <RK_PA4 IRQ_TYPE_LEVEL_LOW>;
		pinctrl-names = "default";
		pinctrl-0 = <&cc_int2>;
		vbus-supply = <&vcc_5v0_usb_c2>;

		connector {
			compatible = "usb-c-connector";
			data-role = "dual";
			label = "USBC-2 P12";
			power-role = "source";
			self-powered;
			source-pdos =
				<PDO_FIXED(5000, 1500, PDO_FIXED_DATA_SWAP | PDO_FIXED_USB_COMM)>;
			vbus-supply = <&vcc_5v0_usb_c2>;

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

				port@0 {
					reg = <0>;

					usbc1_hs: endpoint {
						remote-endpoint = <&usb_host1_xhci_drd_sw>;
					};
				};

				port@1 {
					reg = <1>;

					usbc1_ss: endpoint {
						remote-endpoint = <&usbdp_phy1_typec_ss>;
					};
				};

				port@2 {
					reg = <2>;

					usbc1_sbu: endpoint {
						remote-endpoint = <&usbdp_phy1_typec_sbu>;
					};
				};
			};
		};
	};

	vdd_cpu_big0_s0: regulator@42 {
		compatible = "rockchip,rk8602";
		reg = <0x42>;
		fcs,suspend-voltage-selector = <1>;
		regulator-name = "vdd_cpu_big0_s0";
		regulator-always-on;
		regulator-boot-on;
		regulator-min-microvolt = <550000>;
		regulator-max-microvolt = <1050000>;
		regulator-ramp-delay = <2300>;
		vin-supply = <&vcc5v0_sys>;

		regulator-state-mem {
			regulator-off-in-suspend;
		};
	};
};

&i2s5_8ch {
	status = "okay";
};

&mdio0 {
	rgmii_phy: ethernet-phy@6 {
		/* KSZ9031 or KSZ9131 */
		compatible = "ethernet-phy-ieee802.3-c22";
		reg = <0x6>;
		clocks = <&cru REFCLKO25M_ETH0_OUT>;
	};
};

&pcie2x1l0 {
	reset-gpios = <&gpio4 RK_PB3 GPIO_ACTIVE_HIGH>; /* WIFI_PERST0# */
	vpcie3v3-supply = <&vcc3v3_mdot2>;
	status = "okay";
};

&pcie30phy {
	status = "okay";
};

&pcie3x4 {
	/*
	 * The board has a gpio-controlled "pcie_refclk" generator,
	 * so add it to the list of clocks.
	 */
	clocks = <&cru ACLK_PCIE_4L_MSTR>, <&cru ACLK_PCIE_4L_SLV>,
		 <&cru ACLK_PCIE_4L_DBI>, <&cru PCLK_PCIE_4L>,
		 <&cru CLK_PCIE_AUX0>, <&cru CLK_PCIE4L_PIPE>,
		 <&pcie_refclk>;
	clock-names = "aclk_mst", "aclk_slv",
		      "aclk_dbi", "pclk",
		      "aux", "pipe",
		      "ref";
	pinctrl-names = "default";
	pinctrl-0 = <&pcie30x4_waken_m0 &pcie30x4_perstn_m0>;
	reset-gpios = <&gpio0 RK_PD0 GPIO_ACTIVE_HIGH>; /* PCIE30X4_PERSTN_M0 */
	vpcie3v3-supply = <&vcc3v3_mdot2>;
	status = "okay";
};

&pd_gpu {
	domain-supply = <&vdd_gpu_s0>;
};

&pd_npu {
	domain-supply = <&vdd_npu_s0>;
};

&pinctrl {
	emmc {
		emmc_reset: emmc-reset {
			rockchip,pins = <2 RK_PA3 RK_FUNC_GPIO &pcfg_pull_none>;
		};
	};

	ethernet {
		eth_reset: eth-reset {
			rockchip,pins = <4 RK_PC3 RK_FUNC_GPIO &pcfg_pull_none>;
		};
	};

	hdmi {
		hdmi0_tx_on_h: hdmi0-tx-on-h {
			rockchip,pins = <0 RK_PD3 RK_FUNC_GPIO &pcfg_pull_none>;
		};
	};

	leds {
		led1_pin: led1-pin {
			rockchip,pins = <1 RK_PD4 RK_FUNC_GPIO &pcfg_pull_none>;
		};
	};

	pcie30x4 {
		pcie30x4_clkreqn_m0: pcie30x4-clkreqn-m0 {
			rockchip,pins = <0 RK_PC6 RK_FUNC_GPIO &pcfg_pull_up>;
		};

		pcie30x4_perstn_m0: pcie30x4-perstn-m0 {
			rockchip,pins = <0 RK_PD0 RK_FUNC_GPIO &pcfg_pull_none>;
		};

		pcie30x4_waken_m0: pcie30x4-waken-m0 {
			rockchip,pins = <0 RK_PC7 12 &pcfg_pull_none>;
		};
	};

	usb3 {
		cc_int1: cc-int1 {
			rockchip,pins = <4 RK_PA3 RK_FUNC_GPIO &pcfg_pull_none>;
		};

		cc_int2: cc-int2 {
			rockchip,pins = <4 RK_PA4 RK_FUNC_GPIO &pcfg_pull_none>;
		};

		typec0_sbu_dc_pins: typec0-sbu-dc-pins {
			rockchip,pins = <4 RK_PB0 RK_FUNC_GPIO &pcfg_pull_down>,
					<1 RK_PC3 RK_FUNC_GPIO &pcfg_pull_down>;
		};

		typec1_sbu_dc_pins: typec1-sbu-dc-pins {
			rockchip,pins = <0 RK_PD4 RK_FUNC_GPIO &pcfg_pull_down>,
					<1 RK_PB5 RK_FUNC_GPIO &pcfg_pull_down>;
		};
	};
};

&rknn_core_0 {
	npu-supply = <&vdd_npu_s0>;
	sram-supply = <&vdd_npu_s0>;
	status = "okay";
};

&rknn_core_1 {
	npu-supply = <&vdd_npu_s0>;
	sram-supply = <&vdd_npu_s0>;
	status = "okay";
};

&rknn_core_2 {
	npu-supply = <&vdd_npu_s0>;
	sram-supply = <&vdd_npu_s0>;
	status = "okay";
};

&rknn_mmu_0 {
	status = "okay";
};

&rknn_mmu_1 {
	status = "okay";
};

&rknn_mmu_2 {
	status = "okay";
};

&saradc {
	vref-supply = <&vcc_1v8_s0>;
	status = "okay";
};

&sdhci {
	bus-width = <8>;
	cap-mmc-highspeed;
	mmc-ddr-1_8v;
	mmc-hs200-1_8v;
	mmc-hs400-1_8v;
	mmc-hs400-enhanced-strobe;
	mmc-pwrseq = <&emmc_pwrseq>;
	no-sdio;
	no-sd;
	non-removable;
	pinctrl-names = "default";
	pinctrl-0 = <&emmc_bus8 &emmc_cmd &emmc_clk &emmc_data_strobe>;
	vmmc-supply = <&vcc_3v3_s3>;
	vqmmc-supply = <&vcc_1v8_s3>;
	status = "okay";
};

&sdmmc {
	broken-cd;
	bus-width = <4>;
	cap-sd-highspeed;
	disable-wp;
	max-frequency = <150000000>;
	pinctrl-names = "default";
	pinctrl-0 = <&sdmmc_bus4 &sdmmc_cmd &sdmmc_clk>;
	sd-uhs-sdr12;
	sd-uhs-sdr25;
	sd-uhs-sdr50;
	sd-uhs-ddr50;
	sd-uhs-sdr104;
	vmmc-supply = <&vcc_3v3_s3>;
	vqmmc-supply = <&vccio_sd_s0>;
	status = "okay";
};

&spi2 {
	assigned-clocks = <&cru CLK_SPI2>;
	assigned-clock-rates = <200000000>;
	num-cs = <1>;
	pinctrl-names = "default";
	pinctrl-0 = <&spi2m2_cs0 &spi2m2_pins>;
	status = "okay";

	pmic@0 {
		compatible = "rockchip,rk806";
		reg = <0x0>;
		interrupt-parent = <&gpio0>;
		interrupts = <7 IRQ_TYPE_LEVEL_LOW>;
		gpio-controller;
		#gpio-cells = <2>;
		pinctrl-names = "default";
		pinctrl-0 = <&pmic_pins>, <&rk806_dvs1_null>,
			    <&rk806_dvs2_null>, <&rk806_dvs3_null>;
		spi-max-frequency = <1000000>;
		system-power-controller;
		vcc1-supply = <&vcc5v0_sys>;
		vcc2-supply = <&vcc5v0_sys>;
		vcc3-supply = <&vcc5v0_sys>;
		vcc4-supply = <&vcc5v0_sys>;
		vcc5-supply = <&vcc5v0_sys>;
		vcc6-supply = <&vcc5v0_sys>;
		vcc7-supply = <&vcc5v0_sys>;
		vcc8-supply = <&vcc5v0_sys>;
		vcc9-supply = <&vcc5v0_sys>;
		vcc10-supply = <&vcc5v0_sys>;
		vcc11-supply = <&vcc_2v0_pldo_s3>;
		vcc12-supply = <&vcc5v0_sys>;
		vcc13-supply = <&vcc_1v1_nldo_s3>;
		vcc14-supply = <&vcc_1v1_nldo_s3>;
		vcca-supply = <&vcc5v0_sys>;
		rockchip,reset-mode = <RK806_RESTART>;

		rk806_dvs1_null: dvs1-null-pins {
			pins = "gpio_pwrctrl1";
			function = "pin_fun0";
		};

		rk806_dvs2_null: dvs2-null-pins {
			pins = "gpio_pwrctrl2";
			function = "pin_fun0";
		};

		rk806_dvs3_null: dvs3-null-pins {
			pins = "gpio_pwrctrl3";
			function = "pin_fun0";
		};

		regulators {
			vdd_gpu_s0: dcdc-reg1 {
				regulator-boot-on;
				regulator-min-microvolt = <550000>;
				regulator-max-microvolt = <950000>;
				regulator-ramp-delay = <12500>;
				regulator-name = "vdd_gpu_s0";
				regulator-enable-ramp-delay = <400>;

				regulator-state-mem {
					regulator-off-in-suspend;
				};
			};

			vdd_cpu_lit_s0: dcdc-reg2 {
				regulator-name = "vdd_cpu_lit_s0";
				regulator-always-on;
				regulator-boot-on;
				regulator-min-microvolt = <550000>;
				regulator-max-microvolt = <950000>;
				regulator-ramp-delay = <12500>;

				regulator-state-mem {
					regulator-off-in-suspend;
				};
			};

			vdd_log_s0: dcdc-reg3 {
				regulator-name = "vdd_log_s0";
				regulator-always-on;
				regulator-boot-on;
				regulator-min-microvolt = <675000>;
				regulator-max-microvolt = <750000>;
				regulator-ramp-delay = <12500>;

				regulator-state-mem {
					regulator-off-in-suspend;
					regulator-suspend-microvolt = <750000>;
				};
			};

			vdd_vdenc_s0: dcdc-reg4 {
				regulator-name = "vdd_vdenc_s0";
				regulator-always-on;
				regulator-boot-on;
				regulator-min-microvolt = <550000>;
				regulator-max-microvolt = <950000>;
				regulator-ramp-delay = <12500>;

				regulator-state-mem {
					regulator-off-in-suspend;
				};
			};

			vdd_ddr_s0: dcdc-reg5 {
				regulator-name = "vdd_ddr_s0";
				regulator-always-on;
				regulator-boot-on;
				regulator-min-microvolt = <675000>;
				regulator-max-microvolt = <900000>;
				regulator-ramp-delay = <12500>;

				regulator-state-mem {
					regulator-off-in-suspend;
					regulator-suspend-microvolt = <850000>;
				};
			};

			vdd2_ddr_s3: dcdc-reg6 {
				regulator-name = "vdd2_ddr_s3";
				regulator-always-on;
				regulator-boot-on;

				regulator-state-mem {
					regulator-on-in-suspend;
				};
			};

			vcc_2v0_pldo_s3: dcdc-reg7 {
				regulator-name = "vdd_2v0_pldo_s3";
				regulator-always-on;
				regulator-boot-on;
				regulator-min-microvolt = <2000000>;
				regulator-max-microvolt = <2000000>;
				regulator-ramp-delay = <12500>;

				regulator-state-mem {
					regulator-on-in-suspend;
					regulator-suspend-microvolt = <2000000>;
				};
			};

			vcc_3v3_s3: dcdc-reg8 {
				regulator-name = "vcc_3v3_s3";
				regulator-always-on;
				regulator-boot-on;
				regulator-min-microvolt = <3300000>;
				regulator-max-microvolt = <3300000>;

				regulator-state-mem {
					regulator-on-in-suspend;
					regulator-suspend-microvolt = <3300000>;
				};
			};

			vddq_ddr_s0: dcdc-reg9 {
				regulator-name = "vddq_ddr_s0";
				regulator-always-on;
				regulator-boot-on;

				regulator-state-mem {
					regulator-off-in-suspend;
				};
			};

			vcc_1v8_s3: dcdc-reg10 {
				regulator-name = "vcc_1v8_s3";
				regulator-always-on;
				regulator-boot-on;
				regulator-min-microvolt = <1800000>;
				regulator-max-microvolt = <1800000>;

				regulator-state-mem {
					regulator-on-in-suspend;
					regulator-suspend-microvolt = <1800000>;
				};
			};

			vcca_1v8_s0: pldo-reg1 {
				regulator-name = "vcca_1v8_s0";
				regulator-always-on;
				regulator-boot-on;
				regulator-min-microvolt = <1800000>;
				regulator-max-microvolt = <1800000>;

				regulator-state-mem {
					regulator-off-in-suspend;
				};
			};

			vcc_1v8_s0: pldo-reg2 {
				regulator-name = "vcc_1v8_s0";
				regulator-always-on;
				regulator-boot-on;
				regulator-min-microvolt = <1800000>;
				regulator-max-microvolt = <1800000>;

				regulator-state-mem {
					regulator-off-in-suspend;
					regulator-suspend-microvolt = <1800000>;
				};
			};

			vdda_1v2_s0: pldo-reg3 {
				regulator-name = "vdda_1v2_s0";
				regulator-always-on;
				regulator-boot-on;
				regulator-min-microvolt = <1200000>;
				regulator-max-microvolt = <1200000>;

				regulator-state-mem {
					regulator-off-in-suspend;
				};
			};

			vcca_3v3_s0: pldo-reg4 {
				regulator-name = "vcca_3v3_s0";
				regulator-always-on;
				regulator-boot-on;
				regulator-min-microvolt = <3300000>;
				regulator-max-microvolt = <3300000>;
				regulator-ramp-delay = <12500>;

				regulator-state-mem {
					regulator-off-in-suspend;
				};
			};

			vccio_sd_s0: pldo-reg5 {
				regulator-name = "vccio_sd_s0";
				regulator-always-on;
				regulator-boot-on;
				regulator-min-microvolt = <1800000>;
				regulator-max-microvolt = <3300000>;
				regulator-ramp-delay = <12500>;

				regulator-state-mem {
					regulator-off-in-suspend;
				};
			};

			pldo6_s3: pldo-reg6 {
				regulator-name = "pldo6_s3";
				regulator-always-on;
				regulator-boot-on;
				regulator-min-microvolt = <1800000>;
				regulator-max-microvolt = <1800000>;

				regulator-state-mem {
					regulator-on-in-suspend;
					regulator-suspend-microvolt = <1800000>;
				};
			};

			vdd_0v75_s3: nldo-reg1 {
				regulator-name = "vdd_0v75_s3";
				regulator-always-on;
				regulator-boot-on;
				regulator-min-microvolt = <750000>;
				regulator-max-microvolt = <750000>;

				regulator-state-mem {
					regulator-on-in-suspend;
					regulator-suspend-microvolt = <750000>;
				};
			};

			vdda_ddr_pll_s0: nldo-reg2 {
				regulator-name = "vdda_ddr_pll_s0";
				regulator-always-on;
				regulator-boot-on;
				regulator-min-microvolt = <850000>;
				regulator-max-microvolt = <850000>;

				regulator-state-mem {
					regulator-off-in-suspend;
					regulator-suspend-microvolt = <850000>;
				};
			};

			vdda_0v75_s0: nldo-reg3 {
				regulator-name = "vdda_0v75_s0";
				regulator-always-on;
				regulator-boot-on;
				regulator-min-microvolt = <750000>;
				regulator-max-microvolt = <750000>;

				regulator-state-mem {
					regulator-off-in-suspend;
				};
			};

			vdda_0v85_s0: nldo-reg4 {
				regulator-name = "vdda_0v85_s0";
				regulator-always-on;
				regulator-boot-on;
				regulator-min-microvolt = <850000>;
				regulator-max-microvolt = <850000>;

				regulator-state-mem {
					regulator-off-in-suspend;
				};
			};

			vdd_0v75_s0: nldo-reg5 {
				regulator-name = "vdd_0v75_s0";
				regulator-always-on;
				regulator-boot-on;
				regulator-min-microvolt = <750000>;
				regulator-max-microvolt = <750000>;

				regulator-state-mem {
					regulator-off-in-suspend;
				};
			};
		};
	};
};

&tsadc {
	status = "okay";
};

/* USB-C P11 connector */
&u2phy0 {
	status = "okay";
};

&u2phy0_otg {
	status = "okay";
};

/* USB-C P12 connector */
&u2phy1 {
	status = "okay";
};

&u2phy1_otg {
	status = "okay";
};

&u2phy2 {
	status = "okay";
};

&u2phy2_host {
	phy-supply = <&vcc_5v0_usb_a>;
	status = "okay";
};

&u2phy3 {
	status = "okay";
};

&u2phy3_host {
	status = "okay";
};

/* Mule-ATtiny debug UART; typically baudrate 9600 */
&uart0 {
	pinctrl-0 = <&uart0m0_xfer>;
	pinctrl-names = "default";
	status = "okay";
};

/* Main debug interface on P20 micro-USB B port and P21 header */
&uart2 {
	pinctrl-0 = <&uart2m0_xfer>;
	pinctrl-names = "default";
	status = "okay";
};

/* RS485 on P19 */
&uart3 {
	pinctrl-0 = <&uart3m2_xfer &uart3_rtsn>;
	pinctrl-names = "default";
	linux,rs485-enabled-at-boot-time;
	status = "okay";
};

/* Mule-ATtiny UPDI flashing UART */
&uart7 {
	pinctrl-0 = <&uart7m0_xfer>;
	pinctrl-names = "default";
	status = "okay";
};

/* Type-C on P11 */
&usbdp_phy0 {
	orientation-switch;
	pinctrl-names = "default";
	pinctrl-0 = <&typec0_sbu_dc_pins>;
	sbu1-dc-gpios = <&gpio4 RK_PB0 GPIO_ACTIVE_HIGH>; /* Q7_USB_C0_SBU1_DC */
	sbu2-dc-gpios = <&gpio1 RK_PC3 GPIO_ACTIVE_HIGH>; /* Q7_USB_C0_SBU2_DC */
	status = "okay";

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

		usbdp_phy0_typec_ss: endpoint@0 {
			reg = <0>;
			remote-endpoint = <&usbc0_ss>;
		};

		usbdp_phy0_typec_sbu: endpoint@1 {
			reg = <1>;
			remote-endpoint = <&usbc0_sbu>;
		};
	};
};

/* Type-C on P12 */
&usbdp_phy1 {
	orientation-switch;
	pinctrl-names = "default";
	pinctrl-0 = <&typec1_sbu_dc_pins>;
	sbu1-dc-gpios = <&gpio0 RK_PD4 GPIO_ACTIVE_HIGH>; /* Q7_USB_C1_SBU1_DC */
	sbu2-dc-gpios = <&gpio1 RK_PB5 GPIO_ACTIVE_HIGH>; /* Q7_USB_C1_SBU2_DC */
	status = "okay";

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

		usbdp_phy1_typec_ss: endpoint@0 {
			reg = <0>;
			remote-endpoint = <&usbc1_ss>;
		};

		usbdp_phy1_typec_sbu: endpoint@1 {
			reg = <1>;
			remote-endpoint = <&usbc1_sbu>;
		};
	};
};

/* host0 on P10 USB-A */
&usb_host0_ehci {
	status = "okay";
};

/* host0 on P10 USB-A */
&usb_host0_ohci {
	status = "okay";
};

/* host0 on P11 USB-C */
&usb_host0_xhci {
	usb-role-switch;
	status = "okay";

	port {
		usb_host0_xhci_drd_sw: endpoint {
			remote-endpoint = <&usbc0_hs>;
		};
	};
};

/* host1 on P12 USB-C */
&usb_host1_xhci {
	usb-role-switch;
	status = "okay";

	port {
		usb_host1_xhci_drd_sw: endpoint {
			remote-endpoint = <&usbc1_hs>;
		};
	};
};

/* host1 on M.2 E-key */
&usb_host1_ehci {
	status = "okay";
};

/* host1 on M.2 E-key */
&usb_host1_ohci {
	status = "okay";
};

&vop {
	status = "okay";
};

&vop_mmu {
	status = "okay";
};

&vp0 {
	vp0_out_hdmi0: endpoint@ROCKCHIP_VOP2_EP_HDMI0 {
		reg = <ROCKCHIP_VOP2_EP_HDMI0>;
		remote-endpoint = <&hdmi0_in_vp0>;
	};
};