// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
/*
 * Copyright (c) 2023 Rockchip Electronics Co., Ltd.
 *
 */
/dts-v1/;

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

/ {
	model = "Rockchip RK3562 DICTPEN TEST3 LP4 V20 Board";
	compatible = "rockchip,rk3562-dictpen-test3-v20", "rockchip,rk3562";

	adc_keys: adc-keys {
		compatible = "adc-keys";
		io-channels = <&saradc0 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 = <17000>;
		};
	};

	backlight: backlight {
		compatible = "pwm-backlight";
		pwms = <&pwm12 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  50  51  52  53  54
			 55  55  56  57  58  59  60  61
			 62  63  64  64  65  65  66  67
			 68  69  70  71  71  72  73  74
			 75  76  77  78  79  79  80  81
			 82  83  84  85  86  86  87  88
			 89  90  91  92  93  94  94  95
			 96  97  98  99 100 101 101 102
			103 104 105 106 107 107 108 109
			110 111 112 113 114 115 115 116
			117 118 119 120 121 122 123 123
			124 125 126 127 128 129 130 130
			131 132 133 134 135 136 136 137
			138 139 140 141 142 143 143 144
			145 146 147 147 148 149 150 151
			152 153 154 155 156 156 157 158
			159 157 158 159 160 161 162 162
			163 164 165 166 167 168 169 169
			170 171 172 173 174 175 175 176
			177 178 179 180 181 182 182 183
			184 185 186 187 188 189 190 190
			191 192 193 194 195 196 197 197
			198 199 200 201 202 203 204 204
			205 206 207 208 209 209 210 211
			212 213 213 214 214 215 215 216
			216 217 217 218 218 219 219 220
		>;
		default-brightness-level = <60>;
	};

	charge-animation {
		compatible = "rockchip,uboot-charge";
		rockchip,uboot-charge-on = <0>;
		rockchip,android-charge-on = <0>;
		rockchip,uboot-low-power-voltage = <2800>;
		rockchip,screen-on-voltage = <3000>;
		status = "okay";
	};

	gpio-keys {
		compatible = "gpio-keys";
		autorepeat;
		pinctrl-names = "default";
		pinctrl-0 = <&scan_key>;

		button@0 {
			label = "home";
			linux,code = <KEY_HOME>;
			gpios = <&gpio0 RK_PA7 GPIO_ACTIVE_LOW>;
			debounce-interval = <50>;
		};
	};

	rk817-sound {
		compatible = "rockchip,multicodecs-card";
		rockchip,card-name = "rockchip-rk817";
		rockchip,format = "i2s";
		rockchip,mclk-fs = <256>;
		rockchip,cpu = <&sai0>;
		rockchip,codec = <&rk817_codec>;
	};

	vcc_sys: vcc-sys {
		compatible = "regulator-fixed";
		regulator-name = "vcc_sys";
		regulator-always-on;
		regulator-boot-on;
		regulator-min-microvolt = <3800000>;
		regulator-max-microvolt = <3800000>;
	};

	vccsys_lcd: vccsys-lcd {
		compatible = "regulator-fixed";
		regulator-name = "vccsys_lcd";
		regulator-boot-on;
		enable-active-high;
		gpio = <&gpio3 RK_PB6 GPIO_ACTIVE_HIGH>;
		vin-supply = <&vcc3v3_lcd>;
	};

	sdio_pwrseq: sdio-pwrseq {
		compatible = "mmc-pwrseq-simple";
		pinctrl-names = "default";
		pinctrl-0 = <&wifi_enable_l>;

		/*
		 * 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)
		 */
		post-power-on-delay-ms = <200>;
		reset-gpios = <&gpio2 RK_PA0 GPIO_ACTIVE_HIGH>;
	};

	wireless-wlan {
		compatible = "wlan-platdata";
		rockchip,grf = <&sys_grf>;
		wifi_chip_type = "ap6203";
		pinctrl-names = "default";
		pinctrl-0 = <&wifi_host_wake_irq>;
		WIFI,host_wake_irq = <&gpio1 RK_PC7 GPIO_ACTIVE_HIGH>;
		status = "okay";
	};

	wireless-bluetooth {
		compatible = "bluetooth-platdata";
		clocks = <&rk817 1>;
		clock-names = "ext_clock";
		uart_rts_gpios = <&gpio1 RK_PD3 GPIO_ACTIVE_LOW>;
		pinctrl-names = "default", "rts_gpio";
		pinctrl-0 = <&uart1m0_rtsn>;
		pinctrl-1 = <&uart1_gpios>;
		BT,power_gpio    = <&gpio1 RK_PD7 GPIO_ACTIVE_LOW>;
		//BT,wake_gpio     = <&gpio1 RK_PD5 GPIO_ACTIVE_HIGH>;
		//BT,wake_host_irq = <&gpio1 RK_PD6 GPIO_ACTIVE_HIGH>;
		status = "okay";
	};
};

&cpu0 {
	cpu-supply = <&vdd_cpu>;
};

&cpu0_opp_table {
	opp-408000000 {
	/delete-property/ opp-suspend;
	};

	opp-1200000000 {
		opp-suspend;
	};
	/delete-node/ opp-1608000000;
	/delete-node/ opp-1800000000;
	/delete-node/ opp-2016000000;
};

&csi2_dphy0 {
	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 = <&sc031gs_out>;
				data-lanes = <1>;
			};

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

			csidcphy0_out: endpoint@0 {
				reg = <0>;
				remote-endpoint = <&mipi0_csi2_input>;
			};
		};
	};
};

&csi2_dphy0_hw {
	status = "okay";
};

&dfi {
	status = "okay";
};

&display_subsystem {
	status = "okay";
};

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

&dsi {
	status = "okay";

	panel@0 {
		status = "okay";
		compatible = "simple-panel-dsi";
		reg = <0>;
		backlight = <&backlight>;
		power-supply=<&vccsys_lcd>;
		reset-gpios = <&gpio3 RK_PB7 GPIO_ACTIVE_LOW>;
		enable-gpios = <&gpio3 RK_PB5 GPIO_ACTIVE_HIGH>;

		reset-delay-ms = <60>;
		enable-delay-ms = <60>;
		prepare-delay-ms = <60>;
		unprepare-delay-ms = <60>;
		disable-delay-ms = <60>;
		dsi,flags = <(MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_BURST |
			MIPI_DSI_MODE_LPM | MIPI_DSI_MODE_EOT_PACKET)>;
		dsi,format = <MIPI_DSI_FMT_RGB888>;
		dsi,lanes  = <4>;
		panel-init-sequence = [
			23 00 02 FE 21
			23 00 02 04 00
			23 00 02 00 64
			23 00 02 2A 00
			23 00 02 26 64
			23 00 02 54 00
			23 00 02 50 64
			23 00 02 7B 00
			23 00 02 77 64
			23 00 02 A2 00
			23 00 02 9D 64
			23 00 02 C9 00
			23 00 02 C5 64
			23 00 02 01 71
			23 00 02 27 71
			23 00 02 51 71
			23 00 02 78 71
			23 00 02 9E 71
			23 00 02 C6 71
			23 00 02 02 89
			23 00 02 28 89
			23 00 02 52 89
			23 00 02 79 89
			23 00 02 9F 89
			23 00 02 C7 89
			23 00 02 03 9E
			23 00 02 29 9E
			23 00 02 53 9E
			23 00 02 7A 9E
			23 00 02 A0 9E
			23 00 02 C8 9E
			23 00 02 09 00
			23 00 02 05 B0
			23 00 02 31 00
			23 00 02 2B B0
			23 00 02 5A 00
			23 00 02 55 B0
			23 00 02 80 00
			23 00 02 7C B0
			23 00 02 A7 00
			23 00 02 A3 B0
			23 00 02 CE 00
			23 00 02 CA B0
			23 00 02 06 C0
			23 00 02 2D C0
			23 00 02 56 C0
			23 00 02 7D C0
			23 00 02 A4 C0
			23 00 02 CB C0
			23 00 02 07 CF
			23 00 02 2F CF
			23 00 02 58 CF
			23 00 02 7E CF
			23 00 02 A5 CF
			23 00 02 CC CF
			23 00 02 08 DD
			23 00 02 30 DD
			23 00 02 59 DD
			23 00 02 7F DD
			23 00 02 A6 DD
			23 00 02 CD DD
			23 00 02 0E 15
			23 00 02 0A E9
			23 00 02 36 15
			23 00 02 32 E9
			23 00 02 5F 15
			23 00 02 5B E9
			23 00 02 85 15
			23 00 02 81 E9
			23 00 02 AD 15
			23 00 02 A9 E9
			23 00 02 D3 15
			23 00 02 CF E9
			23 00 02 0B 14
			23 00 02 33 14
			23 00 02 5C 14
			23 00 02 82 14
			23 00 02 AA 14
			23 00 02 D0 14
			23 00 02 0C 36
			23 00 02 34 36
			23 00 02 5D 36
			23 00 02 83 36
			23 00 02 AB 36
			23 00 02 D1 36
			23 00 02 0D 6B
			23 00 02 35 6B
			23 00 02 5E 6B
			23 00 02 84 6B
			23 00 02 AC 6B
			23 00 02 D2 6B
			23 00 02 13 5A
			23 00 02 0F 94
			23 00 02 3B 5A
			23 00 02 37 94
			23 00 02 64 5A
			23 00 02 60 94
			23 00 02 8A 5A
			23 00 02 86 94
			23 00 02 B2 5A
			23 00 02 AE 94
			23 00 02 D8 5A
			23 00 02 D4 94
			23 00 02 10 D1
			23 00 02 38 D1
			23 00 02 61 D1
			23 00 02 87 D1
			23 00 02 AF D1
			23 00 02 D5 D1
			23 00 02 11 04
			23 00 02 39 04
			23 00 02 62 04
			23 00 02 88 04
			23 00 02 B0 04
			23 00 02 D6 04
			23 00 02 12 05
			23 00 02 3A 05
			23 00 02 63 05
			23 00 02 89 05
			23 00 02 B1 05
			23 00 02 D7 05
			23 00 02 18 AA
			23 00 02 14 36
			23 00 02 42 AA
			23 00 02 3D 36
			23 00 02 69 AA
			23 00 02 65 36
			23 00 02 8F AA
			23 00 02 8B 36
			23 00 02 B7 AA
			23 00 02 B3 36
			23 00 02 DD AA
			23 00 02 D9 36
			23 00 02 15 74
			23 00 02 3F 74
			23 00 02 66 74
			23 00 02 8C 74
			23 00 02 B4 74
			23 00 02 DA 74
			23 00 02 16 9F
			23 00 02 40 9F
			23 00 02 67 9F
			23 00 02 8D 9F
			23 00 02 B5 9F
			23 00 02 DB 9F
			23 00 02 17 DC
			23 00 02 41 DC
			23 00 02 68 DC
			23 00 02 8E DC
			23 00 02 B6 DC
			23 00 02 DC DC
			23 00 02 1D FF
			23 00 02 19 03
			23 00 02 47 FF
			23 00 02 43 03
			23 00 02 6E FF
			23 00 02 6A 03
			23 00 02 94 FF
			23 00 02 90 03
			23 00 02 BC FF
			23 00 02 B8 03
			23 00 02 E2 FF
			23 00 02 DE 03
			23 00 02 1A 35
			23 00 02 44 35
			23 00 02 6B 35
			23 00 02 91 35
			23 00 02 B9 35
			23 00 02 DF 35
			23 00 02 1B 45
			23 00 02 45 45
			23 00 02 6C 45
			23 00 02 92 45
			23 00 02 BA 45
			23 00 02 E0 45
			23 00 02 1C 55
			23 00 02 46 55
			23 00 02 6D 55
			23 00 02 93 55
			23 00 02 BB 55
			23 00 02 E1 55
			23 00 02 22 FF
			23 00 02 1E 68
			23 00 02 4C FF
			23 00 02 48 68
			23 00 02 73 FF
			23 00 02 6F 68
			23 00 02 99 FF
			23 00 02 95 68
			23 00 02 C1 FF
			23 00 02 BD 68
			23 00 02 E7 FF
			23 00 02 E3 68
			23 00 02 1F 7E
			23 00 02 49 7E
			23 00 02 70 7E
			23 00 02 96 7E
			23 00 02 BE 7E
			23 00 02 E4 7E
			23 00 02 20 97
			23 00 02 4A 97
			23 00 02 71 97
			23 00 02 97 97
			23 00 02 BF 97
			23 00 02 E5 97
			23 00 02 21 B5
			23 00 02 4B B5
			23 00 02 72 B5
			23 00 02 98 B5
			23 00 02 C0 B5
			23 00 02 E6 B5
			23 00 02 25 F0
			23 00 02 23 E8
			23 00 02 4F F0
			23 00 02 4D E8
			23 00 02 76 F0
			23 00 02 74 E8
			23 00 02 9C F0
			23 00 02 9A E8
			23 00 02 C4 F0
			23 00 02 C2 E8
			23 00 02 EA F0
			23 00 02 E8 E8
			23 00 02 24 FF
			23 00 02 4E FF
			23 00 02 75 FF
			23 00 02 9B FF
			23 00 02 C3 FF
			23 00 02 E9 FF
			23 00 02 FE 3D
			23 00 02 00 04
			23 00 02 FE 23
			23 00 02 08 82
			23 00 02 0A 00
			23 00 02 0B 00
			23 00 02 0C 01
			23 00 02 16 00
			23 00 02 18 02
			23 00 02 1B 04
			23 00 02 19 04
			23 00 02 1C 81
			23 00 02 1F 00
			23 00 02 20 03
			23 00 02 23 04
			23 00 02 21 01
			23 00 02 54 63
			23 00 02 55 54
			23 00 02 6E 45
			23 00 02 6D 36
			23 00 02 FE 3D
			23 00 02 55 78
			23 00 02 FE 20
			23 00 02 26 30
			23 00 02 FE 3D
			23 00 02 20 71
			23 00 02 50 8F
			23 00 02 51 8F
			23 00 02 FE 00
			23 00 02 35 00
			05 78 01 11
			05 1E 01 29
		];

		panel-exit-sequence = [
			05 00 01 28
			05 00 01 10
		];

		disp_timings0: display-timings {
			native-mode = <&dsi_timing0>;

			dsi_timing0: timing0 {
				clock-frequency = <132000000>;
				hactive = <1080>;
				vactive = <1920>;
				hfront-porch = <15>;
				hsync-len = <2>;
				hback-porch = <30>;
				vfront-porch = <15>;
				vsync-len = <2>;
				vback-porch = <15>;
				hsync-active = <0>;
				vsync-active = <0>;
				de-active = <0>;
				pixelclk-active = <1>;
			};
		};

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

			port@0 {
				reg = <0>;
				panel_in_dsi: endpoint {
					remote-endpoint = <&dsi_out_panel>;
				};
			};
		};
	};

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

		port@1 {
			reg = <1>;
			dsi_out_panel: endpoint {
				remote-endpoint = <&panel_in_dsi>;
			};
		};
	};
};

&dsi_in_vp0 {
	status = "okay";
};

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

&gpu_opp_table {
	/delete-node/ opp-800000000;
	/delete-node/ opp-900000000;
};

&i2c0 {
	status = "okay";
	clock-frequency = <400000>;

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

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

			port@0 {
				reg = <0>;
				usbc0_role_sw: endpoint@0 {
					remote-endpoint = <&dwc3_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, 2000, PDO_FIXED_USB_COMM)>;
			source-pdos =
				<PDO_FIXED(5000, 2000, PDO_FIXED_USB_COMM)>;
		};
	};

	rk817: pmic@20 {
		compatible = "rockchip,rk817";
		reg = <0x20>;
		interrupt-parent = <&gpio0>;
		interrupts = <3 IRQ_TYPE_LEVEL_LOW>;

		pinctrl-names = "default", "pmic-sleep",
			"pmic-power-off", "pmic-reset";
		pinctrl-0 = <&pmic_int>;
		pinctrl-1 = <&soc_slppin_slp>, <&rk817_slppin_slp>;
		pinctrl-2 = <&soc_slppin_gpio>, <&rk817_slppin_pwrdn>;
		pinctrl-3 = <&soc_slppin_gpio>, <&rk817_slppin_rst>;
		rockchip,system-power-controller;
		wakeup-source;
		#clock-cells = <1>;
		clock-output-names = "rk808-clkout1", "rk808-clkout2";
		/* 1: rst regs (default in codes), 0: rst the pmic */
		pmic-reset-func = <0>;
		not-save-power-en = <1>;
		vcc1-supply = <&vcc_sys>;
		vcc2-supply = <&vcc_sys>;
		vcc3-supply = <&vcc_sys>;
		vcc4-supply = <&vcc_sys>;
		vcc5-supply = <&vcc_sys>;
		vcc6-supply = <&vcc_sys>;
		vcc7-supply = <&vcc_sys>;
		vcc8-supply = <&vcc_sys>;
		vcc9-supply = <&dcdc_boost>;
		pwrkey {
			status = "okay";
		};

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

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

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

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

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

		regulators {
			vdda_0v9: vdd_logic: DCDC_REG1 {
				regulator-always-on;
				regulator-boot-on;
				regulator-min-microvolt = <800000>;
				regulator-max-microvolt = <1350000>;
				regulator-init-microvolt = <900000>;
				regulator-ramp-delay = <6001>;
				regulator-initial-mode = <0x2>;
				regulator-name = "vdd_logic";
				regulator-state-mem {
					regulator-off-in-suspend;
					regulator-suspend-microvolt = <900000>;
				};
			};

			vdd_npu: vdd_gpu: vdd_cpu: DCDC_REG2 {
				regulator-always-on;
				regulator-boot-on;
				regulator-min-microvolt = <825000>;
				regulator-max-microvolt = <1350000>;
				regulator-init-microvolt = <900000>;
				regulator-ramp-delay = <6001>;
				regulator-initial-mode = <0x2>;
				regulator-name = "vdd_cpu";
				regulator-state-mem {
					regulator-off-in-suspend;
				};
			};

			vcc_1v8: DCDC_REG3 {
				regulator-always-on;
				regulator-boot-on;
				regulator-initial-mode = <0x2>;
				regulator-name = "vcc_1v8";
				regulator-min-microvolt = <1800000>;
				regulator-max-microvolt = <1800000>;
				regulator-state-mem {
					regulator-off-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;
				};
			};

			vcc_ldo1: LDO_REG1 {
				regulator-min-microvolt = <3300000>;
				regulator-max-microvolt = <3300000>;
				regulator-name = "vcc_ldo1";
				regulator-state-mem {
					regulator-off-in-suspend;
				};
			};

			vcc1v5_dvp: LDO_REG2 {
				regulator-min-microvolt = <1500000>;
				regulator-max-microvolt = <1500000>;
				regulator-name = "vcc1v5_dvp";
				regulator-state-mem {
					regulator-off-in-suspend;
				};
			};

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

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

			vcc3v3_lcd: LDO_REG5 {
				regulator-min-microvolt = <3000000>;
				regulator-max-microvolt = <3300000>;
				regulator-name = "vcc3v3_lcd";
				regulator-state-mem {
					regulator-off-in-suspend;
				};
			};

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

			vcc_ldo7: LDO_REG7 {
				regulator-min-microvolt = <1800000>;
				regulator-max-microvolt = <1800000>;
				regulator-name = "vcc_ldo7";
				regulator-state-mem {
					regulator-off-in-suspend;
				};
			};

			vcc1v8_dvp: LDO_REG8 {
				regulator-min-microvolt = <1800000>;
				regulator-max-microvolt = <1800000>;
				regulator-name = "vcc1v8_dvp";
				regulator-state-mem {
					regulator-off-in-suspend;
				};
			};

			vcc2v8_dvp: LDO_REG9 {
				regulator-min-microvolt = <2800000>;
				regulator-max-microvolt = <2800000>;
				regulator-name = "vcc2v8_dvp";
				regulator-state-mem {
					regulator-off-in-suspend;
				};
			};

			dcdc_boost: BOOST {
				regulator-always-on;
				regulator-boot-on;
				regulator-min-microvolt = <5000000>;
				regulator-max-microvolt = <5000000>;
				regulator-name = "boost";
				regulator-state-mem {
					regulator-off-in-suspend;
				};
			};

			otg_switch: OTG_SWITCH {
				regulator-name = "otg_switch";
				regulator-state-mem {
					regulator-off-in-suspend;
				};
			};
		};

		battery {
			compatible = "rk817,battery";
			ntc_table = <42450 40570 38780 37080 35460 33930
				     32460 31070 29750 28490 27280 26140
				     25050 24010 23020 22070 21170 20310
				     19490 18710 17960 17250 16570 15910
				     15290 14700 14130 13590 13070 12570
				     12090 11640 11200 10780 10380 10000
				     9633 9282 8945 8622 8312 8015 7730
				     7456 7194 6942 6700 6468 6245 6031
				     5826 5628 5438 5255 5080 4911 4749
				     4592 4442 4297 4158 4024 3895 3771
				     3651 3536 3425 3318 3215 3115 3019
				     2927 2837 2751 2668 2588>;
				ntc_degree_from = <1 10>;
				ocv_table = <3400 3653 3679 3704 3731 3750
				     3771 3788 3806 3828 3855 3890
				     3943 3993 4043 4095 4149 4206
				     4264 4321 4377>;
				design_capacity = <1000>;
				design_qmax = <1010>;
				bat_res = <110>;
				sleep_enter_current = <30>;
				sleep_exit_current = <30>;
				sleep_filter_current = <20>;
				power_off_thresd = <3400>;
				zero_algorithm_vol = <3000>;
				max_soc_offset = <60>;
				monitor_sec = <5>;
				sample_res = <26>;
				virtual_power = <0>;
				chrg_finish_cur = <50>;
		};

		charger {
			compatible = "rk817,charger";
			min_input_voltage = <4500>;
			max_input_current = <2000>;
			max_chrg_current = <500>;
			max_chrg_voltage = <4400>;
			otg5v_suspend_enable = <0>;
			chrg_term_mode = <0>;
			chrg_finish_cur = <50>;
			virtual_power = <0>;
			dc_det_adc = <0>;
			sample_res = <26>;
			extcon = <&u2phy>;
			gate_function_disable = <1>;
		};

		rk817_codec: codec {
			#sound-dai-cells = <0>;
			compatible = "rockchip,rk817-codec";
			clocks = <&mclkout_sai0>;
			clock-names = "mclk";
			assigned-clocks = <&mclkout_sai0>;
			assigned-clock-rates = <12288000>;
			pinctrl-names = "default";
			pinctrl-0 = <&i2s0m0_mclk>;
			hp-volume = <20>;
			spk-volume = <3>;
			mic-in-differential;
			status = "okay";
		};
	};
};

&i2c2 {
	status = "okay";
	clock-frequency = <400000>;

	gt1x: gt1x@14 {
		compatible = "goodix,gt1x";
		reg = <0x14>;
		pinctrl-names = "default";
		pinctrl-0 = <&touch_gpio>;
		goodix,rst-gpio = <&gpio0 RK_PB4 GPIO_ACTIVE_HIGH>;
		goodix,irq-gpio = <&gpio0 RK_PB3 GPIO_ACTIVE_LOW>;

		power-supply = <&vcc3v3_lcd>;
	};
};

&i2c5 {
	status = "okay";
	clock-frequency = <400000>;

	sc031gs: sc031gs@30 {
		status = "okay";
		compatible = "smartsens,sc031gs";
		reg = <0x30>;
		clocks = <&cru CLK_CAM0_OUT2IO>;
		clock-names = "xvclk";
		pinctrl-names = "default";
		pinctrl-0 = <&camm0_clk0_out>;
		pwdn-gpios = <&gpio3 RK_PC0 GPIO_ACTIVE_HIGH>;
		avdd-supply = <&vcc2v8_dvp>;
		dovdd-supply = <&vcc1v8_dvp>;
		dvdd-supply = <&vcc1v5_dvp>;
		rockchip,camera-module-index = <0>;
		rockchip,camera-module-facing = "back";
		rockchip,camera-module-name = "default";
		rockchip,camera-module-lens-name = "default";

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

&jpegd {
	status = "okay";
};

&jpegd_mmu {
	status = "okay";
};

&mipi0_csi2 {
	status = "okay";

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

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

			mipi0_csi2_input: endpoint@1 {
				reg = <1>;
				remote-endpoint = <&csidcphy0_out>;
			};
		};

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

			mipi0_csi2_output: endpoint@0 {
				reg = <0>;
				remote-endpoint = <&cif_mipi_in0>;
			};
		};
	};
};

&mpp_srv {
	status = "okay";
};

&npu_opp_table {
	/delete-node/ opp-900000000;
	/delete-node/ opp-1000000000;
};

&pinctrl {
	led_control {
		scan_key: scan-key {
			rockchip,pins = <0 RK_PA7 RK_FUNC_GPIO &pcfg_pull_up>;
		};
	};

	touch {
		touch_gpio: touch-gpio {
			rockchip,pins =
				<0 RK_PB3 RK_FUNC_GPIO &pcfg_pull_up>,
				<0 RK_PB4 RK_FUNC_GPIO &pcfg_pull_none>;
		};
	};

	sdio-pwrseq {
		wifi_enable_l: wifi-enable-l {
			rockchip,pins = <2 RK_PA0 RK_FUNC_GPIO &pcfg_pull_none>;
		};
	};

	usb {
		usbc0_int: usbc0-int {
			rockchip,pins = <3 RK_PA1 RK_FUNC_GPIO &pcfg_pull_up>;
		};
	};

	wireless-wlan {
		wifi_host_wake_irq: wifi-host-wake-irq {
			rockchip,pins = <1 RK_PC7 RK_FUNC_GPIO &pcfg_pull_down>;
		};
	};

	wireless-bluetooth {
		uart1_gpios: uart1-gpios {
			rockchip,pins = <1 RK_PD3 RK_FUNC_GPIO &pcfg_pull_none>;
		};
	};
};

&pwm12 {
	status = "okay";
	pinctrl-0 = <&pwm12m1_pins>;
};

&rga2 {
	status = "okay";
};

&rga2_mmu {
	status = "okay";
};

&rkcif {
	status = "okay";
};

&rkcif_mipi_lvds {
	status = "okay";

	port {
		cif_mipi_in0: endpoint {
			remote-endpoint = <&mipi0_csi2_output>;
		};
	};
};

&rkcif_mipi_lvds_sditf {
	status = "okay";

	port {
		mipi_lvds_sditf: endpoint {
			remote-endpoint = <&isp_vir0>;
		};
	};
};

&rkcif_mmu {
	status = "okay";
};

&rkisp {
	status = "okay";
};

&rkisp_mmu {
	status = "okay";
};

&rkisp_vir0 {
	status = "okay";

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

		isp_vir0: endpoint@0 {
			reg = <0>;
			remote-endpoint = <&mipi_lvds_sditf>;
		};
	};
};

&rknpu {
	rknpu-supply = <&vdd_npu>;
	status = "okay";
};

&rknpu_mmu {
	status = "okay";
};

&rkvdec {
	status = "okay";
};

&rkvdec_mmu {
	status = "okay";
};

&rockchip_suspend {
	status = "okay";

	rockchip,sleep-mode-config = <
		(0
		| RKPM_SLP_ULTRA_MODE
		| RKPM_SLP_PMIC_LP
		| RKPM_SLP_HW_PLLS_OFF
		| RKPM_SLP_PMUALIVE_32K
		| RKPM_SLP_OSC_DIS
		| RKPM_SLP_32K_PVTM
		)
	>;
};

&route_dsi {
	status = "okay";
};

&sai0 {
	status = "okay";
	pinctrl-names = "default";
	pinctrl-0 = <&i2s0m0_lrck
		     &i2s0m0_sclk
		     &i2s0m0_sdi0
		     &i2s0m0_sdo0>;
};

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

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

&sdmmc1 {
	no-sd;
	no-mmc;
	bus-width = <4>;
	disable-wp;
	cap-sd-highspeed;
	cap-sdio-irq;
	mmc-pwrseq = <&sdio_pwrseq>;
	non-removable;
	keep-power-in-suspend;
	pinctrl-names = "default";
	pinctrl-0 = <&sdmmc1_bus4 &sdmmc1_cmd &sdmmc1_clk>;
	sd-uhs-sdr104;
	status = "disabled";
};

&tsadc {
	status = "okay";
};

&u2phy {
	status = "okay";
};

/* for inno usb2 phy driver probe and set to phy_sus status */
&u2phy_host {
	/delete-property/ phy-supply;
	status = "okay";
};

&u2phy_otg {
	status = "okay";
	vbus-supply = <&otg_switch>;
};

&uart1 {
	status = "okay";
	pinctrl-names = "default";
	pinctrl-0 = <&uart1m0_xfer &uart1m0_ctsn>;
};

&usbdrd30 {
	status = "okay";
};

&usbdrd_dwc3 {
	status = "okay";
	dr_mode = "otg";
	maximum-speed = "high-speed";
	phys = <&u2phy_otg>;
	phy-names = "usb2-phy";
	snps,dis_u2_susphy_quirk;
	snps,usb2-lpm-disable;

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

&video_phy {
	status = "okay";
};

&vop {
	status = "okay";
};

&vop_mmu {
	status = "okay";
};

&wdt {
	status = "okay";
};
