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>
This commit is contained in:
parent
4080e08c09
commit
b2a1480191
33 changed files with 2407 additions and 2308 deletions
|
|
@ -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;
|
||||
u32 type;
|
||||
|
||||
/*
|
||||
* 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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
buf += len;
|
||||
mtk_dsi_cmdq(init->data, len, type);
|
||||
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;
|
||||
}
|
||||
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();
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue