blob: 1bc9b7cc7e1591061afbea0b3cc8a6ba8682b475 [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>
Simon Glass0af6e2d2019-08-01 09:46:52 -06004#include <env.h>
Masahiro Yamada56a931c2016-09-21 11:28:55 +09005#include <linux/errno.h>
Stefano Babic33731bc2017-06-29 10:16:06 +02006#include <asm/mach-imx/video.h>
Eric Benard4c94fa12014-04-04 19:05:52 +02007
Anatolij Gustschin983e2f2a2019-03-18 23:29:31 +01008#ifdef CONFIG_IMX_HDMI
9#include <asm/arch/mxc_hdmi.h>
10#include <asm/io.h>
11
12int 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 Benard4c94fa12014-04-04 19:05:52 +020019int board_video_skip(void)
20{
21 int i;
Ye Li534e0b52019-01-04 09:11:05 +000022 int ret = 0;
Simon Glass64b723f2017-08-03 12:22:12 -060023 char const *panel = env_get("panel");
Nikolay Dimitrov84c6af82014-11-05 10:55:33 +020024
Eric Benard4c94fa12014-04-04 19:05:52 +020025 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 Dimitrov84c6af82014-11-05 10:55:33 +020045
Eric Benard4c94fa12014-04-04 19:05:52 +020046 if (i < display_count) {
Max Krummenacher27c01b92016-11-01 15:04:21 +010047 ret = ipuv3_fb_init(&displays[i].mode, displays[i].di ? 1 : 0,
Eric Benard4c94fa12014-04-04 19:05:52 +020048 displays[i].pixfmt);
49 if (!ret) {
Nikolay Dimitrov84c6af82014-11-05 10:55:33 +020050 if (displays[i].enable)
51 displays[i].enable(displays + i);
52
Eric Benard4c94fa12014-04-04 19:05:52 +020053 printf("Display: %s (%ux%u)\n",
54 displays[i].mode.name,
55 displays[i].mode.xres,
56 displays[i].mode.yres);
Anatolij Gustschin983e2f2a2019-03-18 23:29:31 +010057
58#ifdef CONFIG_IMX_HDMI
59 if (!strcmp(displays[i].mode.name, "HDMI"))
60 imx_enable_hdmi_phy();
61#endif
Eric Benard4c94fa12014-04-04 19:05:52 +020062 } 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 Li534e0b52019-01-04 09:11:05 +000070 return ret;
Eric Benard4c94fa12014-04-04 19:05:52 +020071}
Eric Benardad0f1d52014-04-04 19:05:56 +020072
Anatolij Gustschin983e2f2a2019-03-18 23:29:31 +010073int ipu_displays_init(void)
Eric Benardad0f1d52014-04-04 19:05:56 +020074{
Anatolij Gustschin983e2f2a2019-03-18 23:29:31 +010075 return board_video_skip();
Eric Benardad0f1d52014-04-04 19:05:56 +020076}