blob: 6cbb49da53cc1c6d26eb4ae315dcbf96580f2eb7 [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
Tom Rini5ab32a02024-04-30 07:35:49 -06003#include <stdio.h>
Simon Glass0af6e2d2019-08-01 09:46:52 -06004#include <env.h>
Masahiro Yamada56a931c2016-09-21 11:28:55 +09005#include <linux/errno.h>
Tom Rini5ab32a02024-04-30 07:35:49 -06006#include <asm/arch/imx-regs.h>
Stefano Babic33731bc2017-06-29 10:16:06 +02007#include <asm/mach-imx/video.h>
Eric Benard4c94fa12014-04-04 19:05:52 +02008
Anatolij Gustschin983e2f2a2019-03-18 23:29:31 +01009#ifdef CONFIG_IMX_HDMI
10#include <asm/arch/mxc_hdmi.h>
11#include <asm/io.h>
12
13int 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 Benard4c94fa12014-04-04 19:05:52 +020020int board_video_skip(void)
21{
22 int i;
Ye Li534e0b52019-01-04 09:11:05 +000023 int ret = 0;
Simon Glass64b723f2017-08-03 12:22:12 -060024 char const *panel = env_get("panel");
Nikolay Dimitrov84c6af82014-11-05 10:55:33 +020025
Eric Benard4c94fa12014-04-04 19:05:52 +020026 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 Dimitrov84c6af82014-11-05 10:55:33 +020046
Eric Benard4c94fa12014-04-04 19:05:52 +020047 if (i < display_count) {
Max Krummenacher27c01b92016-11-01 15:04:21 +010048 ret = ipuv3_fb_init(&displays[i].mode, displays[i].di ? 1 : 0,
Eric Benard4c94fa12014-04-04 19:05:52 +020049 displays[i].pixfmt);
50 if (!ret) {
Nikolay Dimitrov84c6af82014-11-05 10:55:33 +020051 if (displays[i].enable)
52 displays[i].enable(displays + i);
53
Eric Benard4c94fa12014-04-04 19:05:52 +020054 printf("Display: %s (%ux%u)\n",
55 displays[i].mode.name,
56 displays[i].mode.xres,
57 displays[i].mode.yres);
Anatolij Gustschin983e2f2a2019-03-18 23:29:31 +010058
59#ifdef CONFIG_IMX_HDMI
60 if (!strcmp(displays[i].mode.name, "HDMI"))
61 imx_enable_hdmi_phy();
62#endif
Eric Benard4c94fa12014-04-04 19:05:52 +020063 } 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 Li534e0b52019-01-04 09:11:05 +000071 return ret;
Eric Benard4c94fa12014-04-04 19:05:52 +020072}
Eric Benardad0f1d52014-04-04 19:05:56 +020073
Anatolij Gustschin983e2f2a2019-03-18 23:29:31 +010074int ipu_displays_init(void)
Eric Benardad0f1d52014-04-04 19:05:56 +020075{
Anatolij Gustschin983e2f2a2019-03-18 23:29:31 +010076 return board_video_skip();
Eric Benardad0f1d52014-04-04 19:05:56 +020077}