blob: 86ec7508dbbb27390c7fca4763043e39456266b4 [file] [log] [blame]
Vikram Narayanan5d71bd22012-11-10 02:28:52 +00001/*
2 * Copyright (C) 2012 Freescale Semiconductor, Inc.
3 * Fabio Estevam <fabio.estevam@freescale.com>
4 *
Wolfgang Denk1a459662013-07-08 09:37:19 +02005 * SPDX-License-Identifier: GPL-2.0+
Vikram Narayanan5d71bd22012-11-10 02:28:52 +00006 */
7
8#include <common.h>
9#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;
79 char const *e = getenv("panel");
80
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}