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,5 +1,6 @@
## SPDX-License-Identifier: GPL-2.0-only
subdirs-y += mipi
subdirs-y += storage
subdirs-y += bsd/zstd

View file

@ -0,0 +1,55 @@
/* SPDX-License-Identifier: GPL-2.0-only */
#ifndef __COMMONLIB_MIPI_CMD_H__
#define __COMMONLIB_MIPI_CMD_H__
#include <commonlib/bsd/cb_err.h>
#include <commonlib/mipi/dsi.h>
#include <stdint.h>
/* Definitions for cmd in panel_init_command */
enum panel_init_cmd {
PANEL_CMD_END = 0,
PANEL_CMD_DELAY = 1,
PANEL_CMD_GENERIC = 2,
PANEL_CMD_DCS = 3,
};
struct panel_init_command {
u8 cmd;
u8 len;
u8 data[];
};
#define PANEL_DELAY(delay) \
PANEL_CMD_DELAY, \
delay
#define PANEL_GENERIC(...) \
PANEL_CMD_GENERIC, \
sizeof((u8[]){__VA_ARGS__}), \
__VA_ARGS__
#define PANEL_DCS(...) \
PANEL_CMD_DCS, \
sizeof((u8[]){__VA_ARGS__}), \
__VA_ARGS__
#define PANEL_END \
PANEL_CMD_END
/*
* Callback function type for mipi_panel_parse_init_commands().
* @param type MIPI DSI transaction type.
* @param data panel_init_command data.
* @param len panel_init_command len.
* @param user_data Arbitrary user data passed from mipi_panel_parse_init_commands().
*/
typedef enum cb_err (*mipi_cmd_func_t)(enum mipi_dsi_transaction type, const u8 *data, u8 len,
void *user_data);
/* Parse a command array and call cmd_func() for each entry. Delays get handled internally. */
enum cb_err mipi_panel_parse_init_commands(const void *buf, mipi_cmd_func_t cmd_func,
void *user_data);
#endif /* __COMMONLIB_MIPI_CMD_H__ */

View file

@ -1,7 +1,7 @@
/* SPDX-License-Identifier: GPL-2.0-only */
#ifndef __MIPI_DSI_H__
#define __MIPI_DSI_H__
#ifndef __COMMONLIB_MIPI_DSI_H__
#define __COMMONLIB_MIPI_DSI_H__
/* MIPI DSI Processor-to-Peripheral transaction types */
enum mipi_dsi_transaction {
@ -109,4 +109,4 @@ enum {
MIPI_DCS_READ_DDB_CONTINUE = 0xA8,
};
#endif /* __MIPI_DSI_H__ */
#endif /* __COMMONLIB_MIPI_DSI_H__ */

View file

@ -0,0 +1,3 @@
## SPDX-License-Identifier: GPL-2.0-only
ramstage-y += cmd.c

View file

@ -1,9 +1,9 @@
/* SPDX-License-Identifier: GPL-2.0-only */
#include <console/console.h>
#include <commonlib/bsd/cb_err.h>
#include <commonlib/bsd/stdlib.h>
#include <commonlib/mipi/cmd.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)

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

@ -3,29 +3,15 @@
#ifndef __MIPI_PANEL_H__
#define __MIPI_PANEL_H__
#include <commonlib/mipi/cmd.h>
#include <edid.h>
#include <mipi/dsi.h>
#include <types.h>
/* Definitions for cmd in panel_init_command */
enum panel_init_cmd {
PANEL_CMD_END = 0,
PANEL_CMD_DELAY = 1,
PANEL_CMD_GENERIC = 2,
PANEL_CMD_DCS = 3,
};
/* Definitions for flags in panel_serializable_data */
enum panel_flag {
PANEL_FLAG_CPHY = BIT(0),
};
struct panel_init_command {
u8 cmd;
u8 len;
u8 data[];
};
/* VESA Display Stream Compression DSC 1.2 constants */
#define DSC_NUM_BUF_RANGES 15
@ -215,35 +201,4 @@ struct panel_serializable_data {
u8 init[]; /* A packed array of panel_init_command */
};
/*
* Callback function type for mipi_panel_parse_init_commands().
* @param type MIPI DSI transaction type.
* @param data panel_init_command data.
* @param len panel_init_command len.
* @param user_data Arbitrary user data passed from mipi_panel_parse_init_commands().
*/
typedef enum cb_err (*mipi_cmd_func_t)(enum mipi_dsi_transaction type, const u8 *data, u8 len,
void *user_data);
/* Parse a command array and call cmd_func() for each entry. Delays get handled internally. */
enum cb_err mipi_panel_parse_init_commands(const void *buf, mipi_cmd_func_t cmd_func,
void *user_data);
#define PANEL_DCS(...) \
PANEL_CMD_DCS, \
sizeof((u8[]){__VA_ARGS__}), \
__VA_ARGS__
#define PANEL_GENERIC(...) \
PANEL_CMD_GENERIC, \
sizeof((u8[]){__VA_ARGS__}), \
__VA_ARGS__
#define PANEL_DELAY(delay) \
PANEL_CMD_DELAY, \
delay
#define PANEL_END \
PANEL_CMD_END
#endif /* __MIPI_PANEL_H__ */

View file

@ -4,8 +4,8 @@
#define SOC_MEDIATEK_DSI_COMMON_H
#include <commonlib/helpers.h>
#include <commonlib/mipi/dsi.h>
#include <edid.h>
#include <mipi/dsi.h>
#include <types.h>
#include <soc/addressmap.h>
#include <soc/display_dsi.h>

View file

@ -8,7 +8,7 @@
#ifndef __SOC_MIPI_DISPLAY_H__
#define __SOC_MIPI_DISPLAY_H__
#include <mipi/dsi.h>
#include <commonlib/mipi/dsi.h>
/* MIPI DCS pixel formats */
#define MIPI_DCS_PIXEL_FMT_24BIT 7

View file

@ -1,6 +1,5 @@
/* SPDX-License-Identifier: GPL-2.0-only */
#include <mipi/dsi.h>
#include <mipi/panel.h>
#include <device/mmio.h>
#include <console/console.h>

View file

@ -3,7 +3,7 @@
#ifndef __RK_MIPI_H
#define __RK_MIPI_H
#include <mipi/dsi.h>
#include <commonlib/mipi/dsi.h>
#include <types.h>
struct rk_mipi_regs {