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