转接芯片 lvds 转 edp NCS8801

// ncs8801s
&i2c4 {
    status = "okay";

    NCS8801@70{
                                                                                  

            
        compatible = "ztl,ncs8801";
        reg = <0x70>;
        edp_gpio_rstb = <&gpio5 18 GPIO_ACTIVE_HIGH>;
        edp_gpio_pwd = <&gpio5 19 IRQ_TYPE_LEVEL_LOW>;
        status="okay";
    };  

};

&lvds_in_vopl {
    status = "okay";
};

&lvds_in_vopb {
    status = "disabled";
};

&route_lvds {
    status = "display";
};

&lvds {
    status = "okay";
};

&lvds_panel {
    status = "okay";
    compatible ="simple-panel";
    backlight = <&backlight>;
    bus-format = ;
-- 可视 --                                                                                                                                        1,0-1        顶端


    {0x70,0x0f,0x01},  
    {0x70,0x00,0x00},
    {0x70,0x02,0x05},
    {0x70,0x03,0x03},
    {0x70,0x07,0xc2},
    
// ncs8801s
&i2c4 {
    status = "okay";
    
    NCS8801@70{
        
    
        
        compatible = "ztl,ncs8801";
        reg = <0x70>;
        edp_gpio_rstb = <&gpio5 18 GPIO_ACTIVE_HIGH>;
        edp_gpio_pwd = <&gpio5 19 IRQ_TYPE_LEVEL_LOW>;
        status="okay";
    };
    
};  
    
&lvds_in_vopl {
    status = "okay";
};  
    
&lvds_in_vopb {
    status = "disabled";
};  
    
&route_lvds {
    status = "display";
};  
    
&lvds {
    status = "okay";
};  
    
&lvds_panel {
    status = "okay";
    compatible ="simple-panel";
    backlight = <&backlight>;
    bus-format = ;
-- 可视 --                                                                                                                                        1,0-1        顶端
            hactive = <1280>;
            vactive = <800>;
            hfront-porch = <40>;
            hsync-len = <3>;
            hback-porch = <120>;
            vfront-porch = <4>;
            vsync-len = <8>;
            vback-porch = <8>;
            hsync-active = <0>;
            vsync-active = <0>;
            de-active = <0>;
            pixelclk-active = <0>;
        };
        timing_edp1: timing1 {
            clock-frequency = <72300000>;
            hactive = <1366>;
            vactive = <768>;
            hfront-porch = <70>;
            hsync-len = <83>;
            hback-porch = <80>;
            vfront-porch = <19>;
            vsync-len = <3>;
            vback-porch = <3>;
            hsync-active = <0>;
            vsync-active = <0>;
            de-active = <0>;
            pixelclk-active = <0>;
        };


                     
    };
};
#endif 

&hdmi{
    status = "disabled";
};

NCS8801 NcsArray[]={
/*
    {0x70, 0x0f, 0x01},
        {0x70, 0x00, 0x00},
        //{0x70, 0x02, 0x07},    
        {0x70, 0x02, 0x25},
        {0x70, 0x03, 0x03}, 
        {0x70, 0x07, 0xc2},
        {0x70, 0x09, 0x01},
        {0x70, 0x0b, 0x31},
        //{0x70, 0x0c, 0xff},
        //{0x70, 0x0d, 0x00},
        //{0x70, 0x0e, 0x00},
        {0x70, 0x10, 0x08},
        {0x70, 0x11, 0x98},
        {0x70, 0x12, 0x00},
        {0x70, 0x13, 0xc0},
        {0x70, 0x14, 0x07},
        {0x70, 0x15, 0x80},
        {0x70, 0x16, 0x04},
        {0x70, 0x17, 0x65},
        {0x70, 0x18, 0x00},
        {0x70, 0x19, 0x29},
        {0x70, 0x1a, 0x04},
        {0x70, 0x1b, 0x38},
        {0x70, 0x1c, 0x00},
        {0x70, 0x1d, 0x2c},
        {0x70, 0x1e, 0x00},
        {0x70, 0x1f, 0x05},
        {0x70, 0x60, 0x00},
        {0x70, 0x70, 0x00},
        {0x70, 0x71, 0x01},
        {0x70, 0x73, 0x80},
        {0x70, 0x74, 0x20},
        {0x75, 0x00, 0xb0},
        {0x75, 0x84, 0x10},
        {0x75, 0x85, 0x32},
        {0x75, 0x01, 0x00},
        {0x75, 0x02, 0x5c},
        {0x75, 0x0b, 0x4c},
        {0x75, 0x0e, 0x06},
        {0x75, 0x0f, 0x06},
        {0x75, 0x11, 0x88},
        {0x75, 0x22, 0x04},
        {0x75, 0x23, 0xf8},
        {0x75, 0x00, 0xb1},
        {0x70, 0x0f, 0x00}
*/


{0x70,0x0f,0x01},  
{0x70,0x00,0x00},
{0x70,0x02,0x05},
{0x70,0x03,0x03},
{0x70,0x07,0xc2},
{0x70,0x09,0x01},
{0x70,0x0b,0x00},
{0x70,0x10,0x08},
{0x70,0x11,0x5e},
{0x70,0x12,0x00},
{0x70,0x13,0xae},
{0x70,0x14,0x07},
{0x70,0x15,0x80},
{0x70,0x16,0x04},
{0x70,0x17,0x4c},
{0x70,0x18,0x00},
{0x70,0x19,0x11},
{0x70,0x1a,0x04},
{0x70,0x1b,0x38},
{0x70,0x1c,0x80},
{0x70,0x1d,0x20},
{0x70,0x1e,0x80},
{0x70,0x1f,0x06},
{0x70,0x60,0x00},
{0x70,0x70,0x00},
{0x70,0x71,0x01},
{0x70,0x73,0x80},
{0x70,0x74,0x20},
{0x75,0x00,0xb0},
{0x75,0x84,0x10},
{0x75,0x85,0x32},
{0x75,0x01,0x00},
{0x75,0x02,0x5c},
{0x75,0x0b,0x47},
{0x75,0x0e,0x06},
{0x75,0x0f,0x06},
{0x75,0x11,0x88},
{0x75,0x22,0x04},
{0x75,0x23,0xf8},
{0x75,0x00,0xb1},
{0x70,0x0f,0x00}

};
#endif

/******************* Arctan add ********************/

#define ZTL_I2C_DEMO_NAME "ztl_ncs8801"
#define SET_IIC_ADDR 0x30>>1


static const unsigned short normal_i2c[] = {
    SET_IIC_ADDR, I2C_CLIENT_END};

static const struct i2c_device_id i2c_ncs8801_id[] = {
{ZTL_I2C_DEMO_NAME, 0 },
{}
};

static struct of_device_id ztl_ncs8801_ids[] = {
  {.compatible = "ztl,ncs8801"},
  {}   
};


MODULE_DEVICE_TABLE(i2c, i2c_ncs8801_id);


/*
inline static int read_reg(struct i2c_client *client, char *reg,char *buf,int length,int datalen)
{
    //    int ret = 0;
    DEBUG("Arctan : send %d \n",datalen);
    i2c_master_send(client, reg, datalen);  
    msleep(10);
    return i2c_master_recv(client, buf, length); 
}


inline static int write_i2c(struct i2c_client *client,uchar addr,uchar* buf,int length){
    char write_buf[257] ;
    write_buf[0] = addr;
    memcpy(write_buf+1,buf,length);
    return i2c_master_send(client,write_buf,length+1); 
}
*/


static void ztl_edp_gpio_init(struct i2c_client *client){

    
    //struct device *dev = client->dev;
    struct device_node *np = client ->dev.of_node;

    int gpio_rstb = of_get_named_gpio(np,"edp_gpio_rstb",0);
    int gpio_pwd  = of_get_named_gpio(np,"edp_gpio_pwd",0);

    printk("ztl gpio rstb %d,gpio pwd %d \n",gpio_rstb,gpio_pwd);
    if(!gpio_is_valid(gpio_rstb)||!gpio_is_valid(gpio_pwd)){

        printk("ztl get gpio is not valid\n");
    }

    gpio_direction_output(gpio_pwd,0);

    usleep_range(1000,2000);
    
    gpio_direction_output(gpio_rstb,1);
    
}

static int i2c_ncs8801_probe(struct i2c_client *new_client,
                const struct i2c_device_id *id){
    int i = 0;
    char sendBuf[10] = {0};
    int sendLength = 0;
    int i2c_addr = new_client->addr;
    int ArrayLength = sizeof(NcsArray);
    int StructSize = sizeof(struct NCS8801);    
    
    printk("ztl ---i2c_addr %d \n",i2c_addr);
    printk(    "ztl ---i2c_ncs8801_probe %d,%d,%d\n",ArrayLength,StructSize,ArrayLength/StructSize);
//


    ztl_edp_gpio_init(new_client);

    for(i=0;i         
        new_client->addr = NcsArray[i].i2c_address;
        
        sendBuf[0] = NcsArray[i].cmd;
        sendBuf[1] = NcsArray[i].data;
        sendLength = 2;
        if(2!=i2c_master_send(new_client,sendBuf,sendLength)){
            DEBUG("ztl send I2c faild %d\n",i);
        }
    }

    return 0;
}

static int i2c_ncs8801_remove(struct i2c_client *client)
{
    DEBUG(    " i2c_ncs8801_remove\n");

    return 0;
}


static struct i2c_driver i2c_ncs8801_driver = {

    .driver = {
        .name    = ZTL_I2C_DEMO_NAME,
        .owner = THIS_MODULE, 
        .of_match_table = of_match_ptr(ztl_ncs8801_ids), 
    },
    .probe        = i2c_ncs8801_probe,
    .remove     = i2c_ncs8801_remove,
    .id_table    =i2c_ncs8801_id,

};


static int __init ztl_NCS8801_init(void){

    DEBUG("ztl ztl_NCS8801_init2\n");
    return i2c_add_driver(&i2c_ncs8801_driver);
    
}
static void __exit ztl_NCS8801_exit(void){
    i2c_del_driver(&i2c_ncs8801_driver);

}

module_init(ztl_NCS8801_init);
module_exit(ztl_NCS8801_exit);
/******************* end Arctan add ****************/

 

 

你可能感兴趣的:(rk3288,android,7.1)