]> git.sur5r.net Git - u-boot/blob - board/freescale/mx51evk/mx51evk_video.c
SPDX: Convert all of our single license tags to Linux Kernel style
[u-boot] / board / freescale / mx51evk / mx51evk_video.c
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * Copyright (C) 2012 Freescale Semiconductor, Inc.
4  * Fabio Estevam <fabio.estevam@freescale.com>
5  */
6
7 #include <common.h>
8 #include <linux/list.h>
9 #include <asm/gpio.h>
10 #include <asm/arch/iomux-mx51.h>
11 #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
18 static 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
34 static 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
50 void setup_iomux_lcd(void)
51 {
52         /* DI2_PIN15 */
53         imx_iomux_v3_setup_pad(MX51_PAD_DI_GP4__DI2_PIN15);
54
55         /* 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));
58
59         /* Turn on 3.3V voltage for LCD */
60         imx_iomux_v3_setup_pad(NEW_PAD_CTRL(MX51_PAD_CSI2_D12__GPIO4_9,
61                                                 NO_PAD_CTRL));
62         gpio_direction_output(MX51EVK_LCD_3V3, 1);
63
64         /* Turn on 5V voltage for LCD */
65         imx_iomux_v3_setup_pad(NEW_PAD_CTRL(MX51_PAD_CSI2_D13__GPIO4_10,
66                                                 NO_PAD_CTRL));
67         gpio_direction_output(MX51EVK_LCD_5V, 1);
68
69         /* Turn on GPIO backlight */
70         imx_iomux_v3_setup_pad(NEW_PAD_CTRL(MX51_PAD_DI1_D1_CS__GPIO3_4,
71                                                 NO_PAD_CTRL));
72         gpio_direction_output(MX51EVK_LCD_BACKLIGHT, 1);
73 }
74
75 int board_video_skip(void)
76 {
77         int ret;
78         char const *e = env_get("panel");
79
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);
94         if (ret)
95                 printf("dvi cannot be configured: %d\n", ret);
96         return ret;
97 }