RK3288 Android5.1 多MIPI屏的兼容

思路:

1.在dts里配置两套mipi的初始化指令和mipi的hs_clock (假如只有两屏兼容)

2.在uboot阶段读取mipi屏IC的寄存器值mipi.id,根据寄存器值来区分读取都的是那块屏,并加载对应的屏幕数据,最后将该寄存器值mipi.id写入到cmdline里

3.在kernel阶段,去获取cmdline里的mipi.id,根据该值去加载对应的屏参

完整补丁:https://download.csdn.net/download/Mrdeath/12593823

源码分析:

1.dts:

dts代码加了两组hs_clk,和disp_mipi_init_cmds,并要打开uboot logo

rockchip,il9881c,dsi_hs_clk     = <1000>; //il9881c
rockchip,jd9365,dsi_hs_clk     = <434>; //jd9365

disp_mipi_init_cmds1: il9881c-screen-on-cmds {
disp_mipi_init_cmds2: jd9365-screen-on-cmds {
 &fb {
    rockchip,disp-mode = ;
-   rockchip,uboot-logo-on = <0>;
+   rockchip,uboot-logo-on = <1>;
    rockchip,disp-policy = ;
 };

 

2.uboot

  1)定义一个rk32_mipi_read_id函数,去读取MIPI寄存器的值,注意读取前需要先写入开屏指令:dcs_set_display_on,读取完后写入关屏指令:dcs_set_display_off

  2)读取完后,将寄存器值接入到cmdline里

 

  3)修改of_property_read_u32(childnode, "rockchip,dsi_hs_clk", &value)函数为:(名字要与dts里相匹配)

            of_property_read_u32(childnode, "rockchip,jd9365,dsi_hs_clk", &value);

            of_property_read_u32(childnode, "rockchip,il9881c,dsi_hs_clk", &value);

            用于区分不同屏的hs_clk加载

  4) 添加COMPAT_ROCKCHIP_MIPI_INIT,为:(名字要与dts里相匹配)

         COMPAT_ROCKCHIP_IL9881C_MIPI_SONCMDS   ,COMPAT(ROCKCHIP_IL9881C_MIPI_SONCMDS, "rockchip,il9881c-screen-on-cmds"),

         COMPAT_ROCKCHIP_JD9365_MIPI_SONCMDS    , COMPAT(ROCKCHIP_JD9365_MIPI_SONCMDS, "rockchip,jd9365-screen-on-cmds"),

         用于区分不同的screen-on-cmds的加载

diff --git a/u-boot/common/cmd_bootrk.c b/u-boot/common/cmd_bootrk.c
old mode 100755
new mode 100644
index 87b1a85066..b3e6eb8125
--- a/u-boot/common/cmd_bootrk.c
+++ b/u-boot/common/cmd_bootrk.c
@@ -19,6 +19,10 @@ DECLARE_GLOBAL_DATA_PTR;
 extern int g_logo_on_state;
 #endif
  
+#ifdef CONFIG_RK32_DSI
+extern int g_mipi_id;
+#endif
+
 #if defined(CONFIG_RK_HDMI)
 extern int g_hdmi_vic;
 #endif
@@ -457,6 +461,7 @@ static void rk_commandline_setenv(const char *boot_name, rk_boot_img_hdr *hdr, b
    if (g_logo_on_state != 0) {
        snprintf(command_line, sizeof(command_line),
                "%s uboot_logo=0x%08x@0x%08lx", command_line, CONFIG_RK_LCD_SIZE, gd->fb_base);
+
 #if defined(CONFIG_KERNEL_LOGO)
        if (g_rk_fb_size != -1)
            snprintf(command_line, sizeof(command_line),
@@ -465,6 +470,10 @@ static void rk_commandline_setenv(const char *boot_name, rk_boot_img_hdr *hdr, b
    }
 #endif /* CONFIG_RK_FB_DDREND */
  
+   snprintf(command_line, sizeof(command_line),
+                        "%s mipi.id=%d", command_line, g_mipi_id);
+
+
    snprintf(command_line, sizeof(command_line),
            "%s loader.timestamp=%s", command_line, U_BOOT_TIMESTAMP);

diff --git a/u-boot/drivers/video/screen/lcd_mipi.c b/u-boot/drivers/video/screen/lcd_mipi.c
old mode 100755
new mode 100644
index b9e513cd81..3593694d3a
--- a/u-boot/drivers/video/screen/lcd_mipi.c
+++ b/u-boot/drivers/video/screen/lcd_mipi.c
@@ -34,6 +34,7 @@
 #else
 #define    MIPI_SCREEN_DBG(x...) 
 #endif
+
 #ifdef CONFIG_RK32_DSI
 DECLARE_GLOBAL_DATA_PTR;
 #define msleep(a) udelay(a * 1000)
@@ -41,6 +42,7 @@ DECLARE_GLOBAL_DATA_PTR;
 #endif
 static struct mipi_screen *gmipi_screen;
  
+int g_mipi_id = -2;
 static void rk_mipi_screen_pwr_disable(struct mipi_screen *screen)
 {  
    if(screen->lcd_en_gpio != INVALID_GPIO){
@@ -171,6 +173,20 @@ static void rk_mipi_screen_cmd_init(struct mipi_screen *screen)
  
 }
  
+int rockchip_dsi_read_panel_id(int num,int count)
+{
+   int id;
+   unsigned char buf[2] = {0};
+
+   buf[0] = 0xdb;
+   dsi_read_dcs_packet(0, buf, count);
+
+   printf("LOUHN: in rockchip_dsi_read_panel_id--%s:%d, buf[0]=0x%x,buf[1]=0x%x\n", __func__, __LINE__, buf[0],buf[1]);
+  id = ( buf[0] << 8) + buf[1];
+   return id;
+}
+
+
 int rk_mipi_screen(void)
 {
    u8 dcs[16] = {0}, rk_dsi_num;
@@ -255,6 +271,52 @@ int rk_mipi_screen(void)
    return 0;
 }
  
+int read_panel_id(){
+
+   u8 dcs[16] = {0}, rk_dsi_num;
+   rk_dsi_num = gmipi_screen->mipi_dsi_num;
+   //rk_mipi_screen_pwr_enable(gmipi_screen);
+   printf("LOUHN in read_panel_id()\n");      
+   dsi_enable_hs_clk(0,1);
+   dsi_enable_video_mode(0,0);
+   dsi_enable_command_mode(0, 1);
+
+   dcs[0] = LPDT;
+   dcs[1] = DTYPE_DCS_SWRITE_0P;
+   dcs[2] = dcs_exit_sleep_mode;
+  dsi_send_packet(0, dcs, 3);
+   if(rk_dsi_num ==2)  
+       dsi_send_packet(1, dcs, 3);
+  
+   msleep(20);
+   dcs[0] = LPDT;
+   dcs[1] = DTYPE_DCS_SWRITE_0P;
+   dcs[2] = dcs_set_display_on;
+   dsi_send_packet(0, dcs, 3);
+   if(rk_dsi_num ==2)
+        dsi_send_packet(1, dcs, 3);
+
+   msleep(100);
+  
+   g_mipi_id = rockchip_dsi_read_panel_id(1,2);
+   dcs[0] = LPDT;
+   dcs[1] = DTYPE_DCS_SWRITE_0P;
+   dcs[2] = dcs_set_display_off;
+  dsi_send_packet(0, dcs, 3);
+   if(rk_dsi_num ==2)  
+       dsi_send_packet(1, dcs, 3);
+  
+   msleep(20);
+   dcs[0] = LPDT;
+   dcs[1] = DTYPE_DCS_SWRITE_0P;
+   dcs[2] = dcs_enter_sleep_mode;
+   dsi_send_packet(0, dcs, 3);
+   if(rk_dsi_num ==2)
+        dsi_send_packet(1, dcs, 3);
+
+   msleep(20);
+   return g_mipi_id;
+}
 int rk_mipi_screen_standby(u8 enable)
 {
    u8 dcs[16] = {0}, rk_dsi_num;
@@ -307,7 +369,7 @@ static int rk_mipi_screen_init_dt(struct mipi_screen *screen)
    memset(screen, 0, sizeof(*screen));
     
    INIT_LIST_HEAD(&screen->cmdlist_head);
-
+   printf("LOUHN --> in rk_mipi_screen_init_dt\n");
    childnode = of_find_node_by_name(NULL, "mipi_dsi_init");
    if(!childnode ){
        MIPI_SCREEN_DBG("%s: Can not get child => mipi_init.\n", __func__);
@@ -334,8 +396,23 @@ static int rk_mipi_screen_init_dt(struct mipi_screen *screen)
            screen->dsi_lane = value;
            MIPI_SCREEN_DBG("%s: mipi_lcd->dsi_lane = %d.\n", __func__, screen->dsi_lane );
        }
-  
-       ret = of_property_read_u32(childnode, "rockchip,dsi_hs_clk", &value);
+      
+       if(g_mipi_id == 25957)//0x65
+       {
+           ret = of_property_read_u32(childnode, "rockchip,jd9365,dsi_hs_clk", &value);
+           printk("LOUHN: read1 jd9365 mipi ic,value=%d ?\n",value);
+       }
+       else if(g_mipi_id == 0)//0x00
+       {
+           ret = of_property_read_u32(childnode, "rockchip,il9881c,dsi_hs_clk", &value);
+           printf("LOUHN: read il9881c mipi ic,value=%d ?\n ",value);
+       }
+       else
+       {
+           ret = of_property_read_u32(childnode, "rockchip,dsi_hs_clk", &value);
+           printf("LOUHN:Read mipi reg err,is a new mipi screen ?\n ");
+       }      
+
        if (ret) {
            MIPI_SCREEN_DBG("%s: Can not read property: dsi_hs_clk.\n", __func__);
        } else {
@@ -434,8 +511,23 @@ static int rk_mipi_screen_init_dt(struct mipi_screen *screen)
            MIPI_SCREEN_DBG("dsi->lcd_en_gpio=%d, dsi->screen.lcd_en_atv_val=%d\n",screen->lcd_en_gpio,screen->lcd_en_atv_val);
        }
    }
+  
  
-   root= of_find_node_by_name(NULL,"screen-on-cmds");
+   if(g_mipi_id == 25957)//0x65
+   {
+       root = of_find_node_by_name(NULL, "jd9365-screen-on-cmds");
+       printf("LOUHN: read jd9365 mipi ic\n");
+   }
+   else if(g_mipi_id == 0)//0x00
+   {
+       root = of_find_node_by_name(NULL, "il9881c-screen-on-cmds");
+       printf("LOUHN: read il9881c mipi ic\n");
+   }
+   else
+   {
+       root = of_find_node_by_name(NULL, "screen-on-cmds");
+       printf("LOUHN: in read screen-on-cmds, is a new mipi screen ?\n ");
+   }
    if (!root) {
        MIPI_SCREEN_DBG("can't find screen-on-cmds node\n");
    }
@@ -563,7 +655,8 @@ static int rk_mipi_screen_init_dt(struct mipi_screen *screen)
    u32 i,cmds[20];
    int length;
    int err;
-   int node;
+   int id;
+   int node,subnode,rootnode;
    const void *blob;
    struct fdt_gpio_state gpio_val;
    int noffset;
@@ -574,8 +667,26 @@ static int rk_mipi_screen_init_dt(struct mipi_screen *screen)
  
    blob = gd->fdt_blob;//getenv_hex("fdtaddr", 0);
    node = fdtdec_next_compatible(blob, 0, COMPAT_ROCKCHIP_MIPI_INIT);
+   /*
+   rootnode = fdt_path_offset(blob, "/disp_mipi");
+   if (node < 0) {
+       MIPI_SCREEN_DBG("Can not get node of disp_mipi\n");
+   }
+   fdt_for_each_subnode(blob,subnode,rootnode){
+           node = fdtdec_next_compatible(blob, subnode, COMPAT_ROCKCHIP_MIPI_INIT);   
+   */
    if (node < 0) {
        MIPI_SCREEN_DBG("Can not get node of COMPAT_ROCKCHIP_MIPI_INIT\n");
+/*    
+           }
+           id = fdtdec_get_int(blob, node, "rockchip,mipi_id", -1);
+           if (id < 0) {
+               MIPI_SCREEN_DBG("Can not get screen id\n");
+           }
+           printf("read mipi para id = %d,lcd_id=%d\n",id,screen->lcd_id);
+           if(id != screen->lcd_id){
+               continue;
+*/
    }
    screen->screen_init = fdtdec_get_int(blob, node, "rockchip,screen_init", -1);
    if (screen->screen_init < 0) {
@@ -585,7 +696,22 @@ static int rk_mipi_screen_init_dt(struct mipi_screen *screen)
    if (screen->dsi_lane < 0) {
        MIPI_SCREEN_DBG("Can not get dsi_lane\n");
    }
-   screen->hs_tx_clk= fdtdec_get_int(blob, node, "rockchip,dsi_hs_clk", -1);
+
+   if(g_mipi_id == 25957)//0x65
+   {
+       screen->hs_tx_clk= fdtdec_get_int(blob, node, "rockchip,jd9365,dsi_hs_clk", -1);
+       printf("LOUHN: read jd9365 mipi ic,value=%d ?\n ",screen->hs_tx_clk);
+   }
+   else if(g_mipi_id == 0)//0x00
+   {
+       screen->hs_tx_clk= fdtdec_get_int(blob, node, "rockchip,il9881c,dsi_hs_clk", -1);
+       printf("LOUHN: read il9881c mipi ic,value=%d ?\n ",screen->hs_tx_clk);
+   }
+   else
+   {
+       screen->hs_tx_clk= fdtdec_get_int(blob, node, "rockchip,dsi_hs_clk", -1);
+       printf("LOUHN:Read mipi reg err,is a new mipi screen ?\n ");
+   }
    if (screen->hs_tx_clk < 0) {
        MIPI_SCREEN_DBG("Can not get dsi_hs_clk\n");
    } else {
@@ -598,6 +724,7 @@ static int rk_mipi_screen_init_dt(struct mipi_screen *screen)
  
    /* get the lcd rst & en status */
    node = fdtdec_next_compatible(blob, 0, COMPAT_ROCKCHIP_MIPI_PWR);
+//         node = fdtdec_next_compatible(blob, subnode, COMPAT_ROCKCHIP_MIPI_PWR);
    if (node < 0) {
        MIPI_SCREEN_DBG("Can not get node of COMPAT_ROCKCHIP_MIPI_PWR\n");
    } else {
@@ -637,10 +764,27 @@ static int rk_mipi_screen_init_dt(struct mipi_screen *screen)
        }
    }
    /*get the initial command list*/
-   node = fdtdec_next_compatible(blob, 0, COMPAT_ROCKCHIP_MIPI_SONCMDS);
+   if(g_mipi_id == 25957)//0x65
+        {
+       node = fdtdec_next_compatible(blob, 0, COMPAT_ROCKCHIP_JD9365_MIPI_SONCMDS);
+                printf("LOUHN: read jd9365 mipi cmds\n");
+        }
+        else if(g_mipi_id == 0)//0x00
+        {
+                node = fdtdec_next_compatible(blob, 0, COMPAT_ROCKCHIP_IL9881C_MIPI_SONCMDS);
+       printf("LOUHN: read il9881c mipi cmds\n");
+        }
+        else
+        {
+                node = fdtdec_next_compatible(blob, 0, COMPAT_ROCKCHIP_MIPI_SONCMDS);
+       printf("LOUHN: in read screen-on-cmds, is a new mipi screen ?\n ");
+        }
+
    if (node < 0) {
+       printf("LOUHN :read COMPAT_ROCKCHIP_MIPI_SONCMDS err\n");
        MIPI_SCREEN_DBG("Can not get node of COMPAT_ROCKCHIP_MIPI_SONCMDS\n");
    } else {
+       printf("LOUHN :read COMPAT_ROCKCHIP_MIPI_SONCMDS ok\n");
        for (noffset = fdt_first_subnode(blob,node);
        noffset >= 0;
        noffset = fdt_next_subnode(blob, noffset)) {
@@ -676,7 +820,7 @@ static int rk_mipi_screen_init_dt(struct mipi_screen *screen)
 }
 #endif /* CONFIG_OF_LIBFDT */
  
-int rk_mipi_screen_probe(void)
+int rk_mipi_screen_probe(int id)
 {
     int ret = 0;
     gmipi_screen = calloc(1, sizeof(struct mipi_screen));
@@ -684,6 +828,7 @@ int rk_mipi_screen_probe(void)
        printf("request struct screen fail!\n");
        return -ENOMEM;
    }
+    gmipi_screen->lcd_id = id;
 #ifdef CONFIG_OF_LIBFDT
    ret = rk_mipi_screen_init_dt(gmipi_screen);
    if(ret < 0){
diff --git a/u-boot/drivers/video/transmitter/mipi_dsi.h b/u-boot/drivers/video/transmitter/mipi_dsi.h
old mode 100755
new mode 100644
index f4d77a0db8..b5a7558d6b
--- a/u-boot/drivers/video/transmitter/mipi_dsi.h
+++ b/u-boot/drivers/video/transmitter/mipi_dsi.h
@@ -34,6 +34,9 @@
 #define DTYPE_GEN_SWRITE_1P        0x13
 #define DTYPE_GEN_SWRITE_0P        0x03
  
+#define DTYPE_DCS_READ_OP      0x06
+#define DTYPE_GEN_READ_OP      0x04
+#define SET_MAX_RETURN_SIZE        0x37
 //command transmit mode
 #define HSDT           0x00
 #define LPDT           0x01
@@ -283,6 +286,7 @@ struct mipi_screen
     u32 lcd_en_delay;
     u32 lcd_rst_gpio;
     u32 lcd_rst_delay;
+    u32 lcd_id;
  
     struct list_head cmdlist_head;
 };
diff --git a/u-boot/drivers/video/transmitter/rk32_mipi_dsi.c b/u-boot/drivers/video/transmitter/rk32_mipi_dsi.c
old mode 100755
new mode 100644
index 375dfdb87f..2a5c0ff521
--- a/u-boot/drivers/video/transmitter/rk32_mipi_dsi.c
+++ b/u-boot/drivers/video/transmitter/rk32_mipi_dsi.c
@@ -76,7 +76,7 @@ static int rk32_mipi_dsi_is_enable(void *arg, u32 enable);
 int rk_mipi_screen_standby(u8 enable);
  
 DECLARE_GLOBAL_DATA_PTR;
-extern int rk_mipi_screen_probe(void);
+extern int rk_mipi_screen_probe(int);
  
 static void inline writel_relaxed(uint32 val, uint32 addr)
 {
@@ -347,7 +347,6 @@ static int rk312x_phy_power_up(struct dsi *dsi)
    udelay(10);
  
    rk32_dsi_set_bits(dsi, 0xe4, DPHY_REGISTER1);
-   printf("lane = %d\n", dsi->host.lane);
  
    switch (dsi->host.lane) {
    case 4:
@@ -1301,6 +1300,7 @@ static int rk32_mipi_dsi_send_packet(void *arg, unsigned char cmds[], u32 length
    return 0;
 }
  
+#if 0
 static int rk32_mipi_dsi_read_dcs_packet(void *arg, unsigned char *data1, u32 n)
 {
    struct dsi *dsi = arg;
@@ -1343,6 +1343,60 @@ static int rk32_mipi_dsi_read_dcs_packet(void *arg, unsigned char *data1, u32 n)
    msleep(100);
    return 0;
 }
+#else
+static int rk32_mipi_dsi_read_dcs_packet(void *arg, u8 *buf, u32 size)
+{
+   int i;
+   u32 data;
+   u32 reg_val = 0;
+   u32 gen_empty = 0;
+   u32 rd_busy = 0;
+   u8 rd_reg;
+   struct dsi *dsi = arg;
+
+   if ((buf == NULL) || (size == 0))
+       return -1;
+
+   if (rk32_dsi_get_bits(dsi, gen_cmd_full) == 1) {
+       MIPI_DBG("%s: gen_cmd_full\n", __func__);
+       return -1;
+   }
+   /* set bit on max read packet size*/   
+   rk32_dsi_set_bits(dsi, LPDT, max_rd_pkt_size);     
+   //max read packet size is set 3 btye,customer can modify this value,the max value known is 4*/
+   data = (size << 8 )|SET_MAX_RETURN_SIZE; 
+   rk32_dsi_set_bits(dsi, data, GEN_HDR);     
+   udelay(20);
+
+   /* send read command */
+   rk32_dsi_set_bits(dsi, LPDT, dcs_sr_0p_tx);
+
+   /* set back turn-around */
+   rk32_dsi_set_bits(dsi, 1, bta_en);
+
+   rd_reg = buf[0];
+   data = (rd_reg << 8) | DTYPE_DCS_READ_OP;
+   rk32_dsi_set_bits(dsi, data, GEN_HDR);
+
+   udelay(20);
+
+   /* wait command fifo empty and read command fifo is not busy */
+   i = 10;
+   gen_empty = rk32_dsi_get_bits(dsi, gen_cmd_empty);
+   rd_busy = rk32_dsi_get_bits(dsi, gen_rd_cmd_busy);
+   while (!gen_empty && rd_busy && i--) {
+       printf("*");
+       udelay(10);
+   }
+
+   /* get read data from GEN_PLD_DATA */
+   reg_val = rk32_dsi_get_bits(dsi, GEN_PLD_DATA);
+   buf[0] = reg_val & 0xff;
+   buf[1] = (reg_val >> 8) & 0xff;
+
+   return 0;
+}
+#endif
  
 static int rk32_mipi_dsi_power_up(void *arg)
 {
@@ -1874,6 +1928,94 @@ int rk_dsi_host_parse_dt(const void *blob, struct dsi *dsi)
 }
 #endif /* #ifdef CONFIG_OF_LIBFDT */
  
+int rk32_mipi_read_id(vidinfo_t *vid){
+
+   int ret = 0;
+   struct dsi *dsi;
+   struct mipi_dsi_ops *ops;
+   struct rk_screen *screen;
+   struct mipi_dsi_screen *dsi_screen;
+   int id = 0;
+   int i = 3,result = 0;
+   printf("LOUHN in rk32_mipi_read_id \n");   
+   dsi = calloc(1, sizeof(struct dsi));
+   if(!dsi) {
+         MIPI_DBG("request struct dsi.%d fail!\n",id);
+         return -ENOMEM;
+   }
+
+   dsi->dsi_id = id++;
+#ifdef CONFIG_OF_LIBFDT
+   rk_dsi_host_parse_dt(gd->fdt_blob,dsi);
+#endif /* #ifdef CONFIG_OF_LIBFDT */
+   screen = calloc(1, sizeof(struct rk_screen));
+   if(!screen) {
+     MIPI_DBG("request struct rk_screen fail!\n");
+   }
+  
+   ops = &dsi->ops;
+   ops->dsi = dsi;
+   if (cpu_is_rk3288())
+       ops->id = DWC_DSI_VERSION;
+   else if (cpu_is_rk312x())
+       ops->id = DWC_DSI_VERSION_RK312x;
+   else if (cpu_is_rk3368())
+       ops->id = DWC_DSI_VERSION_RK3368;
+   else
+       ops->id = DWC_DSI_VERSION_ERR;
+
+   ops->get_id = rk32_mipi_dsi_get_id,
+   ops->dsi_send_packet = rk32_mipi_dsi_send_packet;
+   ops->dsi_read_dcs_packet = rk32_mipi_dsi_read_dcs_packet,
+   ops->dsi_enable_video_mode = rk32_mipi_dsi_enable_video_mode,
+   ops->dsi_enable_command_mode = rk32_mipi_dsi_enable_command_mode,
+   ops->dsi_enable_hs_clk = rk32_mipi_dsi_enable_hs_clk,
+   ops->dsi_is_active = rk32_mipi_dsi_is_active,
+   ops->dsi_is_enable= rk32_mipi_dsi_is_enable,
+   ops->power_up = rk32_mipi_dsi_power_up,
+   ops->power_down = rk32_mipi_dsi_power_down,
+   ops->dsi_init = rk_mipi_dsi_init,
+
+   dsi_screen = &dsi->screen;
+   dsi_screen->type = screen->type = vid->screen_type;
+   dsi_screen->face = screen->face = vid->lcd_face;
+   dsi_screen->pixclock = screen->mode.pixclock = vid->vl_freq;
+   dsi_screen->left_margin = screen->mode.left_margin = vid->vl_hbpd;
+   dsi_screen->right_margin = screen->mode.right_margin = vid->vl_hfpd;
+   dsi_screen->hsync_len = screen->mode.hsync_len = vid->vl_hspw;
+   dsi_screen->upper_margin = screen->mode.upper_margin = vid->vl_vbpd;
+   dsi_screen->lower_margin = screen->mode.lower_margin = vid->vl_vfpd;
+   dsi_screen->vsync_len = screen->mode.vsync_len = vid->vl_vspw;
+   dsi_screen->x_res = screen->mode.xres = vid->vl_width;
+   dsi_screen->y_res = screen->mode.yres = vid->vl_height;
+   dsi_screen->pin_hsync = screen->pin_hsync = vid->vl_hsp;
+   dsi_screen->pin_vsync = screen->pin_vsync = vid->vl_vsp;
+   dsi_screen->pin_den = screen->pin_den = vid->vl_oep;
+   dsi_screen->lcdc_id = 1;
+   dsi_screen->dsi_lane = 4;
+   dsi_screen->hs_tx_clk = 550000000;
+   dsi->dsi_id = 0;
+   sprintf(ops->name, "rk_mipi_dsi.%d", dsi->dsi_id);
+   ret = rk_mipi_dsi_probe(dsi);
+   if(ret) {
+     MIPI_DBG("rk mipi_dsi probe fail!\n");
+     MIPI_DBG("%s\n", RK_MIPI_DSI_VERSION_AND_TIME);
+   }  
+  
+   if(id == 1){
+       rk_init_phy_mode(vid->lcdc_id);
+       dsi0 = dsi;
+   }else{  
+     dsi1 = dsi;
+   }
+      
+   rk_mipi_dsi_init(dsi,0);
+   //while((i-- > 0) && (result == 0))
+      result = read_panel_id();
+   
+  return result; 
+}
+
 int rk32_mipi_enable(vidinfo_t *vid)
 {
    int ret = 0;
@@ -1883,8 +2025,7 @@ int rk32_mipi_enable(vidinfo_t *vid)
    struct mipi_dsi_screen *dsi_screen;
    static int id = 0;
    u8 dsi_number = 0;
-  
-   rk_mipi_screen_probe();
+   rk_mipi_screen_probe(vid->lcd_id);
  
    dsi_number = rk_mipi_get_dsi_num();
    MIPI_DBG("dsi number is %d\n", dsi_number);
diff --git a/u-boot/include/fdtdec.h b/u-boot/include/fdtdec.h
index 45e3e63809..b126bf9c71 100755
--- a/u-boot/include/fdtdec.h
+++ b/u-boot/include/fdtdec.h
@@ -114,7 +114,9 @@ enum fdt_compat_id {
    COMPAT_ROCKCHIP_DSIHOST,    /*RockChip DSI host Controller*/
    COMPAT_ROCKCHIP_MIPI_INIT,  /*RockChip MIPI init*/
    COMPAT_ROCKCHIP_MIPI_PWR,   /*RockChip MIPI pwr*/
-   COMPAT_ROCKCHIP_MIPI_SONCMDS,   /*RockChip MIPI screen on cmds*/
+   COMPAT_ROCKCHIP_MIPI_SONCMDS,   /*RockChip MIPI screen on cmds*/
+   COMPAT_ROCKCHIP_IL9881C_MIPI_SONCMDS,   /*RockChip MIPI screen on cmds*/
+   COMPAT_ROCKCHIP_JD9365_MIPI_SONCMDS,   /*RockChip MIPI screen on cmds*/
    COMPAT_ROCKCHIP_MIPI_ONCMDS,    /*RockChip MIPI screen on cmd*/
    COMPAT_ROCKCHIP_MIPI_LCD_DT,    /*RockChip MIPI screen display timing */
    COMPAT_ROCKCHIP_MIPI_LCD_RST,   /*RockChip MIPI screen rst pin */
diff --git a/u-boot/include/lcd.h b/u-boot/include/lcd.h
old mode 100755
new mode 100644
index 32e6b73ab3..172884129f
--- a/u-boot/include/lcd.h
+++ b/u-boot/include/lcd.h
@@ -340,7 +340,7 @@ typedef struct vidinfo {
    unsigned int sclk_div;
  
    unsigned int dual_lcd_enabled;
-      
+   int lcd_id;
  
        u_char screen_type;
        u_char lvds_ch_nr;
diff --git a/u-boot/lib/fdtdec.c b/u-boot/lib/fdtdec.c
index 4ed39232d4..f04a27d675 100755
--- a/u-boot/lib/fdtdec.c
+++ b/u-boot/lib/fdtdec.c
@@ -74,6 +74,8 @@ static const char * const compat_names[COMPAT_COUNT] = {
    COMPAT(ROCKCHIP_MIPI_INIT, "rockchip,mipi_dsi_init"),
    COMPAT(ROCKCHIP_MIPI_PWR, "rockchip,mipi_power_ctr"),
    COMPAT(ROCKCHIP_MIPI_SONCMDS, "rockchip,screen-on-cmds"),
+   COMPAT(ROCKCHIP_IL9881C_MIPI_SONCMDS, "rockchip,il9881c-screen-on-cmds"),
+   COMPAT(ROCKCHIP_JD9365_MIPI_SONCMDS, "rockchip,jd9365-screen-on-cmds"),
    COMPAT(ROCKCHIP_MIPI_ONCMDS, "rockchip,on-cmds"),
    COMPAT(ROCKCHIP_MIPI_LCD_DT, "rockchip,display-timings"),
    COMPAT(ROCKCHIP_MIPI_LCD_RST, "rockchip,lcd_rst"),

3.kernel

1)读取cmdline里保存的寄存器值

2)修改of_property_read_u32(childnode, "rockchip,dsi_hs_clk", &value)函数为:(名字要与dts里相匹配)

            of_property_read_u32(childnode, "rockchip,jd9365,dsi_hs_clk", &value);

            of_property_read_u32(childnode, "rockchip,il9881c,dsi_hs_clk", &value);

            用于区分不同屏的hs_clk加载

3)修改of_find_node_by_name(NULL, "screen-on-cmds");函数为:(名字要与dts里相匹配)

           of_find_node_by_name(NULL, "jd9365-screen-on-cmds");

           of_find_node_by_name(NULL, "il9881c-screen-on-cmds");

             用于区分不同屏的screen-on-cmds加载

@@ -323,8 +353,22 @@ static int rk_mipi_screen_init_dt(struct device *dev,
            screen->dsi_lane = value;
            MIPI_SCREEN_DBG("%s: mipi_lcd->dsi_lane = %d.\n", __func__, screen->dsi_lane);
        }
-
-       ret = of_property_read_u32(childnode, "rockchip,dsi_hs_clk", &value);
+          
+       if(mipi_id_int == 25957)//0x65
+       {
+           ret = of_property_read_u32(childnode, "rockchip,jd9365,dsi_hs_clk", &value);
+            printk("LOUHN: read jd9365 mipi ic,value=%d ?\n ",value);
+       }
+       else if(mipi_id_int == 0)//0x00
+       {
+           ret = of_property_read_u32(childnode, "rockchip,il9881c,dsi_hs_clk", &value);
+           printk("LOUHN: read il9881c mipi ic,value=%d ?\n ",value);
+       }
+       else
+       {
+           ret = of_property_read_u32(childnode, "rockchip,dsi_hs_clk", &value);
+           printk("LOUHN:Read mipi reg err,is a new mipi screen ?\n ");
+       }  
        if (ret) {
            MIPI_SCREEN_DBG("%s: Can not read property: dsi_hs_clk.\n", __func__);
        } else {
@@ -419,8 +463,22 @@ static int rk_mipi_screen_init_dt(struct device *dev,
            MIPI_SCREEN_DBG("dsi->lcd_en_gpio=%d, dsi->screen.lcd_en_atv_val=%d\n", screen->lcd_en_gpio, screen->lcd_en_atv_val);
        }
    }
+   if(mipi_id_int == 25957)//0x65
+   {
+       root = of_find_node_by_name(NULL, "jd9365-screen-on-cmds");
+       printk("LOUHN: read jd9365 mipi ic\n");
+   }
+   else if(mipi_id_int == 0)//0x00
+   {
+       root = of_find_node_by_name(NULL, "il9881c-screen-on-cmds");
+       printk("LOUHN: read il9881c mipi ic\n");
+   }
+   else
+   {
+           root = of_find_node_by_name(NULL, "screen-on-cmds");
+       printk("LOUHN: in read screen-on-cmds, is a new mipi screen ?\n ");
+   }
  
-   root = of_find_node_by_name(NULL, "screen-on-cmds");
    if (!root) {
        MIPI_SCREEN_DBG("can't find screen-on-cmds node\n");
    } else {
@@ -567,7 +625,22 @@ static int rk_mipi_screen_init_dt(struct mipi_screen *screen)
    if (screen->dsi_lane < 0) {
        MIPI_SCREEN_DBG("Can not get dsi_lane\n");
    }
-   screen->hs_tx_clk = fdtdec_get_int(blob, node, "rockchip,dsi_hs_clk", -1);
+   if(mipi_id_int == 25957)//0x65
+        {
+       screen->hs_tx_clk = fdtdec_get_int(blob, node, "rockchip,jd9365,dsi_hs_clk", -1);
+           printk("LOUHN:Read jd9365,dsi_hs_clk\n "); 
+   }
+        else if(mipi_id_int == 0)//0x00
+        {
+       screen->hs_tx_clk = fdtdec_get_int(blob, node, "rockchip,il9881c,dsi_hs_clk", -1);
+                printk("LOUHN:Read il9881c,dsi_hs_clk\n ");  
+        }
+        else
+        {
+           screen->hs_tx_clk = fdtdec_get_int(blob, node, "rockchip,dsi_hs_clk", -1);
+       printk("LOUHN:Read mipi reg err,is a new mipi screen ?\n ");
+        }
+
    if (screen->hs_tx_clk < 0) {
        MIPI_SCREEN_DBG("Can not get dsi_hs_clk\n");
    } else {
@@ -717,6 +790,7 @@ int rk_mipi_screen_probe(void)
 {
    int ret = 0;
    gmipi_screen = calloc(1, sizeof(struct mipi_screen));
+
    if (!gmipi_screen) {
        printf("request struct screen fail!\n");
        return -ENOMEM;
@@ -738,7 +812,11 @@ int rk_mipi_screen_probe(void)
 static int __init rk_mipi_screen_probe(struct platform_device *pdev)
 {
    static int ret;
-
+  
+   get_cmdline_str(saved_command_line,"mipi.id=",mipi_id_string);  //获取mipi.id值,保存到mipi_id_string
+   kstrtoint(mipi_id_string, 0, &mipi_id_int);
+   printk("LOUHN in rk_mipi_screen_probe,mipi.id=%d\n",mipi_id_int);
+   printk("LOUHN:cmdline=%s\n",saved_command_line);   
    gmipi_screen = devm_kzalloc(&pdev->dev, sizeof(struct mipi_screen), GFP_KERNEL);
    if (!gmipi_screen) {
        dev_err(&pdev->dev, "request struct screen fail!\n");

 

你可能感兴趣的:(RK3288_Android)