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

/dts-v1/;

#include "../rk3528.dtsi"
#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/input/rk-input.h>
#include <dt-bindings/pinctrl/rockchip.h>

/ {
	dc_12v: dc-12v {
		compatible = "regulator-fixed";
		regulator-name = "dc_12v";
		regulator-always-on;
		regulator-boot-on;
		regulator-min-microvolt = <12000000>;
		regulator-max-microvolt = <12000000>;
	};


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

	/omit-if-no-ref/
	vccio_sd: vccio-sd {
		compatible = "regulator-gpio";
		regulator-name = "vccio_sd";
		regulator-min-microvolt = <1800000>;
		regulator-max-microvolt = <3300000>;
		gpios = <&gpio4 RK_PB6 GPIO_ACTIVE_HIGH>;
		vin-supply = <&vcc5v0_sys>;
		states = <1800000 0x0
			  3300000 0x1>;
	};

	vdd_logic_gpu: vdd-logic-gpu {
		compatible = "pwm-regulator";
		pwms = <&pwm2 0 5000 1>;
		regulator-name = "vdd_logic_gpu";
		regulator-min-microvolt = <705000>;
		regulator-max-microvolt = <1006000>;
		regulator-init-microvolt = <900000>;
		regulator-always-on;
		regulator-boot-on;
		regulator-settling-time-up-us = <250>;
		pwm-supply = <&vcc5v0_sys>;
		status = "okay";
	};

	vdd_cpu: vdd-cpu { //vdd_arm
		compatible = "pwm-regulator";
		pwms = <&pwm1 0 5000 1>;
		regulator-name = "vdd_cpu";
		regulator-min-microvolt = <746000>;
		regulator-max-microvolt = <1201000>;
		regulator-init-microvolt = <953000>;
		regulator-always-on;
		regulator-boot-on;
		regulator-settling-time-up-us = <250>;
		pwm-supply = <&vcc5v0_sys>;
		status = "okay";
	};
	/*
	vdd_gpu: vdd-gpu {
		compatible = "pwm-regulator";
		pwms = <&pwm0 0 5000 1>;
		regulator-name = "vdd_gpu";
		regulator-min-microvolt = <705000>;
		regulator-max-microvolt = <1148000>;
		regulator-init-microvolt = <900000>;
		regulator-always-on;
		regulator-boot-on;
		regulator-settling-time-up-us = <250>;
		pwm-supply = <&vcc5v0_sys>;
		status = "okay";
	};
	*/
	vdd_0v9: vdd-0v9 {
		compatible = "regulator-fixed";
		regulator-name = "vdd_0v9";
		regulator-always-on;
		regulator-boot-on;
		regulator-min-microvolt = <900000>;
		regulator-max-microvolt = <900000>;
		vin-supply = <&vcc5v0_sys>;
	};

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

	vdd_1v8: vdd-1v8 {
                compatible = "regulator-fixed";
                regulator-name = "vdd_1v8";
                regulator-always-on;
                regulator-boot-on;
                regulator-min-microvolt = <1800000>;
                regulator-max-microvolt = <1800000>;
                vin-supply = <&vcc_3v3>;
        };

	/omit-if-no-ref/
	vcc3v3_sd: vcc3v3-sd {
		compatible = "regulator-fixed";
		gpio = <&gpio4 RK_PA1 GPIO_ACTIVE_LOW>;
		regulator-name = "vcc3v3_sd";
		regulator-min-microvolt = <3300000>;
		regulator-max-microvolt = <3300000>;
		vin-supply = <&vcc_3v3>;
	};

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

&acodec {
	pa-ctl-gpios = <&gpio0 RK_PA0 GPIO_ACTIVE_HIGH>;
	status = "okay";
};

&avsd {
	status = "okay";
};

&combphy_pu {
	status = "okay";
};

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

&crypto {
	status = "okay";
};

&dfi {
	status = "okay";
};

&display_subsystem {
	status = "okay";
};

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

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

&gpu_bus {
	bus-supply = <&vdd_logic_gpu>;
	status = "okay";
};

&iep {
	status = "okay";
};

&iep_mmu {
	status = "okay";
};

&jpegd {
	status = "okay";
};

&jpegd_mmu {
	status = "okay";
};

&mpp_srv {
	status = "okay";
};

&pwm1 {
	status = "okay";
};

&pwm2 {
	status = "okay";
};

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

	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_PLAYPAUSE>,
			<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>,
			<0xa4	KEY_SETUP>,
			<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>;
	};
};

&rga2 {
	status = "okay";
};

&rga2_mmu {
	status = "okay";
};

&rkvdec {
	status = "okay";
};

&rkvdec_mmu {
	status = "okay";
};

&rkvenc {
	status = "okay";
};

&rkvenc_mmu {
	status = "okay";
};

&rkvtunnel {
	status = "okay";
};

&rockchip_suspend {
	status = "okay";
	rockchip,sleep-debug-en = <1>;
	rockchip,virtual-poweroff = <1>;
	rockchip,sleep-mode-config = <
		(0
		| RKPM_SLP_ARMPD
		)
	>;
	rockchip,wakeup-config = <
		(0
		| RKPM_CPU0_WKUP_EN
		| RKPM_GPIO_WKUP_EN
		)
	>;
	rockchip,pwm-regulator-config = <
		(0
		| RKPM_PWM0_M0_REGULATOR_EN
		| RKPM_PWM1_M0_REGULATOR_EN
		)
	>;
};

&sai0 {
	pinctrl-0 = <&i2s0m1_lrck &i2s0m1_sclk &i2s0m1_sdi &i2s0m1_sdo>;
	status = "disabled";
};

&sai2 {
	status = "okay";
};

&sai3 {
	status = "okay";
};

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

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

&sdmmc {
	bus-width = <4>;
	cap-mmc-highspeed;
	cap-sd-highspeed;
	disable-wp;
	max-frequency = <150000000>;
	pinctrl-names = "default";
	pinctrl-0 = <&sdmmc_clk &sdmmc_cmd &sdmmc_det &sdmmc_bus4>;
	rockchip,default-sample-phase = <90>;
	supports-sd;
	sd-uhs-sdr12;
	sd-uhs-sdr25;
	sd-uhs-sdr50;
	sd-uhs-sdr104;
	vqmmc-supply = <&vccio_sd>;
	vmmc-supply = <&vcc3v3_sd>;
	status = "disabled";
};

&sfc {
	status = "okay";
};

&spdif_8ch {
	status = "okay";
};

&tsadc {       //Thermal (温度控制)
	status = "okay";
};

&vdpp {
	status = "okay";
};

&vdpu {
	status = "okay";
};

&vdpu_mmu {
	status = "okay";
};

&vop {
	status = "okay";
};

&vop_mmu {
	status = "okay";
};


&gpu_opp_table {
	opp-300000000 {
		opp-hz = /bits/ 64 <300000000>;
		opp-microvolt = <900000 900000 1000000>;
		opp-microvolt-L5 = <900000 900000 1000000>;
		opp-microvolt-L6 = <900000 900000 1000000>;
		opp-microvolt-L7 = <900000 900000 1000000>;
		opp-microvolt-L8 = <900000 900000 1000000>;
	};
	opp-500000000 {
		opp-hz = /bits/ 64 <500000000>;
		opp-microvolt = <900000 900000 1000000>;
		opp-microvolt-L5 = <900000 900000 1000000>;
		opp-microvolt-L6 = <900000 900000 1000000>;
		opp-microvolt-L7 = <900000 900000 1000000>;
		opp-microvolt-L8 = <900000 900000 1000000>;
	};
	opp-600000000 {
		opp-hz = /bits/ 64 <600000000>;
		opp-microvolt = <900000 900000 1000000>;
		opp-microvolt-L5 = <900000 900000 1000000>;
		opp-microvolt-L6 = <900000 900000 1000000>;
		opp-microvolt-L7 = <900000 900000 1000000>;
		opp-microvolt-L8 = <900000 900000 1000000>;
	};
	opp-700000000 {
		opp-hz = /bits/ 64 <700000000>;
		opp-microvolt = <900000 900000 1000000>;
		opp-microvolt-L1 = <900000 900000 1000000>;
		opp-microvolt-L2 = <900000 900000 1000000>;
		opp-microvolt-L3 = <900000 900000 1000000>;
		opp-microvolt-L4 = <900000 900000 1000000>;
		opp-microvolt-L5 = <900000 900000 1000000>;
		opp-microvolt-L6 = <900000 900500 1000000>;
		opp-microvolt-L7 = <900000 900000 1000000>;
		opp-microvolt-L8 = <900000 900000 1000000>;
		clock-latency-ns = <40000>;
	};
	opp-800000000 {
		opp-hz = /bits/ 64 <800000000>;
		opp-microvolt = <950000 950000 1000000>;
		opp-microvolt-L1 = <937500 937500 1000000>;
		opp-microvolt-L2 = <925000 925000 1000000>;
		opp-microvolt-L3 = <912500 912500 1000000>;
		opp-microvolt-L4 = <900000 900000 1000000>;
		opp-microvolt-L5 = <900000 900000 1000000>;
		opp-microvolt-L6 = <900000 900000 1000000>;
		opp-microvolt-L7 = <900000 900000 1000000>;
		opp-microvolt-L8 = <900000 900000 1000000>;
		clock-latency-ns = <40000>;
	};
};

&gpu_bus_opp_table {
	opp-700000000 {
		opp-hz = /bits/ 64 <700000000>;
		opp-microvolt = <900000 900000 1000000>;
	};
	opp-800000000 {
		opp-hz = /bits/ 64 <800000000>;
		opp-microvolt = <900000 900000 1000000>;
		opp-microvolt-L1 = <900000 900000 1000000>;
	};
};



&dfi {
	status = "disabled";
};


&dmc {
	status = "disabled";
};

