/dts-v1/;

#include "rp-rk3399-board.dtsi"

#include "rp-pmu-rk808.dtsi"
#include "rp-audio-rt5640.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-gpio-key.dtsi"
#include "rp-adc-key.dtsi"      

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

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

#include "rp-sdcard-mmc1.dtsi"

#include "rp-lcd-hdmi.dtsi"
#include "rp-lcd-mipi-5-720-1280-v2-boxTP.dtsi"
#include "rp-lcd-mipi-5-720-1280-v2.dtsi"
//#include "rp-lcd-mipi-7-720-1280-jc070hd005-v1.dtsi"
//#include "rp-lcd-mipi-10-1200-1920-jc101fh107-v1.dtsi"
//#include "rp-lcd-mipi2lvds-gm8775-singlelvds-10-1024-600.dtsi"
//#include "rp-lcd-mipi2lvds-gm8775-duallvds-1920-1080.dtsi"
//#include "rp-box-lcd-edp-13.3-15.6-1920-1080.dtsi"

/ {
    model = "rp-box-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{
        status = "okay";
        compatible = "rp_power";
        rp_not_deep_sleep = <1>;

        //pinctrl-0 = <&rp_power_gpio>;

        /* 
         * #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;
        };
        
        hub_rst { //usb hub reset pin
                gpio_num = <&gpio1 RK_PD0 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";
        gpio3c0 {
            gpio_num = <&gpio3 RK_PC0 GPIO_ACTIVE_LOW>;
            gpio_function = <0>;
            /* gpio_event = <KEY_F14>; */ /** define this property if you want to report
                                            * event such as KEY_F14, but this only works
                                            * in case of gpio_function = <1>;
                                            */
        };
                    
        gpio0a6 {   //ir_rx
            gpio_num = <&gpio0 RK_PA6 GPIO_ACTIVE_LOW>;
            gpio_function = <0>;
        };
        
        gpio1b1 {
            gpio_num = <&gpio1 RK_PB1 GPIO_ACTIVE_LOW>;
            gpio_function = <0>;
        };
        
        gpio1b2 {
            gpio_num = <&gpio1 RK_PB2 GPIO_ACTIVE_LOW>;
            gpio_function = <0>;
        };
        
        gpio4c5 {
            gpio_num = <&gpio4 RK_PC5 GPIO_ACTIVE_LOW>;
            gpio_function = <0>;
        };
                
        gpio4d5 {
            gpio_num = <&gpio4 RK_PD5 GPIO_ACTIVE_LOW>;
            gpio_function = <0>;
        };
        
        gpio1c7 {
            gpio_num = <&gpio1 RK_PC7 GPIO_ACTIVE_LOW>;
            gpio_function = <0>;
        };
        
        gpio0b3 {
            gpio_num = <&gpio0 RK_PB3 GPIO_ACTIVE_LOW>;
            gpio_function = <0>;
        };

        gpio1a2 {
            gpio_num = <&gpio1 RK_PA2 GPIO_ACTIVE_LOW>;
            gpio_function = <0>;
        };
    };
};

&spi2 { 
    status = "okay";
    max-freq = <50000000>;
    spi_test:spi_test@00 {
        status = "okay";
        compatible = "rockchip,spi_test_bus2_cs0";
        id = <2>;
        reg = <0>;
        spi-max-frequency = <24000000>;
        spi-cpha;
        spi-cpol;
    };
};


&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_1v8>;     //king usb
};

&dsi {
    pinctrl-names="default";
    pinctrl-0=<&pwr_en>;
};

&i2s0 {
    status = "okay";
};

&rk808 {
    rtc {
        /****** disabled rtc-rk808 for use hym8563 */
        status = "disabled";
    };
};

&i2c1 {
    status = "okay";
    rtc@51 {
        status = "okay";
        compatible = "haoyu,hym8563";
        reg = <0x51>;
    };
};

&gmac {
    tx_delay = <0x25>;
    rx_delay = <0x25>;  
};

&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 = "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>;
};

&pinctrl{
    pwr_5v {
        pwr_en: pwr-en {
            rockchip,pins = <4 30 RK_FUNC_GPIO &pcfg_pull_up>;
        };
    };
};




