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

/dts-v1/;
#include <dt-bindings/input/input.h>
#include "rk3328.dtsi"

/ {
	model = "A95X Z2";
	compatible = "zkmagic,a95x-z2", "rockchip,rk3318";

	chosen {
		stdout-path = "serial2:1500000n8";
	};

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

		recovery {
			label = "recovery";
			linux,code = <KEY_VENDOR>;
			press-threshold-microvolt = <17000>;
		};
	};

	ir-receiver {
		compatible = "gpio-ir-receiver";
		gpios = <&gpio2 RK_PA2 GPIO_ACTIVE_LOW>;
		pinctrl-0 = <&ir_int>;
		pinctrl-names = "default";
	};

	leds {
		compatible = "gpio-leds";
		pinctrl-0 = <&cyx_led_pin>;
		pinctrl-names = "default";

		cyx_led: led-0 {
			default-state = "on";
			gpios = <&gpio2 RK_PC7 GPIO_ACTIVE_LOW>;
			label = "CYX_LED";
		};
	};

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

	spdif-sound {
		compatible = "simple-audio-card";
		simple-audio-card,name = "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 {
		compatible = "linux,spdif-dit";
		#sound-dai-cells = <0>;
	};

	/* Power tree */
	vccio_1v8: vccio-1v8-regulator {
		compatible = "regulator-fixed";
		regulator-name = "vccio_1v8";
		regulator-min-microvolt = <1800000>;
		regulator-max-microvolt = <1800000>;
		regulator-always-on;
	};

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

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

	vcc_sd: sdmmc-regulator {
		compatible = "regulator-fixed";
		gpio = <&gpio0 RK_PD6 GPIO_ACTIVE_LOW>;
		pinctrl-0 = <&sdmmc0m1_pin>;
		pinctrl-names = "default";
		regulator-name = "vcc_sd";
		regulator-min-microvolt = <3300000>;
		regulator-max-microvolt = <3300000>;
		vin-supply = <&vccio_3v3>;
	};

	vdd_arm: vdd-arm {
		compatible = "pwm-regulator";
		pwms = <&pwm0 0 5000 1>;
		regulator-name = "vdd_arm";
		regulator-min-microvolt = <950000>;
		regulator-max-microvolt = <1400000>;
		regulator-settling-time-up-us = <250>;
		regulator-always-on;
		regulator-boot-on;
	};

	vdd_log: vdd-log {
		compatible = "pwm-regulator";
		pwms = <&pwm1 0 5000 1>;
		regulator-name = "vdd_log";
		regulator-min-microvolt = <900000>;
		regulator-max-microvolt = <1300000>;
		regulator-settling-time-up-us = <250>;
		regulator-always-on;
		regulator-boot-on;
	};
};

&analog_sound {
	status = "okay";
};

&codec {
	status = "okay";
};

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

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

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

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

&cpu0_opp_table {
	opp-1200000000 {
		status = "disabled";
	};

	opp-1296000000 {
		status = "disabled";
	};
};

&emmc {
	bus-width = <8>;
	cap-mmc-highspeed;
	non-removable;
	pinctrl-0 = <&emmc_clk &emmc_cmd &emmc_bus8>;
	pinctrl-names = "default";
	status = "okay";
};

&gmac2phy {
	assigned-clock-parents = <&cru SCLK_MAC2PHY_SRC>;
	assigned-clock-rate = <50000000>;
	assigned-clocks = <&cru SCLK_MAC2PHY>;
	clock_in_out = "output";
	status = "okay";
};

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

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

&hdmiphy {
	status = "okay";
};

&hdmi_sound {
	status = "okay";
};

&i2s0 {
	status = "okay";
};

&i2s1 {
	status = "okay";
};

&io_domains {
	pmuio-supply = <&vccio_3v3>;
	vccio1-supply = <&vccio_3v3>;
	vccio2-supply = <&vccio_1v8>;
	vccio3-supply = <&vccio_3v3>;
	vccio4-supply = <&vccio_1v8>;
	vccio5-supply = <&vccio_3v3>;
	vccio6-supply = <&vccio_3v3>;
	status = "okay";
};

&pinctrl {
	ir {
		ir_int: ir-int {
			rockchip,pins = <2 RK_PA2 RK_FUNC_GPIO &pcfg_pull_none>;
		};
	};

	leds {
		cyx_led_pin: cyx-led-pin {
			rockchip,pins = <2 RK_PC7 RK_FUNC_GPIO &pcfg_pull_none>;
		};
	};

	pwm0 {
		pwm0_pin_pull_up: pwm0-pin-pull-up {
			rockchip,pins = <2 RK_PA4 1 &pcfg_pull_up>;
		};
	};

	pwm1 {
		pwm1_pin_pull_up: pwm1-pin-pull-up {
			rockchip,pins = <2 RK_PA5 1 &pcfg_pull_up>;
		};
	};

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

	sdmmc1 {
		clk_32k_out: clk-32k-out {
			rockchip,pins = <1 RK_PD4 1 &pcfg_pull_none>;
		};
	};

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

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

&pwm0 {
	pinctrl-0 = <&pwm0_pin_pull_up>;
	pinctrl-names = "active";
	status = "okay";
};

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

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

&sdio {
	bus-width = <4>;
	cap-sd-highspeed;
	cap-sdio-irq;
	keep-power-in-suspend;
	max-frequency = <125000000>;
	mmc-pwrseq = <&sdio_pwrseq>;
	non-removable;
	pinctrl-0 = <&sdmmc1_bus4 &sdmmc1_cmd &sdmmc1_clk &clk_32k_out>;
	pinctrl-names = "default";
	sd-uhs-sdr104;
	status = "okay";
};

&sdmmc {
	bus-width = <4>;
	cap-sd-highspeed;
	pinctrl-0 = <&sdmmc0_clk &sdmmc0_cmd &sdmmc0_dectn &sdmmc0_bus4>;
	pinctrl-names = "default";
	vmmc-supply = <&vcc_sd>;
	status = "okay";
};

&spdif {
	pinctrl-0 = <&spdifm0_tx>;
	status = "okay";
};

&soc_crit {
	temperature = <115000>; /* millicelsius */
};

&target {
	temperature = <105000>; /* millicelsius */
};

&threshold {
	temperature = <90000>; /* millicelsius */
};

&tsadc {
	rockchip,hw-tshut-temp = <120000>;
	status = "okay";
};

&u2phy {
	status = "okay";
};

&u2phy_host {
	status = "okay";
};

&u2phy_otg {
	phy-supply = <&vcc_otg_vbus>;
	status = "okay";
};

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

&uart2 {
	status = "okay";
};

&usb20_otg {
	dr_mode = "host";
	status = "okay";
};

&usb_host0_ehci {
	status = "okay";
};

&usb_host0_ohci {
	status = "okay";
};

&vop {
	status = "okay";
};

&vop_mmu {
	status = "okay";
};
