Yidi Lin has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/79776?usp=email )
Change subject: soc/mediatek: a common implmentation to configure display ......................................................................
soc/mediatek: a common implmentation to configure display
The sequences of configure_display() are similar on MediaTek platforms.
The sequences usually involve following steps: 1. Setup mtcmos for display hardware block. - mtcmos_display_power_on - mtcmos_protect_display_bus() 2. Configure backlight pins 3. Power on the panel - It also powers on the bridge in MIPI DSI to eDP case. 4. General initialization for DDP(display data path) 5. Initialize eDP/MIPI DSI accordingly, - For eDP path, it calls mtk_edp_init() to get edid from the panel and initializes eDP driver. - For MIPI DSI path, the edid is retrieved either from the bridge or from CBFS (the serializable data), and then initializes DSI driver. 6. Set framebuffer bits per pixel 7. Setup DDP mode 8. Setup panel orientation
This patch extracts geralt/display.c to soc/common/display.c and refacts `struct panel_description` to generalize the sequences of configure_display().
TEST=check FW screen on geralt.
Change-Id: I403bba8a826de5f3fb2ea96a5403725ff194164f Signed-off-by: Yidi Lin yidilin@chromium.org --- M src/mainboard/google/geralt/Makefile.inc M src/mainboard/google/geralt/mainboard.c M src/mainboard/google/geralt/panel.h M src/mainboard/google/geralt/panel_geralt.c R src/soc/mediatek/common/display.c M src/soc/mediatek/common/include/soc/ddp_common.h A src/soc/mediatek/common/include/soc/display.h M src/soc/mediatek/mt8188/Makefile.inc M src/soc/mediatek/mt8188/include/soc/ddp.h 9 files changed, 50 insertions(+), 31 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/76/79776/1
diff --git a/src/mainboard/google/geralt/Makefile.inc b/src/mainboard/google/geralt/Makefile.inc index 2b1f313..e954309 100644 --- a/src/mainboard/google/geralt/Makefile.inc +++ b/src/mainboard/google/geralt/Makefile.inc @@ -20,7 +20,6 @@ ramstage-y += memlayout.ld ramstage-y += boardid.c ramstage-y += chromeos.c -ramstage-y += display.c ramstage-y += mainboard.c ramstage-y += panel.c ramstage-y += regulator.c diff --git a/src/mainboard/google/geralt/mainboard.c b/src/mainboard/google/geralt/mainboard.c index 6bb8380..a24070d 100644 --- a/src/mainboard/google/geralt/mainboard.c +++ b/src/mainboard/google/geralt/mainboard.c @@ -3,13 +3,13 @@ #include <bootmode.h> #include <device/device.h> #include <soc/bl31.h> +#include <soc/display.h> #include <soc/i2c.h> #include <soc/msdc.h> #include <soc/mt6359p.h> #include <soc/mtcmos.h> #include <soc/usb.h>
-#include "display.h" #include "gpio.h"
#define AFE_SE_SECURE_CON (AUDIO_BASE + 0x17a8) diff --git a/src/mainboard/google/geralt/panel.h b/src/mainboard/google/geralt/panel.h index 71cecdf..3d0fafd 100644 --- a/src/mainboard/google/geralt/panel.h +++ b/src/mainboard/google/geralt/panel.h @@ -3,23 +3,11 @@ #ifndef __MAINBOARD_GOOGLE_GERALT_PANEL_H__ #define __MAINBOARD_GOOGLE_GERALT_PANEL_H__
-#include <boot/coreboot_tables.h> -#include <mipi/panel.h> -#include <soc/ddp.h> - -struct panel_description { - const char *name; - struct panel_serializable_data *s; - void (*power_on)(void); - void (*configure_panel_backlight)(void); - enum disp_path_sel disp_path; - bool pwm_ctrl_gpio; -}; +#include <soc/display.h>
void configure_mipi_pwm_backlight(void); void fill_lp_backlight_gpios(struct lb_gpios *gpios); uint32_t panel_id(void); struct panel_description *get_panel_description(uint32_t panel_id); -struct panel_description *get_active_panel(void);
#endif diff --git a/src/mainboard/google/geralt/panel_geralt.c b/src/mainboard/google/geralt/panel_geralt.c index 2ca95be..9453981 100644 --- a/src/mainboard/google/geralt/panel_geralt.c +++ b/src/mainboard/google/geralt/panel_geralt.c @@ -53,6 +53,7 @@ .name = "BOE_TV110C9M_LL0", .power_on = power_on_mipi_boe_tv110c9m_ll0, .configure_panel_backlight = configure_mipi_pwm_backlight, + .orientation = LB_FB_ORIENTATION_BOTTOM_UP, .disp_path = DISP_PATH_MIPI, .pwm_ctrl_gpio = true, }, diff --git a/src/mainboard/google/geralt/display.c b/src/soc/mediatek/common/display.c similarity index 78% rename from src/mainboard/google/geralt/display.c rename to src/soc/mediatek/common/display.c index 68a0a22..79651d5 100644 --- a/src/mainboard/google/geralt/display.c +++ b/src/soc/mediatek/common/display.c @@ -4,23 +4,19 @@ #include <delay.h> #include <edid.h> #include <framebuffer_info.h> -#include <gpio.h> #include <soc/ddp.h> +#include <soc/display.h> #include <soc/dptx.h> #include <soc/dsi.h> -#include <soc/gpio_common.h> #include <soc/mtcmos.h>
-#include "display.h" -#include "gpio.h" -#include "panel.h" - int configure_display(void) { struct edid edid; struct fb_info *info; const char *name; struct panel_description *panel = get_active_panel(); + if (!panel) return -1;
@@ -29,8 +25,10 @@ mtcmos_display_power_on(); mtcmos_protect_display_bus();
- panel->configure_panel_backlight(); - panel->power_on(); + if (panel->configure_panel_backlight) + panel->configure_panel_backlight(); + if (panel->power_on) + panel->power_on();
mtk_ddp_init();
@@ -40,8 +38,10 @@ printk(BIOS_ERR, "%s: Failed to initialize eDP\n", __func__); return -1; } - } else { + if (panel->get_edid && panel->get_edid(panel) < 0) + return -1; + u32 mipi_dsi_flags = (MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_SYNC_PULSE | MIPI_DSI_MODE_LPM | @@ -54,6 +54,11 @@ printk(BIOS_ERR, "%s: Failed in DSI init\n", __func__); return -1; } + + if (panel->post_power_on && panel->post_power_on(panel) < 0) { + printk(BIOS_ERR, "%s: Failed to post power on bridge\n", __func__); + return -1; + } }
name = edid.ascii_string; @@ -68,7 +73,7 @@ mtk_ddp_mode_set(&edid, panel->disp_path); info = fb_new_framebuffer_info_from_edid(&edid, (uintptr_t)0); if (info) - fb_set_orientation(info, LB_FB_ORIENTATION_BOTTOM_UP); + fb_set_orientation(info, panel->orientation);
return 0; } diff --git a/src/soc/mediatek/common/include/soc/ddp_common.h b/src/soc/mediatek/common/include/soc/ddp_common.h index 43893f7..a7edc05 100644 --- a/src/soc/mediatek/common/include/soc/ddp_common.h +++ b/src/soc/mediatek/common/include/soc/ddp_common.h @@ -139,4 +139,10 @@ void color_start(u32 width, u32 height); void ovl_layer_config(u32 fmt, u32 bpp, u32 width, u32 height);
+enum disp_path_sel { + DISP_PATH_NONE = 0, + DISP_PATH_EDP, + DISP_PATH_MIPI, +}; + #endif diff --git a/src/soc/mediatek/common/include/soc/display.h b/src/soc/mediatek/common/include/soc/display.h new file mode 100644 index 0000000..7de577a --- /dev/null +++ b/src/soc/mediatek/common/include/soc/display.h @@ -0,0 +1,25 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#ifndef __SOC_MEDIATEK_COMMON_DISPLAY_H__ +#define __SOC_MEDIATEK_COMMON_DISPLAY_H__ + +#include <commonlib/coreboot_tables.h> +#include <mipi/panel.h> +#include <soc/ddp.h> + +struct panel_description { + const char *name; + struct panel_serializable_data *s; + void (*configure_panel_backlight)(void); + void (*power_on)(void); + int (*get_edid)(const struct panel_description *panel); + int (*post_power_on)(const struct panel_description *panel); + enum lb_fb_orientation orientation; + enum disp_path_sel disp_path; + bool pwm_ctrl_gpio; +}; + +int configure_display(void); +struct panel_description *get_active_panel(void); + +#endif diff --git a/src/soc/mediatek/mt8188/Makefile.inc b/src/soc/mediatek/mt8188/Makefile.inc index 6a643b0..4731fab 100644 --- a/src/soc/mediatek/mt8188/Makefile.inc +++ b/src/soc/mediatek/mt8188/Makefile.inc @@ -37,6 +37,7 @@ ramstage-y += ../common/ddp.c ddp.c ramstage-y += ../common/devapc.c devapc.c ramstage-y += ../common/dfd.c +ramstage-y += ../common/display.c ramstage-y += ../common/dp/dp_intf.c ../common/dp/dptx.c ../common/dp/dptx_hal.c dp_intf.c ramstage-y += ../common/dpm.c ramstage-$(CONFIG_DPM_FOUR_CHANNEL) += ../common/dpm_4ch.c diff --git a/src/soc/mediatek/mt8188/include/soc/ddp.h b/src/soc/mediatek/mt8188/include/soc/ddp.h index da14a2c..1f167db 100644 --- a/src/soc/mediatek/mt8188/include/soc/ddp.h +++ b/src/soc/mediatek/mt8188/include/soc/ddp.h @@ -282,12 +282,6 @@ SMI_LARB_PORT_L0_OVL_RDMA0 = 0xF88, };
-enum disp_path_sel { - DISP_PATH_NONE = 0, - DISP_PATH_EDP, - DISP_PATH_MIPI, -}; - void mtk_ddp_init(void); void mtk_ddp_mode_set(const struct edid *edid, enum disp_path_sel);