blob: 22a371a212d6c471d8fc6b5854152c3d738cf651 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Eric Benard93ad66c2014-04-04 19:05:52 +02002
3#include <common.h>
Masahiro Yamada1221ce42016-09-21 11:28:55 +09004#include <linux/errno.h>
Stefano Babic552a8482017-06-29 10:16:06 +02005#include <asm/mach-imx/video.h>
Eric Benard93ad66c2014-04-04 19:05:52 +02006
Anatolij Gustschin57f065f2019-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 Benard93ad66c2014-04-04 19:05:52 +020018int board_video_skip(void)
19{
20 int i;
Ye Li3fd39932019-01-04 09:11:05 +000021 int ret = 0;
Simon Glass00caae62017-08-03 12:22:12 -060022 char const *panel = env_get("panel");
Nikolay Dimitrov11076f02014-11-05 10:55:33 +020023
Eric Benard93ad66c2014-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 Dimitrov11076f02014-11-05 10:55:33 +020044
Eric Benard93ad66c2014-04-04 19:05:52 +020045 if (i < display_count) {
Max Krummenacher15fde0f2016-11-01 15:04:21 +010046 ret = ipuv3_fb_init(&displays[i].mode, displays[i].di ? 1 : 0,
Eric Benard93ad66c2014-04-04 19:05:52 +020047 displays[i].pixfmt);
48 if (!ret) {
Nikolay Dimitrov11076f02014-11-05 10:55:33 +020049 if (displays[i].enable)
50 displays[i].enable(displays + i);
51
Eric Benard93ad66c2014-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 Gustschin57f065f2019-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 Benard93ad66c2014-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 Li3fd39932019-01-04 09:11:05 +000069 return ret;
Eric Benard93ad66c2014-04-04 19:05:52 +020070}
Eric Benarde688a992014-04-04 19:05:56 +020071
Anatolij Gustschin57f065f2019-03-18 23:29:31 +010072int ipu_displays_init(void)
Eric Benarde688a992014-04-04 19:05:56 +020073{
Anatolij Gustschin57f065f2019-03-18 23:29:31 +010074 return board_video_skip();
Eric Benarde688a992014-04-04 19:05:56 +020075}