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",
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;
}
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]);
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), ¶[0]);
+ ret = of_property_read_u32_index(m_node, propname,
+ (i + DSI_CMD_SIZE_INDEX + 2), ¶[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);
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));
}
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,
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) {
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;
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;
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;
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");
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)