Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Eric Benard | 93ad66c | 2014-04-04 19:05:52 +0200 | [diff] [blame] | 2 | |
| 3 | #include <common.h> |
Masahiro Yamada | 1221ce4 | 2016-09-21 11:28:55 +0900 | [diff] [blame] | 4 | #include <linux/errno.h> |
Stefano Babic | 552a848 | 2017-06-29 10:16:06 +0200 | [diff] [blame] | 5 | #include <asm/mach-imx/video.h> |
Eric Benard | 93ad66c | 2014-04-04 19:05:52 +0200 | [diff] [blame] | 6 | |
Anatolij Gustschin | 57f065f | 2019-03-18 23:29:31 +0100 | [diff] [blame] | 7 | #ifdef CONFIG_IMX_HDMI |
| 8 | #include <asm/arch/mxc_hdmi.h> |
| 9 | #include <asm/io.h> |
| 10 | |
| 11 | int detect_hdmi(struct display_info_t const *dev) |
| 12 | { |
| 13 | struct hdmi_regs *hdmi = (struct hdmi_regs *)HDMI_ARB_BASE_ADDR; |
| 14 | return readb(&hdmi->phy_stat0) & HDMI_DVI_STAT; |
| 15 | } |
| 16 | #endif |
| 17 | |
Eric Benard | 93ad66c | 2014-04-04 19:05:52 +0200 | [diff] [blame] | 18 | int board_video_skip(void) |
| 19 | { |
| 20 | int i; |
Ye Li | 3fd3993 | 2019-01-04 09:11:05 +0000 | [diff] [blame] | 21 | int ret = 0; |
Simon Glass | 00caae6 | 2017-08-03 12:22:12 -0600 | [diff] [blame] | 22 | char const *panel = env_get("panel"); |
Nikolay Dimitrov | 11076f0 | 2014-11-05 10:55:33 +0200 | [diff] [blame] | 23 | |
Eric Benard | 93ad66c | 2014-04-04 19:05:52 +0200 | [diff] [blame] | 24 | if (!panel) { |
| 25 | for (i = 0; i < display_count; i++) { |
| 26 | struct display_info_t const *dev = displays+i; |
| 27 | if (dev->detect && dev->detect(dev)) { |
| 28 | panel = dev->mode.name; |
| 29 | printf("auto-detected panel %s\n", panel); |
| 30 | break; |
| 31 | } |
| 32 | } |
| 33 | if (!panel) { |
| 34 | panel = displays[0].mode.name; |
| 35 | printf("No panel detected: default to %s\n", panel); |
| 36 | i = 0; |
| 37 | } |
| 38 | } else { |
| 39 | for (i = 0; i < display_count; i++) { |
| 40 | if (!strcmp(panel, displays[i].mode.name)) |
| 41 | break; |
| 42 | } |
| 43 | } |
Nikolay Dimitrov | 11076f0 | 2014-11-05 10:55:33 +0200 | [diff] [blame] | 44 | |
Eric Benard | 93ad66c | 2014-04-04 19:05:52 +0200 | [diff] [blame] | 45 | if (i < display_count) { |
Max Krummenacher | 15fde0f | 2016-11-01 15:04:21 +0100 | [diff] [blame] | 46 | ret = ipuv3_fb_init(&displays[i].mode, displays[i].di ? 1 : 0, |
Eric Benard | 93ad66c | 2014-04-04 19:05:52 +0200 | [diff] [blame] | 47 | displays[i].pixfmt); |
| 48 | if (!ret) { |
Nikolay Dimitrov | 11076f0 | 2014-11-05 10:55:33 +0200 | [diff] [blame] | 49 | if (displays[i].enable) |
| 50 | displays[i].enable(displays + i); |
| 51 | |
Eric Benard | 93ad66c | 2014-04-04 19:05:52 +0200 | [diff] [blame] | 52 | printf("Display: %s (%ux%u)\n", |
| 53 | displays[i].mode.name, |
| 54 | displays[i].mode.xres, |
| 55 | displays[i].mode.yres); |
Anatolij Gustschin | 57f065f | 2019-03-18 23:29:31 +0100 | [diff] [blame] | 56 | |
| 57 | #ifdef CONFIG_IMX_HDMI |
| 58 | if (!strcmp(displays[i].mode.name, "HDMI")) |
| 59 | imx_enable_hdmi_phy(); |
| 60 | #endif |
Eric Benard | 93ad66c | 2014-04-04 19:05:52 +0200 | [diff] [blame] | 61 | } else |
| 62 | printf("LCD %s cannot be configured: %d\n", |
| 63 | displays[i].mode.name, ret); |
| 64 | } else { |
| 65 | printf("unsupported panel %s\n", panel); |
| 66 | return -EINVAL; |
| 67 | } |
| 68 | |
Ye Li | 3fd3993 | 2019-01-04 09:11:05 +0000 | [diff] [blame] | 69 | return ret; |
Eric Benard | 93ad66c | 2014-04-04 19:05:52 +0200 | [diff] [blame] | 70 | } |
Eric Benard | e688a99 | 2014-04-04 19:05:56 +0200 | [diff] [blame] | 71 | |
Anatolij Gustschin | 57f065f | 2019-03-18 23:29:31 +0100 | [diff] [blame] | 72 | int ipu_displays_init(void) |
Eric Benard | e688a99 | 2014-04-04 19:05:56 +0200 | [diff] [blame] | 73 | { |
Anatolij Gustschin | 57f065f | 2019-03-18 23:29:31 +0100 | [diff] [blame] | 74 | return board_video_skip(); |
Eric Benard | e688a99 | 2014-04-04 19:05:56 +0200 | [diff] [blame] | 75 | } |