]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - arch/arm/mach-mx2/eukrea_mbimx27-baseboard.c
eukrea_mbimx27: use card detect through DAT3 for SDHC1
[mirror_ubuntu-artful-kernel.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>
62d725b1 38#include <mach/spi.h>
a961bf38
EB
39
40#include "devices.h"
41
42static int eukrea_mbimx27_pins[] = {
43 /* UART2 */
44 PE3_PF_UART2_CTS,
45 PE4_PF_UART2_RTS,
46 PE6_PF_UART2_TXD,
47 PE7_PF_UART2_RXD,
48 /* UART3 */
49 PE8_PF_UART3_TXD,
50 PE9_PF_UART3_RXD,
51 PE10_PF_UART3_CTS,
52 PE11_PF_UART3_RTS,
53 /* UART4 */
2d66c780 54#if !defined(MACH_EUKREA_CPUIMX27_USEUART4)
a961bf38
EB
55 PB26_AF_UART4_RTS,
56 PB28_AF_UART4_TXD,
57 PB29_AF_UART4_CTS,
58 PB31_AF_UART4_RXD,
2d66c780 59#endif
a961bf38
EB
60 /* SDHC1*/
61 PE18_PF_SD1_D0,
62 PE19_PF_SD1_D1,
63 PE20_PF_SD1_D2,
64 PE21_PF_SD1_D3,
65 PE22_PF_SD1_CMD,
66 PE23_PF_SD1_CLK,
67 /* display */
68 PA5_PF_LSCLK,
69 PA6_PF_LD0,
70 PA7_PF_LD1,
71 PA8_PF_LD2,
72 PA9_PF_LD3,
73 PA10_PF_LD4,
74 PA11_PF_LD5,
75 PA12_PF_LD6,
76 PA13_PF_LD7,
77 PA14_PF_LD8,
78 PA15_PF_LD9,
79 PA16_PF_LD10,
80 PA17_PF_LD11,
81 PA18_PF_LD12,
82 PA19_PF_LD13,
83 PA20_PF_LD14,
84 PA21_PF_LD15,
85 PA22_PF_LD16,
86 PA23_PF_LD17,
87 PA28_PF_HSYNC,
88 PA29_PF_VSYNC,
89 PA30_PF_CONTRAST,
90 PA31_PF_OE_ACD,
91 /* SPI1 */
a961bf38
EB
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 },
a961bf38
EB
110};
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 = {
4eaad66a 128 .name = "CMO-QVGA",
a961bf38
EB
129 .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,
a465242e
EB
141 .bpp = 16,
142 }, {
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,
a961bf38
EB
173 .bpp = 16,
174 },
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
fc04ad0e
EB
186static 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
a961bf38
EB
227static struct imxuart_platform_data uart_pdata[] = {
228 {
229 .flags = IMXUART_HAVE_RTSCTS,
230 },
231 {
232 .flags = IMXUART_HAVE_RTSCTS,
233 },
2d66c780
EB
234 {
235 .flags = IMXUART_HAVE_RTSCTS,
236 },
a961bf38
EB
237};
238
62d725b1 239#if defined(CONFIG_TOUCHSCREEN_ADS7846) \
a961bf38
EB
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 }
a961bf38
EB
250 gpio_direction_input(ADS7846_PENDOWN);
251}
252
253static int ads7846_get_pendown_state(void)
254{
255 return !gpio_get_value(ADS7846_PENDOWN);
256}
257
258static struct ads7846_platform_data ads7846_config __initdata = {
259 .get_pendown_state = ads7846_get_pendown_state,
260 .keep_vref_on = 1,
261};
62d725b1 262#endif
a961bf38 263
62d725b1 264#if defined(CONFIG_SPI_IMX) || defined(CONFIG_SPI_IMX_MODULE)
a961bf38
EB
265static struct spi_board_info eukrea_mbimx27_spi_board_info[] __initdata = {
266 [0] = {
267 .modalias = "ads7846",
268 .bus_num = 0,
269 .chip_select = 0,
270 .max_speed_hz = 1500000,
271 .irq = IRQ_GPIOD(25),
272 .platform_data = &ads7846_config,
273 .mode = SPI_MODE_2,
274 },
275};
276
277static int eukrea_mbimx27_spi_cs[] = {GPIO_PORTD | 28};
278
279static struct spi_imx_master eukrea_mbimx27_spi_0_data = {
280 .chipselect = eukrea_mbimx27_spi_cs,
281 .num_chipselect = ARRAY_SIZE(eukrea_mbimx27_spi_cs),
282};
283#endif
284
285static struct platform_device *platform_devices[] __initdata = {
286 &leds_gpio,
287};
288
e76a17c2
EB
289static struct imxmmc_platform_data sdhc_pdata = {
290 .dat3_card_detect = 1,
291};
292
a961bf38
EB
293/*
294 * system init for baseboard usage. Will be called by cpuimx27 init.
295 *
296 * Add platform devices present on this baseboard and init
297 * them from CPU side as far as required to use them later on
298 */
299void __init eukrea_mbimx27_baseboard_init(void)
300{
301 mxc_gpio_setup_multiple_pins(eukrea_mbimx27_pins,
302 ARRAY_SIZE(eukrea_mbimx27_pins), "MBIMX27");
303
304 mxc_register_device(&mxc_uart_device1, &uart_pdata[0]);
305 mxc_register_device(&mxc_uart_device2, &uart_pdata[1]);
2d66c780
EB
306#if !defined(MACH_EUKREA_CPUIMX27_USEUART4)
307 mxc_register_device(&mxc_uart_device3, &uart_pdata[2]);
308#endif
a961bf38
EB
309
310 mxc_register_device(&mxc_fb_device, &eukrea_mbimx27_fb_data);
e76a17c2 311 mxc_register_device(&mxc_sdhc_device0, &sdhc_pdata);
a961bf38 312
62d725b1 313#if defined(CONFIG_TOUCHSCREEN_ADS7846) \
a961bf38 314 || defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
62d725b1 315 /* ADS7846 Touchscreen controller init */
a961bf38 316 mxc_gpio_mode(GPIO_PORTD | 25 | GPIO_GPIO | GPIO_IN);
62d725b1
EB
317 ads7846_dev_init();
318#endif
319
320#if defined(CONFIG_SPI_IMX) || defined(CONFIG_SPI_IMX_MODULE)
321 /* SPI_CS0 init */
322 mxc_gpio_mode(GPIO_PORTD | 28 | GPIO_GPIO | GPIO_OUT);
a961bf38
EB
323 mxc_register_device(&mxc_spi_device0, &eukrea_mbimx27_spi_0_data);
324 spi_register_board_info(eukrea_mbimx27_spi_board_info,
325 ARRAY_SIZE(eukrea_mbimx27_spi_board_info));
a961bf38
EB
326#endif
327
328 /* Leds configuration */
329 mxc_gpio_mode(GPIO_PORTF | 16 | GPIO_GPIO | GPIO_OUT);
330 mxc_gpio_mode(GPIO_PORTF | 19 | GPIO_GPIO | GPIO_OUT);
331 /* Backlight */
332 mxc_gpio_mode(GPIO_PORTE | 5 | GPIO_GPIO | GPIO_OUT);
fc04ad0e
EB
333 gpio_request(GPIO_PORTE | 5, "backlight");
334 platform_device_register(&eukrea_mbimx27_bl_dev);
335 /* LCD Reset */
336 mxc_gpio_mode(GPIO_PORTA | 25 | GPIO_GPIO | GPIO_OUT);
337 gpio_request(GPIO_PORTA | 25, "lcd_enable");
338 platform_device_register(&eukrea_mbimx27_lcd_powerdev);
a961bf38
EB
339
340 platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices));
341}