diff options
author | Julius Werner <jwerner@chromium.org> | 2021-08-24 16:03:57 -0700 |
---|---|---|
committer | Felix Held <felix-coreboot@felixheld.de> | 2021-08-26 15:18:45 +0000 |
commit | 5ff1808f20a70912796b274c03cec3d91ddf890a (patch) | |
tree | 5b8207fc81eca4b6c1dddf478ad47a8537a0a2e6 /src/drivers/mipi/panel.c | |
parent | 7d41491e76eea186fe0e734e50fdb827e877e0ad (diff) |
device/mipi: Move to drivers/mipi
Sounds like we prefer to have this under drivers/ instead of device/.
Also move all MIPI-related headers out from device/ into their own
directory.
Signed-off-by: Julius Werner <jwerner@chromium.org>
Change-Id: Ib3e66954b8f0cf85b28d8d186b09d7846707559d
Reviewed-on: https://review.coreboot.org/c/coreboot/+/57128
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Hung-Te Lin <hungte@chromium.org>
Reviewed-by: Yu-Ping Wu <yupingso@google.com>
Reviewed-by: Nico Huber <nico.h@gmx.de>
Diffstat (limited to 'src/drivers/mipi/panel.c')
-rw-r--r-- | src/drivers/mipi/panel.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/drivers/mipi/panel.c b/src/drivers/mipi/panel.c new file mode 100644 index 0000000000..e8469a6e36 --- /dev/null +++ b/src/drivers/mipi/panel.c @@ -0,0 +1,48 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#include <console/console.h> +#include <delay.h> +#include <mipi/panel.h> + +cb_err_t mipi_panel_parse_init_commands(const void *buf, mipi_cmd_func_t cmd_func) +{ + const struct panel_init_command *init = buf; + + /* + * 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; + + switch (cmd) { + case PANEL_CMD_DELAY: + mdelay(len); + break; + + case PANEL_CMD_DCS: + case PANEL_CMD_GENERIC: + buf += len; + + cb_err_t ret = cmd_func(cmd, init->data, len); + if (ret != CB_SUCCESS) + return ret; + break; + + default: + printk(BIOS_ERR, "%s: Unknown command code: %d, " + "abort panel initialization.\n", __func__, cmd); + return CB_ERR; + } + } + + return CB_SUCCESS; +} |