]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - board/freescale/mx51evk/mx51evk_video.c
Merge branch 'u-boot-imx/master' into 'u-boot-arm/master'
[karo-tx-uboot.git] / board / freescale / mx51evk / mx51evk_video.c
1 /*
2  * Copyright (C) 2012 Freescale Semiconductor, Inc.
3  * Fabio Estevam <fabio.estevam@freescale.com>
4  *
5  * See file CREDITS for list of people who contributed to this
6  * project.
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License as
10  * published by the Free Software Foundation; either version 2 of
11  * the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21  * MA 02111-1307 USA
22  */
23
24 #include <common.h>
25 #include <linux/list.h>
26 #include <asm/gpio.h>
27 #include <asm/arch/iomux-mx51.h>
28 #include <linux/fb.h>
29 #include <ipu_pixfmt.h>
30
31 #define MX51EVK_LCD_3V3         IMX_GPIO_NR(4, 9)
32 #define MX51EVK_LCD_5V          IMX_GPIO_NR(4, 10)
33 #define MX51EVK_LCD_BACKLIGHT   IMX_GPIO_NR(3, 4)
34
35 static struct fb_videomode const claa_wvga = {
36         .name           = "CLAA07LC0ACW",
37         .refresh        = 57,
38         .xres           = 800,
39         .yres           = 480,
40         .pixclock       = 37037,
41         .left_margin    = 40,
42         .right_margin   = 60,
43         .upper_margin   = 10,
44         .lower_margin   = 10,
45         .hsync_len      = 20,
46         .vsync_len      = 10,
47         .sync           = 0,
48         .vmode          = FB_VMODE_NONINTERLACED
49 };
50
51 static struct fb_videomode const dvi = {
52         .name           = "DVI panel",
53         .refresh        = 60,
54         .xres           = 1024,
55         .yres           = 768,
56         .pixclock       = 15385,
57         .left_margin    = 220,
58         .right_margin   = 40,
59         .upper_margin   = 21,
60         .lower_margin   = 7,
61         .hsync_len      = 60,
62         .vsync_len      = 10,
63         .sync           = 0,
64         .vmode          = FB_VMODE_NONINTERLACED
65 };
66
67 void setup_iomux_lcd(void)
68 {
69         /* DI2_PIN15 */
70         imx_iomux_v3_setup_pad(MX51_PAD_DI_GP4__DI2_PIN15);
71
72         /* Pad settings for DI2_DISP_CLK */
73         imx_iomux_v3_setup_pad(NEW_PAD_CTRL(MX51_PAD_DI2_DISP_CLK__DI2_DISP_CLK,
74                             PAD_CTL_PKE | PAD_CTL_DSE_MAX | PAD_CTL_SRE_SLOW));
75
76         /* Turn on 3.3V voltage for LCD */
77         imx_iomux_v3_setup_pad(NEW_PAD_CTRL(MX51_PAD_CSI2_D12__GPIO4_9,
78                                                 NO_PAD_CTRL));
79         gpio_direction_output(MX51EVK_LCD_3V3, 1);
80
81         /* Turn on 5V voltage for LCD */
82         imx_iomux_v3_setup_pad(NEW_PAD_CTRL(MX51_PAD_CSI2_D13__GPIO4_10,
83                                                 NO_PAD_CTRL));
84         gpio_direction_output(MX51EVK_LCD_5V, 1);
85
86         /* Turn on GPIO backlight */
87         imx_iomux_v3_setup_pad(NEW_PAD_CTRL(MX51_PAD_DI1_D1_CS__GPIO3_4,
88                                                 NO_PAD_CTRL));
89         gpio_direction_output(MX51EVK_LCD_BACKLIGHT, 1);
90 }
91
92 int board_video_skip(void)
93 {
94         int ret;
95         char const *e = getenv("panel");
96
97         if (e) {
98                 if (strcmp(e, "claa") == 0) {
99                         ret = ipuv3_fb_init(&claa_wvga, 1, IPU_PIX_FMT_RGB565);
100                         if (ret)
101                                 printf("claa cannot be configured: %d\n", ret);
102                         return ret;
103                 }
104         }
105
106         /*
107          * 'panel' env variable not found or has different value than 'claa'
108          *  Defaulting to dvi output.
109          */
110         ret = ipuv3_fb_init(&dvi, 0, IPU_PIX_FMT_RGB24);
111         if (ret)
112                 printf("dvi cannot be configured: %d\n", ret);
113         return ret;
114 }