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

#include "dt-bindings/pwm/pwm.h"
#include "rk3399.dtsi"
#include "rk3399-opp.dtsi"
#include <dt-bindings/sensor-dev.h>
#include "rk3399-vop-clk-set.dtsi"
#include <dt-bindings/input/input.h>
#include "dt-bindings/usb/pd.h"

/ {
	compatible = "rockchip,rk3399-evb-ind", "rockchip,rk3399";

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

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

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

	backlight: backlight {
		status = "okay";
		compatible = "pwm-backlight";
		pwms = <&pwm2 0 25000 0>;
		brightness-levels = <
			  0   1   2   3   4   5   6   7
			  8   9  10  11  12  13  14  15
			 16  17  18  19  20  21  22  23
			 24  25  26  27  28  29  30  31
			 32  33  34  35  36  37  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>;
	};

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

	dw_hdmi_audio: dw-hdmi-audio {
		status = "disabled";
		compatible = "rockchip,dw-hdmi-audio";
		#sound-dai-cells = <0>;
	};

	rk809_sound: rk809-sound {
		compatible = "rockchip,multicodecs-card";
		rockchip,card-name = "rockchip-rk809";
		hp-det-gpio = <&gpio0 RK_PB3 GPIO_ACTIVE_HIGH>;
		io-channels = <&saradc 2>;
		io-channel-names = "adc-detect";
		keyup-threshold-microvolt = <1800000>;
		poll-interval = <100>;
		rockchip,format = "i2s";
		rockchip,mclk-fs = <256>;
		rockchip,cpu = <&i2s1>;
		rockchip,codec = <&rk809_codec>;
		pinctrl-names = "default";
		pinctrl-0 = <&hp_det>;
		play-pause-key {
			label = "playpause";
			linux,code = <KEY_PLAYPAUSE>;
			press-threshold-microvolt = <2000>;
		};
	};

	dp_sound: dp-sound {
		status = "disabled";
		compatible = "rockchip,cdndp-sound";
		rockchip,cpu = <&spdif>;
		rockchip,codec = <&cdn_dp 1>;
	};

	hdmi_sound: hdmi-sound {
		status = "disabled";
		compatible = "rockchip,hdmi";
		rockchip,mclk-fs = <256>;
		rockchip,card-name = "rockchip-hdmi0";
		rockchip,cpu = <&i2s2>;
		rockchip,codec = <&hdmi>;
		rockchip,jack-det;
	};

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

	spdif_sound: spdif-sound {
		status = "okay";
		compatible = "simple-audio-card";
		simple-audio-card,name = "ROCKCHIP,SPDIF";
		simple-audio-card,mclk-fs = <128>;
		simple-audio-card,cpu {
			sound-dai = <&spdif>;
		};
		simple-audio-card,codec {
			sound-dai = <&spdif_out>;
		};
	};

	spdif_out: spdif-out {
		status = "okay";
		compatible = "linux,spdif-dit";
		#sound-dai-cells = <0>;
	};

	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 = <&gpio0 10 GPIO_ACTIVE_LOW>; /* GPIO0_B2 */
	};

	wireless-wlan {
		compatible = "wlan-platdata";
		rockchip,grf = <&grf>;
		wifi_chip_type = "ap6354";
		sdio_vref = <1800>;
		WIFI,host_wake_irq = <&gpio0 3 GPIO_ACTIVE_HIGH>; /* GPIO0_a3 */
		WIFI,poweren_gpio = <&gpio0 10 GPIO_ACTIVE_HIGH>;
		status = "okay";
	};

	wireless-bluetooth {
		compatible = "bluetooth-platdata";
		clocks = <&rk809 1>;
		clock-names = "ext_clock";
		//wifi-bt-power-toggle;
		uart_rts_gpios = <&gpio2 19 GPIO_ACTIVE_LOW>; /* GPIO2_C3 */
		pinctrl-names = "default", "rts_gpio";
		pinctrl-0 = <&uart0_rts>, <&bt_reset_gpio>, <&bt_wake_gpio>, <&bt_irq_gpio>;
		pinctrl-1 = <&uart0_gpios>;
		//BT,power_gpio  = <&gpio3 19 GPIO_ACTIVE_HIGH>; /* GPIOx_xx */
		BT,reset_gpio    = <&gpio0 9 GPIO_ACTIVE_HIGH>; /* GPIO0_B1 */
		BT,wake_gpio     = <&gpio0 4 GPIO_ACTIVE_HIGH>; /* GPIO0_A4 */
		BT,wake_host_irq = <&gpio2 27 GPIO_ACTIVE_HIGH>; /* GPIO2_D3 */
		status = "okay";
	};

	rk_modem: rk-modem {
		compatible="4g-modem-platdata";
		pinctrl-names = "default";
		pinctrl-0 = <&lte_vbat &lte_power_en &lte_reset>;
		4G,vbat-gpio = <&gpio4 RK_PD0 GPIO_ACTIVE_HIGH>;
		4G,power-gpio = <&gpio4 RK_PC6 GPIO_ACTIVE_LOW>;
		4G,reset-gpio = <&gpio4 RK_PD4 GPIO_ACTIVE_LOW>;
		status = "okay";
	};

	tc358749x_sound:tc358749x-sound {
		status = "okay";
		compatible = "simple-audio-card";
		simple-audio-card,format = "i2s";
		simple-audio-card,name = "rk,hdmiin-tc358749x-codec";
		simple-audio-card,bitclock-master = <&sound0_master>;
		simple-audio-card,frame-master = <&sound0_master>;
		simple-audio-card,cpu {
				sound-dai = <&i2s0>;
		};
		sound0_master: simple-audio-card,codec {
				sound-dai = <&tc358749x>;
		};
	};

	vcc5v0_host: vcc5v0-host-regulator {
		compatible = "regulator-fixed";
		enable-active-high;
		gpio = <&gpio0 8 GPIO_ACTIVE_HIGH>;
		pinctrl-names = "default";
		pinctrl-0 = <&host_vbus_drv>;
		regulator-name = "vcc5v0_host";
		regulator-always-on;
	};

	vcc5v0_usbnet: vcc5v0-usbnet {
		compatible = "regulator-fixed";
		enable-active-high;
		/*disabled r8152 usb net default*/
		//regulator-always-on;
		//regulator-boot-on;
		gpio = <&gpio4 18 GPIO_ACTIVE_HIGH>;
		pinctrl-names = "default";
		pinctrl-0 = <&usbnet_pwr_drv>;
		regulator-name = "vcc5v0_usbnet";
		startup-delay-us = <20000>;
		regulator-min-microvolt = <5000000>;
		regulator-max-microvolt = <5000000>;
		status = "okay";
	};

	vcc5v0_sys: vcc5v0-sys {
		compatible = "regulator-fixed";
		enable-active-high;
		gpio = <&gpio4 26 GPIO_ACTIVE_HIGH>;
		regulator-name = "vcc5v0_sys";
		regulator-always-on;
		regulator-boot-on;
		regulator-min-microvolt = <5000000>;
		regulator-max-microvolt = <5000000>;
	};

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

	vdd_log: vdd-log {
		compatible = "regulator-fixed";
		regulator-name = "vdd_log";
		regulator-min-microvolt = <950000>;
		regulator-max-microvolt = <950000>;
		regulator-always-on;
		regulator-boot-on;
	};
};

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

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

&dp_in_vopb {
	status = "disabled";
};

&dfi {
	status = "okay";
};

&dmc {
	status = "okay";
	center-supply = <&vdd_center>;
	upthreshold = <40>;
	downdifferential = <20>;
	system-status-freq = <
		/*system status         freq(KHz)*/
		SYS_STATUS_NORMAL       856000
		SYS_STATUS_REBOOT       856000
		SYS_STATUS_SUSPEND      328000
		SYS_STATUS_VIDEO_1080P  666000
		SYS_STATUS_VIDEO_4K     856000
		SYS_STATUS_VIDEO_4K_10B 856000
		SYS_STATUS_PERFORMANCE  856000
		SYS_STATUS_BOOST        856000
		SYS_STATUS_DUALVIEW     856000
		SYS_STATUS_ISP          856000
	>;
	vop-bw-dmc-freq = <
	/* min_bw(MB/s) max_bw(MB/s) freq(KHz) */
		0       762      416000
		763     3012     666000
		3013    99999    856000
	>;

	vop-pn-msch-readlatency = <
		0	0x20
		4	0x20
	>;

	auto-min-freq = <328000>;
	auto-freq-en = <0>;
};

&dmc_opp_table {
		compatible = "operating-points-v2";

		opp-200000000 {
			opp-hz = /bits/ 64 <200000000>;
			opp-microvolt = <900000>;
			status = "disabled";
		};
		opp-300000000 {
			opp-hz = /bits/ 64 <300000000>;
			opp-microvolt = <900000>;
			status = "disabled";
		};
		opp-328000000 {
			opp-hz = /bits/ 64 <328000000>;
			opp-microvolt = <900000>;
		};
		opp-400000000 {
			opp-hz = /bits/ 64 <400000000>;
			opp-microvolt = <900000>;
			status = "disabled";
		};
		opp-416000000 {
			opp-hz = /bits/ 64 <416000000>;
			opp-microvolt = <900000>;
		};
		opp-528000000 {
			opp-hz = /bits/ 64 <528000000>;
			opp-microvolt = <900000>;
			status = "disabled";
		};
		opp-600000000 {
			opp-hz = /bits/ 64 <600000000>;
			opp-microvolt = <900000>;
			status = "disabled";
		};
		opp-666000000 {
			opp-hz = /bits/ 64 <666000000>;
			opp-microvolt = <900000>;
		};
		opp-800000000 {
			opp-hz = /bits/ 64 <800000000>;
			opp-microvolt = <900000>;
			status = "disabled";
		};
		opp-856000000 {
			opp-hz = /bits/ 64 <856000000>;
			opp-microvolt = <900000>;
		};
		opp-928000000 {
			opp-hz = /bits/ 64 <928000000>;
			opp-microvolt = <900000>;
			status = "disabled";
		};
};

&emmc_phy {
	status = "okay";
};

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

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

&hdmi {
	status = "okay";
};

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

	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 = <1000>;
		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 = <712500>;
		regulator-max-microvolt = <1500000>;
		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;
		};
	};

	rk809: pmic@20 {
		compatible = "rockchip,rk809";
		reg = <0x20>;
		interrupt-parent = <&gpio1>;
		interrupts = <21 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;
		#clock-cells = <1>;
		pmic-reset-func = <0>;
		wakeup-source;
		clock-output-names = "xin32k", "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 = <&vcc5v0_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-ramp-delay = <6001>;
				regulator-initial-mode = <0x2>;
				regulator-name = "vdd_center";
				regulator-state-mem {
					regulator-off-in-suspend;
				};
			};

			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-always-on;
				regulator-boot-on;
				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;
				};
			};
		};
		/*
		battery {
			compatible = "rk817,battery";
			ocv_table = <7000 7250 7370 7384 7436 7470 7496
						7520 7548 7576 7604 7632 7668 7706
						7754 7816 7892 7950 8036 8142 8212>;
			design_capacity = <2500>;
			design_qmax = <2750>;
			bat_res = <100>;
			sleep_enter_current = <300>;
			sleep_exit_current = <300>;
			sleep_filter_current = <100>;
			power_off_thresd = <7000>;
			zero_algorithm_vol = <7700>;
			max_soc_offset = <60>;
			monitor_sec = <5>;
			sample_res = <10>;
			virtual_power = <0>;
			bat_res_up = <140>;
			bat_res_down = <20>;
		};
		*/
		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>;
			assigned-clocks = <&cru SCLK_I2SOUT_SRC>;
			assigned-clock-parents = <&cru SCLK_I2S1_8CH>;
			hp-volume = <20>;
			spk-volume = <3>;
			status = "okay";
		};
	};
};

&i2c1 {
	status = "okay";
	i2c-scl-rising-time-ns = <300>;
	i2c-scl-falling-time-ns = <15>;
	clock-frequency = <400000>;

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

	tc358749x: tc358749x@0f {
		#sound-dai-cells = <0>;
		compatible = "toshiba,tc358749x";
		reg = <0x0f>;
		power-gpios = <&gpio0 13 GPIO_ACTIVE_HIGH>;
		stanby-gpios = <&gpio3 25 GPIO_ACTIVE_HIGH>;
		reset-gpios = <&gpio0 2 GPIO_ACTIVE_HIGH>;
		int-gpios = <&gpio4 4 GPIO_ACTIVE_HIGH>;
		pinctrl-names = "default";
		pinctrl-0 = <&hdmiin_gpios>;
		status = "okay";
	};
};

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

	mpu6500@68 {
		status = "disabled";
		compatible = "invensense,mpu6500";
		reg = <0x68>;
		irq-gpio = <&gpio1 22 IRQ_TYPE_EDGE_RISING>;
		pinctrl-names = "default";
		pinctrl-0 = <&mpu6500_irq_gpio>;
		mpu-int_config = <0x10>;
		mpu-level_shifter = <0>;
		mpu-orientation = <0 1 0 1 0 0 0 0 1>;
		orientation-x= <0>;
		orientation-y= <0>;
		orientation-z= <0>;
		mpu-debug = <1>;
	};

	mpu6500_acc: mpu_acc@68 {
		compatible = "mpu6500_acc";
		reg = <0x68>;
		irq-gpio = <&gpio1 22 IRQ_TYPE_EDGE_RISING>;
		irq_enable = <0>;
		poll_delay_ms = <30>;
		type = <SENSOR_TYPE_ACCEL>;
		layout = <8>;
	};

	mpu6500_gyro: mpu_gyro@68 {
		compatible = "mpu6500_gyro";
		reg = <0x68>;
		irq_enable = <0>;
		poll_delay_ms = <30>;
		type = <SENSOR_TYPE_GYROSCOPE>;
		layout = <8>;
	};

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

			displayport = <&cdn_dp>;

			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 = <&tcphy0_orientation_switch>;
					};
				};
				port@1 {
					reg = <1>;
					dp_mode_sw: endpoint {
						remote-endpoint = <&tcphy_dp_altmode_switch>;
					};
				};
			};
		};
	};

	sensor@0d {
		status = "okay";
		compatible = "ak8963";
		pinctrl-names = "default";
		pinctrl-0 = <&ak8963_irq_gpio>;
		reg = <0x0d>;
		type = <SENSOR_TYPE_COMPASS>;
		irq-gpio = <&gpio1 0 IRQ_TYPE_EDGE_RISING>;
		irq_enable = <0>;
		poll_delay_ms = <30>;
		layout = <6>;
	};

	bq25700: bq25700@6b {//6a
		compatible = "ti,bq25703";
		reg = <0x6b>;

		interrupt-parent = <&gpio0>;
		interrupts = <5 IRQ_TYPE_LEVEL_LOW>;
		pinctrl-names = "default";
		pinctrl-0 = <&charger_ok>;
		ti,charge-current = <2500000>;
		ti,max-input-voltage = <20000000>;
		ti,max-input-current = <6000000>;
		ti,max-charge-voltage = <8750000>;
		ti,input-current = <500000>;
		ti,input-current-sdp = <500000>;
		ti,input-current-dcp = <2000000>;
		ti,input-current-cdp = <2000000>;
		ti,minimum-sys-voltage = <7400000>;
		ti,otg-voltage = <5000000>;
		ti,otg-current = <500000>;
		pd-charge-only = <0>;
		status = "disabled";
	};
};

&i2c6 {
	cw2015@62 {
		status = "disabled";
		compatible = "cw201x";
		reg = <0x62>;
		bat_config_info = <0x15 0x42 0x60 0x59 0x52 0x58 0x4D 0x48
				   0x48 0x44 0x44 0x46 0x49 0x48 0x32 0x24
				   0x20 0x17 0x13 0x0F 0x19 0x3E 0x51 0x45
				   0x08 0x76 0x0B 0x85 0x0E 0x1C 0x2E 0x3E
				   0x4D 0x52 0x52 0x57 0x3D 0x1B 0x6A 0x2D
				   0x25 0x43 0x52 0x87 0x8F 0x91 0x94 0x52
				   0x82 0x8C 0x92 0x96 0xFF 0x7B 0xBB 0xCB
				   0x2F 0x7D 0x72 0xA5 0xB5 0xC1 0x46 0xAE>;
		monitor_sec = <5>;
		virtual_power = <0>;
	};
};

&i2s0 {
	status = "disabled";
	rockchip,i2s-broken-burst-len;
	rockchip,playback-channels = <8>;
	rockchip,capture-channels = <8>;
	#sound-dai-cells = <0>;
};

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

&i2s2 {
	#sound-dai-cells = <0>;
	dmas = <&dmac_bus 4>;
	dma-names = "tx";
	status = "disabled";
};

&io_domains {
	status = "okay";

	bt656-supply = <&vcc_3v0>;		/* bt656_gpio2ab_ms */
	audio-supply = <&vcca_1v8>;	/* audio_gpio3d4a_ms */
	sdmmc-supply = <&vccio_sd>;		/* sdmmc_gpio4b_ms */
	gpio1830-supply = <&vcc_3v0>;		/* gpio1833_gpio4cd_ms */
};

&isp0_mmu {
	status = "okay";
};

&isp1_mmu {
	status = "okay";
};

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

&pcie_phy {
	status = "okay";
};

&pcie0 {
	ep-gpios = <&gpio2 RK_PA4 GPIO_ACTIVE_HIGH>;
	num-lanes = <4>;
	pinctrl-names = "default";
	pinctrl-0 = <&pcie_clkreqn_cpm>;
	status = "okay";
};

&pwm0 {
	status = "disabled";
};

&pwm2 {
	status = "okay";
	pinctrl-names = "active";
	pinctrl-0 = <&pwm2_pin_pull_down>;
};

&pwm3 {
	status = "okay";

	interrupts = <GIC_SPI 61 IRQ_TYPE_LEVEL_HIGH 0>;
	compatible = "rockchip,remotectl-pwm";
	remote_pwm_id = <3>;
	handle_cpu_id = <1>;
	remote_support_psci = <4>;
	pinctrl-names = "default";

	ir_key1 {
		rockchip,usercode = <0x4040>;
		rockchip,key_table =
			<0xf2	KEY_REPLY>,
			<0xba	KEY_BACK>,
			<0xf4	KEY_UP>,
			<0xf1	KEY_DOWN>,
			<0xef	KEY_LEFT>,
			<0xee	KEY_RIGHT>,
			<0xbd	KEY_HOME>,
			<0xea	KEY_VOLUMEUP>,
			<0xe3	KEY_VOLUMEDOWN>,
			<0xe2	KEY_SEARCH>,
			<0xb2	KEY_POWER>,
			<0xbc	KEY_MUTE>,
			<0xec	KEY_MENU>,
			<0xbf	0x190>,
			<0xe0	0x191>,
			<0xe1	0x192>,
			<0xe9	183>,
			<0xe6	248>,
			<0xe8	185>,
			<0xe7	186>,
			<0xf0	388>,
			<0xbe	0x175>;
	};

	ir_key2 {
		rockchip,usercode = <0xff00>;
		rockchip,key_table =
			<0xf9	KEY_HOME>,
			<0xbf	KEY_BACK>,
			<0xfb	KEY_MENU>,
			<0xaa	KEY_REPLY>,
			<0xb9	KEY_UP>,
			<0xe9	KEY_DOWN>,
			<0xb8	KEY_LEFT>,
			<0xea	KEY_RIGHT>,
			<0xeb	KEY_VOLUMEDOWN>,
			<0xef	KEY_VOLUMEUP>,
			<0xf7	KEY_MUTE>,
			<0xe7	KEY_POWER>,
			<0xfc	KEY_POWER>,
			<0xa9	KEY_VOLUMEDOWN>,
			<0xa8	KEY_VOLUMEDOWN>,
			<0xe0	KEY_VOLUMEDOWN>,
			<0xa5	KEY_VOLUMEDOWN>,
			<0xab	183>,
			<0xb7	388>,
			<0xe8	388>,
			<0xf8	184>,
			<0xaf	185>,
			<0xed	KEY_VOLUMEDOWN>,
			<0xee	186>,
			<0xb3	KEY_VOLUMEDOWN>,
			<0xf1	KEY_VOLUMEDOWN>,
			<0xf2	KEY_VOLUMEDOWN>,
			<0xf3	KEY_SEARCH>,
			<0xb4	KEY_VOLUMEDOWN>,
			<0xbe	KEY_SEARCH>;
	};

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

&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_AP_PWROFF
		)
		>;
	rockchip,wakeup-config = <
		(0
		| RKPM_GPIO_WKUP_EN
		| RKPM_PWM_WKUP_EN
		)
		>;
		rockchip,pwm-regulator-config = <
		(0
		| PWM2_REGULATOR_EN
		)
		>;
		rockchip,power-ctrl =
		<&gpio1 17 GPIO_ACTIVE_HIGH>,
		<&gpio1 14 GPIO_ACTIVE_HIGH>;
};

&saradc {
	status = "okay";
};

&spdif {
	status = "okay";
	pinctrl-0 = <&spdif_bus>;
	i2c-scl-rising-time-ns = <450>;
	i2c-scl-falling-time-ns = <15>;
	#sound-dai-cells = <0>;
};

&sdio0 {
	clock-frequency = <150000000>;
	clock-freq-min-max = <200000 150000000>;
	no-sd;
	no-mmc;
	bus-width = <4>;
	disable-wp;
	cap-sd-highspeed;
	cap-sdio-irq;
	keep-power-in-suspend;
	mmc-pwrseq = <&sdio_pwrseq>;
	non-removable;
	num-slots = <1>;
	pinctrl-names = "default";
	pinctrl-0 = <&sdio0_bus4 &sdio0_cmd &sdio0_clk>;
	sd-uhs-sdr104;
	status = "okay";
};

&sdmmc {
	clock-frequency = <150000000>;
	clock-freq-min-max = <100000 150000000>;
	no-sdio;
	no-mmc;
	bus-width = <4>;
	cap-mmc-highspeed;
	cap-sd-highspeed;
	disable-wp;
	num-slots = <1>;
	sd-uhs-sdr104;
	vmmc-supply = <&vcc_sd>;
	vqmmc-supply = <&vccio_sd>;
	pinctrl-names = "default";
	pinctrl-0 = <&sdmmc_clk &sdmmc_cmd &sdmmc_cd &sdmmc_bus4>;
	status = "okay";
};

&sdhci {
	bus-width = <8>;
	mmc-hs400-1_8v;
	no-sdio;
	no-sd;
	non-removable;
	keep-power-in-suspend;
	mmc-hs400-enhanced-strobe;
	status = "okay";
};

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

&tcphy0 {
	status = "okay";

	svid = <0xff01>;
	orientation-switch;
	port {
		#address-cells = <1>;
		#size-cells = <0>;
		tcphy0_orientation_switch: endpoint@0 {
			reg = <0>;
			remote-endpoint = <&usbc0_orien_sw>;
		};
		tcphy_dp_altmode_switch: endpoint@1 {
			reg = <1>;
			remote-endpoint = <&dp_mode_sw>;
		};
	};
};

&tcphy1 {
	status = "okay";
};

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

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

&uart2 {
	status = "disabled";
};

&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 {
		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";
	dr_mode = "host";
};

&usb_host0_ehci {
	status = "okay";
};

&usb_host0_ohci {
	status = "okay";
};

&usb_host1_ehci {
	status = "okay";
};

&usb_host1_ohci {
	status = "okay";
};

&vopb {
	assigned-clocks = <&cru DCLK_VOP0_DIV>;
	assigned-clock-parents = <&cru PLL_CPLL>;
};

&vopl {
	assigned-clocks = <&cru DCLK_VOP1_DIV>;
	assigned-clock-parents = <&cru PLL_VPLL>;
};

&pinctrl {

	ak8963 {
		ak8963_irq_gpio: ak8963-irq-gpio {
			rockchip,pins = <1 RK_PA0 RK_FUNC_GPIO &pcfg_pull_none>;
		};
	};

	charger {
		charger_ok: charge-ok {
			rockchip,pins =
				<0 RK_PA5 RK_FUNC_GPIO &pcfg_pull_up>;
		};
	};

	i2s0 {
		i2s0_8ch_bus: i2s0-8ch-bus {
			rockchip,pins =
				<3 RK_PD0 1 &pcfg_pull_none>,
				<3 RK_PD2 1 &pcfg_pull_none>,
				<3 RK_PD3 1 &pcfg_pull_none>,
				<3 RK_PD4 1 &pcfg_pull_none>,
				<3 RK_PD5 1 &pcfg_pull_none>,
				<3 RK_PD6 1 &pcfg_pull_none>,
				<3 RK_PD7 1 &pcfg_pull_none>;
			};

		i2s_8ch_mclk: i2s-8ch-mclk {
				rockchip,pins = <4 RK_PA0 1 &pcfg_pull_none>;
		};
	};

	i2s1 {
		i2s1_2ch_bus: i2s1-2ch-bus {
			rockchip,pins =
				<4 RK_PA3 1 &pcfg_pull_none>,
				<4 RK_PA5 1 &pcfg_pull_none>,
				<4 RK_PA6 1 &pcfg_pull_none>,
				<4 RK_PA7 1 &pcfg_pull_none>;
		};
	};

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

	hdmiin {
		hdmiin_gpios: hdmiin_gpios {
		rockchip,pins =
				<0 RK_PB5 RK_FUNC_GPIO &pcfg_pull_none>,
				<3 RK_PD1 RK_FUNC_GPIO &pcfg_pull_none>,
				<0 RK_PA2 RK_FUNC_GPIO &pcfg_pull_none>,
				<4 RK_PA4 RK_FUNC_GPIO &pcfg_pull_none>;
		};
	};

	mpu6500 {
		mpu6500_irq_gpio: mpu6500-irq-gpio {
			rockchip,pins = <1 RK_PC6 RK_FUNC_GPIO &pcfg_pull_none>;
		};
	};

	pmic {
		pmic_int_l: pmic-int-l {
			rockchip,pins =
				<1 RK_PC5 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_none>;
		};
	};

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

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

		bt_reset_gpio: bt-reset-gpio {
			rockchip,pins =
				<0 RK_PB1 RK_FUNC_GPIO &pcfg_pull_none>;
		};

		bt_wake_gpio: bt-wake-gpio {
			rockchip,pins =
				<0 RK_PA4 RK_FUNC_GPIO &pcfg_pull_none>;
		};

		bt_irq_gpio: bt-irq-gpio {
			rockchip,pins =
				<2 RK_PD3 RK_FUNC_GPIO &pcfg_pull_down>;
		};
	};

	rk-modem {
		lte_vbat: lte-vbat {
			rockchip,pins = <4 RK_PD0 RK_FUNC_GPIO &pcfg_pull_none>;
		};

		lte_power_en: lte-power-en {
			rockchip,pins = <4 RK_PC6 RK_FUNC_GPIO &pcfg_pull_none>;
		};

		lte_reset: lte-reset {
			rockchip,pins = <4 RK_PD4 RK_FUNC_GPIO &pcfg_pull_none>;
		};
	};

	usb2 {
		host_vbus_drv: host-vbus-drv {
			rockchip,pins =
				<0 RK_PB0 RK_FUNC_GPIO &pcfg_pull_none>;
		};
	};

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

	vcc_sd {
		vcc_sd_h: vcc-sd-h {
			rockchip,pins =
				<0 RK_PA1 RK_FUNC_GPIO &pcfg_pull_up>;
		};
	};

	usbnet {
		usbnet_pwr_drv: usbnet-pwr-drv {
			rockchip,pins =
				<4 RK_PC2 RK_FUNC_GPIO &pcfg_pull_none>;
		};
	};
};
