blob: 22a371a212d6c471d8fc6b5854152c3d738cf651 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Eric Benard4c94fa12014-04-04 19:05:52 +02002
3#include <common.h>
Masahiro Yamada56a931c2016-09-21 11:28:55 +09004#include <linux/errno.h>
Stefano Babic33731bc2017-06-29 10:16:06 +02005#include <asm/mach-imx/video.h>
Eric Benard4c94fa12014-04-04 19:05:52 +02006
Anatolij Gustschin983e2f2a2019-03-18 23:29:31 +01007#ifdef CONFIG_IMX_HDMI
8#include <asm/arch/mxc_hdmi.h>
9#include <asm/io.h>
10
11int 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 Benard4c94fa12014-04-04 19:05:52 +020018int board_video_skip(void)
19{
20 int i;
Ye Li534e0b52019-01-04 09:11:05 +000021 int ret = 0;
Simon Glass64b723f2017-08-03 12:22:12 -060022 char const *panel = env_get("panel");
Nikolay Dimitrov84c6af82014-11-05 10:55:33 +020023
Eric Benard4c94fa12014-04-04 19:05:52 +020024 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 Dimitrov84c6af82014-11-05 10:55:33 +020044
Eric Benard4c94fa12014-04-04 19:05:52 +020045 if (i < display_count) {
Max Krummenacher27c01b92016-11-01 15:04:21 +010046 ret = ipuv3_fb_init(&displays[i].mode, displays[i].di ? 1 : 0,
Eric Benard4c94fa12014-04-04 19:05:52 +020047 displays[i].pixfmt);
48 if (!ret) {
Nikolay Dimitrov84c6af82014-11-05 10:55:33 +020049 if (displays[i].enable)
50 displays[i].enable(displays + i);
51
Eric Benard4c94fa12014-04-04 19:05:52 +020052 printf("Display: %s (%ux%u)\n",
53 displays[i].mode.name,
54 displays[i].mode.xres,
55 displays[i].mode.yres);
Anatolij Gustschin983e2f2a2019-03-18 23:29:31 +010056
57#ifdef CONFIG_IMX_HDMI
58 if (!strcmp(displays[i].mode.name, "HDMI"))
59 imx_enable_hdmi_phy();
60#endif
Eric Benard4c94fa12014-04-04 19:05:52 +020061 } 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 Li534e0b52019-01-04 09:11:05 +000069 return ret;
Eric Benard4c94fa12014-04-04 19:05:52 +020070}
Eric Benardad0f1d52014-04-04 19:05:56 +020071
Anatolij Gustschin983e2f2a2019-03-18 23:29:31 +010072int ipu_displays_init(void)
Eric Benardad0f1d52014-04-04 19:05:56 +020073{
Anatolij Gustschin983e2f2a2019-03-18 23:29:31 +010074 return board_video_skip();
Eric Benardad0f1d52014-04-04 19:05:56 +020075}