summaryrefslogtreecommitdiff
path: root/src/soc/mediatek
diff options
context:
space:
mode:
Diffstat (limited to 'src/soc/mediatek')
-rw-r--r--src/soc/mediatek/common/dsi.c102
-rw-r--r--src/soc/mediatek/common/include/soc/dsi_common.h12
2 files changed, 39 insertions, 75 deletions
diff --git a/src/soc/mediatek/common/dsi.c b/src/soc/mediatek/common/dsi.c
index 5c969db1da..c517726175 100644
--- a/src/soc/mediatek/common/dsi.c
+++ b/src/soc/mediatek/common/dsi.c
@@ -2,6 +2,7 @@
#include <assert.h>
#include <console/console.h>
+#include <device/mipi_panel.h>
#include <device/mmio.h>
#include <delay.h>
#include <edid.h>
@@ -347,75 +348,50 @@ static void mtk_dsi_cmdq(const u8 *data, u8 len, u32 type)
}
}
-static void mtk_dsi_send_init_commands(const u8 *buf)
+static cb_err_t mtk_dsi_send_init_command(enum panel_init_cmd cmd, const u8 *data, u8 len)
{
- if (!buf)
- return;
- const struct lcm_init_command *init = (const void *)buf;
-
- /*
- * The given commands should be in a buffer containing a packed array of
- * lcm_init_command and each element may be in variable size so we have
- * to parse and scan.
- */
-
- for (; init->cmd != LCM_END_CMD; init = (const void *)buf) {
- /*
- * For some commands like DELAY, the init->len should not be
- * counted for buf.
- */
- buf += sizeof(*init);
-
- u32 cmd = init->cmd, len = init->len;
- u32 type;
-
- switch (cmd) {
- case LCM_DELAY_CMD:
- mdelay(len);
- continue;
-
- case LCM_DCS_CMD:
- switch (len) {
- case 0:
- return;
- case 1:
- type = MIPI_DSI_DCS_SHORT_WRITE;
- break;
- case 2:
- type = MIPI_DSI_DCS_SHORT_WRITE_PARAM;
- break;
- default:
- type = MIPI_DSI_DCS_LONG_WRITE;
- break;
- }
+ u32 type;
+
+ switch (cmd) {
+ case PANEL_CMD_DCS:
+ switch (len) {
+ case 0:
+ return CB_ERR;
+ case 1:
+ type = MIPI_DSI_DCS_SHORT_WRITE;
break;
-
- case LCM_GENERIC_CMD:
- switch (len) {
- case 0:
- type = MIPI_DSI_GENERIC_SHORT_WRITE_0_PARAM;
- break;
- case 1:
- type = MIPI_DSI_GENERIC_SHORT_WRITE_1_PARAM;
- break;
- case 2:
- type = MIPI_DSI_GENERIC_SHORT_WRITE_2_PARAM;
- break;
- default:
- type = MIPI_DSI_GENERIC_LONG_WRITE;
- break;
- }
+ case 2:
+ type = MIPI_DSI_DCS_SHORT_WRITE_PARAM;
break;
-
default:
- printk(BIOS_ERR, "%s: Unknown cmd: %d, "
- "abort panel initialization.\n", __func__, cmd);
- return;
+ type = MIPI_DSI_DCS_LONG_WRITE;
+ break;
+ }
+ break;
+ case PANEL_CMD_GENERIC:
+ switch (len) {
+ case 0:
+ type = MIPI_DSI_GENERIC_SHORT_WRITE_0_PARAM;
+ break;
+ case 1:
+ type = MIPI_DSI_GENERIC_SHORT_WRITE_1_PARAM;
+ break;
+ case 2:
+ type = MIPI_DSI_GENERIC_SHORT_WRITE_2_PARAM;
+ break;
+ default:
+ type = MIPI_DSI_GENERIC_LONG_WRITE;
+ break;
}
- buf += len;
- mtk_dsi_cmdq(init->data, len, type);
+ break;
+ default:
+ printk(BIOS_ERR, "Unsupported MIPI panel init command: %d\n", cmd);
+ return CB_ERR;
}
+
+ mtk_dsi_cmdq(data, len, type);
+ return CB_SUCCESS;
}
static void mtk_dsi_reset_dphy(void)
@@ -444,7 +420,7 @@ int mtk_dsi_init(u32 mode_flags, u32 format, u32 lanes, const struct edid *edid,
mtk_dsi_clk_hs_mode_disable();
mtk_dsi_config_vdo_timing(mode_flags, format, lanes, edid, &phy_timing);
mtk_dsi_clk_hs_mode_enable();
- mtk_dsi_send_init_commands(init_commands);
+ mipi_panel_parse_init_commands(init_commands, mtk_dsi_send_init_command);
mtk_dsi_set_mode(mode_flags);
mtk_dsi_start();
diff --git a/src/soc/mediatek/common/include/soc/dsi_common.h b/src/soc/mediatek/common/include/soc/dsi_common.h
index 489a591890..31abce026c 100644
--- a/src/soc/mediatek/common/include/soc/dsi_common.h
+++ b/src/soc/mediatek/common/include/soc/dsi_common.h
@@ -340,18 +340,6 @@ struct mtk_phy_timing {
u32 d_phy;
};
-/* Definitions for cmd in lcm_init_command */
-#define LCM_END_CMD 0
-#define LCM_DELAY_CMD 1
-#define LCM_GENERIC_CMD 2
-#define LCM_DCS_CMD 3
-
-struct lcm_init_command {
- u8 cmd;
- u8 len;
- u8 data[];
-};
-
/* Functions that each SOC should provide. */
void mtk_dsi_reset(void);
void mtk_dsi_configure_mipi_tx(u32 data_rate, u32 lanes);