blob: fff6c8dc4b3b684f507abd1fe53937c15dbe127b [file] [log] [blame]
Eric Benarda961bf32009-07-16 16:26:34 +02001/*
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>
Eric Bénardfc04ad02010-05-19 18:45:57 +020027#include <linux/backlight.h>
28#include <video/platform_lcd.h>
Eric Benarda961bf32009-07-16 16:26:34 +020029
30#include <asm/mach/arch.h>
31
32#include <mach/common.h>
Uwe Kleine-Könige835d882010-02-16 11:07:49 +010033#include <mach/iomux-mx27.h>
Eric Benarda961bf32009-07-16 16:26:34 +020034#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 */
Eric Bénard2d66c782010-05-19 18:45:59 +020053#if !defined(MACH_EUKREA_CPUIMX27_USEUART4)
Eric Benarda961bf32009-07-16 16:26:34 +020054 PB26_AF_UART4_RTS,
55 PB28_AF_UART4_TXD,
56 PB29_AF_UART4_CTS,
57 PB31_AF_UART4_RXD,
Eric Bénard2d66c782010-05-19 18:45:59 +020058#endif
Eric Benarda961bf32009-07-16 16:26:34 +020059 /* SDHC1*/
60 PE18_PF_SD1_D0,
61 PE19_PF_SD1_D1,
62 PE20_PF_SD1_D2,
63 PE21_PF_SD1_D3,
64 PE22_PF_SD1_CMD,
65 PE23_PF_SD1_CLK,
66 /* display */
67 PA5_PF_LSCLK,
68 PA6_PF_LD0,
69 PA7_PF_LD1,
70 PA8_PF_LD2,
71 PA9_PF_LD3,
72 PA10_PF_LD4,
73 PA11_PF_LD5,
74 PA12_PF_LD6,
75 PA13_PF_LD7,
76 PA14_PF_LD8,
77 PA15_PF_LD9,
78 PA16_PF_LD10,
79 PA17_PF_LD11,
80 PA18_PF_LD12,
81 PA19_PF_LD13,
82 PA20_PF_LD14,
83 PA21_PF_LD15,
84 PA22_PF_LD16,
85 PA23_PF_LD17,
86 PA28_PF_HSYNC,
87 PA29_PF_VSYNC,
88 PA30_PF_CONTRAST,
89 PA31_PF_OE_ACD,
90 /* SPI1 */
91 PD28_PF_CSPI1_SS0,
92 PD29_PF_CSPI1_SCLK,
93 PD30_PF_CSPI1_MISO,
94 PD31_PF_CSPI1_MOSI,
95};
96
97static struct gpio_led gpio_leds[] = {
98 {
99 .name = "led1",
100 .default_trigger = "heartbeat",
101 .active_low = 1,
102 .gpio = GPIO_PORTF | 16,
103 },
104 {
105 .name = "led2",
106 .default_trigger = "none",
107 .active_low = 1,
108 .gpio = GPIO_PORTF | 19,
109 },
Eric Benarda961bf32009-07-16 16:26:34 +0200110};
111
112static struct gpio_led_platform_data gpio_led_info = {
113 .leds = gpio_leds,
114 .num_leds = ARRAY_SIZE(gpio_leds),
115};
116
117static struct platform_device leds_gpio = {
118 .name = "leds-gpio",
119 .id = -1,
120 .dev = {
121 .platform_data = &gpio_led_info,
122 },
123};
124
125static struct imx_fb_videomode eukrea_mbimx27_modes[] = {
126 {
127 .mode = {
Eric Bénard4eaad662010-05-19 18:45:56 +0200128 .name = "CMO-QVGA",
Eric Benarda961bf32009-07-16 16:26:34 +0200129 .refresh = 60,
130 .xres = 320,
131 .yres = 240,
132 .pixclock = 156000,
133 .hsync_len = 30,
134 .left_margin = 38,
135 .right_margin = 20,
136 .vsync_len = 3,
137 .upper_margin = 15,
138 .lower_margin = 4,
139 },
140 .pcr = 0xFAD08B80,
141 .bpp = 16,
Eric Bénarda4652422010-05-19 18:45:58 +0200142 }, {
143 .mode = {
144 .name = "DVI-VGA",
145 .refresh = 60,
146 .xres = 640,
147 .yres = 480,
148 .pixclock = 32000,
149 .hsync_len = 1,
150 .left_margin = 35,
151 .right_margin = 0,
152 .vsync_len = 1,
153 .upper_margin = 7,
154 .lower_margin = 0,
155 },
156 .pcr = 0xFA208B80,
157 .bpp = 16,
158 }, {
159 .mode = {
160 .name = "DVI-SVGA",
161 .refresh = 60,
162 .xres = 800,
163 .yres = 600,
164 .pixclock = 25000,
165 .hsync_len = 1,
166 .left_margin = 35,
167 .right_margin = 0,
168 .vsync_len = 1,
169 .upper_margin = 7,
170 .lower_margin = 0,
171 },
172 .pcr = 0xFA208B80,
173 .bpp = 16,
Eric Benarda961bf32009-07-16 16:26:34 +0200174 },
175};
176
177static struct imx_fb_platform_data eukrea_mbimx27_fb_data = {
178 .mode = eukrea_mbimx27_modes,
179 .num_modes = ARRAY_SIZE(eukrea_mbimx27_modes),
180
181 .pwmr = 0x00A903FF,
182 .lscr1 = 0x00120300,
183 .dmacr = 0x00040060,
184};
185
Eric Bénardfc04ad02010-05-19 18:45:57 +0200186static void eukrea_mbimx27_bl_set_intensity(int intensity)
187{
188 if (intensity)
189 gpio_direction_output(GPIO_PORTE | 5, 1);
190 else
191 gpio_direction_output(GPIO_PORTE | 5, 0);
192}
193
194static struct generic_bl_info eukrea_mbimx27_bl_info = {
195 .name = "eukrea_mbimx27-bl",
196 .max_intensity = 0xff,
197 .default_intensity = 0xff,
198 .set_bl_intensity = eukrea_mbimx27_bl_set_intensity,
199};
200
201static struct platform_device eukrea_mbimx27_bl_dev = {
202 .name = "generic-bl",
203 .id = 1,
204 .dev = {
205 .platform_data = &eukrea_mbimx27_bl_info,
206 },
207};
208
209static void eukrea_mbimx27_lcd_power_set(struct plat_lcd_data *pd,
210 unsigned int power)
211{
212 if (power)
213 gpio_direction_output(GPIO_PORTA | 25, 1);
214 else
215 gpio_direction_output(GPIO_PORTA | 25, 0);
216}
217
218static struct plat_lcd_data eukrea_mbimx27_lcd_power_data = {
219 .set_power = eukrea_mbimx27_lcd_power_set,
220};
221
222static struct platform_device eukrea_mbimx27_lcd_powerdev = {
223 .name = "platform-lcd",
224 .dev.platform_data = &eukrea_mbimx27_lcd_power_data,
225};
226
Eric Benarda961bf32009-07-16 16:26:34 +0200227static struct imxuart_platform_data uart_pdata[] = {
228 {
229 .flags = IMXUART_HAVE_RTSCTS,
230 },
231 {
232 .flags = IMXUART_HAVE_RTSCTS,
233 },
Eric Bénard2d66c782010-05-19 18:45:59 +0200234 {
235 .flags = IMXUART_HAVE_RTSCTS,
236 },
Eric Benarda961bf32009-07-16 16:26:34 +0200237};
238
239#if defined(CONFIG_TOUCHSCREEN_ADS7846)
240 || defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
241
242#define ADS7846_PENDOWN (GPIO_PORTD | 25)
243
244static void ads7846_dev_init(void)
245{
246 if (gpio_request(ADS7846_PENDOWN, "ADS7846 pendown") < 0) {
247 printk(KERN_ERR "can't get ads746 pen down GPIO\n");
248 return;
249 }
250
251 gpio_direction_input(ADS7846_PENDOWN);
252}
253
254static int ads7846_get_pendown_state(void)
255{
256 return !gpio_get_value(ADS7846_PENDOWN);
257}
258
259static struct ads7846_platform_data ads7846_config __initdata = {
260 .get_pendown_state = ads7846_get_pendown_state,
261 .keep_vref_on = 1,
262};
263
264static struct spi_board_info eukrea_mbimx27_spi_board_info[] __initdata = {
265 [0] = {
266 .modalias = "ads7846",
267 .bus_num = 0,
268 .chip_select = 0,
269 .max_speed_hz = 1500000,
270 .irq = IRQ_GPIOD(25),
271 .platform_data = &ads7846_config,
272 .mode = SPI_MODE_2,
273 },
274};
275
276static int eukrea_mbimx27_spi_cs[] = {GPIO_PORTD | 28};
277
278static struct spi_imx_master eukrea_mbimx27_spi_0_data = {
279 .chipselect = eukrea_mbimx27_spi_cs,
280 .num_chipselect = ARRAY_SIZE(eukrea_mbimx27_spi_cs),
281};
282#endif
283
284static struct platform_device *platform_devices[] __initdata = {
285 &leds_gpio,
286};
287
288/*
289 * system init for baseboard usage. Will be called by cpuimx27 init.
290 *
291 * Add platform devices present on this baseboard and init
292 * them from CPU side as far as required to use them later on
293 */
294void __init eukrea_mbimx27_baseboard_init(void)
295{
296 mxc_gpio_setup_multiple_pins(eukrea_mbimx27_pins,
297 ARRAY_SIZE(eukrea_mbimx27_pins), "MBIMX27");
298
299 mxc_register_device(&mxc_uart_device1, &uart_pdata[0]);
300 mxc_register_device(&mxc_uart_device2, &uart_pdata[1]);
Eric Bénard2d66c782010-05-19 18:45:59 +0200301#if !defined(MACH_EUKREA_CPUIMX27_USEUART4)
302 mxc_register_device(&mxc_uart_device3, &uart_pdata[2]);
303#endif
Eric Benarda961bf32009-07-16 16:26:34 +0200304
305 mxc_register_device(&mxc_fb_device, &eukrea_mbimx27_fb_data);
306 mxc_register_device(&mxc_sdhc_device0, NULL);
307
308#if defined(CONFIG_TOUCHSCREEN_ADS7846)
309 || defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
310 /* SPI and ADS7846 Touchscreen controler init */
311 mxc_gpio_mode(GPIO_PORTD | 28 | GPIO_GPIO | GPIO_OUT);
312 mxc_gpio_mode(GPIO_PORTD | 25 | GPIO_GPIO | GPIO_IN);
313 mxc_register_device(&mxc_spi_device0, &eukrea_mbimx27_spi_0_data);
314 spi_register_board_info(eukrea_mbimx27_spi_board_info,
315 ARRAY_SIZE(eukrea_mbimx27_spi_board_info));
316 ads7846_dev_init();
317#endif
318
319 /* Leds configuration */
320 mxc_gpio_mode(GPIO_PORTF | 16 | GPIO_GPIO | GPIO_OUT);
321 mxc_gpio_mode(GPIO_PORTF | 19 | GPIO_GPIO | GPIO_OUT);
322 /* Backlight */
323 mxc_gpio_mode(GPIO_PORTE | 5 | GPIO_GPIO | GPIO_OUT);
Eric Bénardfc04ad02010-05-19 18:45:57 +0200324 gpio_request(GPIO_PORTE | 5, "backlight");
325 platform_device_register(&eukrea_mbimx27_bl_dev);
326 /* LCD Reset */
327 mxc_gpio_mode(GPIO_PORTA | 25 | GPIO_GPIO | GPIO_OUT);
328 gpio_request(GPIO_PORTA | 25, "lcd_enable");
329 platform_device_register(&eukrea_mbimx27_lcd_powerdev);
Eric Benarda961bf32009-07-16 16:26:34 +0200330
331 platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices));
332}