Bo-Chen Chen | c1345d6 | 2022-09-29 17:32:02 +0800 | [diff] [blame] | 1 | /* 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 Chen | 7d94b2b | 2022-11-30 15:16:47 +0800 | [diff] [blame] | 10 | #include <soc/dsi.h> |
Bo-Chen Chen | c1345d6 | 2022-09-29 17:32:02 +0800 | [diff] [blame] | 11 | #include <soc/gpio_common.h> |
| 12 | #include <soc/mtcmos.h> |
| 13 | |
| 14 | #include "display.h" |
yangcong | 6538464 | 2023-03-02 20:59:30 +0800 | [diff] [blame] | 15 | #include "gpio.h" |
Bo-Chen Chen | 7d94b2b | 2022-11-30 15:16:47 +0800 | [diff] [blame] | 16 | #include "panel.h" |
Bo-Chen Chen | c1345d6 | 2022-09-29 17:32:02 +0800 | [diff] [blame] | 17 | |
| 18 | int configure_display(void) |
| 19 | { |
| 20 | struct edid edid; |
| 21 | struct fb_info *info; |
| 22 | const char *name; |
Bo-Chen Chen | 7d94b2b | 2022-11-30 15:16:47 +0800 | [diff] [blame] | 23 | struct panel_description *panel = get_active_panel(); |
| 24 | if (!panel) |
| 25 | return -1; |
Bo-Chen Chen | c1345d6 | 2022-09-29 17:32:02 +0800 | [diff] [blame] | 26 | |
| 27 | printk(BIOS_INFO, "%s: Starting display initialization\n", __func__); |
| 28 | |
| 29 | mtcmos_display_power_on(); |
Liju-Clr Chen | bc1fde3 | 2023-03-02 15:47:15 +0800 | [diff] [blame] | 30 | mtcmos_protect_display_bus(); |
Bo-Chen Chen | 7d94b2b | 2022-11-30 15:16:47 +0800 | [diff] [blame] | 31 | |
| 32 | panel->configure_panel_backlight(); |
| 33 | panel->power_on(); |
Bo-Chen Chen | c1345d6 | 2022-09-29 17:32:02 +0800 | [diff] [blame] | 34 | |
| 35 | mtk_ddp_init(); |
| 36 | mdelay(200); |
| 37 | |
Bo-Chen Chen | 7d94b2b | 2022-11-30 15:16:47 +0800 | [diff] [blame] | 38 | if (panel->disp_path == DISP_PATH_EDP) { |
| 39 | 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 Chen | c1345d6 | 2022-09-29 17:32:02 +0800 | [diff] [blame] | 57 | } |
Bo-Chen Chen | 7d94b2b | 2022-11-30 15:16:47 +0800 | [diff] [blame] | 58 | |
Bo-Chen Chen | c1345d6 | 2022-09-29 17:32:02 +0800 | [diff] [blame] | 59 | 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 Chen | 7d94b2b | 2022-11-30 15:16:47 +0800 | [diff] [blame] | 68 | mtk_ddp_mode_set(&edid, panel->disp_path); |
Bo-Chen Chen | c1345d6 | 2022-09-29 17:32:02 +0800 | [diff] [blame] | 69 | info = fb_new_framebuffer_info_from_edid(&edid, (uintptr_t)0); |
| 70 | if (info) |
Yidi Lin | 13ed70f | 2023-03-23 17:14:08 +0800 | [diff] [blame] | 71 | fb_set_orientation(info, LB_FB_ORIENTATION_BOTTOM_UP); |
Bo-Chen Chen | c1345d6 | 2022-09-29 17:32:02 +0800 | [diff] [blame] | 72 | |
| 73 | return 0; |
| 74 | } |