blob: 68a0a222312a50876907f3259191b5756b76e90a [file] [log] [blame]
Bo-Chen Chenc1345d62022-09-29 17:32:02 +08001/* SPDX-License-Identifier: GPL-2.0-only */
2
3#include <console/console.h>
4#include <delay.h>
5#include <edid.h>
6#include <framebuffer_info.h>
7#include <gpio.h>
8#include <soc/ddp.h>
9#include <soc/dptx.h>
Bo-Chen Chen7d94b2b2022-11-30 15:16:47 +080010#include <soc/dsi.h>
Bo-Chen Chenc1345d62022-09-29 17:32:02 +080011#include <soc/gpio_common.h>
12#include <soc/mtcmos.h>
13
14#include "display.h"
yangcong65384642023-03-02 20:59:30 +080015#include "gpio.h"
Bo-Chen Chen7d94b2b2022-11-30 15:16:47 +080016#include "panel.h"
Bo-Chen Chenc1345d62022-09-29 17:32:02 +080017
18int configure_display(void)
19{
20 struct edid edid;
21 struct fb_info *info;
22 const char *name;
Bo-Chen Chen7d94b2b2022-11-30 15:16:47 +080023 struct panel_description *panel = get_active_panel();
24 if (!panel)
25 return -1;
Bo-Chen Chenc1345d62022-09-29 17:32:02 +080026
27 printk(BIOS_INFO, "%s: Starting display initialization\n", __func__);
28
29 mtcmos_display_power_on();
Liju-Clr Chenbc1fde32023-03-02 15:47:15 +080030 mtcmos_protect_display_bus();
Bo-Chen Chen7d94b2b2022-11-30 15:16:47 +080031
32 panel->configure_panel_backlight();
33 panel->power_on();
Bo-Chen Chenc1345d62022-09-29 17:32:02 +080034
35 mtk_ddp_init();
Bo-Chen Chenc1345d62022-09-29 17:32:02 +080036
Bo-Chen Chen7d94b2b2022-11-30 15:16:47 +080037 if (panel->disp_path == DISP_PATH_EDP) {
Yidi Linec1a8802023-11-14 15:56:48 +080038 mdelay(200);
Bo-Chen Chen7d94b2b2022-11-30 15:16:47 +080039 if (mtk_edp_init(&edid) < 0) {
40 printk(BIOS_ERR, "%s: Failed to initialize eDP\n", __func__);
41 return -1;
42 }
43
44 } else {
45 u32 mipi_dsi_flags = (MIPI_DSI_MODE_VIDEO |
46 MIPI_DSI_MODE_VIDEO_SYNC_PULSE |
47 MIPI_DSI_MODE_LPM |
48 MIPI_DSI_MODE_EOT_PACKET);
49
50 edid = panel->s->edid;
51
52 if (mtk_dsi_init(mipi_dsi_flags, MIPI_DSI_FMT_RGB888, 4, &edid,
53 panel->s->init) < 0) {
54 printk(BIOS_ERR, "%s: Failed in DSI init\n", __func__);
55 return -1;
56 }
Bo-Chen Chenc1345d62022-09-29 17:32:02 +080057 }
Bo-Chen Chen7d94b2b2022-11-30 15:16:47 +080058
Bo-Chen Chenc1345d62022-09-29 17:32:02 +080059 name = edid.ascii_string;
60 if (name[0] == '\0')
61 name = "unknown name";
62 printk(BIOS_INFO, "%s: '%s %s' %dx%d@%dHz\n", __func__,
63 edid.manufacturer_name, name, edid.mode.ha, edid.mode.va,
64 edid.mode.refresh);
65
66 edid_set_framebuffer_bits_per_pixel(&edid, 32, 0);
67
Bo-Chen Chen7d94b2b2022-11-30 15:16:47 +080068 mtk_ddp_mode_set(&edid, panel->disp_path);
Bo-Chen Chenc1345d62022-09-29 17:32:02 +080069 info = fb_new_framebuffer_info_from_edid(&edid, (uintptr_t)0);
70 if (info)
Yidi Lin13ed70f2023-03-23 17:14:08 +080071 fb_set_orientation(info, LB_FB_ORIENTATION_BOTTOM_UP);
Bo-Chen Chenc1345d62022-09-29 17:32:02 +080072
73 return 0;
74}