// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
/*
 * Copyright (c) 2018 Theobroma Systems Design und Consulting GmbH
 */

/dts-v1/;
#include "rk3368.dtsi"

/ {
	chosen {
		stdout-path = "serial0:115200n8";
	};

	ext_gmac: gmac-clk {
		compatible = "fixed-clock";
		clock-frequency = <125000000>;
		clock-output-names = "ext_gmac";
		#clock-cells = <0>;
	};

	i2cmux1 {
		compatible = "i2c-mux-gpio";
		#address-cells = <1>;
		#size-cells = <0>;
		i2c-parent = <&i2c1>;
		mux-gpios = <&gpio1 RK_PA7 GPIO_ACTIVE_HIGH>;

		/* Q7_GPO_I2C */
		i2c@0 {
			reg = <0>;
			#address-cells = <1>;
			#size-cells = <0>;
		};

		/* Q7_SMB */
		i2c@1 {
			reg = <1>;
			#address-cells = <1>;
			#size-cells = <0>;
		};
	};

	i2cmux2 {
		compatible = "i2c-mux-gpio";
		#address-cells = <1>;
		#size-cells = <0>;
		i2c-parent = <&i2c2>;
		mux-gpios = <&gpio1 RK_PB4 GPIO_ACTIVE_HIGH>;

		/* Q7_LVDS_BLC_I2C */
		i2c@0 {
			reg = <0>;
			#address-cells = <1>;
			#size-cells = <0>;

			fan: fan@18 {
				compatible = "ti,amc6821";
				reg = <0x18>;
				#cooling-cells = <2>;
			};

			rtc_twi: rtc@6f {
				compatible = "isil,isl1208";
				reg = <0x6f>;
			};
		};

		/* Q7_GP2_I2C */
		i2c@1 {
			reg = <1>;
			#address-cells = <1>;
			#size-cells = <0>;
		};
	};

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

		module_led1: led-1 {
			label = "module_led1";
			gpios = <&gpio2 RK_PB5 GPIO_ACTIVE_HIGH>;
			linux,default-trigger = "heartbeat";
			panic-indicator;
		};

		module_led2: led-2 {
			label = "module_led2";
			gpios = <&gpio3 RK_PA3 GPIO_ACTIVE_HIGH>;
			default-state = "off";
		};
	};

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

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

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

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

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

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

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

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

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

&emmc {
	bus-width = <8>;
	clock-frequency = <150000000>;
	mmc-hs200-1_8v;
	non-removable;
	vmmc-supply = <&vcc33_io>;
	vqmmc-supply = <&vcc18_io>;
	pinctrl-names = "default";
	pinctrl-0 = <&emmc_clk>, <&emmc_cmd>, <&emmc_bus8>;
	status = "okay";
};

&gmac {
	assigned-clocks = <&cru SCLK_MAC>;
	assigned-clock-parents = <&ext_gmac>;
	clock_in_out = "input";
	phy-supply = <&vcc33_io>;
	phy-mode = "rgmii";
	pinctrl-names = "default";
	pinctrl-0 = <&rgmii_pins>;
	snps,reset-active-low;
	snps,reset-delays-us = <0 10000 50000>;
	snps,reset-gpio = <&gpio3 RK_PB3 GPIO_ACTIVE_LOW>;
	tx_delay = <0x10>;
	rx_delay = <0x10>;
	status = "okay";
};

&i2c0 {
	status = "okay";

	rk808: pmic@1b {
		compatible = "rockchip,rk808";
		reg = <0x1b>;
		interrupt-parent = <&gpio0>;
		interrupts = <RK_PA5 IRQ_TYPE_LEVEL_LOW>;
		clock-output-names = "xin32k", "rk808-clkout2";
		#clock-cells = <1>;
		pinctrl-names = "default";
		pinctrl-0 = <&pmic_int_l>, <&pmic_sleep>;
		rockchip,system-power-controller;
		vcc1-supply = <&vcc_sys>;
		vcc2-supply = <&vcc_sys>;
		vcc3-supply = <&vcc_sys>;
		vcc4-supply = <&vcc_sys>;
		vcc6-supply = <&vcc_sys>;
		vcc7-supply = <&vcc_sys>;
		vcc8-supply = <&vcc_sys>;
		vcc9-supply = <&vcc_sys>;
		vcc10-supply = <&vcc_sys>;
		vcc11-supply = <&vcc_sys>;
		vcc12-supply = <&vcc_sys>;

		regulators {
			vdd_cpu: DCDC_REG1 {
				regulator-name = "vdd_cpu";
				regulator-min-microvolt = <700000>;
				regulator-max-microvolt = <1500000>;
				regulator-always-on;
				regulator-boot-on;
			};

			vdd_log: DCDC_REG2 {
				regulator-name = "vdd_log";
				regulator-min-microvolt = <700000>;
				regulator-max-microvolt = <1500000>;
				regulator-always-on;
				regulator-boot-on;
			};

			vcc_ddr: DCDC_REG3 {
				regulator-name = "vcc_ddr";
				regulator-always-on;
				regulator-boot-on;
			};

			vcc33_io: DCDC_REG4 {
				regulator-name = "vcc33_io";
				regulator-min-microvolt = <3300000>;
				regulator-max-microvolt = <3300000>;
				regulator-always-on;
				regulator-boot-on;
			};

			vcc33_video: LDO_REG2 {
				regulator-name = "vcc33_video";
				regulator-min-microvolt = <3300000>;
				regulator-max-microvolt = <3300000>;
				regulator-always-on;
				regulator-boot-on;
			};

			vdd10_pll: LDO_REG3 {
				regulator-name = "vdd10_pll";
				regulator-min-microvolt = <1000000>;
				regulator-max-microvolt = <1000000>;
				regulator-always-on;
				regulator-boot-on;
			};

			vcc18_io: LDO_REG4 {
				regulator-name = "vcc18_io";
				regulator-min-microvolt = <1800000>;
				regulator-max-microvolt = <1800000>;
				regulator-boot-on;
			};

			vdd10_video: LDO_REG6 {
				regulator-name = "vdd10_video";
				regulator-min-microvolt = <1000000>;
				regulator-max-microvolt = <1000000>;
				regulator-always-on;
				regulator-boot-on;
			};

			vcc18_video: LDO_REG8 {
				regulator-name = "vcc18_video";
				regulator-min-microvolt = <1800000>;
				regulator-max-microvolt = <1800000>;
				regulator-always-on;
				regulator-boot-on;
			};
		};
	};
};

&i2c1 {
	status = "okay";
};

&i2c2 {
	status = "okay";
};

&pinctrl {
	leds {
		module_led_pins: module-led-pins {
			rockchip,pins =
				<2 RK_PB5 RK_FUNC_GPIO &pcfg_pull_none>,
				<3 RK_PA3 RK_FUNC_GPIO &pcfg_pull_none>;
		};
	};
	pmic {
		pmic_int_l: pmic-int-l {
			rockchip,pins = <0 RK_PA5 RK_FUNC_GPIO &pcfg_pull_up>;
		};

		pmic_sleep: pmic-sleep {
			rockchip,pins = <0 RK_PA0 2 &pcfg_pull_none>;
		};
	};
};

&spi1 {
	status = "okay";

	norflash: flash@0 {
		compatible = "jedec,spi-nor";
		reg = <0>;
		spi-max-frequency = <50000000>;
	};
};

&uart1 {
	status = "okay";
};

&uart3 {
	status = "okay";
};

&usb_host0_ehci {
	status = "okay";
};

&wdt {
	status = "okay";
};
