blob: 995fb9a9abb6e06e9bd907c5754fc34064404290 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Vikram Narayanan9ddfa242012-11-10 02:28:52 +00002/*
3 * Copyright (C) 2012 Freescale Semiconductor, Inc.
4 * Fabio Estevam <fabio.estevam@freescale.com>
Vikram Narayanan9ddfa242012-11-10 02:28:52 +00005 */
6
7#include <common.h>
8#include <linux/list.h>
9#include <asm/gpio.h>
Benoît Thébaudeau168dc712013-05-03 10:32:27 +000010#include <asm/arch/iomux-mx51.h>
Vikram Narayanan9ddfa242012-11-10 02:28:52 +000011#include <linux/fb.h>
12#include <ipu_pixfmt.h>
13
14#define MX51EVK_LCD_3V3 IMX_GPIO_NR(4, 9)
15#define MX51EVK_LCD_5V IMX_GPIO_NR(4, 10)
16#define MX51EVK_LCD_BACKLIGHT IMX_GPIO_NR(3, 4)
17
18static struct fb_videomode const claa_wvga = {
19 .name = "CLAA07LC0ACW",
20 .refresh = 57,
21 .xres = 800,
22 .yres = 480,
23 .pixclock = 37037,
24 .left_margin = 40,
25 .right_margin = 60,
26 .upper_margin = 10,
27 .lower_margin = 10,
28 .hsync_len = 20,
29 .vsync_len = 10,
30 .sync = 0,
31 .vmode = FB_VMODE_NONINTERLACED
32};
33
Fabio Estevamc74d3232013-01-09 04:55:09 +000034static struct fb_videomode const dvi = {
35 .name = "DVI panel",
36 .refresh = 60,
37 .xres = 1024,
38 .yres = 768,
39 .pixclock = 15385,
40 .left_margin = 220,
41 .right_margin = 40,
42 .upper_margin = 21,
43 .lower_margin = 7,
44 .hsync_len = 60,
45 .vsync_len = 10,
46 .sync = 0,
47 .vmode = FB_VMODE_NONINTERLACED
48};
49
Vikram Narayanan9ddfa242012-11-10 02:28:52 +000050void setup_iomux_lcd(void)
51{
52 /* DI2_PIN15 */
Benoît Thébaudeau168dc712013-05-03 10:32:27 +000053 imx_iomux_v3_setup_pad(MX51_PAD_DI_GP4__DI2_PIN15);
Vikram Narayanan9ddfa242012-11-10 02:28:52 +000054
Benoît Thébaudeau168dc712013-05-03 10:32:27 +000055 /* Pad settings for DI2_DISP_CLK */
56 imx_iomux_v3_setup_pad(NEW_PAD_CTRL(MX51_PAD_DI2_DISP_CLK__DI2_DISP_CLK,
57 PAD_CTL_PKE | PAD_CTL_DSE_MAX | PAD_CTL_SRE_SLOW));
Vikram Narayanan9ddfa242012-11-10 02:28:52 +000058
59 /* Turn on 3.3V voltage for LCD */
Benoît Thébaudeau168dc712013-05-03 10:32:27 +000060 imx_iomux_v3_setup_pad(NEW_PAD_CTRL(MX51_PAD_CSI2_D12__GPIO4_9,
61 NO_PAD_CTRL));
Vikram Narayanan9ddfa242012-11-10 02:28:52 +000062 gpio_direction_output(MX51EVK_LCD_3V3, 1);
63
64 /* Turn on 5V voltage for LCD */
Benoît Thébaudeau168dc712013-05-03 10:32:27 +000065 imx_iomux_v3_setup_pad(NEW_PAD_CTRL(MX51_PAD_CSI2_D13__GPIO4_10,
66 NO_PAD_CTRL));
Vikram Narayanan9ddfa242012-11-10 02:28:52 +000067 gpio_direction_output(MX51EVK_LCD_5V, 1);
68
69 /* Turn on GPIO backlight */
Benoît Thébaudeau168dc712013-05-03 10:32:27 +000070 imx_iomux_v3_setup_pad(NEW_PAD_CTRL(MX51_PAD_DI1_D1_CS__GPIO3_4,
71 NO_PAD_CTRL));
Vikram Narayanan9ddfa242012-11-10 02:28:52 +000072 gpio_direction_output(MX51EVK_LCD_BACKLIGHT, 1);
73}
74
Fabio Estevamc74d3232013-01-09 04:55:09 +000075int board_video_skip(void)
Vikram Narayanan9ddfa242012-11-10 02:28:52 +000076{
Fabio Estevamc74d3232013-01-09 04:55:09 +000077 int ret;
Simon Glass64b723f2017-08-03 12:22:12 -060078 char const *e = env_get("panel");
Fabio Estevamc74d3232013-01-09 04:55:09 +000079
80 if (e) {
81 if (strcmp(e, "claa") == 0) {
82 ret = ipuv3_fb_init(&claa_wvga, 1, IPU_PIX_FMT_RGB565);
83 if (ret)
84 printf("claa cannot be configured: %d\n", ret);
85 return ret;
86 }
87 }
88
89 /*
90 * 'panel' env variable not found or has different value than 'claa'
91 * Defaulting to dvi output.
92 */
93 ret = ipuv3_fb_init(&dvi, 0, IPU_PIX_FMT_RGB24);
Vikram Narayanan9ddfa242012-11-10 02:28:52 +000094 if (ret)
Fabio Estevamc74d3232013-01-09 04:55:09 +000095 printf("dvi cannot be configured: %d\n", ret);
96 return ret;
Vikram Narayanan9ddfa242012-11-10 02:28:52 +000097}