blob: 3715c5d738f90176feb86dcf0326ea379d7a68c9 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Vikram Narayanan5d71bd22012-11-10 02:28:52 +00002/*
3 * Copyright (C) 2012 Freescale Semiconductor, Inc.
4 * Fabio Estevam <fabio.estevam@freescale.com>
Vikram Narayanan5d71bd22012-11-10 02:28:52 +00005 */
6
7#include <common.h>
Simon Glass7b51b572019-08-01 09:46:52 -06008#include <env.h>
Vikram Narayanan5d71bd22012-11-10 02:28:52 +00009#include <linux/list.h>
10#include <asm/gpio.h>
Benoît Thébaudeau4d15d362013-05-03 10:32:27 +000011#include <asm/arch/iomux-mx51.h>
Vikram Narayanan5d71bd22012-11-10 02:28:52 +000012#include <linux/fb.h>
13#include <ipu_pixfmt.h>
14
15#define MX51EVK_LCD_3V3 IMX_GPIO_NR(4, 9)
16#define MX51EVK_LCD_5V IMX_GPIO_NR(4, 10)
17#define MX51EVK_LCD_BACKLIGHT IMX_GPIO_NR(3, 4)
18
19static struct fb_videomode const claa_wvga = {
20 .name = "CLAA07LC0ACW",
21 .refresh = 57,
22 .xres = 800,
23 .yres = 480,
24 .pixclock = 37037,
25 .left_margin = 40,
26 .right_margin = 60,
27 .upper_margin = 10,
28 .lower_margin = 10,
29 .hsync_len = 20,
30 .vsync_len = 10,
31 .sync = 0,
32 .vmode = FB_VMODE_NONINTERLACED
33};
34
Fabio Estevam11d80af2013-01-09 04:55:09 +000035static struct fb_videomode const dvi = {
36 .name = "DVI panel",
37 .refresh = 60,
38 .xres = 1024,
39 .yres = 768,
40 .pixclock = 15385,
41 .left_margin = 220,
42 .right_margin = 40,
43 .upper_margin = 21,
44 .lower_margin = 7,
45 .hsync_len = 60,
46 .vsync_len = 10,
47 .sync = 0,
48 .vmode = FB_VMODE_NONINTERLACED
49};
50
Vikram Narayanan5d71bd22012-11-10 02:28:52 +000051void setup_iomux_lcd(void)
52{
53 /* DI2_PIN15 */
Benoît Thébaudeau4d15d362013-05-03 10:32:27 +000054 imx_iomux_v3_setup_pad(MX51_PAD_DI_GP4__DI2_PIN15);
Vikram Narayanan5d71bd22012-11-10 02:28:52 +000055
Benoît Thébaudeau4d15d362013-05-03 10:32:27 +000056 /* Pad settings for DI2_DISP_CLK */
57 imx_iomux_v3_setup_pad(NEW_PAD_CTRL(MX51_PAD_DI2_DISP_CLK__DI2_DISP_CLK,
58 PAD_CTL_PKE | PAD_CTL_DSE_MAX | PAD_CTL_SRE_SLOW));
Vikram Narayanan5d71bd22012-11-10 02:28:52 +000059
60 /* Turn on 3.3V voltage for LCD */
Benoît Thébaudeau4d15d362013-05-03 10:32:27 +000061 imx_iomux_v3_setup_pad(NEW_PAD_CTRL(MX51_PAD_CSI2_D12__GPIO4_9,
62 NO_PAD_CTRL));
Vikram Narayanan5d71bd22012-11-10 02:28:52 +000063 gpio_direction_output(MX51EVK_LCD_3V3, 1);
64
65 /* Turn on 5V voltage for LCD */
Benoît Thébaudeau4d15d362013-05-03 10:32:27 +000066 imx_iomux_v3_setup_pad(NEW_PAD_CTRL(MX51_PAD_CSI2_D13__GPIO4_10,
67 NO_PAD_CTRL));
Vikram Narayanan5d71bd22012-11-10 02:28:52 +000068 gpio_direction_output(MX51EVK_LCD_5V, 1);
69
70 /* Turn on GPIO backlight */
Benoît Thébaudeau4d15d362013-05-03 10:32:27 +000071 imx_iomux_v3_setup_pad(NEW_PAD_CTRL(MX51_PAD_DI1_D1_CS__GPIO3_4,
72 NO_PAD_CTRL));
Vikram Narayanan5d71bd22012-11-10 02:28:52 +000073 gpio_direction_output(MX51EVK_LCD_BACKLIGHT, 1);
74}
75
Fabio Estevam11d80af2013-01-09 04:55:09 +000076int board_video_skip(void)
Vikram Narayanan5d71bd22012-11-10 02:28:52 +000077{
Fabio Estevam11d80af2013-01-09 04:55:09 +000078 int ret;
Simon Glass00caae62017-08-03 12:22:12 -060079 char const *e = env_get("panel");
Fabio Estevam11d80af2013-01-09 04:55:09 +000080
81 if (e) {
82 if (strcmp(e, "claa") == 0) {
83 ret = ipuv3_fb_init(&claa_wvga, 1, IPU_PIX_FMT_RGB565);
84 if (ret)
85 printf("claa cannot be configured: %d\n", ret);
86 return ret;
87 }
88 }
89
90 /*
91 * 'panel' env variable not found or has different value than 'claa'
92 * Defaulting to dvi output.
93 */
94 ret = ipuv3_fb_init(&dvi, 0, IPU_PIX_FMT_RGB24);
Vikram Narayanan5d71bd22012-11-10 02:28:52 +000095 if (ret)
Fabio Estevam11d80af2013-01-09 04:55:09 +000096 printf("dvi cannot be configured: %d\n", ret);
97 return ret;
Vikram Narayanan5d71bd22012-11-10 02:28:52 +000098}