1 /* SPDX-License-Identifier: GPL-2.0-only */
4 #include <console/console.h>
7 #include <framebuffer_info.h>
9 #include <soc/display.h>
12 #include <soc/mtcmos.h>
15 static struct panel_serializable_data
*get_mipi_cmd_from_cbfs(struct panel_description
*desc
)
18 * The CBFS file name is panel-{MANUFACTURER}-${PANEL_NAME}, where MANUFACTURER is 3
19 * characters and PANEL_NAME is usually 13 characters.
23 u8 raw
[4 * 1024]; /* Most panels only need < 2K. */
24 struct panel_serializable_data s
;
28 printk(BIOS_ERR
, "Missing panel CBFS file name.\n");
32 snprintf(cbfs_name
, sizeof(cbfs_name
), "panel-%s", desc
->name
);
33 if (cbfs_load(cbfs_name
, buffer
.raw
, sizeof(buffer
)))
36 printk(BIOS_ERR
, "Missing %s in CBFS.\n", cbfs_name
);
40 __weak
int mtk_edp_init(struct edid
*edid
)
42 printk(BIOS_WARNING
, "%s: Not supported\n", __func__
);
46 __weak
int mtk_dsi_init(u32 mode_flags
, u32 format
, u32 lanes
,
47 const struct edid
*edid
, const u8
*init_commands
)
49 printk(BIOS_WARNING
, "%s: Not supported\n", __func__
);
53 int mtk_display_init(void)
58 struct panel_description
*panel
= get_active_panel();
60 if (!panel
|| panel
->disp_path
== DISP_PATH_NONE
) {
61 printk(BIOS_ERR
, "%s: Failed to get the active panel\n", __func__
);
65 printk(BIOS_INFO
, "%s: Starting display initialization\n", __func__
);
67 mtcmos_display_power_on();
68 mtcmos_protect_display_bus();
70 if (panel
->configure_backlight
)
71 panel
->configure_backlight();
77 if (panel
->disp_path
== DISP_PATH_EDP
) {
79 if (mtk_edp_init(&edid
) < 0) {
80 printk(BIOS_ERR
, "%s: Failed to initialize eDP\n", __func__
);
84 struct panel_serializable_data
*mipi_data
= NULL
;
86 if (panel
->get_edid
) {
87 if (panel
->get_edid(&edid
) < 0)
90 mipi_data
= get_mipi_cmd_from_cbfs(panel
);
93 edid
= mipi_data
->edid
;
96 u32 mipi_dsi_flags
= (MIPI_DSI_MODE_VIDEO
|
97 MIPI_DSI_MODE_VIDEO_SYNC_PULSE
|
99 MIPI_DSI_MODE_EOT_PACKET
);
101 if (mtk_dsi_init(mipi_dsi_flags
, MIPI_DSI_FMT_RGB888
, 4, &edid
,
102 mipi_data
? mipi_data
->init
: NULL
) < 0) {
103 printk(BIOS_ERR
, "%s: Failed in DSI init\n", __func__
);
107 if (panel
->post_power_on
&& panel
->post_power_on(&edid
) < 0) {
108 printk(BIOS_ERR
, "%s: Failed to post power on bridge\n", __func__
);
113 name
= edid
.ascii_string
;
115 name
= "unknown name";
116 printk(BIOS_INFO
, "%s: '%s %s' %dx%d@%dHz\n", __func__
,
117 edid
.manufacturer_name
, name
, edid
.mode
.ha
, edid
.mode
.va
,
120 edid_set_framebuffer_bits_per_pixel(&edid
, 32, 0);
122 mtk_ddp_mode_set(&edid
, panel
->disp_path
);
123 info
= fb_new_framebuffer_info_from_edid(&edid
, (uintptr_t)0);
125 fb_set_orientation(info
, panel
->orientation
);