treewide: Move mipi_panel_parse_commands() to commonlib

Move the MIPI panel init command parsing function
mipi_panel_parse_init_commands() and related macros and structs from
drivers/mipi/ to commonlib/mipi/, so that the function can be shared
with payloads.

In a follow-up patch, a 'poweroff' field will be added to the
panel_serializable_data struct and then passed to payloads, so that
payloads can utilize mipi_panel_parse_init_commands() to run the panel
poweroff commands.

BUG=b:474187570
TEST=emerge-jedi coreboot libpayload
BRANCH=skywalker

Change-Id: I19011669f03d060e9f030b673687cbe5965d7e2f
Signed-off-by: Yu-Ping Wu <yupingso@chromium.org>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/90736
Reviewed-by: Subrata Banik <subratabanik@google.com>
Reviewed-by: Paul Menzel <paulepanter@mailbox.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Chen-Tsung Hsieh <chentsung@google.com>
Reviewed-by: Alicja Michalska <ahplka19@gmail.com>
Reviewed-by: Julius Werner <jwerner@chromium.org>
Reviewed-by: Yidi Lin <yidilin@google.com>
This commit is contained in:
Yu-Ping Wu 2026-01-13 11:42:18 +08:00 committed by Yu-Ping Wu
commit b4fbc59c6f
11 changed files with 69 additions and 58 deletions

View file

@ -1,7 +1,5 @@
# SPDX-License-Identifier: GPL-2.0-only
ramstage-y += panel.c
panel-params-y :=
panel-params-$(CONFIG_MIPI_PANEL_AUO_B101UAN08_3) += panel-AUO_B101UAN08_3

View file

@ -1,80 +0,0 @@
/* SPDX-License-Identifier: GPL-2.0-only */
#include <console/console.h>
#include <delay.h>
#include <mipi/panel.h>
#include <types.h>
enum cb_err mipi_panel_parse_init_commands(const void *buf, mipi_cmd_func_t cmd_func,
void *user_data)
{
const struct panel_init_command *init = buf;
enum mipi_dsi_transaction type;
/*
* The given commands should be in a buffer containing a packed array of
* panel_init_command and each element may be in variable size so we have
* to parse and scan.
*/
for (; init->cmd != PANEL_CMD_END; 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;
if (cmd == PANEL_CMD_DELAY) {
mdelay(len);
continue;
}
switch (cmd) {
case PANEL_CMD_DCS:
switch (len) {
case 0:
printk(BIOS_ERR, "%s: DCS command length 0?\n", __func__);
return CB_ERR;
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;
}
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, "%s: Unknown command code: %d, "
"abort panel initialization.\n", __func__, cmd);
return CB_ERR;
}
enum cb_err ret = cmd_func(type, init->data, len, user_data);
if (ret != CB_SUCCESS)
return ret;
buf += len;
}
return CB_SUCCESS;
}