/dts-v1/;

#include "rp-rk3399-board.dtsi"

#include "rp-usb2-host0.dtsi"
#include "rp-usb2-host1.dtsi"
#include "rp-usb3-otg-typeA.dtsi"
//#include "rp-usb3-otg-typeC.dtsi"
#include "rp-usb3_1-host.dtsi"

#include "rp-audio-rt5640.dtsi"
#include "rp-pmu-rk808.dtsi"

#include "rp-gpio-key.dtsi"
#include "rp-adc-key.dtsi"      

#include "rp-gmac.dtsi"    

#include "rp-wifi-sdio.dtsi" 
#include "rp-bt-uart0.dtsi"

#include "rp-mipi-ov13850-camera.dtsi" 
//#include "rp-hdmiin.dtsi"

#include "rp-sdcard-mmc1.dtsi"

//#include "rp-lcd-hdmi.dtsi"
//#include "rp-lcd-mipi-5-720-1280.dtsi"
//#include "rp-lcd-mipi-5-720-1280-v2.dtsi"
//#include "rp-lcd-mipi-5-720-1280-v2-boxTP.dtsi"
//#include "rp-lcd-mipi-5.5-720-1280.dtsi"
//#include "rp-lcd-mipi-5.5-1080-1920.dtsi"
//#include "rp-lcd-mipi-5.5-720-1280-v2.dtsi"
#include "rp-lcd-mipi-7-1024-600.dtsi"
//#include "rp-lcd-mipi-7-800-1280.dtsi"
//#include "rp-lcd-mipi-7-1200-1920.dtsi"
//#include "rp-lcd-mipi-8-800-1280.dtsi"
//#include "rp-lcd-mipi-8-800-1280-new.dtsi"
//#include "rp-lcd-mipi-8-800-1280-v3.dtsi"
//#include "rp-lcd-mipi-8-1200-1920.dtsi"
//#include "rp-lcd-mipi-10-800-1280.dtsi"
//#include "rp-lcd-mipi-10-800-1280-v2.dtsi"
//#include "rp-lcd-mipi-10-800-1280-v3.dtsi"
//#include "rp-lcd-mipi-10-1920-1200.dtsi"
//#include "rp-lcd-edp-13.3-1920-1080.dtsi"
//#include "rp-lcd-edp-13.3-15.6-1920-1080.dtsi"
//#include "rp-lcd-mipi2lvds-10-1024-600.dtsi"
//#include "rp-lcd-mipi2Duallvds-1920-1080.dtsi"


/ {

        model = "nano-rk3399";
        compatible = "rockchip,rk3399-excavator-linux", "rockchip,rk3399";

	fan_gpio_control {
            compatible = "fan_gpio_control";
            gpio-pin = <&gpio1 RK_PC2 GPIO_ACTIVE_HIGH>;
            thermal-zone = "cpu-thermal";
            threshold-temp = <60000>; //60C
            running-time = <10000>; //10s
            status = "okay";
        };

        rp_power{
            compatible = "rp_power";     
        rp_not_deep_sleep = <1>;
            status = "okay";
    
            /* 
         * #define GPIO_FUNCTION_OUTPUT 0
         * #define GPIO_FUNCTION_INPUT 1
         * #define GPIO_FUNCTION_IRQ 2
         * #define GPIO_FUNCTION_FLASH 3
         * #define GPIO_FUNCTION_OUTPUT_CTRL 4 //output and creat proc ctrl
         * 
         * you can define the gpio function as above
         * on gpio_function = <>;
     *
     *If you want to set the uboot to high level, add the lower properties
     *    regulator_uboot_on    
         */        

            vdd_en { //vdd5v and vdd_io power en
                    gpio_num = <&gpio4 RK_PD6 GPIO_ACTIVE_HIGH>;
                    gpio_function = <4>;
                    regulator_uboot_on;
            };
            
            host_en { //usb2.0 and 3.0 host 5v power en
                    gpio_num = <&gpio4 RK_PD1 GPIO_ACTIVE_HIGH>;
                    gpio_function = <4>;
                    regulator_uboot_on;
            };        
            
            //fan { //fan en
            //        gpio_num = <&gpio1 RK_PC2 GPIO_ACTIVE_HIGH>;
            //        gpio_function = <4>;
            //        regulator_uboot_on;
            //};
            
            vdd_3g {    //vdd 3G power en
                    gpio_num = <&gpio4 RK_PC6 GPIO_ACTIVE_HIGH>;
                    gpio_function = <4>;
                    regulator_uboot_on;
            };
                    
            run_led {    //LED for indicate system is runing
                    gpio_num = <&gpio4 RK_PD0 GPIO_ACTIVE_HIGH>;
                    gpio_function = <3>;
                    regulator_uboot_on;
            };
            
        };

        rp_gpio {
                status = "okay";
                compatible = "rp_gpio";
                base_value = <0>; //3288_5.1 = 0   3288_7.1.2 = 992  3288_ubuntu = 992   3399_7.1.2 = 1000 3399_ubuntu = 0  

        gpio1a1 {
                    gpio_num = <&gpio1 RK_PA1 GPIO_ACTIVE_HIGH>;
                        gpio_function = <0>;            //0:output，1:input
                };

                gpio1a2 {
                        gpio_num = <&gpio1 RK_PA2 GPIO_ACTIVE_HIGH>;
                        gpio_function = <0>;            //0:output，1:input
                };

                gpio1a3 {
                        gpio_num = <&gpio1 RK_PA3 GPIO_ACTIVE_HIGH>;
                        gpio_function = <0>;            //0:output，1:input
                };

        gpio1c7 {
                    gpio_num = <&gpio1 RK_PC7 GPIO_ACTIVE_HIGH>;
                        gpio_function = <0>;            //0:output，1:input
                };
    };

	rp-keys {
		compatible = "rp-keys";
		name = "rp-keys";
		status = "disabled";

		gpio1a1 {
			gpios = <&gpio1 RK_PA1 GPIO_ACTIVE_HIGH>;
		};
		gpio1a2 {
			label = "gpio1a1_key";
			gpios = <&gpio1 RK_PA2 GPIO_ACTIVE_HIGH>;
			wakeup;
			debounce_interval = <10>;
			press_type = <1>;
			code = <KEY_ENTER>;
		};
	};

   /* wireless-bluetooth {
                compatible = "bluetooth-platdata";
                clocks = <&rk808 1>;
                clock-names = "ext_clock";
                //wifi-bt-power-toggle;
                uart_rts_gpios = <&gpio2 RK_PC3 GPIO_ACTIVE_LOW>; /* GPIO2_C3 */
     /*           pinctrl-names = "default", "rts_gpio";
                pinctrl-0 = <&uart0_rts>,<&bt_wake_gpio>, <&bt_irq_gpio>;
                pinctrl-1 = <&uart0_gpios>;
                //BT,power_gpio  = <&gpio3 19 GPIO_ACTIVE_HIGH>; /* GPIOx_xx */
         //       BT,reset_gpio    = <&gpio0 RK_PB1 GPIO_ACTIVE_HIGH>; /* GPIO0_B1 */
         //       BT,wake_gpio     = <&gpio2 RK_PD2 GPIO_ACTIVE_HIGH>; /* GPIO2_D2 */
         //       BT,wake_host_irq = <&gpio0 RK_PA4 GPIO_ACTIVE_HIGH>; /* GPIO0_A4 */
         //       status = "okay";
       // };


};



&spi1 {
        status = "okay";
        spi_wk2xxx: spi_wk2xxx@0{
                status = "okay";
                compatible = "spi-wk2xxx";
                reg = <0>;
                spi-max-frequency = <10000000>;
                reset-gpio = <&gpio4 29 GPIO_ACTIVE_HIGH>;
                irq-gpio = <&gpio1 20 IRQ_TYPE_EDGE_FALLING>;
                cs-gpio = <&gpio1 10 GPIO_ACTIVE_HIGH>;
        };

};



&io_domains {
        status = "okay";
        bt656-supply = <&vcc_1v8>;              /* bt656_gpio2ab_ms */
        audio-supply = <&vcca1v8_codec>;        /* audio_gpio3d4a_ms */
        sdmmc-supply = <&vcc_sdio>;             /* sdmmc_gpio4b_ms */
        gpio1830-supply = <&vcc_3v0>;           /* gpio1833_gpio4cd_ms */
};

&pmu_io_domains {
        status = "okay";
        pmu1830-supply = <&vcc_3v0>;     //nano usb
};

//used to bluetooth
//&uart0 {
//        status = "okay";
        //dma-names = "tx", "rx";
        //dmas = <&dmac_peri 0>, <&dmac_peri 1>;
//};

//conflicts to ethernet
&uart1 {
        status = "disabled";
        //dma-names = "tx", "rx";
        //dmas = <&dmac_peri 2>, <&dmac_peri 3>;
};

//conflicts to debugger
&uart2 {
        status = "disabled";
        //dma-names = "tx", "rx";
        //dmas = <&dmac_peri 4>, <&dmac_peri 5>;
};

//conflicts to ethernet
&uart3 {
        status = "disabled";
        //dma-names = "tx", "rx";
        //dmas = <&dmac_peri 6>, <&dmac_peri 7>;
};

&uart4 {
        status = "disabled";//okay
        pinctrl-names = "default";
        pinctrl-0 = <&uart4_xfer>;
        dma-names = "tx", "rx";
        dmas = <&dmac_peri 8>, <&dmac_peri 9>;
};

&fiq_debugger {
        rockchip,serial-id = <2>; //uart2
        rockchip,wake-irq = <0>;
        rockchip,irq-mode-enable = <1>;
        compatible = "rockchip,fiq-debugger";
        rockchip,baudrate = <115200>;
        pinctrl-names = "default";
        pinctrl-0 = <&uart2c_xfer>;
};

&vcc_otg_vbus {
    gpio = <&gpio0 RK_PA6 GPIO_ACTIVE_LOW>;    
    pinctrl-names = "default";
        pinctrl-0 = <&otg_vbus_drv>;
};



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



