Hung-Te Lin has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/34778 )
Change subject: soc/mediatek: Change DSI init commands to take flexible length array ......................................................................
soc/mediatek: Change DSI init commands to take flexible length array
The fixed size of init command in lcm_init_table is wasting lots of space and we should change to packed array since the command buffer already provides length information.
With this change, BOE panel init commands have been reduced from 4848 bytes to 1309 bytes.
BUG=b:80501386,b:117254947 TEST=emerge-kukui coreboot chromeos-bootimage; Boots properly
Change-Id: I359dde8e6f2e1c0983f4677193bb47a7ae497ca6 Signed-off-by: Hung-Te Lin hungte@chromium.org --- M src/mainboard/google/kukui/Makefile.inc M src/mainboard/google/kukui/mainboard.c M src/mainboard/google/kukui/panel.h M src/soc/mediatek/common/dsi.c M src/soc/mediatek/common/include/soc/dsi_common.h 5 files changed, 41 insertions(+), 32 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/78/34778/1
diff --git a/src/mainboard/google/kukui/Makefile.inc b/src/mainboard/google/kukui/Makefile.inc index e34bff1..4f5a201 100644 --- a/src/mainboard/google/kukui/Makefile.inc +++ b/src/mainboard/google/kukui/Makefile.inc @@ -1,4 +1,5 @@ subdirs-y += sdram_params/ +subdirs-y += panel_params/
bootblock-y += boardid.c bootblock-y += bootblock.c diff --git a/src/mainboard/google/kukui/mainboard.c b/src/mainboard/google/kukui/mainboard.c index 6c98689..cd32385 100644 --- a/src/mainboard/google/kukui/mainboard.c +++ b/src/mainboard/google/kukui/mainboard.c @@ -129,7 +129,7 @@ MIPI_DSI_MODE_VIDEO_SYNC_PULSE | MIPI_DSI_MODE_LPM); if (mtk_dsi_init(mipi_dsi_flags, MIPI_DSI_FMT_RGB888, 4, edid, - panel->init) < 0) { + (const struct lcm_init_command *)panel->init) < 0) { printk(BIOS_ERR, "%s: Failed in DSI init.\n", __func__); return false; } diff --git a/src/mainboard/google/kukui/panel.h b/src/mainboard/google/kukui/panel.h index 80dbdb8..a986934 100644 --- a/src/mainboard/google/kukui/panel.h +++ b/src/mainboard/google/kukui/panel.h @@ -23,27 +23,28 @@ const char *name; /* human readable name */ void (*power_on)(void); /* Callback to turn on panel */ struct edid edid; /* edid info of this panel */ - struct lcm_init_table init[]; /* table of init commands */ + char init[]; /* should be a packed array of lcm_init_command */ };
/* Returns the panel description from given ID. */ extern struct panel_description *get_panel_description(int panel_id);
-#define INIT_DCS_CMD(...) { \ - .cmd = LCM_DCS_CMD, \ - .len = sizeof((u8[]){__VA_ARGS__}), \ - .data = {__VA_ARGS__} } +#define INIT_DCS_CMD(...) \ + LCM_DCS_CMD, \ + sizeof((u8[]){__VA_ARGS__}), \ + __VA_ARGS__
-#define INIT_GENERIC_CMD(...) { \ - .cmd = LCM_GENERIC_CMD, \ - .len = sizeof((u8[]){__VA_ARGS__}), \ - .data = {__VA_ARGS__} } +#define INIT_GENERIC_CMD(...) \ + LCM_GENERIC_CMD, \ + sizeof((u8[]){__VA_ARGS__}), \ + __VA_ARGS__
-#define INIT_DELAY_CMD(delay) { \ - .cmd = LCM_DELAY_CMD,\ - .len = delay, } +#define INIT_DELAY_CMD(delay) \ + LCM_DELAY_CMD, \ + (delay)
-#define INIT_END_CMD { .cmd = LCM_END_CMD, } +#define INIT_END_CMD \ + LCM_END_CMD
/* GPIO names */ #define GPIO_LCM_RST_1V8 GPIO(LCM_RST) /* 45 */ diff --git a/src/soc/mediatek/common/dsi.c b/src/soc/mediatek/common/dsi.c index c452fd1..205ff08 100644 --- a/src/soc/mediatek/common/dsi.c +++ b/src/soc/mediatek/common/dsi.c @@ -241,10 +241,10 @@ return false; }
-static void mtk_dsi_cmdq(u8 *data, u8 len, u32 type) +static void mtk_dsi_cmdq(const u8 *data, u8 len, u32 type) { struct stopwatch sw; - u8 *tx_buf = data; + const u8 *tx_buf = data; u8 cmdq_size; u32 reg_val, cmdq_mask, i, config, cmdq_off, intsta_0;
@@ -298,12 +298,19 @@ printk(BIOS_ERR, "dsi send cmd time-out(400uS)\n"); }
-static void mtk_dsi_send_init_commands(struct lcm_init_table *init_cmd) +static void mtk_dsi_send_init_commands(const struct lcm_init_command *cmds) { - assert(init_cmd); + assert(cmds);
- for (; init_cmd->cmd != LCM_END_CMD; init_cmd++) { - u32 cmd = init_cmd->cmd, len = init_cmd->len; + /* The cmds were packed as a single data buffer so we can't simply + * iterate by cmd++; instead we have to parse and scan. + */ + const u8 *buf = (const void *)cmds; + + for (; cmds->cmd != LCM_END_CMD; cmds = (const void *)buf) { + buf += sizeof(*cmds); + + u32 cmd = cmds->cmd, len = cmds->len; u32 type;
switch (cmd) { @@ -350,13 +357,13 @@ return;
} - assert(len <= sizeof(init_cmd->data)); - mtk_dsi_cmdq(init_cmd->data, len, type); + buf += len; + mtk_dsi_cmdq(cmds->data, len, type); } }
-int mtk_dsi_init(u32 mode_flags, u32 format, u32 lanes, - const struct edid *edid, struct lcm_init_table *init_cmd) +int mtk_dsi_init(u32 mode_flags, u32 format, u32 lanes, const struct edid *edid, + const struct lcm_init_command *init_cmds) { int data_rate; u32 bpp = mtk_dsi_get_bits_per_pixel(format); @@ -373,8 +380,8 @@ mtk_dsi_clk_hs_mode_disable(); mtk_dsi_config_vdo_timing(mode_flags, format, lanes, edid, &phy_timing); mtk_dsi_clk_hs_mode_enable(); - if (init_cmd) - mtk_dsi_send_init_commands(init_cmd); + if (init_cmds) + mtk_dsi_send_init_commands(init_cmds); 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 8597b60..4c26946 100644 --- a/src/soc/mediatek/common/include/soc/dsi_common.h +++ b/src/soc/mediatek/common/include/soc/dsi_common.h @@ -40,16 +40,16 @@ u8 clk_hs_exit; };
-/* Definitions for cmd in lcm_init_table */ +/* 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_table { - u32 cmd; - u32 len; - u8 data[7]; +struct lcm_init_command { + u8 cmd; + u8 len; + u8 data[]; };
/* Functions that each SOC should provide. */ @@ -63,6 +63,6 @@ /* Public API provided in common/dsi.c */ int mtk_dsi_bpp_from_format(u32 format); int mtk_dsi_init(u32 mode_flags, u32 format, u32 lanes, const struct edid *edid, - struct lcm_init_table *init_cmd); + const struct lcm_init_command *init_cmds);
#endif // SOC_MEDIATEK_DSI_COMMON_H