/dts-v1/;
/plugin/;

#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/input/input.h>
#include <dt-bindings/pinctrl/rockchip.h>
#include <dt-bindings/interrupt-controller/irq.h>

&{/regulators/regulator@0} {
	status = "disabled";
};

&{/regulators/regulator@1} {
	status = "disabled";
};

&{/vdd-arm} {
	status = "disabled";
};

&{/vdd-log} {
	status = "disabled";
};

&{/xin32k} {
	status = "disabled";
};

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

	clock-frequency = <1000000>;
	i2c-scl-rising-time-ns = <83>;
	i2c-scl-falling-time-ns = <5>;
	status = "okay";

	rk805: rk805@18 {
		compatible = "rockchip,rk805";
		reg = <0x18>;
		status = "okay";

		gpio-controller;
		#gpio-cells = <2>;

		interrupt-parent = <&gpio2>;
		interrupts = <RK_PA6 IRQ_TYPE_LEVEL_LOW>;

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

		system-power-controller;
		wakeup-source;

		#clock-cells = <1>;
		clock-output-names = "xin32k", "rk805-clkout2";

		vcc1-supply = <&vcc_sys>;
		vcc2-supply = <&vcc_sys>;
		vcc3-supply = <&vcc_sys>;
		vcc4-supply = <&vcc_sys>;
		vcc5-supply = <&rk805_vcc_io>;
		vcc6-supply = <&rk805_vcc_io>;

		rtc {
			status = "okay";
		};

		pwrkey {
			status = "okay";
		};

		gpio {
			status = "okay";
		};

		regulators {
			compatible = "rk805-regulator";
			status = "okay";
			#address-cells = <1>;
			#size-cells = <0>;

			vdd_logic: DCDC_REG1 {
				regulator-name = "vdd_logic";
				regulator-min-microvolt = <700000>;
				regulator-max-microvolt = <1350000>;
				regulator-ramp-delay = <12500>;
				regulator-boot-on;
				regulator-always-on;
				regulator-state-mem {
					regulator-on-in-suspend;
					regulator-suspend-microvolt = <1000000>;
				};
			};

			vdd_arm: DCDC_REG2 {
				regulator-name = "vdd_arm";
				regulator-min-microvolt = <700000>;
				regulator-max-microvolt = <1350000>;
				regulator-ramp-delay = <12500>;
				regulator-boot-on;
				regulator-always-on;
				regulator-state-mem {
					regulator-on-in-suspend;
					regulator-suspend-microvolt = <950000>;
				};
			};

			vcc_ddr: DCDC_REG3 {
				regulator-name = "vcc_ddr";
				regulator-boot-on;
				regulator-always-on;
				regulator-state-mem {
					regulator-on-in-suspend;
				};
			};

			vcc_io: rk805_vcc_io: DCDC_REG4 {
				regulator-name = "vccio_3v3";
				regulator-min-microvolt = <3300000>;
				regulator-max-microvolt = <3300000>;
				regulator-boot-on;
				regulator-always-on;
				regulator-state-mem {
					regulator-on-in-suspend;
					regulator-suspend-microvolt = <3300000>;
				};
			};

			vdd_18: vcc_18: LDO_REG1 {
				regulator-name = "vccio_1v8";
				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_11: LDO_REG3 {
				regulator-name = "vdd_11";
				regulator-min-microvolt = <1100000>;
				regulator-max-microvolt = <1100000>;
				regulator-boot-on;
				regulator-always-on;
				regulator-state-mem {
					regulator-on-in-suspend;
					regulator-suspend-microvolt = <1100000>;
				};
			};
		};
	};

};

&pinctrl {

	leds {
		ir_led: ir-led {
			rockchip,pins = <2 RK_PC2 RK_FUNC_GPIO &pcfg_pull_none>;
		};
	};

};

&gpio_led {

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

	working {
		gpios = <&rk805 0 GPIO_ACTIVE_LOW>;
		linux,default-trigger = "mmc2";
		default-state = "off";
		mode = <35>;
	};

	/*
	 * These leds are described in the original dtb, but are not present on the board
	auxiliary {
		gpios = <&rk805 1 GPIO_ACTIVE_LOW>;
		linux,default-trigger = "mmc2";
		default-state = "off";
		mode = <5>;
	};

	ir {
		gpios = <&gpio2 RK_PC2 GPIO_ACTIVE_LOW>;
		linux,default-trigger = "ir";
		default-state = "off";
		mode = <0>;
	};
	*/

};

&io_domains {
	vccio1-supply = <&vcc_io>;
	vccio2-supply = <&vcc_18emmc>;
	vccio3-supply = <&vcc_io>;
	vccio4-supply = <&vdd_18>;
	vccio5-supply = <&vcc_io>;
	vccio6-supply = <&vcc_io>;
	pmuio-supply = <&vcc_io>;
};

&{/} {
	gpio_keys: gpio-keys {
		compatible = "gpio-keys";

		power {
			label = "Power button";
			linux,code = <KEY_POWER>;
			gpios = <&gpio2 RK_PC5 GPIO_ACTIVE_HIGH>;
		};
	};
};

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

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

&vpu {
	vcodec-supply = <&vdd_logic>;
};

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

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

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

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


&vcc_sd {
	vin-supply = <&vcc_io>;
};

&emmc {
	vmmc-supply = <&vcc_io>;
	vqmmc-supply = <&vcc_18emmc>;
};

&saradc {
	vref-supply = <&vcc_18>;
};

&pwm0 {
	status = "disabled";
};

&pwm1 {
	status = "disabled";
};

/*
 * Following section enables the sdio bus on sdmmc_ext controller
 */
&sdio {
	/delete-property/ mmc-pwrseq;
	status = "disabled";
};

&sdio_ext {
	rockchip,default-sample-phase = <112>; // Allows ssv6051 chips to be detected at 50 MHz
	sd-uhs-sdr50;
	mmc-pwrseq = <&sdio_pwrseq>;
	status = "okay";
};

&sdmmc_ext {
	status = "disabled";
};

&spdif {
	pinctrl-0 = <&spdifm1_tx>;
};

