// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
/*
 * Copyright (c) 2021 Rockchip Electronics Co., Ltd.
 * Copyright (c) 2023 EmbedFire <embedfire@embedfire.com>
 * Copyright (c) 2023 erd-yunmu <cancet@embedfire.com>
 */

/dts-v1/;

#include <dt-bindings/usb/pd.h>
#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/pwm/pwm.h>
#include <dt-bindings/pinctrl/rockchip.h>
#include <dt-bindings/input/rk-input.h>
#include <dt-bindings/display/drm_mipi_dsi.h>
#include <dt-bindings/display/rockchip_vop.h>
#include <dt-bindings/sensor-dev.h>
#include "rk3588s.dtsi"
#include "rk3588-linux.dtsi"

/ {
	model = "Embedfire LubanCat-4";
	compatible = "rockchip,rk3588s-lubancat-4", "rockchip,rk3588";

	chosen: chosen {
		bootargs = "earlycon=uart8250,mmio32,0xfeb50000 console=ttyFIQ0 coherent_pool=1m irqchip.gicv3_pseudo_nmi=0";
	};

	adc_keys: adc-keys {
		compatible = "adc-keys";
		io-channels = <&saradc 1>;
		io-channel-names = "buttons";
		keyup-threshold-microvolt = <1800000>;
		poll-interval = <100>;
		
		power {
			label = "power";
			linux,code = <KEY_POWER>;
			press-threshold-microvolt = <1750>;
		};
	};

	leds: leds {
		status = "okay";
		compatible = "gpio-leds";

		sys_status_led: sys-status-led {
			label = "sys_status_led";
			linux,default-trigger = "heartbeat";
			default-state = "on";
			gpios = <&gpio4 RK_PB5 GPIO_ACTIVE_LOW>;
			pinctrl-names = "default";
			pinctrl-0 = <&sys_status_led_pin>;
		};
	};

	vcc5v0_dcin: vcc5v0-dcin {
		compatible = "regulator-fixed";
		regulator-name = "vcc5v_dcin";
		regulator-always-on;
		regulator-boot-on;
		regulator-min-microvolt = <5000000>;
		regulator-max-microvolt = <5000000>;
	};
	
	vcc5v0_sys: 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 = <&vcc5v0_dcin>;
	};

	vcc_5v0: vcc-5v0 {
		compatible = "regulator-fixed";
		regulator-name = "vcc_5v0";
		regulator-always-on;
		regulator-boot-on;
		regulator-min-microvolt = <5000000>;
		regulator-max-microvolt = <5000000>;
		vin-supply = <&vcc5v0_sys>;
	};

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

	combophy_avdd0v85: combophy-avdd0v85 {
		compatible = "regulator-fixed";
		regulator-name = "combophy_avdd0v85";
		regulator-boot-on;
		regulator-min-microvolt = <850000>;
		regulator-max-microvolt = <850000>;
		vin-supply = <&avdd_0v85_s0>;
	};

	combophy_avdd1v8: combophy-avdd1v8 {
		compatible = "regulator-fixed";
		regulator-name = "combophy_avdd1v8";
		regulator-boot-on;
		regulator-min-microvolt = <1800000>;
		regulator-max-microvolt = <1800000>;
		vin-supply = <&avcc_1v8_s0>;
	};

	vcc_1v1_nldo_s3: 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_3v3_s0: vcc-3v3-s0 {
		compatible = "regulator-fixed";
		regulator-name = "vcc_3v3_s0";
		regulator-always-on;
		regulator-boot-on;
		regulator-min-microvolt = <3300000>;
		regulator-max-microvolt = <3300000>;
		vin-supply = <&vcc_3v3_s3>;
	};

	vcc_3v3_sd_s3: vcc-3v3-sd-s3 {
		compatible = "regulator-fixed";
		regulator-name = "vcc_3v3_sd_s3";
		regulator-always-on;
		regulator-boot-on;
		regulator-min-microvolt = <3300000>;
		regulator-max-microvolt = <3300000>;
		vin-supply = <&vcc_3v3_s3>;
	};

	vbus5v0_typec: vbus5v0-typec {
		compatible = "regulator-fixed";
		regulator-name = "vbus5v0_typec";
		regulator-min-microvolt = <5000000>;
		regulator-max-microvolt = <5000000>;
		enable-active-high;
		gpio = <&gpio1 RK_PC1 GPIO_ACTIVE_HIGH>;
		vin-supply = <&vcc5v0_usb>;
		pinctrl-names = "default";
		pinctrl-0 = <&typec_vbus_en>;
	};

	vcc5v0_usb30_host: vcc5v0-usb30-host {
		compatible = "regulator-fixed";
		regulator-name = "vcc5v0_usb30_host";
		regulator-min-microvolt = <5000000>;
		regulator-max-microvolt = <5000000>;
		enable-active-high;
		gpio = <&gpio1 RK_PC4 GPIO_ACTIVE_HIGH>;
		vin-supply = <&vcc5v0_usb>;
		pinctrl-names = "default";
		pinctrl-0 = <&usb30_host_pwr_en>;
	};

	vcc5v0_usb20_host: vcc5v0-usb20-host {
		compatible = "regulator-fixed";
		regulator-name = "vcc5v0_usb20_host";
		regulator-min-microvolt = <5000000>;
		regulator-max-microvolt = <5000000>;
		enable-active-high;
		gpio = <&gpio1 RK_PC6 GPIO_ACTIVE_HIGH>;
		vin-supply = <&vcc5v0_usb>;
		pinctrl-names = "default";
		pinctrl-0 = <&usb20_host_pwr_en>;
	};

	vcc3v3_pcie20: vcc3v3-pcie20 {
		compatible = "regulator-fixed";
		regulator-name = "vcc3v3_pcie20";
		regulator-min-microvolt = <3300000>;
		regulator-max-microvolt = <3300000>;
		enable-active-high;
		regulator-always-on;
		gpios = <&gpio1 RK_PD5 GPIO_ACTIVE_HIGH>;
		startup-delay-us = <5000>;
		vin-supply = <&vcc5v0_sys>;
	};

	mipi_dsi0_power: mipi-dsi0-power-regulator {
		compatible = "regulator-fixed";
		regulator-name = "mipi_dsi0_power";
		gpio = <&gpio1 RK_PD2 GPIO_ACTIVE_HIGH>;
		enable-active-high;
		regulator-boot-on;
		regulator-always-on;
	};

	mipi_dsi1_power: mipi-dsi1-power-regulator {
		compatible = "regulator-fixed";
		regulator-name = "mipi_dsi1_power";
		gpio = <&gpio1 RK_PD3 GPIO_ACTIVE_HIGH>;
		enable-active-high;
		regulator-boot-on;
		regulator-always-on;
	};

	dp0_sound: dp0-sound {
		status = "okay";
		compatible = "rockchip,hdmi";
		rockchip,card-name = "rockchip-dp0";
		rockchip,mclk-fs = <512>;
		rockchip,cpu = <&spdif_tx2>;
		rockchip,codec = <&dp0 1>;
		rockchip,jack-det;
	};

	hdmi0_sound: hdmi0-sound {
		status = "okay";
		compatible = "rockchip,hdmi";
		rockchip,mclk-fs = <128>;
		rockchip,card-name = "rockchip-hdmi0";
		rockchip,cpu = <&i2s5_8ch>;
		rockchip,codec = <&hdmi0>;
		rockchip,jack-det;
	};

	es8388_sound: es8388-sound {
		status = "okay";
		compatible = "rockchip,multicodecs-card";
		rockchip,card-name = "rockchip-es8388";
		hp-det-gpio = <&gpio1 RK_PC0 GPIO_ACTIVE_HIGH>;
		hp-con-gpio = <&gpio1 RK_PA6 GPIO_ACTIVE_HIGH>;
		io-channels = <&saradc 4>;
		io-channel-names = "adc-detect";
		keyup-threshold-microvolt = <1800000>;
		poll-interval = <100>;
		rockchip,format = "i2s";
		rockchip,mclk-fs = <256>;
		rockchip,cpu = <&i2s0_8ch>;
		rockchip,codec = <&es8388>;
		rockchip,audio-routing =
			"Headphone", "LOUT1",
			"Headphone", "ROUT1",
			"Headphone", "Headphone Power",
			"Headphone", "Headphone Power",
			"LINPUT1", "Main Mic",
			"LINPUT2", "Main Mic",
			"RINPUT1", "Headset Mic",
			"RINPUT2", "Headset Mic";
		pinctrl-names = "default";
		pinctrl-0 = <&hp_det>;
		play-pause-key {
			label = "playpause";
			linux,code = <KEY_PLAYPAUSE>;
			press-threshold-microvolt = <2000>;
		};

		previous-song-key {
			label = "previoussong";
			linux,code = <KEY_PREVIOUSSONG>;
			press-threshold-microvolt = <145000>;
		};

		next-song-key {
			label = "nextsong";
			linux,code = <KEY_NEXTSONG>;
			press-threshold-microvolt = <290000>;
		};
	};

	fan: pwm-fan {
		compatible = "pwm-fan";
		#cooling-cells = <2>;
		pwms = <&pwm0 0 250000 0>;
		cooling-levels = <0 100 150 200 255>;
		rockchip,temp-trips = <
			50000	1
			55000	2
			60000	3
			65000	4
		>;
	};

	backlight0: backlight0 {
		compatible = "pwm-backlight";
		pwms = <&pwm2 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>;
	};

	backlight1: backlight1 {
		compatible = "pwm-backlight";
		pwms = <&pwm6 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>;
	};

	test-power {
		status = "okay";
	};
};

&rockchip_suspend {
	status = "disabled";
	rockchip,sleep-debug-en = <1>;
	rockchip,sleep-mode-config = <
		(0
		| RKPM_SLP_ARMOFF_DDRPD 
		)
	>;
	rockchip,wakeup-config = <
		(0
		| RKPM_GPIO_WKUP_EN
		| RKPM_CPU0_WKUP_EN
		)
	>;
};

&av1d {
	status = "okay";
};

&av1d_mmu {
	status = "okay";
};

&spdif_tx2 {
    status = "okay";
};

&i2s5_8ch {
	status = "okay";
};

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

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

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

&gpu {
	mali-supply = <&vdd_gpu_s0>;
	mem-supply = <&vdd_gpu_mem_s0>;
	upthreshold = <60>;
	downdifferential = <30>;
	status = "okay";
};

&dfi {
	status = "okay";
};

&dmc {
	status = "okay";
	center-supply = <&vdd_ddr_s0>;
	mem-supply = <&vdd_log_s0>;
};

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

	hym8563: hym8563@51 {
		compatible = "haoyu,hym8563";
		reg = <0x51>;
		#clock-cells = <0>;
		clock-frequency = <32768>;
		clock-output-names = "hym8563";
		pinctrl-names = "default";
		pinctrl-0 = <&hym8563_int>;
		interrupt-parent = <&gpio0>;
		interrupts = <RK_PB0 IRQ_TYPE_LEVEL_LOW>;
		wakeup-source;
	};

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

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

&i2c1 {
	pinctrl-names = "default";
	pinctrl-0 = <&i2c1m2_xfer>;
	status = "okay";

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

	/* Typec Controller Fusb302 */
	usbc0: fusb302@22 {
		compatible = "fcs,fusb302";
		reg = <0x22>;
		interrupt-parent = <&gpio0>;
		interrupts = <RK_PC6 IRQ_TYPE_LEVEL_LOW>;
		pinctrl-names = "default";
		pinctrl-0 = <&fusb302_int>;
		vbus-supply = <&vbus5v0_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, 1000, PDO_FIXED_USB_COMM)>;
			source-pdos =
				<PDO_FIXED(5000, 3000, PDO_FIXED_USB_COMM)>;

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

				altmode@0 {
					reg = <0>;
					svid = <0xff01>;
					vdo = <0xffffffff>;
				};
			};

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

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

				port@1 {
					reg = <1>;
					dp_altmode_mux: endpoint {
						remote-endpoint = <&usbdp_phy0_dp_altmode_mux>;
					};
				};
			};
		};
	};
};

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

	rk806single@0 {
		compatible = "rockchip,rk806";
		spi-max-frequency = <1000000>;
		reg = <0x0>;

		interrupt-parent = <&gpio0>;
		interrupts = <RK_PA7 IRQ_TYPE_LEVEL_LOW>;

		pinctrl-names = "default", "pmic-power-off";
		pinctrl-0 = <&pmic_pins>, <&rk806_dvs1_null>, <&rk806_dvs2_null>, <&rk806_dvs3_null>;
		pinctrl-1 = <&rk806_dvs1_pwrdn>;

		/* 2800mv-3500mv */
		low_voltage_threshold = <3000>;
		/* 2700mv-3400mv */
		shutdown_voltage_threshold = <2700>;
		/* 140 160 */
		shutdown_temperture_threshold = <160>;
		hotdie_temperture_threshold = <115>;

		/* 0: restart PMU;
		 * 1: reset all the power off reset registers,
		 *	forcing the state to switch to ACTIVE mode;
		 * 2: Reset all the power off reset registers,
		 *	forcing the state to switch to ACTIVE mode,
		 *	and simultaneously pull down the RESETB PIN for 5mS before releasing
		 */
		pmic-reset-func = <1>;

		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>;

		pwrkey {
			status = "okay";
		};

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

			rk806_dvs1_null: rk806_dvs1_null {
				pins = "gpio_pwrctrl2";
				function = "pin_fun0";
			};

			rk806_dvs1_slp: rk806_dvs1_slp {
				pins = "gpio_pwrctrl1";
				function = "pin_fun1";
			};

			rk806_dvs1_pwrdn: rk806_dvs1_pwrdn {
				pins = "gpio_pwrctrl1";
				function = "pin_fun2";
			};

			rk806_dvs1_rst: rk806_dvs1_rst {
				pins = "gpio_pwrctrl1";
				function = "pin_fun3";
			};

			rk806_dvs2_null: rk806_dvs2_null {
				pins = "gpio_pwrctrl2";
				function = "pin_fun0";
			};

			rk806_dvs2_slp: rk806_dvs2_slp {
				pins = "gpio_pwrctrl2";
				function = "pin_fun1";
			};

			rk806_dvs2_pwrdn: rk806_dvs2_pwrdn {
				pins = "gpio_pwrctrl2";
				function = "pin_fun2";
			};

			rk806_dvs2_rst: rk806_dvs2_rst {
				pins = "gpio_pwrctrl2";
				function = "pin_fun3";
			};

			rk806_dvs2_dvs: rk806_dvs2_dvs {
				pins = "gpio_pwrctrl2";
				function = "pin_fun4";
			};

			rk806_dvs2_gpio: rk806_dvs2_gpio {
				pins = "gpio_pwrctrl2";
				function = "pin_fun5";
			};

			rk806_dvs3_null: rk806_dvs3_null {
				pins = "gpio_pwrctrl3";
				function = "pin_fun0";
			};

			rk806_dvs3_slp: rk806_dvs3_slp {
				pins = "gpio_pwrctrl3";
				function = "pin_fun1";
			};

			rk806_dvs3_pwrdn: rk806_dvs3_pwrdn {
				pins = "gpio_pwrctrl3";
				function = "pin_fun2";
			};

			rk806_dvs3_rst: rk806_dvs3_rst {
				pins = "gpio_pwrctrl3";
				function = "pin_fun3";
			};

			rk806_dvs3_dvs: rk806_dvs3_dvs {
				pins = "gpio_pwrctrl3";
				function = "pin_fun4";
			};

			rk806_dvs3_gpio: rk806_dvs3_gpio {
				pins = "gpio_pwrctrl3";
				function = "pin_fun5";
			};
		};

		regulators {
			vdd_gpu_s0: vdd_gpu_mem_s0: DCDC_REG1 {
				regulator-always-on;
				regulator-boot-on;
				regulator-min-microvolt = <550000>;
				regulator-max-microvolt = <950000>;
				regulator-ramp-delay = <12500>;
				regulator-name = "vdd_gpu_s0";
				regulator-state-mem {
					regulator-off-in-suspend;
				};
			};

			vdd_cpu_lit_s0: vdd_cpu_lit_mem_s0: DCDC_REG2 {
				regulator-always-on;
				regulator-boot-on;
				regulator-min-microvolt = <550000>;
				regulator-max-microvolt = <950000>;
				regulator-ramp-delay = <12500>;
				regulator-name = "vdd_cpu_lit_s0";
				regulator-state-mem {
					regulator-off-in-suspend;
				};
			};

			vdd_log_s0: DCDC_REG3 {
				regulator-always-on;
				regulator-boot-on;
				regulator-min-microvolt = <750000>;
				regulator-max-microvolt = <750000>;
				regulator-ramp-delay = <12500>;
				regulator-name = "vdd_log_s0";
				regulator-state-mem {
					regulator-on-in-suspend;
				};
			};

			vdd_vdenc_s0: vdd_vdenc_mem_s0: DCDC_REG4 {
				regulator-always-on;
				regulator-boot-on;
				regulator-min-microvolt = <550000>;
				regulator-max-microvolt = <950000>;
				regulator-init-microvolt = <750000>;
				regulator-ramp-delay = <12500>;
				regulator-name = "vdd_vdenc_s0";
				regulator-state-mem {
					regulator-off-in-suspend;
				};
			};

			vdd_ddr_s0: DCDC_REG5 {
				regulator-always-on;
				regulator-boot-on;
				regulator-min-microvolt = <850000>;
				regulator-max-microvolt = <850000>;
				regulator-ramp-delay = <12500>;
				regulator-name = "vdd_ddr_s0";
				regulator-state-mem {
					regulator-off-in-suspend;
					regulator-suspend-microvolt = <850000>;
				};
			};

			vdd2_ddr_s3: DCDC_REG6 {
				regulator-always-on;
				regulator-boot-on;
				regulator-name = "vdd2_ddr_s3";
				regulator-state-mem {
					regulator-on-in-suspend;
				};
			};

			vcc_2v0_pldo_s3: DCDC_REG7 {
				regulator-always-on;
				regulator-boot-on;
				regulator-min-microvolt = <2000000>;
				regulator-max-microvolt = <2000000>;
				regulator-name = "vdd_2v0_pldo_s3";
				regulator-state-mem {
					regulator-on-in-suspend;
					regulator-suspend-microvolt = <2000000>;
				};
			};

			vcc_3v3_s3: DCDC_REG8 {
				regulator-always-on;
				regulator-boot-on;
				regulator-min-microvolt = <3300000>;
				regulator-max-microvolt = <3300000>;
				regulator-name = "vcc_3v3_s3";
				regulator-state-mem {
					regulator-on-in-suspend;
				};
			};

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

			vcc_1v8_s3: DCDC_REG10 {
				regulator-always-on;
				regulator-boot-on;
				regulator-min-microvolt = <1800000>;
				regulator-max-microvolt = <1800000>;
				regulator-name = "vcc_1v8_s3";
				regulator-state-mem {
					regulator-on-in-suspend;
					regulator-suspend-microvolt = <1800000>;
				};
			};

			vcc_1v8_s0: PLDO_REG1 {
				regulator-always-on;
				regulator-boot-on;
				regulator-min-microvolt = <1800000>;
				regulator-max-microvolt = <1800000>;
				regulator-name = "vcc_1v8_s0";
				regulator-state-mem {
					regulator-on-in-suspend;
				};
			};

			avcc_1v8_s0: PLDO_REG2 {
				regulator-always-on;
				regulator-boot-on;
				regulator-min-microvolt = <1800000>;
				regulator-max-microvolt = <1800000>;
				regulator-name = "avcc_1v8_s0";
				regulator-state-mem {
					regulator-off-in-suspend;
					regulator-suspend-microvolt = <1800000>;
				};
			};

			avdd_1v2_s0: PLDO_REG3 {
				regulator-always-on;
				regulator-boot-on;
				regulator-min-microvolt = <1200000>;
				regulator-max-microvolt = <1200000>;
				regulator-name = "avdd_1v2_s0";
				regulator-state-mem {
					regulator-off-in-suspend;
				};
			};

			avcc_3v3_s0: PLDO_REG4 {
				regulator-always-on;
				regulator-boot-on;
				regulator-min-microvolt = <3300000>;
				regulator-max-microvolt = <3300000>;
				regulator-name = "avcc_3v3_s0";
				regulator-state-mem {
					regulator-off-in-suspend;
				};
			};

			vccio_sd_s0: PLDO_REG5 {
				regulator-always-on;
				regulator-boot-on;
				regulator-min-microvolt = <1800000>;
				regulator-max-microvolt = <3300000>;
				regulator-name = "vccio_sd_s0";
				regulator-state-mem {
					regulator-off-in-suspend;
				};
			};

			pldo6_s3: PLDO_REG6 {
				regulator-always-on;
				regulator-boot-on;
				regulator-min-microvolt = <1800000>;
				regulator-max-microvolt = <1800000>;
				regulator-name = "pldo6_s3";
				regulator-state-mem {
					regulator-on-in-suspend;
					regulator-suspend-microvolt = <1800000>;
				};
			};

			vdd_0v75_s3: NLDO_REG1 {
				regulator-always-on;
				regulator-boot-on;
				regulator-min-microvolt = <750000>;
				regulator-max-microvolt = <750000>;
				regulator-name = "vdd_0v75_s3";
				regulator-state-mem {
					regulator-on-in-suspend;
					regulator-suspend-microvolt = <750000>;
				};
			};

			avdd_ddr_pll_s0: NLDO_REG2 {
				regulator-always-on;
				regulator-boot-on;
				regulator-min-microvolt = <850000>;
				regulator-max-microvolt = <850000>;
				regulator-name = "avdd_ddr_pll_s0";
				regulator-state-mem {
					regulator-off-in-suspend;
					regulator-suspend-microvolt = <850000>;
				};
			};

			avdd_0v75_s0: NLDO_REG3 {
				regulator-always-on;
				regulator-boot-on;
				regulator-min-microvolt = <750000>;
				regulator-max-microvolt = <750000>;
				regulator-name = "avdd_0v75_s0";
				regulator-state-mem {
					regulator-off-in-suspend;
				};
			};

			avdd_0v85_s0: NLDO_REG4 {
				regulator-always-on;
				regulator-boot-on;
				regulator-min-microvolt = <850000>;
				regulator-max-microvolt = <850000>;
				regulator-name = "avdd_0v85_s0";
				regulator-state-mem {
					regulator-off-in-suspend;
				};
			};

			nldo5_s0: NLDO_REG5 {
				regulator-name = "nldo5_s0";
				regulator-state-mem {
					regulator-off-in-suspend;
				};
			};
		};
	};
};

&i2c7 {
	pinctrl-names = "default";
	pinctrl-0 = <&i2c7m0_xfer>;
	status = "okay";

	es8388: es8388@11 {
		status = "okay";
		#sound-dai-cells = <0>;
		compatible = "everest,es8388", "everest,es8323";
		reg = <0x11>;
		clocks = <&mclkout_i2s0>;
		clock-names = "mclk";
		assigned-clocks = <&mclkout_i2s0>;
		assigned-clock-rates = <12288000>;
		pinctrl-names = "default";
		pinctrl-0 = <&i2s0_mclk>;
	};
};

&i2s0_8ch {
    status = "okay";
    rockchip,clk-trcm = <1>;
    pinctrl-0 = <&i2s0_lrck
             &i2s0_sclk
             &i2s0_sdi0
             &i2s0_sdo0>;
};

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

&tsadc {
	status = "okay";
};

&sdhci {
	bus-width = <8>;
	no-sdio;
	no-sd;
	non-removable;
	max-frequency = <200000000>;
	mmc-hs400-1_8v;
	mmc-hs400-enhanced-strobe;
	status = "okay";
};

&sdmmc {
	max-frequency = <200000000>;
	no-sdio;
	no-mmc;
	bus-width = <4>;
	cap-mmc-highspeed;
	cap-sd-highspeed;
	disable-wp;
	sd-uhs-sdr104;
	vmmc-supply = <&vcc_3v3_sd_s3>;
	vqmmc-supply = <&vccio_sd_s0>;
	pinctrl-names = "default";
	pinctrl-0 = <&sdmmc_bus4 &sdmmc_clk &sdmmc_cmd &sdmmc_det>;
	status = "okay";
};

&iep {
	status = "okay";
};

&iep_mmu {
	status = "okay";
};

&jpegd {
	status = "okay";
};

&jpegd_mmu {
	status = "okay";
};

&jpege_ccu {
	status = "okay";
};

&jpege0 {
	status = "okay";
};

&jpege0_mmu {
	status = "okay";
};

&jpege1 {
	status = "okay";
};

&jpege1_mmu {
	status = "okay";
};

&jpege2 {
	status = "okay";
};

&jpege2_mmu {
	status = "okay";
};

&jpege3 {
	status = "okay";
};

&jpege3_mmu {
	status = "okay";
};

&mpp_srv {
	status = "okay";
};

&pwm0 {
	pinctrl-0 = <&pwm0m2_pins>;
	status = "okay";
};

&pwm2 {
	pinctrl-0 = <&pwm2m0_pins>;
	status = "okay";
};

&pwm6 {
	pinctrl-0 = <&pwm6m0_pins>;
	status = "okay";
};

&pwm7 {
	compatible = "rockchip,remotectl-pwm";
	pinctrl-names = "default";
	pinctrl-0 = <&pwm7m0_pins>;
	remote_pwm_id = <3>;
	handle_cpu_id = <1>;
	remote_support_psci = <0>;
	status = "okay";

	ir_key_lubancat{
	rockchip,usercode = <0xff00>;
	rockchip,key_table =
		<0xeb   KEY_POWER>,
		<0xec   KEY_MENU>,
		<0xfe   KEY_BACK>,
		<0xb7   KEY_HOME>,
		<0xa3   KEY_WWW>,
		<0xf4   KEY_VOLUMEUP>,
		<0xa7   KEY_VOLUMEDOWN>,
		<0xf8   KEY_REPLY>,
		<0xfc   KEY_UP>,
		<0xfd   KEY_DOWN>,
		<0xf1   KEY_LEFT>,
		<0xe5   KEY_RIGHT>;
	};

	ir_key2 {	
		rockchip,usercode = <0xf708>;
		rockchip,key_table =	
			<0x28   KEY_POWER>,
			<0xfe   KEY_SETUP>,
			<0xa4   KEY_MUTE>,
			<0x6d   KEY_UP>,
			<0x68   KEY_LEFT>,
			<0x64   KEY_ENTER>,
			<0x60   KEY_RIGHT>,
			<0x27   KEY_DOWN>,
			<0x3c   KEY_MENU>,
			<0x7d   KEY_HOME>,
			<0x2b   KEY_BACK>,
			<0x7c   KEY_VOLUMEDOWN>,
			<0x79   KEY_VOLUMEUP>,
			<0x57   KEY_AUDIO>,
			<0x5d   KEY_SUBTITLE>,  
			<0x99   KEY_PHONE>, 
			<0xfd   KEY_WWW>,
			<0xfc   KEY_F1>,
			<0x7e   KEY_TV>;			
	};

	ir_key3 {
		rockchip,usercode = <0x1dcc>;
		rockchip,key_table =
			<0xee   KEY_REPLY>,
			<0xf0   KEY_BACK>,
			<0xf8   KEY_UP>,
			<0xbb   KEY_DOWN>,
			<0xef   KEY_LEFT>,
			<0xed   KEY_RIGHT>,
			<0xfc   KEY_HOME>,
			<0xf1   KEY_VOLUMEUP>,
			<0xfd   KEY_VOLUMEDOWN>,
			<0xb7   KEY_SEARCH>,
			<0xff   KEY_POWER>,
			<0xf3   KEY_MUTE>,
			<0xbf   KEY_MENU>,
			<0xf9   0x191>,
			<0xf5   0x192>,
			<0xb3   388>,
			<0xbe   KEY_1>,
			<0xba   KEY_2>,
			<0xb2   KEY_3>,
			<0xbd   KEY_4>,
			<0xf9   KEY_5>,
			<0xb1   KEY_6>,
			<0xfc   KEY_7>,
			<0xf8   KEY_8>,
			<0xb0   KEY_9>,
			<0xb6   KEY_0>,
			<0xb5   KEY_BACKSPACE>;
	};
};

&rga3_core0 {
	status = "okay";
};

&rga3_0_mmu {
	status = "okay";
};

&rga3_core1 {
	status = "okay";
};

&rga3_1_mmu {
	status = "okay";
};

&rga2 {
	status = "okay";
};

&rknpu {
	rknpu-supply = <&vdd_npu_s0>;
	mem-supply = <&vdd_npu_mem_s0>;
	status = "okay";
};

&rknpu_mmu {
	status = "okay";
};

&rkvdec_ccu {
	status = "okay";
};

&rkvdec0 {
	status = "okay";
};

&rkvdec0_mmu {
	status = "okay";
};

&rkvdec1 {
	status = "okay";
};

&rkvdec1_mmu {
	status = "okay";
};

&rkvenc_ccu {
	status = "okay";
};

&rkvenc0 {
	status = "okay";
};

&rkvenc0_mmu {
	status = "okay";
};

&rkvenc1 {
	status = "okay";
};

&rkvenc1_mmu {
	status = "okay";
};

&gmac1 {
	/* Use rgmii-rxid mode to disable rx delay inside Soc */
	phy-mode = "rgmii-rxid";
	clock_in_out = "output";

	snps,reset-gpio = <&gpio3 RK_PB2 GPIO_ACTIVE_LOW>;
	snps,reset-active-low;
	/* Reset time is 20ms, 100ms for rtl8211f */
	snps,reset-delays-us = <0 20000 100000>;

	pinctrl-names = "default";
	pinctrl-0 = <&gmac1_miim
			 &gmac1_tx_bus2
			 &gmac1_rx_bus2
			 &gmac1_rgmii_clk
			 &gmac1_rgmii_bus>;

	tx_delay = <0x30>;
	/* rx_delay = <0x4f>; */

	phy-handle = <&rgmii_phy1>;
	status = "okay";
};

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

/* SATA30/PCIe20x1_2 Combo PHY */
&combphy0_ps {
	status = "okay";
};

&pcie2x1l2 {
	reset-gpios = <&gpio3 RK_PD1 GPIO_ACTIVE_HIGH>;
	disable-gpios = <&gpio3 RK_PC6 GPIO_ACTIVE_HIGH>;
	vpcie3v3-supply = <&vcc3v3_pcie20>;
	status = "okay";
};

/* USB3.1/DP Combo PHY0 */
&usbdp_phy0 {
	orientation-switch;
	svid = <0xff01>;
	sbu1-dc-gpios = <&gpio4 RK_PB3 GPIO_ACTIVE_HIGH>;
	sbu2-dc-gpios = <&gpio4 RK_PB4 GPIO_ACTIVE_HIGH>;
	status = "okay";

	port {
		#address-cells = <1>;
		#size-cells = <0>;
		usbdp_phy0_orientation_switch: endpoint@0 {
			reg = <0>;
			remote-endpoint = <&usbc0_orien_sw>;
		};

		usbdp_phy0_dp_altmode_mux: endpoint@1 {
			reg = <1>;
			remote-endpoint = <&dp_altmode_mux>;
		};
	};
};

&usbdp_phy0_u3 {
	status = "okay";
};

&usbdp_phy0_dp {
	status = "okay";
};

/* USB3.1 OTG0 Controller  */
&usbdrd3_0 {
	status = "okay";
};

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

/* USB2.0 PHY0 */
&u2phy0 {
	status = "okay";
};

&u2phy0_otg {
	rockchip,typec-vbus-det;
	status = "okay";
};

/* USB3.1/SATA/PCIe20x1_1 Combo PHY */
&combphy2_psu {
	status = "okay";
};

/* USB3.1 HOST2 Controller  */
&usbhost3_0 {
	status = "okay";
};

&usbhost_dwc3_0 {
	dr_mode = "host";
	status = "okay";
};

/* USB2.0 HOST0 PHY2 */
&u2phy2 {
	status = "okay";
};

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

/* USB2.0 HOST0 Controller */
&usb_host0_ehci {
	status = "okay";
};

&usb_host0_ohci {
	status = "okay";
};

/* USB2.0 HOST1 PHY3 */
&u2phy3 {
	status = "okay";
};

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

/* USB2.0 HOST1 Controller */
&usb_host1_ehci {
	status = "okay";
};

&usb_host1_ohci {
	status = "okay";
};

&vdpu {
	status = "okay";
};

&vdpu_mmu {
	status = "okay";
};

&vepu {
	status = "okay";
};

/* hdmi0 display */
&hdmi0 {
	enable-gpios = <&gpio4 RK_PB6 GPIO_ACTIVE_HIGH>;
	cec-enable = "true";
	status = "okay";
};

&route_hdmi0{
	status = "okay";
	connect = <&vp0_out_hdmi0>;
};

&hdmi0_in_vp0 {
	status = "okay";
};

&hdmi0_in_vp1 {
	status = "disabled";
};

&hdmi0_in_vp2 {
	status = "disabled";
};

&hdptxphy_hdmi0 {
	status = "okay";
};

/* dp0 display */
&dp0 {
	status = "okay";
};

&route_dp0 {
	status = "okay";
	connect = <&vp2_out_dp0>;	
};

&dp0_in_vp0 {
	status = "disabled";
};

&dp0_in_vp1 {
	status = "dsiabled";
};

&dp0_in_vp2 {
	status = "okay";
};

&vop {
	status = "okay";
	disable-win-move;
	assigned-clocks = <&cru ACLK_VOP>;
	assigned-clock-rates = <800000000>;
};

&vop_mmu {
	status = "okay";
};

/* vp0 & vp1 splice for 8K output */
&vp0 {
	rockchip,plane-mask = <(1 << ROCKCHIP_VOP2_CLUSTER0 | 1 << ROCKCHIP_VOP2_ESMART0)>;
	rockchip,primary-plane = <ROCKCHIP_VOP2_ESMART0>;
	cursor-win-id = <ROCKCHIP_VOP2_CLUSTER0>;
};

&vp1 {
	rockchip,plane-mask = <(1 << ROCKCHIP_VOP2_CLUSTER1 | 1 << ROCKCHIP_VOP2_ESMART1)>;
	rockchip,primary-plane = <ROCKCHIP_VOP2_ESMART1>;
	cursor-win-id = <ROCKCHIP_VOP2_CLUSTER1>;
};

&vp2 {
	rockchip,plane-mask = <(1 << ROCKCHIP_VOP2_CLUSTER2 | 1 << ROCKCHIP_VOP2_ESMART2)>;
	rockchip,primary-plane = <ROCKCHIP_VOP2_ESMART2>;
	cursor-win-id = <ROCKCHIP_VOP2_CLUSTER2>;
};

&vp3 {
	rockchip,plane-mask = <(1 << ROCKCHIP_VOP2_CLUSTER3 | 1 << ROCKCHIP_VOP2_ESMART3)>;
	rockchip,primary-plane = <ROCKCHIP_VOP2_ESMART3>;
	cursor-win-id = <ROCKCHIP_VOP2_CLUSTER3>;
};

&display_subsystem {
	clocks = <&hdptxphy_hdmi_clk0>;
	clock-names = "hdmi0_phy_pll";
};

&hdptxphy_hdmi_clk0 {
    status = "okay";
};

&pinctrl {
    hym8563 {
        hym8563_int: hym8563-int {
            rockchip,pins = <0 RK_PB0 RK_FUNC_GPIO &pcfg_pull_up>;
        };
    };

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

	usb-typec {
		fusb302_int: fusb302-int {
			rockchip,pins = <0 RK_PC6 RK_FUNC_GPIO &pcfg_pull_up>;
		};

		typec_vbus_en: typec-vbus-en {
			rockchip,pins = <1 RK_PC1 RK_FUNC_GPIO &pcfg_pull_none>;
		};
	};

	usb {
		usb30_host_pwr_en: usb30-host-pwr-en {
			rockchip,pins = <1 RK_PC4 RK_FUNC_GPIO &pcfg_pull_none>;
		};

		usb20_host_pwr_en: usb20-host-pwr-en {
			rockchip,pins = <1 RK_PC6 RK_FUNC_GPIO &pcfg_pull_none>;
		};
	};

	leds {
		sys_status_led_pin: sys-status-led-pin {
			rockchip,pins = <4 RK_PB5 RK_FUNC_GPIO &pcfg_pull_none>;
		};
	};
};
