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

/dts-v1/;

#include "rk3528.dtsi"
#include "rk3528-demo.dtsi"

/ {
	model = "Rockchip RK3528 DEMO6 DDR3 V10 Board";
	compatible = "rockchip,rk3528-demo6-ddr3-v10", "rockchip,rk3528";

	/delete-node/ vcc-ddr-s3;
	/delete-node/ vcc-3v3-s3;
	/delete-node/ vdd-cpu;
	/delete-node/ vdd-logic;
	/delete-node/ vdd-0v9-s3;
	/delete-node/ vdd-1v8-s3;

	/omit-if-no-ref/
	vcc_sd: vcc-sd {
		compatible = "regulator-fixed";
		regulator-boot-on;
		gpio = <&gpio4 RK_PA1 GPIO_ACTIVE_LOW>;
		regulator-name = "vcc_sd";
		regulator-min-microvolt = <3300000>;
		regulator-max-microvolt = <3300000>;
		vin-supply = <&vcc_3v3_s3>;
	};

	sdio_pwrseq: sdio-pwrseq {
		compatible = "mmc-pwrseq-simple";
		pinctrl-names = "default";
		pinctrl-0 = <&wifi_enable_h  &clkm1_32k_out>;
		reset-gpios = <&gpio1 RK_PA6 GPIO_ACTIVE_LOW>;
	};

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

	wireless_bluetooth: wireless-bluetooth {
		compatible = "bluetooth-platdata";
		//wifi-bt-power-toggle;
		uart_rts_gpios = <&gpio1 RK_PB2 GPIO_ACTIVE_LOW>;
		pinctrl-names = "default", "rts_gpio";
		pinctrl-0 = <&uart2m1_rtsn &bt_enable_h>;
		pinctrl-1 = <&uart2m1_gpios>;
		BT,reset_gpio    = <&gpio1 RK_PC1 GPIO_ACTIVE_HIGH>;
		BT,wake_gpio     = <&gpio1 RK_PB4 GPIO_ACTIVE_HIGH>;
		BT,wake_host_irq = <&gpio1 RK_PC2 GPIO_ACTIVE_HIGH>;
		status = "okay";
	};

	wireless_wlan: wireless-wlan {
		compatible = "wlan-platdata";
		rockchip,grf = <&grf>;
		wifi_chip_type = "aic8800";
		pinctrl-names = "default";
		pinctrl-0 = <&wifi_host_wake_irq >;
		WIFI,host_wake_irq = <&gpio1 RK_PA7 GPIO_ACTIVE_HIGH>;
		//WIFI,reset_gpio = <&gpio1 RK_PA6  GPIO_ACTIVE_HIGH>;
		status = "okay";
	};
};

&gmac0 {
	status = "disabled";
};

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

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

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

	pinctrl-names = "default";
	pinctrl-0 = <&rgmii_miim
		     &rgmii_tx_bus2
		     &rgmii_rx_bus2
		     &rgmii_rgmii_clk
		     &rgmii_rgmii_bus
		     &eth_pins>;

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

&i2c0 {
	status = "okay";

	rk805: rk805@18 {
		compatible = "rockchip,rk805";
		status = "okay";
		reg = <0x18>;
		interrupt-parent = <&gpio4>;
		interrupts = <RK_PB2 IRQ_TYPE_LEVEL_LOW>;
		pinctrl-names = "default";
		pinctrl-0 = <&pmic_int_l>;
		wakeup-source;
		gpio-controller;
		#gpio-cells = <2>;
		#clock-cells = <1>;
		clock-output-names = "rk805-clkout1", "rk805-clkout2";
		rockchip,system-power-controller;

		vcc1-supply = <&vcc5v0_sys>;
		vcc2-supply = <&vcc5v0_sys>;
		vcc3-supply = <&vcc5v0_sys>;
		vcc4-supply = <&vcc5v0_sys>;
		vcc5-supply = <&vcc_3v3_s3>;
		vcc6-supply = <&vcc5v0_sys>;

		rtc {
			status = "okay";
		};

		pwrkey {
			status = "disabled";
		};

		gpio {
			status = "okay";
		};

		regulators {
			vdd_cpu: DCDC_REG1 {
				regulator-name = "vdd_cpu";
				regulator-min-microvolt = <712500>;
				regulator-max-microvolt = <1450000>;
				regulator-init-microvolt = <953000>;
				regulator-initial-mode = <0x1>;
				regulator-ramp-delay = <12500>;
				regulator-boot-on;
				regulator-always-on;
				regulator-state-mem {
					regulator-off-in-suspend;
				};
			};

			vdd_logic: DCDC_REG2 {
				regulator-name = "vdd_logic";
				regulator-min-microvolt = <712500>;
				regulator-max-microvolt = <1450000>;
				regulator-init-microvolt = <900000>;
				regulator-initial-mode = <0x1>;
				regulator-ramp-delay = <12500>;
				regulator-boot-on;
				regulator-always-on;
				regulator-state-mem {
					regulator-mode = <0x2>;
					regulator-on-in-suspend;
					regulator-suspend-microvolt = <712500>;
				};
			};

			vcc_ddr_s3: DCDC_REG3 {
				regulator-name = "vcc_ddr_s3";
				regulator-initial-mode = <0x1>;
				regulator-boot-on;
				regulator-always-on;
				regulator-state-mem {
					regulator-mode = <0x2>;
					regulator-on-in-suspend;
				};
			};

			vcc_3v3_s3: DCDC_REG4 {
				regulator-name = "vcc_3v3_s3";
				regulator-min-microvolt = <3300000>;
				regulator-max-microvolt = <3300000>;
				regulator-initial-mode = <0x1>;
				regulator-boot-on;
				regulator-always-on;
				regulator-state-mem {
					regulator-mode = <0x2>;
					regulator-on-in-suspend;
					regulator-suspend-microvolt = <3300000>;
				};
			};

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

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

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

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

&pinctrl {
	pmic {
		pmic_int_l: pmic-int-l {
		rockchip,pins =
			<4 RK_PB2 RK_FUNC_GPIO &pcfg_pull_up>;
		};
	};

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

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

	wireless-bluetooth {
		uart2m1_gpios: uart2m1-gpios {
			rockchip,pins = <1 RK_PB2 RK_FUNC_GPIO &pcfg_pull_none>;
		};
		bt_enable_h: bt-enable-h {
			rockchip,pins = <1 RK_PC1 RK_FUNC_GPIO &pcfg_pull_down>;
		};
	};
};

&pwm1 {
	status = "disabled";
};

&pwm2 {
	status = "disabled";
};

&rockchip_suspend {
	status = "okay";
	rockchip,sleep-mode-config = <
		(0
		 |RKPM_SLP_ARMOFF
		)
	>;
};

&sdio0 {
	max-frequency = <200000000>;
	no-sd;
	no-mmc;
	supports-sdio;
	bus-width = <4>;
	disable-wp;
	cap-sd-highspeed;
	cap-sdio-irq;
	keep-power-in-suspend;
	non-removable;
	mmc-pwrseq = <&sdio_pwrseq>;
	pinctrl-names = "default";
	pinctrl-0 = <&sdio0_bus4 &sdio0_cmd &sdio0_clk>;
	post-power-on-delay-ms = <50>;
	/delete-property/ rockchip,use-v2-tuning;
	sd-uhs-sdr104;
	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 = <&vcc_sd>;
	status = "okay";
};

&uart2 {
	status = "okay";
	pinctrl-names = "default";
	pinctrl-0 = <&uart2m1_xfer &uart2m1_ctsn>;
};
