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