u200: dts: modify panel P070ACB reset sequence
authorEvoke Zhang <evoke.zhang@amlogic.com>
Wed, 28 Mar 2018 05:49:35 +0000 (13:49 +0800)
committerYixun Lan <yixun.lan@amlogic.com>
Fri, 13 Apr 2018 10:30:34 +0000 (02:30 -0800)
PD#163160: u200: dts: modify panel P070ACB reset sequence
also optimize place check state function into dsi_on_init sequence.

Change-Id: I22cbb057b278bd44efb2e7b141f6426c03c1945f
Signed-off-by: Evoke Zhang <evoke.zhang@amlogic.com>
arch/arm64/boot/dts/amlogic/mesong12a_skt-panel.dtsi
drivers/amlogic/media/vout/lcd/lcd_tablet/lcd_tablet.c
drivers/amlogic/media/vout/lcd/lcd_tablet/mipi_dsi_util.c

index ecad668..81787b8 100644 (file)
                                0 /*clk_ss_level*/
                                1 /*clk_auto_generate*/
                                44250000>; /*pixel_clk(unit in Hz)*/
-                       check_state = <0x04 /* check_reg */
-                               3>; /* check_cnt */
                        mipi_attr = <4 /*lane_num*/
                                360 /*bit_rate_max(MHz)*/
                                0 /*factor(*100, default 0 for auto)*/
                                0>; /*phy_stop_wait(0=auto,1=standard,2=slow)*/
                                /* dsi_init: data_type, num, data... */
                        dsi_init_on = <
+                               0xff 10
                                0xf0 3 0 1 30 /* reset high, delay 30ms */
                                0xf0 3 0 0 10 /* reset low, delay 10ms */
                                0xf0 3 0 1 30 /* reset high, delay 30ms */
+                               0xfc 2 0x04 3 /* check_reg, check_cnt */
                                0xff 100   /* delay */
                                0xff 0xff>; /* ending flag */
                        dsi_init_off = <0xff 0xff>; /* ending flag */
                                0 /*clk_ss_level*/
                                1 /*clk_auto_generate*/
                                48715200>; /*pixel_clk(unit in Hz)*/
-                       check_state = <0x04 /* check_reg */
-                               3>; /* check_cnt */
                        mipi_attr = <4 /*lane_num*/
                                400 /*bit_rate_max(MHz)*/
                                0 /*factor(*100, default 0 for auto)*/
                                1 /*clk_lp_continuous(0=stop,1=continue)*/
                                0>; /*phy_stop_wait(0=auto,1=standard,2=slow)*/
                                /* dsi_init: data_type, num, data... */
-                       dsi_init_on = <0xff 0xff>; /* ending flag */
+                       dsi_init_on = <
+                               0xff 10
+                               0xf0 3 0 1 30 /* reset high, delay 30ms */
+                               0xf0 3 0 0 10 /* reset low, delay 10ms */
+                               0xf0 3 0 1 30 /* reset high, delay 30ms */
+                               0xfc 2 0x04 3 /* check_reg, check_cnt */
+                               0xff 0xff>; /* ending flag */
                        dsi_init_off = <0xff 0xff>; /* ending flag */
                                /* extern_init: 0xff for invalid */
                        extern_init = <2>;
                                /* power step: type,index,value,delay(ms) */
                        power_on_step = <
-                                       0 1 0 200
-                                       0 0 1 20
-                                       0 0 0 10
-                                       0 0 1 20
+                                       0 1 0 200 /* panel power on */
                                        2 0 0 0
                                        0xff 0 0 0>;
                        power_off_step = <
                                        2 0 0 0
-                                       0 0 0 20
-                                       0 1 1 100
+                                       0 0 0 20  /* reset low */
+                                       0 1 1 100 /* panel power off */
                                        0xff 0 0 0>;
                        backlight_index = <0>;
                };
index 15a52c1..d486969 100644 (file)
@@ -821,24 +821,6 @@ static int lcd_config_load_from_dts(struct lcd_config_s *pconf,
                }
                break;
        case LCD_MIPI:
-               ret = of_property_read_u32_array(child, "check_state",
-                       &para[0], 2);
-               if (ret) {
-                       if (lcd_debug_print_flag)
-                               LCDPR("failed to get check_state\n");
-                       pconf->lcd_control.mipi_config->check_en = 0;
-               } else {
-                       if (para[0] == 0xffff) {
-                               pconf->lcd_control.mipi_config->check_en = 0;
-                       } else {
-                               pconf->lcd_control.mipi_config->check_en = 1;
-                               pconf->lcd_control.mipi_config->check_reg =
-                                       (unsigned char)(para[0]);
-                               pconf->lcd_control.mipi_config->check_cnt =
-                                       (unsigned char)(para[1]);
-                       }
-               }
-
                ret = of_property_read_u32_array(child, "mipi_attr",
                        &para[0], 8);
                if (ret) {
index 4de8a05..ec5ce3a 100644 (file)
@@ -113,7 +113,7 @@ static void mipi_dsi_init_table_print(struct dsi_config_s *dconf, int on_off)
        i = 0;
        n = 0;
        while (i < n_max) {
-               if (dsi_table[i] == 0xff) {
+               if (dsi_table[i] == 0xff) { /* ctrl flag */
                        n = 2;
                        if (dsi_table[i+1] == 0xff) {
                                pr_info("  0x%02x,0x%02x,\n",
@@ -123,7 +123,7 @@ static void mipi_dsi_init_table_print(struct dsi_config_s *dconf, int on_off)
                                pr_info("  0x%02x,%d,\n",
                                        dsi_table[i], dsi_table[i+1]);
                        }
-               } else if (dsi_table[i] == 0xf0) {
+               } else if (dsi_table[i] == 0xf0) { /* gpio */
                        n = (DSI_CMD_SIZE_INDEX + 1) +
                                dsi_table[i+DSI_CMD_SIZE_INDEX];
                        len = 0;
@@ -138,6 +138,21 @@ static void mipi_dsi_init_table_print(struct dsi_config_s *dconf, int on_off)
                        }
                        if (len > 0)
                                pr_info("  %s\n", str);
+               } else if (dsi_table[i] == 0xfc) { /* check state */
+                       n = (DSI_CMD_SIZE_INDEX + 1) +
+                               dsi_table[i+DSI_CMD_SIZE_INDEX];
+                       len = 0;
+                       for (j = 0; j < n; j++) {
+                               if (j == DSI_CMD_SIZE_INDEX) {
+                                       len += sprintf(str+len, "%d,",
+                                               dsi_table[i+j]);
+                               } else {
+                                       len += sprintf(str+len, "0x%02x,",
+                                               dsi_table[i+j]);
+                               }
+                       }
+                       if (len > 0)
+                               pr_info("  %s\n", str);
                } else if ((dsi_table[i] & 0xf) == 0x0) {
                        pr_info("dsi_init_%s wrong data_type: 0x%02x\n",
                                on_off ? "on" : "off", dsi_table[i]);
@@ -343,6 +358,21 @@ int lcd_mipi_dsi_init_table_detect(struct device_node *m_node,
                                break;
                        }
                        i = i + (DSI_CMD_SIZE_INDEX + 1) + (val & 0xff);
+               } else if (val == 0xfc) { /* check state */
+                       ret = of_property_read_u32_index(m_node,
+                               propname, (i + DSI_CMD_SIZE_INDEX), &val);
+                       if (val > n_max)
+                               break;
+
+                       ret = of_property_read_u32_index(m_node, propname,
+                               (i + DSI_CMD_SIZE_INDEX + 1), &para[0]);
+                       ret = of_property_read_u32_index(m_node, propname,
+                               (i + DSI_CMD_SIZE_INDEX + 2), &para[1]);
+                       dconf->check_reg = para[0];
+                       dconf->check_cnt = para[1];
+                       if (dconf->check_cnt > 0)
+                               dconf->check_en = 1;
+                       i = i + (DSI_CMD_SIZE_INDEX + 1) + (val & 0xff);
                } else if ((val & 0xf) == 0x0) {
                        LCDERR("get %s wrong data_type: 0x%02x\n",
                                propname, val);
@@ -418,7 +448,7 @@ static void mipi_dcs_set(int trans_type, int req_ack, int tear_en)
        dsi_host_write(MIPI_DSI_DWC_PCKHDL_CFG_OS,
                (1 << BIT_CRC_RX_EN)  |
                (1 << BIT_ECC_RX_EN)  |
-               (0 << BIT_BTA_EN)     |
+               (req_ack << BIT_BTA_EN)     |
                (0 << BIT_EOTP_RX_EN) |
                (0 << BIT_EOTP_TX_EN));
 }
@@ -1182,6 +1212,117 @@ static void dsi_write_long_packet(struct dsi_cmd_request_s *req)
                wait_cmd_fifo_empty();
 }
 
+#ifdef DSI_CMD_READ_VALID
+/* *************************************************************
+ * Function: dsi_read_single
+ * Supported Data Type: DT_GEN_RD_0, DT_GEN_RD_1, DT_GEN_RD_2,
+ *             DT_DCS_RD_0
+ * Return:              data count, -1 for error
+ */
+int dsi_read_single(unsigned char *payload, unsigned char *rd_data,
+               unsigned int rd_byte_len)
+{
+       int num = 0;
+       unsigned char temp[4];
+       unsigned char vc_id = MIPI_DSI_VIRTUAL_CHAN_ID;
+       unsigned int req_ack;
+       struct dsi_cmd_request_s dsi_cmd_req;
+
+       req_ack = MIPI_DSI_DCS_ACK_TYPE;
+       dsi_cmd_req.data_type = DT_SET_MAX_RET_PKT_SIZE;
+       dsi_cmd_req.vc_id = (vc_id & 0x3);
+       temp[0] = dsi_cmd_req.data_type;
+       temp[1] = 2;
+       temp[2] = (unsigned char)((rd_byte_len >> 0) & 0xff);
+       temp[3] = (unsigned char)((rd_byte_len >> 8) & 0xff);
+       dsi_cmd_req.payload = &temp[0];
+       dsi_cmd_req.pld_count = 2;
+       dsi_cmd_req.req_ack = req_ack;
+       dsi_set_max_return_pkt_size(&dsi_cmd_req);
+
+       /* payload struct: */
+       /* data_type, data_cnt, command, parameters... */
+       req_ack = MIPI_DSI_DCS_REQ_ACK; /* need BTA ack */
+       dsi_cmd_req.data_type = payload[0];
+       dsi_cmd_req.vc_id = (vc_id & 0x3);
+       dsi_cmd_req.payload = &payload[0];
+       dsi_cmd_req.pld_count = payload[DSI_CMD_SIZE_INDEX];
+       dsi_cmd_req.req_ack = req_ack;
+       switch (dsi_cmd_req.data_type) {/* analysis data_type */
+       case DT_GEN_RD_0:
+       case DT_GEN_RD_1:
+       case DT_GEN_RD_2:
+               num = dsi_generic_read_packet(&dsi_cmd_req, rd_data);
+               break;
+       case DT_DCS_RD_0:
+               num = dsi_dcs_read_packet(&dsi_cmd_req, rd_data);
+               break;
+       default:
+               LCDPR("read un-support data_type: 0x%02x\n",
+                       dsi_cmd_req.data_type);
+               break;
+       }
+
+       if (num < 0)
+               LCDERR("mipi-dsi read error\n");
+
+       return num;
+}
+#else
+int dsi_read_single(unsigned char *payload, unsigned char *rd_data,
+               unsigned int rd_byte_len)
+{
+       LCDPR("Don't support mipi-dsi read command\n");
+       return -1;
+}
+#endif
+
+static void mipi_dsi_check_state(unsigned char reg, int cnt)
+{
+       int ret = 0, i, len;
+       unsigned char *rd_data;
+       unsigned char payload[3] = {DT_GEN_RD_1, 1, 0x04};
+       char str[100];
+       struct aml_lcd_drv_s *lcd_drv = aml_lcd_get_driver();
+
+       if (lcd_drv->lcd_config->lcd_control.mipi_config->check_en == 0)
+               return;
+       LCDPR("%s\n", __func__);
+
+       rd_data = kmalloc_array(cnt, sizeof(unsigned char), GFP_KERNEL);
+       if (rd_data == NULL) {
+               LCDERR("%s: rd_data error\n", __func__);
+               return;
+       }
+
+       payload[2] = reg;
+       ret = dsi_read_single(payload, rd_data, cnt);
+       if (ret < 0) {
+               lcd_drv->lcd_config->lcd_control.mipi_config->check_state = 0;
+               lcd_vcbus_setb(L_VCOM_VS_ADDR, 0, 12, 1);
+               kfree(rd_data);
+               return;
+       }
+       if (ret > cnt) {
+               LCDERR("%s: read back cnt is wrong\n", __func__);
+               kfree(rd_data);
+               return;
+       }
+
+       lcd_drv->lcd_config->lcd_control.mipi_config->check_state = 1;
+       lcd_vcbus_setb(L_VCOM_VS_ADDR, 1, 12, 1);
+       len = sprintf(str, "read reg 0x%02x: ", reg);
+       for (i = 0; i < ret; i++) {
+               if (i == 0)
+                       len += sprintf(str+len, "0x%02x", rd_data[i]);
+               else
+                       len += sprintf(str+len, ",0x%02x", rd_data[i]);
+       }
+       pr_info("%s\n", str);
+
+       kfree(rd_data);
+}
+
 /* *************************************************************
  * Function: dsi_write_cmd
  * Supported Data Type: DT_GEN_SHORT_WR_0, DT_GEN_SHORT_WR_1, DT_GEN_SHORT_WR_2,
@@ -1220,7 +1361,7 @@ int dsi_write_cmd(unsigned char *payload)
                                break;
                        else
                                mdelay(payload[i+1]);
-               } else if (payload[i] == 0xf0) {
+               } else if (payload[i] == 0xf0) { /* gpio */
                        j = (DSI_CMD_SIZE_INDEX + 1) +
                                payload[i+DSI_CMD_SIZE_INDEX];
                        if (payload[i+DSI_CMD_SIZE_INDEX] < 3) {
@@ -1232,6 +1373,19 @@ int dsi_write_cmd(unsigned char *payload)
                                payload[i+DSI_GPIO_INDEX+1]);
                        if (payload[i+DSI_GPIO_INDEX+2])
                        mdelay(payload[i+DSI_GPIO_INDEX+2]);
+               } else if (payload[i] == 0xfc) { /* check state */
+                       j = (DSI_CMD_SIZE_INDEX + 1) +
+                               payload[i+DSI_CMD_SIZE_INDEX];
+                       if (payload[i+DSI_CMD_SIZE_INDEX] < 2) {
+                               LCDERR("wrong cmd_size %d for check state\n",
+                                       payload[i+DSI_CMD_SIZE_INDEX]);
+                               break;
+                       }
+                       if (payload[i+DSI_GPIO_INDEX+2] > 0) {
+                               mipi_dsi_check_state(
+                                       payload[i+DSI_GPIO_INDEX],
+                                       payload[i+DSI_GPIO_INDEX+1]);
+                       }
                } else if ((payload[i] & 0xf) == 0x0) {
                                LCDERR("data_type: 0x%02x\n", payload[i]);
                                break;
@@ -1324,71 +1478,6 @@ int dsi_write_cmd(unsigned char *payload)
        return num;
 }
 
-#ifdef DSI_CMD_READ_VALID
-/* *************************************************************
- * Function: dsi_read_single
- * Supported Data Type: DT_GEN_RD_0, DT_GEN_RD_1, DT_GEN_RD_2,
- *             DT_DCS_RD_0
- * Return:              data count, -1 for error
- */
-int dsi_read_single(unsigned char *payload, unsigned char *rd_data,
-               unsigned int rd_byte_len)
-{
-       int num = 0;
-       unsigned char temp[4];
-       unsigned char vc_id = MIPI_DSI_VIRTUAL_CHAN_ID;
-       unsigned int req_ack;
-       struct dsi_cmd_request_s dsi_cmd_req;
-
-       req_ack = MIPI_DSI_DCS_ACK_TYPE;
-       dsi_cmd_req.data_type = DT_SET_MAX_RET_PKT_SIZE;
-       dsi_cmd_req.vc_id = (vc_id & 0x3);
-       temp[0] = dsi_cmd_req.data_type;
-       temp[1] = 2;
-       temp[2] = (unsigned char)((rd_byte_len >> 0) & 0xff);
-       temp[3] = (unsigned char)((rd_byte_len >> 8) & 0xff);
-       dsi_cmd_req.payload = &temp[0];
-       dsi_cmd_req.pld_count = 2;
-       dsi_cmd_req.req_ack = req_ack;
-       dsi_set_max_return_pkt_size(&dsi_cmd_req);
-
-       /* payload struct: */
-       /* data_type, data_cnt, command, parameters... */
-       req_ack = MIPI_DSI_DCS_REQ_ACK; /* need BTA ack */
-       dsi_cmd_req.data_type = payload[0];
-       dsi_cmd_req.vc_id = (vc_id & 0x3);
-       dsi_cmd_req.payload = &payload[0];
-       dsi_cmd_req.pld_count = payload[DSI_CMD_SIZE_INDEX];
-       dsi_cmd_req.req_ack = req_ack;
-       switch (dsi_cmd_req.data_type) {/* analysis data_type */
-       case DT_GEN_RD_0:
-       case DT_GEN_RD_1:
-       case DT_GEN_RD_2:
-               num = dsi_generic_read_packet(&dsi_cmd_req, rd_data);
-               break;
-       case DT_DCS_RD_0:
-               num = dsi_dcs_read_packet(&dsi_cmd_req, rd_data);
-               break;
-       default:
-               LCDPR("read un-support data_type: 0x%02x\n",
-                       dsi_cmd_req.data_type);
-               break;
-       }
-
-       if (num < 0)
-               LCDERR("mipi-dsi read error\n");
-
-       return num;
-}
-#else
-int dsi_read_single(unsigned char *payload, unsigned char *rd_data,
-               unsigned int rd_byte_len)
-{
-       LCDPR("Don't support mipi-dsi read command\n");
-       return -1;
-}
-#endif
-
 static void mipi_dsi_phy_config(struct dsi_phy_s *dphy, unsigned int dsi_ui)
 {
        unsigned int temp, t_ui, t_req_min, t_req_max, t_req, n;
@@ -1740,45 +1829,6 @@ static void mipi_dsi_host_init(struct lcd_config_s *pconf)
                pconf);
 }
 
-static void mipi_dsi_check_state(struct dsi_config_s *dconf,
-               unsigned char reg, int cnt)
-{
-       int ret = 0, i, len;
-       unsigned char *rd_data;
-       unsigned char payload[3] = {DT_GEN_RD_1, 1, 0x04};
-       char str[100];
-
-       LCDPR("%s\n", __func__);
-
-       rd_data = kmalloc_array(cnt, sizeof(unsigned char), GFP_KERNEL);
-       if (rd_data == NULL) {
-               LCDERR("%s: rd_data error\n", __func__);
-               return;
-       }
-
-       payload[2] = reg;
-       ret = dsi_read_single(payload, rd_data, cnt);
-       if (ret < 0) {
-               dconf->check_state = 0;
-               lcd_vcbus_setb(L_VCOM_VS_ADDR, 0, 12, 1);
-               kfree(rd_data);
-               return;
-       }
-
-       dconf->check_state = 1;
-       lcd_vcbus_setb(L_VCOM_VS_ADDR, 1, 12, 1);
-       len = sprintf(str, "read reg 0x%02x: ", reg);
-       for (i = 0; i < ret; i++) {
-               if (i == 0)
-                       len += sprintf(str+len, "0x%02x", rd_data[i]);
-               else
-                       len += sprintf(str+len, ",0x%02x", rd_data[i]);
-       }
-       pr_info("%s\n", str);
-
-       kfree(rd_data);
-}
-
 static void mipi_dsi_link_on(struct lcd_config_s *pconf)
 {
        unsigned int op_mode_init, op_mode_disp;
@@ -1794,9 +1844,6 @@ static void mipi_dsi_link_on(struct lcd_config_s *pconf)
        op_mode_init = dconf->operation_mode_init;
        op_mode_disp = dconf->operation_mode_display;
 
-       if (dconf->check_en)
-               mipi_dsi_check_state(dconf, dconf->check_reg, dconf->check_cnt);
-
        if (dconf->dsi_init_on) {
                dsi_write_cmd(dconf->dsi_init_on);
                LCDPR("dsi init on\n");
@@ -1829,33 +1876,35 @@ static void mipi_dsi_link_on(struct lcd_config_s *pconf)
 
 void mipi_dsi_link_off(struct lcd_config_s *pconf)
 {
+       struct dsi_config_s *dconf;
 #ifdef CONFIG_AMLOGIC_LCD_EXTERN
        struct aml_lcd_extern_driver_s *lcd_ext;
-       int ext_index;
 #endif
 
        if (lcd_debug_print_flag)
                LCDPR("%s\n", __func__);
 
-       if (pconf->lcd_control.mipi_config->dsi_init_off) {
-               dsi_write_cmd(pconf->lcd_control.mipi_config->dsi_init_off);
-               LCDPR("dsi init off\n");
-       }
+       dconf = pconf->lcd_control.mipi_config;
 
 #ifdef CONFIG_AMLOGIC_LCD_EXTERN
-       ext_index = pconf->lcd_control.mipi_config->extern_init;
-       if (ext_index < LCD_EXTERN_INDEX_INVALID) {
-               lcd_ext = aml_lcd_extern_get_driver(ext_index);
+       if (dconf->extern_init < LCD_EXTERN_INDEX_INVALID) {
+               lcd_ext = aml_lcd_extern_get_driver(dconf->extern_init);
                if (lcd_ext == NULL) {
                        LCDPR("no lcd_extern driver\n");
                } else {
                        if (lcd_ext->config.table_init_off) {
                                dsi_write_cmd(lcd_ext->config.table_init_off);
-                               LCDPR("[extern]%s dsi init off\n", lcd_ext->config.name);
+                               LCDPR("[extern]%s dsi init off\n",
+                                       lcd_ext->config.name);
                        }
                }
        }
 #endif
+
+       if (dconf->dsi_init_off) {
+               dsi_write_cmd(dconf->dsi_init_off);
+               LCDPR("dsi init off\n");
+       }
 }
 
 void lcd_mipi_dsi_config_set(struct lcd_config_s *pconf)