// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
// Copyright (c) 2018 Fuzhou Rockchip Electronics Co., Ltd

/dts-v1/;
#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/pinctrl/rockchip.h>
#include <dt-bindings/input/input.h>
#include <dt-bindings/display/drm_mipi_dsi.h>
#include <dt-bindings/sensor-dev.h>
#include <dt-bindings/pwm/pwm.h>
#include "dt-bindings/usb/pd.h"
#include "rk3399pro.dtsi"
#include "rk3399-linux.dtsi"
#include "rk3399-opp.dtsi"
#include "rk3399-vop-clk-set.dtsi"

/ {
	compatible = "rockchip,rk3399pro-evb-v11-linux", "rockchip,rk3399pro";

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

		esc-key {
			linux,code = <KEY_ESC>;
			label = "esc";
			press-threshold-microvolt = <1310000>;
		};

		menu-key {
			linux,code = <KEY_MENU>;
			label = "menu";
			press-threshold-microvolt = <987000>;
		};

		home-key {
			linux,code = <KEY_HOME>;
			label = "home";
			press-threshold-microvolt = <624000>;
		};

		vol-down-key {
			linux,code = <KEY_VOLUMEDOWN>;
			label = "volume down";
			press-threshold-microvolt = <300000>;
		};

		vol-up-key {
			linux,code = <KEY_VOLUMEUP>;
			label = "volume up";
			press-threshold-microvolt = <17000>;
		};
	};

	backlight: backlight {
		compatible = "pwm-backlight";
		pwms = <&pwm0 0 25000 0>;
		brightness-levels = <
			  0  20  20  21  21  22  22  23
			 23  24  24  25  25  26  26  27
			 27  28  28  29  29  30  30  31
			 31  32  32  33  33  34  34  35
			 35  36  36  37  37  38  38  39
			 40  41  42  43  44  45  46  47
			 48  49  50  51  52  53  54  55
			 56  57  58  59  60  61  62  63
			 64  65  66  67  68  69  70  71
			 72  73  74  75  76  77  78  79
			 80  81  82  83  84  85  86  87
			 88  89  90  91  92  93  94  95
			 96  97  98  99 100 101 102 103
			104 105 106 107 108 109 110 111
			112 113 114 115 116 117 118 119
			120 121 122 123 124 125 126 127
			128 129 130 131 132 133 134 135
			136 137 138 139 140 141 142 143
			144 145 146 147 148 149 150 151
			152 153 154 155 156 157 158 159
			160 161 162 163 164 165 166 167
			168 169 170 171 172 173 174 175
			176 177 178 179 180 181 182 183
			184 185 186 187 188 189 190 191
			192 193 194 195 196 197 198 199
			200 201 202 203 204 205 206 207
			208 209 210 211 212 213 214 215
			216 217 218 219 220 221 222 223
			224 225 226 227 228 229 230 231
			232 233 234 235 236 237 238 239
			240 241 242 243 244 245 246 247
			248 249 250 251 252 253 254 255
		>;
		default-brightness-level = <200>;
		enable-gpios = <&gpio1 RK_PB5 GPIO_ACTIVE_HIGH>;
	};

	clkin_gmac: external-gmac-clock {
		compatible = "fixed-clock";
		clock-frequency = <125000000>;
		clock-output-names = "clkin_gmac";
		#clock-cells = <0>;
	};

	fiq_debugger: fiq-debugger {
		compatible = "rockchip,fiq-debugger";
		rockchip,serial-id = <2>;
		rockchip,wake-irq = <0>;
		rockchip,irq-mode-enable = <0>;  /* If enable uart uses irq instead of fiq */
		rockchip,baudrate = <1500000>;  /* Only 115200 and 1500000 */
		pinctrl-names = "default";
		pinctrl-0 = <&uart2c_xfer>;
		interrupts = <GIC_SPI 150 IRQ_TYPE_LEVEL_HIGH 0>;
	};

	hdmi_sound: hdmi-sound {
		status = "okay";
		compatible = "simple-audio-card";
		simple-audio-card,format = "i2s";
		simple-audio-card,mclk-fs = <256>;
		simple-audio-card,name = "rockchip,hdmi";

		simple-audio-card,cpu {
			sound-dai = <&i2s2>;
		};
		simple-audio-card,codec {
			sound-dai = <&hdmi>;
		};
	};

	panel: panel {
		compatible = "simple-panel";
		backlight = <&backlight>;
		enable-gpios = <&gpio4 RK_PD6 GPIO_ACTIVE_HIGH>;
		prepare-delay-ms = <20>;
		enable-delay-ms = <20>;
		reset-delay-ms = <20>;
		width-mm = <120>;
		height-mm = <160>;

		display-timings {
			native-mode = <&timing0>;

			timing0: timing0 {
				clock-frequency = <200000000>;
				hactive = <1536>;
				vactive = <2048>;
				hfront-porch = <12>;
				hsync-len = <16>;
				hback-porch = <48>;
				vfront-porch = <8>;
				vsync-len = <4>;
				vback-porch = <8>;
				hsync-active = <0>;
				vsync-active = <0>;
				de-active = <0>;
				pixelclk-active = <0>;
			};
		};

		ports {
			panel_in: endpoint {
				remote-endpoint = <&edp_out>;
			};
		};
	};

	rk809_sound: rk809-sound {
		compatible = "rockchip,multicodecs-card";
		rockchip,card-name = "rockchip,rk809-codec";
		rockchip,codec-hp-det;
		rockchip,mclk-fs = <256>;
		rockchip,cpu = <&i2s1>;
		rockchip,codec = <&rk809_codec>;
	};

	rk_headset: rk-headset {
		compatible = "rockchip_headset";
		headset_gpio = <&gpio0 RK_PB5 GPIO_ACTIVE_HIGH>;
		pinctrl-names = "default";
		pinctrl-0 = <&hp_det>;
		io-channels = <&saradc 3>;
	};

	sdio_pwrseq: sdio-pwrseq {
		compatible = "mmc-pwrseq-simple";
		clocks = <&rk809 1>;
		clock-names = "ext_clock";
		pinctrl-names = "default";
		pinctrl-0 = <&wifi_enable_h>;

		/*
		 * On the module itself this is one of these (depending
		 * on the actual card populated):
		 * - SDIO_RESET_L_WL_REG_ON
		 * - PDN (power down when low)
		 */
		reset-gpios = <&gpio2 RK_PD3 GPIO_ACTIVE_LOW>;
	};

	usbacm_video_control: usbacm-video-control {
		compatible = "rockchip,usbacm-video-control";
		status = "disabled";
	};

	vbus_typec: vbus-typec-regulator {
		compatible = "regulator-fixed";
		enable-active-high;
		gpio = <&gpio1 18 GPIO_ACTIVE_HIGH>;
		pinctrl-names = "default";
		pinctrl-0 = <&vcc5v0_typec0_en>;
		regulator-name = "vbus_typec";
		vin-supply = <&vcc5v0_sys>;
	};

	vbus_typec: vbus-typec-regulator {
		compatible = "regulator-fixed";
		enable-active-high;
		gpio = <&gpio1 18 GPIO_ACTIVE_HIGH>;
		pinctrl-names = "default";
		pinctrl-0 = <&vcc5v0_typec0_en>;
		regulator-name = "vbus_typec";
		vin-supply = <&vcc5v0_sys>;
	};

	vcc_phy: vcc-phy-regulator {
		compatible = "regulator-fixed";
		regulator-name = "vcc_phy";
		regulator-always-on;
		regulator-boot-on;
	};

	vcc5v0_sys: vccsys {
		compatible = "regulator-fixed";
		regulator-name = "vcc5v0_sys";
		regulator-always-on;
		regulator-boot-on;
		regulator-min-microvolt = <5000000>;
		regulator-max-microvolt = <5000000>;
	};

	wireless-wlan {
		compatible = "wlan-platdata";
		rockchip,grf = <&grf>;
		wifi_chip_type = "ap6398s";
		sdio_vref = <1800>;
		WIFI,host_wake_irq = <&gpio0 RK_PA3 GPIO_ACTIVE_HIGH>;
		status = "okay";
	};

	wireless-bluetooth {
		compatible = "bluetooth-platdata";
		clocks = <&rk809 1>;
		clock-names = "ext_clock";
		uart_rts_gpios = <&gpio2 RK_PC3 GPIO_ACTIVE_LOW>;
		pinctrl-names = "default", "rts_gpio";
		pinctrl-0 = <&uart0_rts>, <&bt_irq_gpio>;
		pinctrl-1 = <&uart0_gpios>;
		BT,reset_gpio    = <&gpio2 RK_PD4 GPIO_ACTIVE_HIGH>;
		BT,wake_gpio     = <&gpio2 RK_PD2 GPIO_ACTIVE_HIGH>;
		BT,wake_host_irq = <&gpio0 RK_PA5 GPIO_ACTIVE_HIGH>;
		status = "okay";
	};
};

&cdn_dp {
	status = "okay";
	phys = <&tcphy0_dp>;
};

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

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

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

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

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

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

&display_subsystem {
	status = "okay";
};

&dmc {
	status = "okay";
	center-supply = <&vdd_center>;
};

&dp_in_vopb {
	status = "disabled";
};

&edp {
	status = "okay";
	force-hpd;

	ports {
		port@1 {
			reg = <1>;

			edp_out: endpoint {
				remote-endpoint = <&panel_in>;
			};
		};
	};
};

&edp_in_vopb {
	status = "disabled";
};

&emmc_phy {
	status = "okay";
};

&fiq_debugger {
	pinctrl-0 = <&uart2a_xfer>;
};

&gmac {
	phy-supply = <&vcc_phy>;
	phy-mode = "rgmii";
	clock_in_out = "input";
	snps,reset-gpio = <&gpio3 RK_PB7 GPIO_ACTIVE_LOW>;
	snps,reset-active-low;
	snps,reset-delays-us = <0 10000 50000>;
	assigned-clocks = <&cru SCLK_RMII_SRC>;
	assigned-clock-parents = <&clkin_gmac>;
	pinctrl-names = "default";
	pinctrl-0 = <&rgmii_pins>;
	tx_delay = <0x28>;
	rx_delay = <0x11>;
	status = "okay";
};

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

&hdmi {
	status = "okay";
	#sound-dai-cells = <0>;
	rockchip,phy-table =
		<74250000  0x8009 0x0004 0x0272>,
		<165000000 0x802b 0x0004 0x0209>,
		<297000000 0x8039 0x0005 0x028d>,
		<594000000 0x8039 0x0000 0x00f6>,
		<000000000 0x0000 0x0000 0x0000>;
};

&hdmi_in_vopl {
	status = "disabled";
};

&i2c0 {
	status = "okay";
	i2c-scl-rising-time-ns = <180>;
	i2c-scl-falling-time-ns = <30>;
	clock-frequency = <400000>;

	rk809: pmic@20 {
		compatible = "rockchip,rk809";
		reg = <0x20>;
		interrupt-parent = <&gpio1>;
		interrupts = <RK_PC2 IRQ_TYPE_LEVEL_LOW>;
		pinctrl-names = "default", "pmic-sleep",
				"pmic-power-off", "pmic-reset";
		pinctrl-0 = <&pmic_int_l>;
		pinctrl-1 = <&soc_slppin_slp>, <&rk809_slppin_slp>;
		pinctrl-2 = <&soc_slppin_gpio>, <&rk809_slppin_pwrdn>;
		pinctrl-3 = <&soc_slppin_gpio>, <&rk809_slppin_null>;
		rockchip,system-power-controller;
		pmic-reset-func = <0>;
		wakeup-source;
		#clock-cells = <1>;
		clock-output-names = "rk808-clkout1", "rk808-clkout2";

		vcc1-supply = <&vcc5v0_sys>;
		vcc2-supply = <&vcc5v0_sys>;
		vcc3-supply = <&vcc5v0_sys>;
		vcc4-supply = <&vcc5v0_sys>;
		vcc5-supply = <&vcc_buck5>;
		vcc6-supply = <&vcc_buck5>;
		vcc7-supply = <&vcc3v3_sys>;
		vcc8-supply = <&vcc3v3_sys>;
		vcc9-supply = <&vcc5v0_sys>;

		pwrkey {
			status = "okay";
		};

		rtc {
			status = "okay";
		};

		pinctrl_rk8xx: pinctrl_rk8xx {
			gpio-controller;
			#gpio-cells = <2>;

			rk809_slppin_null: rk809_slppin_null {
				pins = "gpio_slp";
				function = "pin_fun0";
			};

			rk809_slppin_slp: rk809_slppin_slp {
				pins = "gpio_slp";
				function = "pin_fun1";
			};

			rk809_slppin_pwrdn: rk809_slppin_pwrdn {
				pins = "gpio_slp";
				function = "pin_fun2";
			};

			rk809_slppin_rst: rk809_slppin_rst {
				pins = "gpio_slp";
				function = "pin_fun3";
			};
		};

		regulators {
			vdd_center: DCDC_REG1 {
				regulator-always-on;
				regulator-boot-on;
				regulator-min-microvolt = <750000>;
				regulator-max-microvolt = <1350000>;
				regulator-initial-mode = <0x2>;
				regulator-name = "vdd_center";
				regulator-state-mem {
					regulator-off-in-suspend;
					regulator-suspend-microvolt = <900000>;
				};
			};

			vdd_cpu_l: DCDC_REG2 {
				regulator-always-on;
				regulator-boot-on;
				regulator-min-microvolt = <750000>;
				regulator-max-microvolt = <1350000>;
				regulator-ramp-delay = <6001>;
				regulator-initial-mode = <0x2>;
				regulator-name = "vdd_cpu_l";
				regulator-state-mem {
					regulator-off-in-suspend;
				};
			};

			vcc_ddr: DCDC_REG3 {
				regulator-always-on;
				regulator-boot-on;
				regulator-name = "vcc_ddr";
				regulator-initial-mode = <0x2>;
				regulator-state-mem {
					regulator-on-in-suspend;
				};
			};

			vcc3v3_sys: DCDC_REG4 {
				regulator-always-on;
				regulator-boot-on;
				regulator-min-microvolt = <3300000>;
				regulator-max-microvolt = <3300000>;
				regulator-initial-mode = <0x2>;
				regulator-name = "vcc3v3_sys";
				regulator-state-mem {
					regulator-on-in-suspend;
					regulator-suspend-microvolt = <3300000>;
				};
			};

			vcc_buck5: DCDC_REG5 {
				regulator-always-on;
				regulator-boot-on;
				regulator-min-microvolt = <2200000>;
				regulator-max-microvolt = <2200000>;
				regulator-name = "vcc_buck5";
				regulator-state-mem {
					regulator-on-in-suspend;
					regulator-suspend-microvolt = <2200000>;
				};
			};

			vcca_0v9: LDO_REG1 {
				regulator-always-on;
				regulator-boot-on;
				regulator-min-microvolt = <900000>;
				regulator-max-microvolt = <900000>;
				regulator-name = "vcca_0v9";
				regulator-state-mem {
					regulator-off-in-suspend;
				};
			};

			vcc_1v8: LDO_REG2 {
				regulator-always-on;
				regulator-boot-on;
				regulator-min-microvolt = <1800000>;
				regulator-max-microvolt = <1800000>;

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

			vcc0v9_soc: LDO_REG3 {
				regulator-always-on;
				regulator-boot-on;
				regulator-min-microvolt = <900000>;
				regulator-max-microvolt = <900000>;

				regulator-name = "vcc0v9_soc";
				regulator-state-mem {
					regulator-on-in-suspend;
					regulator-suspend-microvolt = <900000>;
				};
			};

			vcca_1v8: LDO_REG4 {
				regulator-always-on;
				regulator-boot-on;
				regulator-min-microvolt = <1800000>;
				regulator-max-microvolt = <1800000>;

				regulator-name = "vcca_1v8";
				regulator-state-mem {
					regulator-off-in-suspend;
				};
			};

			vdd1v5_dvp: LDO_REG5 {
				regulator-always-on;
				regulator-boot-on;
				regulator-min-microvolt = <1500000>;
				regulator-max-microvolt = <1500000>;

				regulator-name = "vdd1v5_dvp";
				regulator-state-mem {
					regulator-off-in-suspend;
				};
			};

			vcc_1v5: LDO_REG6 {
				regulator-always-on;
				regulator-boot-on;
				regulator-min-microvolt = <1500000>;
				regulator-max-microvolt = <1500000>;

				regulator-name = "vcc_1v5";
				regulator-state-mem {
					regulator-off-in-suspend;
				};
			};

			vcc_3v0: LDO_REG7 {
				regulator-always-on;
				regulator-boot-on;
				regulator-min-microvolt = <3000000>;
				regulator-max-microvolt = <3000000>;

				regulator-name = "vcc_3v0";
				regulator-state-mem {
					regulator-off-in-suspend;
				};
			};

			vccio_sd: LDO_REG8 {
				regulator-always-on;
				regulator-boot-on;
				regulator-min-microvolt = <1800000>;
				regulator-max-microvolt = <3300000>;

				regulator-name = "vccio_sd";
				regulator-state-mem {
					regulator-off-in-suspend;
				};
			};

			vcc_sd: LDO_REG9 {
				regulator-always-on;
				regulator-boot-on;
				regulator-min-microvolt = <3300000>;
				regulator-max-microvolt = <3300000>;

				regulator-name = "vcc_sd";
				regulator-state-mem {
					regulator-off-in-suspend;
				};
			};

			vcc5v0_usb: SWITCH_REG1 {
				regulator-name = "vcc5v0_usb";
				regulator-state-mem {
					regulator-on-in-suspend;
				};
			};

			vccio_3v3: SWITCH_REG2 {
				regulator-always-on;
				regulator-boot-on;
				regulator-name = "vccio_3v3";
				regulator-state-mem {
					regulator-off-in-suspend;
				};
			};
		};

		rk809_codec: codec {
			#sound-dai-cells = <0>;
			compatible = "rockchip,rk809-codec", "rockchip,rk817-codec";
			clocks = <&cru SCLK_I2S_8CH_OUT>;
			clock-names = "mclk";
			pinctrl-names = "default";
			pinctrl-0 = <&i2s_8ch_mclk>;
			hp-volume = <20>;
			spk-volume = <3>;
			status = "okay";
		};
	};

	vdd_cpu_b: tcs4525@1c {
		compatible = "tcs,tcs4525";
		reg = <0x1c>;
		vin-supply = <&vcc5v0_sys>;
		regulator-compatible = "fan53555-reg";
		pinctrl-0 = <&vsel1_gpio>;
		vsel-gpios = <&gpio1 RK_PC1 GPIO_ACTIVE_HIGH>;
		regulator-name = "vdd_cpu_b";
		regulator-min-microvolt = <712500>;
		regulator-max-microvolt = <1500000>;
		regulator-ramp-delay = <2300>;
		fcs,suspend-voltage-selector = <1>;
		regulator-always-on;
		regulator-boot-on;
		regulator-initial-state = <3>;
		regulator-state-mem {
			regulator-off-in-suspend;
		};
	};

	vdd_gpu: tcs4526@10 {
		compatible = "tcs,tcs4526";
		reg = <0x10>;
		vin-supply = <&vcc5v0_sys>;
		regulator-compatible = "fan53555-reg";
		pinctrl-0 = <&vsel2_gpio>;
		vsel-gpios = <&gpio1 RK_PB6 GPIO_ACTIVE_HIGH>;
		regulator-name = "vdd_gpu";
		regulator-min-microvolt = <735000>;
		regulator-max-microvolt = <1400000>;
		regulator-ramp-delay = <1000>;
		fcs,suspend-voltage-selector = <1>;
		regulator-always-on;
		regulator-boot-on;
		regulator-initial-state = <3>;
		regulator-state-mem {
			regulator-off-in-suspend;
		};
	};

	bq25700: bq25700@6b {
		compatible = "ti,bq25703";
		reg = <0x6b>;
		interrupt-parent = <&gpio1>;
		interrupts = <RK_PA1 IRQ_TYPE_LEVEL_LOW>;
		pinctrl-names = "default";
		pinctrl-0 = <&charger_ok_int>;
		ti,charge-current = <1500000>;
		ti,max-charge-voltage = <8704000>;
		ti,max-input-voltage = <20000000>;
		ti,max-input-current = <6000000>;
		ti,input-current-sdp = <500000>;
		ti,input-current-dcp = <2000000>;
		ti,input-current-cdp = <2000000>;
		ti,input-current-dc = <2000000>;
		ti,minimum-sys-voltage = <6700000>;
		ti,otg-voltage = <5000000>;
		ti,otg-current = <500000>;
		ti,input-current = <500000>;
		pd-charge-only = <0>;
		status = "disabled";
	};
};

&i2c1 {
	status = "okay";
	i2c-scl-rising-time-ns = <140>;
	i2c-scl-falling-time-ns = <30>;

	mpu6500@68 {
		status = "okay";
		compatible = "invensense,mpu6500";
		reg = <0x68>;
		irq-gpio = <&gpio3 RK_PD2 IRQ_TYPE_EDGE_RISING>;
		mpu-int_config = <0x10>;
		mpu-level_shifter = <0>;
		mpu-orientation = <0 1 0 1 0 0 0 0 1>;
		orientation-x= <1>;
		orientation-y= <0>;
		orientation-z= <0>;
		mpu-debug = <1>;
	};

	sensor@d {
		status = "okay";
		compatible = "ak8963";
		reg = <0x0d>;
		type = <SENSOR_TYPE_COMPASS>;
		irq-gpio = <&gpio3 RK_PD7 IRQ_TYPE_EDGE_RISING>;
		irq_enable = <0>;
		poll_delay_ms = <30>;
		layout = <3>;
	};

	vm149c: vm149c@0c {
		compatible = "silicon touch,vm149c";
		status = "okay";
		reg = <0x0c>;
		rockchip,camera-module-index = <0>;
		rockchip,camera-module-facing = "back";
	};

	ov13850: ov13850@10 {
		compatible = "ovti,ov13850";
		status = "okay";
		reg = <0x10>;
		clocks = <&cru SCLK_CIF_OUT>;
		clock-names = "xvclk";

		/* conflict with csi-ctl-gpios */
		reset-gpios = <&gpio4 26 GPIO_ACTIVE_HIGH>;
		pwdn-gpios = <&gpio4 25 GPIO_ACTIVE_HIGH>;
		pinctrl-names = "rockchip,camera_default";
		pinctrl-0 = <&cif_clkout>;

		lens-focus = <&vm149c>;

		port {
			ucam_out0: endpoint {
				remote-endpoint = <&mipi_in_ucam0>;
				data-lanes = <1 2>;
			};
		};
	};

	imx327: imx327@1a {
		compatible = "sony,imx327";
		status = "okay";
		reg = <0x1a>;
		clocks = <&cru SCLK_CIF_OUT>;
		clock-names = "xvclk";
		/* conflict with csi-ctl-gpios */
		reset-gpios = <&gpio4 26 GPIO_ACTIVE_HIGH>;
		pwdn-gpios = <&gpio4 25 GPIO_ACTIVE_HIGH>;
		pinctrl-names = "default";
		pinctrl-0 = <&cif_clkout>;
		rockchip,camera-module-index = <0>;
		rockchip,camera-module-facing = "back";
		rockchip,camera-module-name = "TongJu";
		rockchip,camera-module-lens-name = "CHT842-MD";
		port {
			ucam_out2: endpoint {
				remote-endpoint = <&mipi_in_ucam2>;
				data-lanes = <1 2>;
			};
		};
	};

};

&i2c4 {
	status = "okay";
	i2c-scl-rising-time-ns = <345>;
	i2c-scl-falling-time-ns = <11>;

	gsl3673: gsl3673@40 {
		compatible = "GSL,GSL3673";
		reg = <0x40>;
		screen_max_x = <1536>;
		screen_max_y = <2048>;
		irq_gpio_number = <&gpio4 RK_PC3 IRQ_TYPE_LEVEL_LOW>;
		rst_gpio_number = <&gpio4 RK_PC6 GPIO_ACTIVE_HIGH>;
	};
};

&i2c8 {
	status = "okay";
	i2c-scl-rising-time-ns = <345>;
	i2c-scl-falling-time-ns = <11>;
	clock-frequency = <100000>;

	usbc0: fusb302@22 {
		compatible = "fcs,fusb302";
		reg = <0x22>;
		interrupt-parent = <&gpio1>;
		interrupts = <RK_PA2 IRQ_TYPE_LEVEL_LOW>;
		pinctrl-names = "default";
		pinctrl-0 = <&usbc0_int>;
		vbus-supply = <&vbus_typec>;
		status = "okay";

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

			port@0 {
				reg = <0>;
				usbc0_role_sw: endpoint@0 {
					remote-endpoint = <&dwc3_0_role_switch>;
				};
			};
		};

		usb_con: connector {
			compatible = "usb-c-connector";
			label = "USB-C";
			data-role = "dual";
			power-role = "dual";
			try-power-role = "sink";
			op-sink-microwatt = <1000000>;
			sink-pdos =
				<PDO_FIXED(5000, 2500, PDO_FIXED_USB_COMM)>;
			source-pdos =
				<PDO_FIXED(5000, 1500, PDO_FIXED_USB_COMM)>;

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

				port@0 {
					reg = <0>;
					usbc0_orien_sw: endpoint {
						remote-endpoint = <&tcphy0_orientation_switch>;
					};
				};
			};
		};
	};
};

&i2s1 {
	status = "okay";
	#sound-dai-cells = <0>;
};

&i2s2 {
	#sound-dai-cells = <0>;
	status = "okay";
};

&io_domains {
	status = "okay";
	bt656-supply = <&vcca_1v8>;
	audio-supply = <&vcca_1v8>;
	sdmmc-supply = <&vccio_sd>;
	gpio1830-supply = <&vcc_3v0>;
};

&isp0_mmu {
	status = "okay";
};

&isp1_mmu {
	status = "okay";
};

&mipi_dphy_tx1rx1 {
	status = "okay";

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

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

			mipi_in_ucam1: endpoint@1 {
				reg = <1>;
				/* Unlinked camera */
				//remote-endpoint = <&ucam_out1>;
				data-lanes = <1 2>;
			};
		};

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

			dphy_tx1rx1_out: endpoint@0 {
				reg = <0>;
				remote-endpoint = <&isp1_mipi_in>;
			};
		};
	};
};

&mipi_dphy_rx0 {
	status = "okay";

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

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

			mipi_in_ucam0: endpoint@1 {
				reg = <1>;
				remote-endpoint = <&ucam_out0>;
				data-lanes = <1 2>;
			};

			mipi_in_ucam2: endpoint@2 {
				reg = <2>;
				remote-endpoint = <&ucam_out2>;
				data-lanes = <1 2>;
			};
		};

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

			dphy_rx0_out: endpoint@0 {
				reg = <0>;
				remote-endpoint = <&isp0_mipi_in>;
			};
		};
	};
};

&pcie_phy {
	status = "okay";
};

&pcie0 {
	status = "okay";
};

&pmu_io_domains {
	status = "okay";
	pmu1830-supply = <&vcc_1v8>;
};

&pwm0 {
	status = "okay";
};

&pwm2 {
	status = "okay";
};

&rkisp1_0 {
	status = "okay";
	assigned-clocks = <&cru PLL_NPLL>, <&cru SCLK_CIF_OUT_SRC>, <&cru SCLK_CIF_OUT>;
	assigned-clock-rates = <594000000>, <594000000>, <37125000>;

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

		isp0_mipi_in: endpoint@0 {
			reg = <0>;
			remote-endpoint = <&dphy_rx0_out>;
		};
	};
};

&rkisp1_1 {
	status = "okay";

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

		isp1_mipi_in: endpoint@0 {
			reg = <0>;
			remote-endpoint = <&dphy_tx1rx1_out>;
		};
	};
};

&rockchip_suspend {
	status = "okay";
	rockchip,sleep-debug-en = <1>;
	rockchip,sleep-mode-config = <
		(0
		| RKPM_SLP_ARMPD
		| RKPM_SLP_PERILPPD
		| RKPM_SLP_DDR_RET
		| RKPM_SLP_PLLPD
		| RKPM_SLP_CENTER_PD
		| RKPM_SLP_OSC_DIS
		| RKPM_SLP_AP_PWROFF
		)
	>;
	rockchip,wakeup-config = <RKPM_GPIO_WKUP_EN>;
	rockchip,pwm-regulator-config = <PWM2_REGULATOR_EN>;
	rockchip,power-ctrl =
		<&gpio1 RK_PC1 GPIO_ACTIVE_HIGH>,
		<&gpio1 RK_PB6 GPIO_ACTIVE_HIGH>;
};

&route_edp {
	status = "okay";
};

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

&sdmmc {
	sd-uhs-sdr12;
	sd-uhs-sdr25;
	sd-uhs-sdr50;
	sd-uhs-sdr104;
};

&spi1 {
	status = "okay";
	max-freq = <48000000>; /* spi internal clk, don't modify */
	spi_dev@0 {
		compatible = "rockchip,spidev";
		reg = <0>;
		spi-max-frequency = <12000000>;
		spi-lsb-first;
	};
};

&tcphy0 {
	status = "okay";
	orientation-switch;
	port {
		#address-cells = <1>;
		#size-cells = <0>;
		tcphy0_orientation_switch: endpoint@0 {
			reg = <0>;
			remote-endpoint = <&usbc0_orien_sw>;
		};
	};
};

&tcphy1 {
	status = "okay";
};

&tsadc {
	rockchip,hw-tshut-mode = <1>; /* tshut mode 0:CRU 1:GPIO */
	rockchip,hw-tshut-polarity = <1>; /* tshut polarity 0:LOW 1:HIGH */
	status = "okay";
};

&u2phy0 {
	status = "okay";

	u2phy0_otg: otg-port {
		status = "okay";
	};

	u2phy0_host: host-port {
		phy-supply = <&vcc5v0_usb>;
		status = "okay";
	};
};

&u2phy1 {
	status = "okay";

	u2phy1_otg: otg-port {
		status = "okay";
	};

	u2phy1_host: host-port {
		phy-supply = <&vcc5v0_usb>;
		status = "okay";
	};
};

&uart0 {
	pinctrl-names = "default";
	pinctrl-0 = <&uart0_xfer &uart0_cts>;
	status = "okay";
};

&usb_host0_ehci {
	status = "okay";
};

&usb_host1_ehci {
	status = "okay";
};
&usb_host0_ohci {
	status = "okay";
};

&usb_host1_ohci {
	status = "okay";
};

&usbdrd3_0 {
	status = "okay";
};

&usbdrd3_1 {
	status = "okay";
};

&usbdrd_dwc3_0 {
	status = "okay";
	usb-role-switch;
	port {
		#address-cells = <1>;
		#size-cells = <0>;
		dwc3_0_role_switch: endpoint@0 {
			reg = <0>;
			remote-endpoint = <&usbc0_role_sw>;
		};
	};
};

&usbdrd_dwc3_1 {
	status = "okay";
};

&vopb {
	status = "okay";
};

&vopb_mmu {
	status = "okay";
};

&vopl {
	status = "okay";
};

&vopl_mmu {
	status = "okay";
};

&pinctrl {
	pinctrl-names = "default";
	pinctrl-0 = <&npu_ref_clk>;

	bq2570 {
		charger_ok_int: charger-ok-int {
			rockchip,pins =
				<1 RK_PA1 RK_FUNC_GPIO &pcfg_pull_up>;
			};
	};

	camera {
		cam_pwren_high: cam-pwren-high {
			rockchip,pins =
				<4 RK_PC5 RK_FUNC_GPIO &pcfg_output_high>;
			};
	};

	headphone {
		hp_det: hp-det {
			rockchip,pins =
				<0 RK_PB5 RK_FUNC_GPIO &pcfg_pull_up>;
		};
	};

	lcd_rst {
		lcd_rst_gpio: lcd-rst-gpio {
			rockchip,pins =
				<3 RK_PA4 RK_FUNC_GPIO &pcfg_pull_none>;
		};
	};

	npu_clk {
		npu_ref_clk: npu-ref-clk {
		     rockchip,pins =
			     <0 RK_PA2 1 &pcfg_pull_none>;
	     };
	};

	pmic {
		pmic_int_l: pmic-int-l {
			rockchip,pins =
				<1 RK_PC2 RK_FUNC_GPIO &pcfg_pull_up>;
		};
		vsel1_gpio: vsel1-gpio {
			rockchip,pins =
				<1 RK_PC1 RK_FUNC_GPIO &pcfg_pull_down>;
		};
		vsel2_gpio: vsel2-gpio {
			rockchip,pins =
				<1 RK_PB6 RK_FUNC_GPIO &pcfg_pull_down>;
		};

		soc_slppin_gpio: soc-slppin-gpio {
			rockchip,pins =
				<1 RK_PA5 RK_FUNC_GPIO &pcfg_output_low>;
		};

		soc_slppin_slp: soc-slppin-slp {
			rockchip,pins =
				<1 RK_PA5 1 &pcfg_pull_down>;
		};

		soc_slppin_rst: soc-slppin-rst {
			rockchip,pins =
				<1 RK_PA5 2 &pcfg_pull_none>;
		};
	};

	sdio-pwrseq {
		wifi_enable_h: wifi-enable-h {
			rockchip,pins =
				<2 RK_PD3 RK_FUNC_GPIO &pcfg_pull_none>;
		};
	};

	sdmmc {
		sdmmc_bus1: sdmmc-bus1 {
			rockchip,pins =
				<4 RK_PB0 1 &pcfg_pull_up_10ma>;
		};

		sdmmc_bus4: sdmmc-bus4 {
			rockchip,pins =
				<4 RK_PB0 1 &pcfg_pull_up_10ma>,
				<4 RK_PB1 1 &pcfg_pull_up_10ma>,
				<4 RK_PB2 1 &pcfg_pull_up_10ma>,
				<4 RK_PB3 1 &pcfg_pull_up_10ma>;
		};

		sdmmc_clk: sdmmc-clk {
			rockchip,pins =
				<4 RK_PB4 1 &pcfg_pull_none_10ma>;
		};

		sdmmc_cmd: sdmmc-cmd {
			rockchip,pins =
				<4 RK_PB5 1 &pcfg_pull_up_10ma>;
		};
	};

	tp_irq {
		tp_irq_gpio: tp-irq-gpio {
			rockchip,pins =
				<3 RK_PB0 RK_FUNC_GPIO &pcfg_pull_up>;
		};
	};

	usb-typec {
		usbc0_int: usbc0-int {
			rockchip,pins = <1 RK_PA2 RK_FUNC_GPIO &pcfg_pull_up>;
		};

		vcc5v0_typec0_en: vcc5v0-typec0-en {
			rockchip,pins = <1 RK_PC2 RK_FUNC_GPIO &pcfg_pull_none>;
		};
	};

	wireless-bluetooth {
		bt_irq_gpio: bt-irq-gpio {
			rockchip,pins =
				<0 RK_PA5 RK_FUNC_GPIO &pcfg_pull_down>;
		};

		uart0_gpios: uart0-gpios {
			rockchip,pins =
				<2 RK_PC3 RK_FUNC_GPIO &pcfg_pull_none>;
		};
	};
};

/* DON'T PUT ANYTHING BELOW HERE.  PUT IT ABOVE PINCTRL */
/* DON'T PUT ANYTHING BELOW HERE.  PUT IT ABOVE PINCTRL */
/* DON'T PUT ANYTHING BELOW HERE.  PUT IT ABOVE PINCTRL */
