// SPDX-License-Identifier: (GPL-2.0+ OR MIT)

/dts-v1/;

#include "rk322x.dtsi"
#include "rk3229-cpu-opp.dtsi"
#include "rk322x-android.dtsi"

/ {
	model = "Rockchip RK3229 Evaluation board";
	compatible = "rockchip,rk3229-evb", "rockchip,rk3229";

	memory@60000000 {
		device_type = "memory";
		reg = <0x60000000 0x40000000>;
	};

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

	gpio_keys {
		compatible = "gpio-keys";
		#address-cells = <1>;
		#size-cells = <0>;
		autorepeat;

		pinctrl-names = "default";
		pinctrl-0 = <&pwr_key>;

		power_key: power-key {
			label = "GPIO Key Power";
			gpios = <&gpio3 23 GPIO_ACTIVE_LOW>;
			linux,code = <KEY_POWER>;
			debounce-interval = <100>;
			wakeup-source;
		};
	};

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

	reserved-memory {
		#address-cells = <1>;
		#size-cells = <1>;
		ranges;

		trust_reserved: trust@0x68400000 {
			reg = <0x68400000 0xe00000>;
			no-map;
		};
	};

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

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

	sound {
		compatible = "simple-audio-card";
		simple-audio-card,format = "i2s";
		simple-audio-card,mclk-fs = <256>;
		simple-audio-card,name = "rockchip,rk3229";
		simple-audio-card,cpu {
			sound-dai = <&i2s1>;
		};
		simple-audio-card,codec {
			sound-dai = <&codec>;
		};
	};

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

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

	vcc_host: vcc-host-regulator {
		compatible = "regulator-fixed";
		enable-active-high;
		gpio = <&gpio3 20 GPIO_ACTIVE_HIGH>;
		pinctrl-names = "default";
		pinctrl-0 = <&host_vbus_drv>;
		regulator-name = "vcc_host";
		regulator-always-on;
		regulator-boot-on;
		vin-supply = <&vcc_sys>;
	};

	vcc_otg_vbus: otg-vbus-regulator {
		compatible = "regulator-fixed";
		gpio = <&gpio3 RK_PC6 GPIO_ACTIVE_HIGH>;
		pinctrl-names = "default";
		pinctrl-0 = <&otg_vbus_drv>;
		regulator-name = "vcc_otg_vbus";
		regulator-min-microvolt = <5000000>;
		regulator-max-microvolt = <5000000>;
		enable-active-high;
	};

	vcc_phy: vcc-phy-regulator {
		compatible = "regulator-fixed";
		enable-active-high;
		regulator-name = "vcc_phy";
		regulator-min-microvolt = <1800000>;
		regulator-max-microvolt = <1800000>;
		regulator-always-on;
		regulator-boot-on;
		vin-supply = <&vccio_1v8>;
	};

	vcc_sys: vcc-sys-regulator {
		compatible = "regulator-fixed";
		regulator-name = "vcc_sys";
		regulator-always-on;
		regulator-boot-on;
		regulator-min-microvolt = <5000000>;
		regulator-max-microvolt = <5000000>;
		vin-supply = <&dc_12v>;
	};

	vccio_1v8: vccio-1v8-regulator {
		compatible = "regulator-fixed";
		regulator-name = "vccio_1v8";
		regulator-min-microvolt = <1800000>;
		regulator-max-microvolt = <1800000>;
		regulator-always-on;
		vin-supply = <&vcc_sys>;
	};

	vccio_3v3: vccio-3v3-regulator {
		compatible = "regulator-fixed";
		regulator-name = "vccio_3v3";
		regulator-min-microvolt = <3300000>;
		regulator-max-microvolt = <3300000>;
		regulator-always-on;
		vin-supply = <&vcc_sys>;
	};

	vdd_arm: vdd-arm-regulator {
		compatible = "pwm-regulator";
		rockchip,pwm_id = <1>;
		rockchip,pwm_voltage = <1100000>;
		pwms = <&pwm1 0 25000 1>;
		pwm-supply = <&vcc_sys>;
		regulator-name = "vdd_arm";
		regulator-min-microvolt = <950000>;
		regulator-max-microvolt = <1400000>;
		regulator-always-on;
		regulator-boot-on;
	};

	vdd_log: vdd-log-regulator {
		compatible = "pwm-regulator";
		rockchip,pwm_id = <2>;
		rockchip,pwm_voltage = <1200000>;
		pwms = <&pwm2 0 25000 1>;
		pwm-supply = <&vcc_sys>;
		regulator-name = "vdd_log";
		regulator-min-microvolt = <1000000>;
		regulator-max-microvolt = <1300000>;
		regulator-always-on;
		regulator-boot-on;
	};

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

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

&cpu1 {
	cpu-supply = <&vdd_arm>;
};

&cpu2 {
	cpu-supply = <&vdd_arm>;
};

&cpu3 {
	cpu-supply = <&vdd_arm>;
};

&gmac {
	assigned-clocks = <&cru SCLK_MAC_SRC>;
	assigned-clock-rates = <50000000>;
	clock_in_out = "output";
	phy-supply = <&vcc_phy>;
	phy-mode = "rmii";
	phy-is-integrated;
	status = "okay";
};

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

&hdmi {
	status = "okay";
	#sound-dai-cells = <0>;
	ddc-i2c-scl-high-time-ns = <9625>;
	ddc-i2c-scl-low-time-ns = <10000>;
};

&io_domains {
	status = "okay";

	vccio1-supply = <&vccio_3v3>;
	vccio2-supply = <&vccio_1v8>;
	vccio4-supply = <&vccio_3v3>;
};

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

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

&i2c0 {
	status = "okay";

	hym8563: hym8563@51 {
		compatible = "haoyu,hym8563";
		reg = <0x51>;
		#clock-cells = <0>;
		clock-frequency = <32768>;
		clock-output-names = "xin32k";
	};
};

&i2s0 {
	status = "okay";
	rockchip,bclk-fs = <128>;
	#sound-dai-cells = <0>;
};

&pinctrl {
	keys {
		pwr_key: pwr-key {
			rockchip,pins = <3 RK_PC7 RK_FUNC_GPIO &pcfg_pull_up>;
		};
	};

	sdmmc {
		sdmmc_pwr: sdmmc-pwr {
			rockchip,pins = <1 RK_PB6 RK_FUNC_GPIO &pcfg_pull_none>;
		};
	};

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

	usb {
		host_vbus_drv: host-vbus-drv {
			rockchip,pins = <3 RK_PC4 RK_FUNC_GPIO &pcfg_pull_none>;
		};

		otg_vbus_drv: otg-vbus-drv {
			rockchip,pins = <3 RK_PC6 RK_FUNC_GPIO &pcfg_pull_none>;
		};
	};
};

&pwm1 {
	status = "okay";
	pinctrl-names = "active";
	pinctrl-0 = <&pwm1_pin_pull_down>;
};

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

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

&sdio {
	status = "okay";
	mmc-pwrseq = <&sdio_pwrseq>;
};

&sdmmc {
	status = "okay";
	pinctrl-names = "default";
	pinctrl-0 = <&sdmmc_pwr &sdmmc_clk &sdmmc_cmd &sdmmc_bus4>;
};

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

&u2phy0 {
	status = "okay";

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

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

&u2phy1 {
	status = "okay";

	u2phy1_otg: otg-port {
		phy-supply = <&vcc_host>;
		status = "okay";
	};

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

&u2phy0_otg {
	vbus-supply = <&vcc_otg_vbus>;
};

&usb_host0_ehci {
	status = "okay";
};

&usb_host0_ohci {
	status = "okay";
};

&usb_host1_ehci {
	status = "okay";
};

&usb_host1_ohci {
	status = "okay";
};

&usb_host2_ehci {
	status = "okay";
};

&usb_host2_ohci {
	status = "okay";
};

&usb_otg {
	status = "okay";
};
