From f2c259cf2a16714bd2695507b9241080de660e05 Mon Sep 17 00:00:00 2001 From: Jitao Shi Date: Thu, 3 Jun 2021 13:51:29 +0800 Subject: [PATCH] mb/google/cherry: enable display support To enable display, we have to: 1. Configure panel power and backlight 2. Configure eDP driver BUG=b:189985956 Signed-off-by: Jitao Shi Change-Id: Ida6c157a6a3bd904d3fa3dd2001385ced34f7711 Reviewed-on: https://review.coreboot.org/c/coreboot/+/55574 Reviewed-by: Yu-Ping Wu Reviewed-by: Hung-Te Lin Tested-by: build bot (Jenkins) --- src/mainboard/google/cherry/mainboard.c | 68 +++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/src/mainboard/google/cherry/mainboard.c b/src/mainboard/google/cherry/mainboard.c index 04f4293308..a454adfd8a 100644 --- a/src/mainboard/google/cherry/mainboard.c +++ b/src/mainboard/google/cherry/mainboard.c @@ -6,10 +6,15 @@ #include #include #include +#include +#include #include +#include +#include #include #include #include +#include #include #include #include @@ -18,6 +23,12 @@ #include +/* GPIO to schematics names */ +#define GPIO_AP_EDP_BKLTEN GPIO(DGI_D5) +#define GPIO_BL_PWM_1V8 GPIO(DISP_PWM0) +#define GPIO_EDP_HPD_1V8 GPIO(GPIO_07) +#define GPIO_EN_PP3300_DISP_X GPIO(I2SO1_D2) + DEFINE_BITFIELD(MSDC0_DRV, 29, 0) DEFINE_BITFIELD(MSDC1_DRV, 17, 0) DEFINE_BITFIELD(MSDC1_GPIO_MODE0_0, 26, 24) @@ -119,8 +130,65 @@ static void configure_sdcard(void) mt6360_ldo_enable(MT6360_LDO5, 1); } +/* Set up backlight control pins as output pin and power-off by default */ +static void configure_panel_backlight(void) +{ + gpio_output(GPIO_AP_EDP_BKLTEN, 0); + gpio_output(GPIO_BL_PWM_1V8, 0); +} + +static void power_on_panel(void) +{ + /* Default power sequence for most panels. */ + gpio_set_pull(GPIO_EDP_HPD_1V8, GPIO_PULL_ENABLE, GPIO_PULL_UP); + gpio_set_mode(GPIO_EDP_HPD_1V8, 2); + gpio_output(GPIO_EN_PP3300_DISP_X, 1); +} + +static bool configure_display(void) +{ + struct edid edid; + struct fb_info *info; + const char *name; + + printk(BIOS_INFO, "%s: Starting display initialization\n", __func__); + + mtcmos_display_power_on(); + mtcmos_protect_display_bus(); + configure_panel_backlight(); + power_on_panel(); + + mtk_ddp_init(); + mdelay(200); + + if (mtk_edp_init(&edid) < 0) { + printk(BIOS_ERR, "%s: Failed to initialize eDP\n", __func__); + return false; + } + name = edid.ascii_string; + if (name[0] == '\0') + name = "unknown name"; + printk(BIOS_INFO, "%s: '%s %s' %dx%d@%dHz\n", __func__, + edid.manufacturer_name, name, edid.mode.ha, edid.mode.va, + edid.mode.refresh); + + edid_set_framebuffer_bits_per_pixel(&edid, 32, 0); + + mtk_ddp_mode_set(&edid); + info = fb_new_framebuffer_info_from_edid(&edid, (uintptr_t)0); + if (info) + fb_set_orientation(info, LB_FB_ORIENTATION_NORMAL); + + return true; +} + static void mainboard_init(struct device *dev) { + if (display_init_required()) + configure_display(); + else + printk(BIOS_INFO, "%s: Skipped display initialization\n", __func__); + configure_emmc(); configure_sdcard(); setup_usb_host();