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-mx53.h>
28 #include <linux/fb.h>
29 #include <ipu_pixfmt.h>
30 
31 #define MX53LOCO_LCD_POWER		IMX_GPIO_NR(3, 24)
32 
33 static struct fb_videomode const claa_wvga = {
34 	.name		= "CLAA07LC0ACW",
35 	.refresh	= 57,
36 	.xres		= 800,
37 	.yres		= 480,
38 	.pixclock	= 37037,
39 	.left_margin	= 40,
40 	.right_margin	= 60,
41 	.upper_margin	= 10,
42 	.lower_margin	= 10,
43 	.hsync_len	= 20,
44 	.vsync_len	= 10,
45 	.sync		= 0,
46 	.vmode		= FB_VMODE_NONINTERLACED
47 };
48 
49 static struct fb_videomode const seiko_wvga = {
50 	.name		= "Seiko-43WVF1G",
51 	.refresh	= 60,
52 	.xres		= 800,
53 	.yres		= 480,
54 	.pixclock	= 29851, /* picosecond (33.5 MHz) */
55 	.left_margin	= 89,
56 	.right_margin	= 164,
57 	.upper_margin	= 23,
58 	.lower_margin	= 10,
59 	.hsync_len	= 10,
60 	.vsync_len	= 10,
61 	.sync		= 0,
62 };
63 
64 void setup_iomux_lcd(void)
65 {
66 	static const iomux_v3_cfg_t lcd_pads[] = {
67 		MX53_PAD_DI0_DISP_CLK__IPU_DI0_DISP_CLK,
68 		MX53_PAD_DI0_PIN15__IPU_DI0_PIN15,
69 		MX53_PAD_DI0_PIN2__IPU_DI0_PIN2,
70 		MX53_PAD_DI0_PIN3__IPU_DI0_PIN3,
71 		MX53_PAD_DISP0_DAT0__IPU_DISP0_DAT_0,
72 		MX53_PAD_DISP0_DAT1__IPU_DISP0_DAT_1,
73 		MX53_PAD_DISP0_DAT2__IPU_DISP0_DAT_2,
74 		MX53_PAD_DISP0_DAT3__IPU_DISP0_DAT_3,
75 		MX53_PAD_DISP0_DAT4__IPU_DISP0_DAT_4,
76 		MX53_PAD_DISP0_DAT5__IPU_DISP0_DAT_5,
77 		MX53_PAD_DISP0_DAT6__IPU_DISP0_DAT_6,
78 		MX53_PAD_DISP0_DAT7__IPU_DISP0_DAT_7,
79 		MX53_PAD_DISP0_DAT8__IPU_DISP0_DAT_8,
80 		MX53_PAD_DISP0_DAT9__IPU_DISP0_DAT_9,
81 		MX53_PAD_DISP0_DAT10__IPU_DISP0_DAT_10,
82 		MX53_PAD_DISP0_DAT11__IPU_DISP0_DAT_11,
83 		MX53_PAD_DISP0_DAT12__IPU_DISP0_DAT_12,
84 		MX53_PAD_DISP0_DAT13__IPU_DISP0_DAT_13,
85 		MX53_PAD_DISP0_DAT14__IPU_DISP0_DAT_14,
86 		MX53_PAD_DISP0_DAT15__IPU_DISP0_DAT_15,
87 		MX53_PAD_DISP0_DAT16__IPU_DISP0_DAT_16,
88 		MX53_PAD_DISP0_DAT17__IPU_DISP0_DAT_17,
89 		MX53_PAD_DISP0_DAT18__IPU_DISP0_DAT_18,
90 		MX53_PAD_DISP0_DAT19__IPU_DISP0_DAT_19,
91 		MX53_PAD_DISP0_DAT20__IPU_DISP0_DAT_20,
92 		MX53_PAD_DISP0_DAT21__IPU_DISP0_DAT_21,
93 		MX53_PAD_DISP0_DAT22__IPU_DISP0_DAT_22,
94 		MX53_PAD_DISP0_DAT23__IPU_DISP0_DAT_23,
95 	};
96 
97 	imx_iomux_v3_setup_multiple_pads(lcd_pads, ARRAY_SIZE(lcd_pads));
98 
99 	/* Turn on GPIO backlight */
100 	imx_iomux_v3_setup_pad(MX53_PAD_EIM_D24__GPIO3_24);
101 	gpio_direction_output(MX53LOCO_LCD_POWER, 1);
102 
103 	/* Turn on display contrast */
104 	imx_iomux_v3_setup_pad(MX53_PAD_GPIO_1__GPIO1_1);
105 	gpio_direction_output(IMX_GPIO_NR(1, 1), 1);
106 }
107 
108 int board_video_skip(void)
109 {
110 	int ret;
111 	char const *e = getenv("panel");
112 
113 	if (e) {
114 		if (strcmp(e, "seiko") == 0) {
115 			ret = ipuv3_fb_init(&seiko_wvga, 0, IPU_PIX_FMT_RGB24);
116 			if (ret)
117 				printf("Seiko cannot be configured: %d\n", ret);
118 			return ret;
119 		}
120 	}
121 
122 	/*
123 	 * 'panel' env variable not found or has different value than 'seiko'
124 	 *  Defaulting to claa lcd.
125 	 */
126 	ret = ipuv3_fb_init(&claa_wvga, 0, IPU_PIX_FMT_RGB565);
127 	if (ret)
128 		printf("CLAA cannot be configured: %d\n", ret);
129 	return ret;
130 }
131