]> bbs.cooldavid.org Git - net-next-2.6.git/blame - arch/arm/mach-mx2/eukrea_mbimx27-baseboard.c
eukrea_mbimx27-baseboard: add timings for DVI output
[net-next-2.6.git] / arch / arm / mach-mx2 / eukrea_mbimx27-baseboard.c
CommitLineData
a961bf38
EB
1/*
2 * Copyright (C) 2009 Eric Benard - eric@eukrea.com
3 *
4 * Based on pcm970-baseboard.c which is :
5 * Copyright (C) 2008 Juergen Beisert (kernel@pengutronix.de)
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19 * MA 02110-1301, USA.
20 */
21
22#include <linux/gpio.h>
23#include <linux/irq.h>
24#include <linux/platform_device.h>
25#include <linux/spi/spi.h>
26#include <linux/spi/ads7846.h>
fc04ad0e
EB
27#include <linux/backlight.h>
28#include <video/platform_lcd.h>
a961bf38
EB
29
30#include <asm/mach/arch.h>
31
32#include <mach/common.h>
e835d88e 33#include <mach/iomux-mx27.h>
a961bf38
EB
34#include <mach/imxfb.h>
35#include <mach/hardware.h>
36#include <mach/mmc.h>
37#include <mach/imx-uart.h>
38
39#include "devices.h"
40
41static int eukrea_mbimx27_pins[] = {
42 /* UART2 */
43 PE3_PF_UART2_CTS,
44 PE4_PF_UART2_RTS,
45 PE6_PF_UART2_TXD,
46 PE7_PF_UART2_RXD,
47 /* UART3 */
48 PE8_PF_UART3_TXD,
49 PE9_PF_UART3_RXD,
50 PE10_PF_UART3_CTS,
51 PE11_PF_UART3_RTS,
52 /* UART4 */
53 PB26_AF_UART4_RTS,
54 PB28_AF_UART4_TXD,
55 PB29_AF_UART4_CTS,
56 PB31_AF_UART4_RXD,
57 /* SDHC1*/
58 PE18_PF_SD1_D0,
59 PE19_PF_SD1_D1,
60 PE20_PF_SD1_D2,
61 PE21_PF_SD1_D3,
62 PE22_PF_SD1_CMD,
63 PE23_PF_SD1_CLK,
64 /* display */
65 PA5_PF_LSCLK,
66 PA6_PF_LD0,
67 PA7_PF_LD1,
68 PA8_PF_LD2,
69 PA9_PF_LD3,
70 PA10_PF_LD4,
71 PA11_PF_LD5,
72 PA12_PF_LD6,
73 PA13_PF_LD7,
74 PA14_PF_LD8,
75 PA15_PF_LD9,
76 PA16_PF_LD10,
77 PA17_PF_LD11,
78 PA18_PF_LD12,
79 PA19_PF_LD13,
80 PA20_PF_LD14,
81 PA21_PF_LD15,
82 PA22_PF_LD16,
83 PA23_PF_LD17,
84 PA28_PF_HSYNC,
85 PA29_PF_VSYNC,
86 PA30_PF_CONTRAST,
87 PA31_PF_OE_ACD,
88 /* SPI1 */
89 PD28_PF_CSPI1_SS0,
90 PD29_PF_CSPI1_SCLK,
91 PD30_PF_CSPI1_MISO,
92 PD31_PF_CSPI1_MOSI,
93};
94
95static struct gpio_led gpio_leds[] = {
96 {
97 .name = "led1",
98 .default_trigger = "heartbeat",
99 .active_low = 1,
100 .gpio = GPIO_PORTF | 16,
101 },
102 {
103 .name = "led2",
104 .default_trigger = "none",
105 .active_low = 1,
106 .gpio = GPIO_PORTF | 19,
107 },
a961bf38
EB
108};
109
110static struct gpio_led_platform_data gpio_led_info = {
111 .leds = gpio_leds,
112 .num_leds = ARRAY_SIZE(gpio_leds),
113};
114
115static struct platform_device leds_gpio = {
116 .name = "leds-gpio",
117 .id = -1,
118 .dev = {
119 .platform_data = &gpio_led_info,
120 },
121};
122
123static struct imx_fb_videomode eukrea_mbimx27_modes[] = {
124 {
125 .mode = {
4eaad66a 126 .name = "CMO-QVGA",
a961bf38
EB
127 .refresh = 60,
128 .xres = 320,
129 .yres = 240,
130 .pixclock = 156000,
131 .hsync_len = 30,
132 .left_margin = 38,
133 .right_margin = 20,
134 .vsync_len = 3,
135 .upper_margin = 15,
136 .lower_margin = 4,
137 },
138 .pcr = 0xFAD08B80,
a465242e
EB
139 .bpp = 16,
140 }, {
141 .mode = {
142 .name = "DVI-VGA",
143 .refresh = 60,
144 .xres = 640,
145 .yres = 480,
146 .pixclock = 32000,
147 .hsync_len = 1,
148 .left_margin = 35,
149 .right_margin = 0,
150 .vsync_len = 1,
151 .upper_margin = 7,
152 .lower_margin = 0,
153 },
154 .pcr = 0xFA208B80,
155 .bpp = 16,
156 }, {
157 .mode = {
158 .name = "DVI-SVGA",
159 .refresh = 60,
160 .xres = 800,
161 .yres = 600,
162 .pixclock = 25000,
163 .hsync_len = 1,
164 .left_margin = 35,
165 .right_margin = 0,
166 .vsync_len = 1,
167 .upper_margin = 7,
168 .lower_margin = 0,
169 },
170 .pcr = 0xFA208B80,
a961bf38
EB
171 .bpp = 16,
172 },
173};
174
175static struct imx_fb_platform_data eukrea_mbimx27_fb_data = {
176 .mode = eukrea_mbimx27_modes,
177 .num_modes = ARRAY_SIZE(eukrea_mbimx27_modes),
178
179 .pwmr = 0x00A903FF,
180 .lscr1 = 0x00120300,
181 .dmacr = 0x00040060,
182};
183
fc04ad0e
EB
184static void eukrea_mbimx27_bl_set_intensity(int intensity)
185{
186 if (intensity)
187 gpio_direction_output(GPIO_PORTE | 5, 1);
188 else
189 gpio_direction_output(GPIO_PORTE | 5, 0);
190}
191
192static struct generic_bl_info eukrea_mbimx27_bl_info = {
193 .name = "eukrea_mbimx27-bl",
194 .max_intensity = 0xff,
195 .default_intensity = 0xff,
196 .set_bl_intensity = eukrea_mbimx27_bl_set_intensity,
197};
198
199static struct platform_device eukrea_mbimx27_bl_dev = {
200 .name = "generic-bl",
201 .id = 1,
202 .dev = {
203 .platform_data = &eukrea_mbimx27_bl_info,
204 },
205};
206
207static void eukrea_mbimx27_lcd_power_set(struct plat_lcd_data *pd,
208 unsigned int power)
209{
210 if (power)
211 gpio_direction_output(GPIO_PORTA | 25, 1);
212 else
213 gpio_direction_output(GPIO_PORTA | 25, 0);
214}
215
216static struct plat_lcd_data eukrea_mbimx27_lcd_power_data = {
217 .set_power = eukrea_mbimx27_lcd_power_set,
218};
219
220static struct platform_device eukrea_mbimx27_lcd_powerdev = {
221 .name = "platform-lcd",
222 .dev.platform_data = &eukrea_mbimx27_lcd_power_data,
223};
224
a961bf38
EB
225static struct imxuart_platform_data uart_pdata[] = {
226 {
227 .flags = IMXUART_HAVE_RTSCTS,
228 },
229 {
230 .flags = IMXUART_HAVE_RTSCTS,
231 },
232};
233
234#if defined(CONFIG_TOUCHSCREEN_ADS7846)
235 || defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
236
237#define ADS7846_PENDOWN (GPIO_PORTD | 25)
238
239static void ads7846_dev_init(void)
240{
241 if (gpio_request(ADS7846_PENDOWN, "ADS7846 pendown") < 0) {
242 printk(KERN_ERR "can't get ads746 pen down GPIO\n");
243 return;
244 }
245
246 gpio_direction_input(ADS7846_PENDOWN);
247}
248
249static int ads7846_get_pendown_state(void)
250{
251 return !gpio_get_value(ADS7846_PENDOWN);
252}
253
254static struct ads7846_platform_data ads7846_config __initdata = {
255 .get_pendown_state = ads7846_get_pendown_state,
256 .keep_vref_on = 1,
257};
258
259static struct spi_board_info eukrea_mbimx27_spi_board_info[] __initdata = {
260 [0] = {
261 .modalias = "ads7846",
262 .bus_num = 0,
263 .chip_select = 0,
264 .max_speed_hz = 1500000,
265 .irq = IRQ_GPIOD(25),
266 .platform_data = &ads7846_config,
267 .mode = SPI_MODE_2,
268 },
269};
270
271static int eukrea_mbimx27_spi_cs[] = {GPIO_PORTD | 28};
272
273static struct spi_imx_master eukrea_mbimx27_spi_0_data = {
274 .chipselect = eukrea_mbimx27_spi_cs,
275 .num_chipselect = ARRAY_SIZE(eukrea_mbimx27_spi_cs),
276};
277#endif
278
279static struct platform_device *platform_devices[] __initdata = {
280 &leds_gpio,
281};
282
283/*
284 * system init for baseboard usage. Will be called by cpuimx27 init.
285 *
286 * Add platform devices present on this baseboard and init
287 * them from CPU side as far as required to use them later on
288 */
289void __init eukrea_mbimx27_baseboard_init(void)
290{
291 mxc_gpio_setup_multiple_pins(eukrea_mbimx27_pins,
292 ARRAY_SIZE(eukrea_mbimx27_pins), "MBIMX27");
293
294 mxc_register_device(&mxc_uart_device1, &uart_pdata[0]);
295 mxc_register_device(&mxc_uart_device2, &uart_pdata[1]);
296
297 mxc_register_device(&mxc_fb_device, &eukrea_mbimx27_fb_data);
298 mxc_register_device(&mxc_sdhc_device0, NULL);
299
300#if defined(CONFIG_TOUCHSCREEN_ADS7846)
301 || defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
302 /* SPI and ADS7846 Touchscreen controler init */
303 mxc_gpio_mode(GPIO_PORTD | 28 | GPIO_GPIO | GPIO_OUT);
304 mxc_gpio_mode(GPIO_PORTD | 25 | GPIO_GPIO | GPIO_IN);
305 mxc_register_device(&mxc_spi_device0, &eukrea_mbimx27_spi_0_data);
306 spi_register_board_info(eukrea_mbimx27_spi_board_info,
307 ARRAY_SIZE(eukrea_mbimx27_spi_board_info));
308 ads7846_dev_init();
309#endif
310
311 /* Leds configuration */
312 mxc_gpio_mode(GPIO_PORTF | 16 | GPIO_GPIO | GPIO_OUT);
313 mxc_gpio_mode(GPIO_PORTF | 19 | GPIO_GPIO | GPIO_OUT);
314 /* Backlight */
315 mxc_gpio_mode(GPIO_PORTE | 5 | GPIO_GPIO | GPIO_OUT);
fc04ad0e
EB
316 gpio_request(GPIO_PORTE | 5, "backlight");
317 platform_device_register(&eukrea_mbimx27_bl_dev);
318 /* LCD Reset */
319 mxc_gpio_mode(GPIO_PORTA | 25 | GPIO_GPIO | GPIO_OUT);
320 gpio_request(GPIO_PORTA | 25, "lcd_enable");
321 platform_device_register(&eukrea_mbimx27_lcd_powerdev);
a961bf38
EB
322
323 platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices));
324}