summaryrefslogtreecommitdiff
path: root/src/soc/mediatek/common/dsi.c
diff options
context:
space:
mode:
authorJulius Werner <jwerner@chromium.org>2021-08-12 16:48:12 -0700
committerFelix Held <felix-coreboot@felixheld.de>2021-08-18 14:21:28 +0000
commitb2a14801916ad9dfa2a6b4fa9ceb6de7d2d03e24 (patch)
tree75788742da59525637ea977bcb419891f98d0c2e /src/soc/mediatek/common/dsi.c
parent4080e08c09a4f063ed1df280e74fa2b87d304b87 (diff)
device: Move MIPI panel library from mainboard/google/kukui into common
All boards that are trying to use MIPI panels eventually run into the problem that they need to store physical parameters and a list of DCS initialization commands for each panel, and these commands can be very different (e.g. a large amount of very short commands, a few very large commands, etc.). Finding a data format to fit all these different cases efficiently into the same structures keeps being a challenge, and the Kukui mainboard already once put a lot of effort into designing a clean, flexible and efficient solution for this. This patch moves that framework into a common src/device/mipi/ library where it can be used by other boards as well. (Also, this will hopefully allow us to save some duplicated work when using the same panel on different boards at some point.) Signed-off-by: Julius Werner <jwerner@chromium.org> Change-Id: I877f2b0c7ab984412b288e2ed27f37cd93c70863 Reviewed-on: https://review.coreboot.org/c/coreboot/+/56965 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Yu-Ping Wu <yupingso@google.com> Reviewed-by: Hung-Te Lin <hungte@chromium.org>
Diffstat (limited to 'src/soc/mediatek/common/dsi.c')
-rw-r--r--src/soc/mediatek/common/dsi.c102
1 files changed, 39 insertions, 63 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();