ARM: imx: eliminate macro IOMUX_TO_IRQ()
[deliverable/linux.git] / arch / arm / mach-imx / eukrea_mbimx27-baseboard.c
CommitLineData
a961bf38 1/*
d2195d52 2 * Copyright (C) 2009-2010 Eric Benard - eric@eukrea.com
a961bf38
EB
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 34#include <mach/hardware.h>
a961bf38 35
7536cf99 36#include "devices-imx27.h"
a961bf38 37
6c80ee51 38static const int eukrea_mbimx27_pins[] __initconst = {
a961bf38
EB
39 /* UART2 */
40 PE3_PF_UART2_CTS,
41 PE4_PF_UART2_RTS,
42 PE6_PF_UART2_TXD,
43 PE7_PF_UART2_RXD,
44 /* UART3 */
45 PE8_PF_UART3_TXD,
46 PE9_PF_UART3_RXD,
47 PE10_PF_UART3_CTS,
48 PE11_PF_UART3_RTS,
49 /* UART4 */
2d66c780 50#if !defined(MACH_EUKREA_CPUIMX27_USEUART4)
a961bf38
EB
51 PB26_AF_UART4_RTS,
52 PB28_AF_UART4_TXD,
53 PB29_AF_UART4_CTS,
54 PB31_AF_UART4_RXD,
2d66c780 55#endif
a961bf38
EB
56 /* SDHC1*/
57 PE18_PF_SD1_D0,
58 PE19_PF_SD1_D1,
59 PE20_PF_SD1_D2,
60 PE21_PF_SD1_D3,
61 PE22_PF_SD1_CMD,
62 PE23_PF_SD1_CLK,
63 /* display */
64 PA5_PF_LSCLK,
65 PA6_PF_LD0,
66 PA7_PF_LD1,
67 PA8_PF_LD2,
68 PA9_PF_LD3,
69 PA10_PF_LD4,
70 PA11_PF_LD5,
71 PA12_PF_LD6,
72 PA13_PF_LD7,
73 PA14_PF_LD8,
74 PA15_PF_LD9,
75 PA16_PF_LD10,
76 PA17_PF_LD11,
77 PA18_PF_LD12,
78 PA19_PF_LD13,
79 PA20_PF_LD14,
80 PA21_PF_LD15,
81 PA22_PF_LD16,
82 PA23_PF_LD17,
83 PA28_PF_HSYNC,
84 PA29_PF_VSYNC,
85 PA30_PF_CONTRAST,
86 PA31_PF_OE_ACD,
87 /* SPI1 */
a961bf38
EB
88 PD29_PF_CSPI1_SCLK,
89 PD30_PF_CSPI1_MISO,
90 PD31_PF_CSPI1_MOSI,
d2195d52 91 /* SSI4 */
e8c74860
EB
92#if defined(CONFIG_SND_SOC_EUKREA_TLV320) \
93 || defined(CONFIG_SND_SOC_EUKREA_TLV320_MODULE)
d2195d52
EB
94 PC16_PF_SSI4_FS,
95 PC17_PF_SSI4_RXD | GPIO_PUEN,
96 PC18_PF_SSI4_TXD | GPIO_PUEN,
97 PC19_PF_SSI4_CLK,
98#endif
a961bf38
EB
99};
100
5203b99c
EB
101static const uint32_t eukrea_mbimx27_keymap[] = {
102 KEY(0, 0, KEY_UP),
103 KEY(0, 1, KEY_DOWN),
104 KEY(1, 0, KEY_RIGHT),
105 KEY(1, 1, KEY_LEFT),
106};
107
3f880141
UKK
108static const struct matrix_keymap_data
109eukrea_mbimx27_keymap_data __initconst = {
5203b99c
EB
110 .keymap = eukrea_mbimx27_keymap,
111 .keymap_size = ARRAY_SIZE(eukrea_mbimx27_keymap),
112};
113
47e837b5 114static const struct gpio_led eukrea_mbimx27_gpio_leds[] __initconst = {
a961bf38
EB
115 {
116 .name = "led1",
117 .default_trigger = "heartbeat",
118 .active_low = 1,
119 .gpio = GPIO_PORTF | 16,
120 },
121 {
122 .name = "led2",
123 .default_trigger = "none",
124 .active_low = 1,
125 .gpio = GPIO_PORTF | 19,
126 },
a961bf38
EB
127};
128
47e837b5
UKK
129static const struct gpio_led_platform_data
130 eukrea_mbimx27_gpio_led_info __initconst = {
131 .leds = eukrea_mbimx27_gpio_leds,
132 .num_leds = ARRAY_SIZE(eukrea_mbimx27_gpio_leds),
a961bf38
EB
133};
134
135static struct imx_fb_videomode eukrea_mbimx27_modes[] = {
136 {
137 .mode = {
4eaad66a 138 .name = "CMO-QVGA",
a961bf38
EB
139 .refresh = 60,
140 .xres = 320,
141 .yres = 240,
142 .pixclock = 156000,
143 .hsync_len = 30,
144 .left_margin = 38,
145 .right_margin = 20,
146 .vsync_len = 3,
147 .upper_margin = 15,
148 .lower_margin = 4,
149 },
150 .pcr = 0xFAD08B80,
a465242e
EB
151 .bpp = 16,
152 }, {
153 .mode = {
154 .name = "DVI-VGA",
155 .refresh = 60,
156 .xres = 640,
157 .yres = 480,
158 .pixclock = 32000,
159 .hsync_len = 1,
160 .left_margin = 35,
161 .right_margin = 0,
162 .vsync_len = 1,
163 .upper_margin = 7,
164 .lower_margin = 0,
165 },
166 .pcr = 0xFA208B80,
167 .bpp = 16,
168 }, {
169 .mode = {
170 .name = "DVI-SVGA",
171 .refresh = 60,
172 .xres = 800,
173 .yres = 600,
174 .pixclock = 25000,
175 .hsync_len = 1,
176 .left_margin = 35,
177 .right_margin = 0,
178 .vsync_len = 1,
179 .upper_margin = 7,
180 .lower_margin = 0,
181 },
182 .pcr = 0xFA208B80,
a961bf38
EB
183 .bpp = 16,
184 },
185};
186
ad851bff 187static const struct imx_fb_platform_data eukrea_mbimx27_fb_data __initconst = {
a961bf38
EB
188 .mode = eukrea_mbimx27_modes,
189 .num_modes = ARRAY_SIZE(eukrea_mbimx27_modes),
190
191 .pwmr = 0x00A903FF,
192 .lscr1 = 0x00120300,
193 .dmacr = 0x00040060,
194};
195
fc04ad0e
EB
196static void eukrea_mbimx27_bl_set_intensity(int intensity)
197{
198 if (intensity)
199 gpio_direction_output(GPIO_PORTE | 5, 1);
200 else
201 gpio_direction_output(GPIO_PORTE | 5, 0);
202}
203
204static struct generic_bl_info eukrea_mbimx27_bl_info = {
205 .name = "eukrea_mbimx27-bl",
206 .max_intensity = 0xff,
207 .default_intensity = 0xff,
208 .set_bl_intensity = eukrea_mbimx27_bl_set_intensity,
209};
210
211static struct platform_device eukrea_mbimx27_bl_dev = {
212 .name = "generic-bl",
213 .id = 1,
214 .dev = {
215 .platform_data = &eukrea_mbimx27_bl_info,
216 },
217};
218
219static void eukrea_mbimx27_lcd_power_set(struct plat_lcd_data *pd,
220 unsigned int power)
221{
222 if (power)
223 gpio_direction_output(GPIO_PORTA | 25, 1);
224 else
225 gpio_direction_output(GPIO_PORTA | 25, 0);
226}
227
228static struct plat_lcd_data eukrea_mbimx27_lcd_power_data = {
229 .set_power = eukrea_mbimx27_lcd_power_set,
230};
231
232static struct platform_device eukrea_mbimx27_lcd_powerdev = {
233 .name = "platform-lcd",
234 .dev.platform_data = &eukrea_mbimx27_lcd_power_data,
235};
236
d5dac4a6
UKK
237static const struct imxuart_platform_data uart_pdata __initconst = {
238 .flags = IMXUART_HAVE_RTSCTS,
a961bf38
EB
239};
240
a961bf38
EB
241#define ADS7846_PENDOWN (GPIO_PORTD | 25)
242
9b1e1ea3 243static void __maybe_unused ads7846_dev_init(void)
a961bf38
EB
244{
245 if (gpio_request(ADS7846_PENDOWN, "ADS7846 pendown") < 0) {
07f0450e 246 printk(KERN_ERR "can't get ads7846 pen down GPIO\n");
a961bf38
EB
247 return;
248 }
a961bf38
EB
249 gpio_direction_input(ADS7846_PENDOWN);
250}
251
252static int ads7846_get_pendown_state(void)
253{
254 return !gpio_get_value(ADS7846_PENDOWN);
255}
256
257static struct ads7846_platform_data ads7846_config __initdata = {
258 .get_pendown_state = ads7846_get_pendown_state,
259 .keep_vref_on = 1,
260};
261
9b1e1ea3
UKK
262static struct spi_board_info __maybe_unused
263 eukrea_mbimx27_spi_board_info[] __initdata = {
a961bf38
EB
264 [0] = {
265 .modalias = "ads7846",
266 .bus_num = 0,
267 .chip_select = 0,
268 .max_speed_hz = 1500000,
269 .irq = IRQ_GPIOD(25),
270 .platform_data = &ads7846_config,
271 .mode = SPI_MODE_2,
272 },
273};
274
275static int eukrea_mbimx27_spi_cs[] = {GPIO_PORTD | 28};
276
7536cf99 277static const struct spi_imx_master eukrea_mbimx27_spi0_data __initconst = {
a961bf38
EB
278 .chipselect = eukrea_mbimx27_spi_cs,
279 .num_chipselect = ARRAY_SIZE(eukrea_mbimx27_spi_cs),
280};
a961bf38 281
5055d1ef
EB
282static struct i2c_board_info eukrea_mbimx27_i2c_devices[] = {
283 {
284 I2C_BOARD_INFO("tlv320aic23", 0x1a),
285 },
286};
287
9d3d945a 288static const struct imxmmc_platform_data sdhc_pdata __initconst = {
e76a17c2
EB
289 .dat3_card_detect = 1,
290};
291
4697bb92
UKK
292static const
293struct imx_ssi_platform_data eukrea_mbimx27_ssi_pdata __initconst = {
d2195d52
EB
294 .flags = IMX_SSI_DMA | IMX_SSI_USE_I2S_SLAVE,
295};
296
a961bf38
EB
297/*
298 * system init for baseboard usage. Will be called by cpuimx27 init.
299 *
300 * Add platform devices present on this baseboard and init
301 * them from CPU side as far as required to use them later on
302 */
303void __init eukrea_mbimx27_baseboard_init(void)
304{
305 mxc_gpio_setup_multiple_pins(eukrea_mbimx27_pins,
306 ARRAY_SIZE(eukrea_mbimx27_pins), "MBIMX27");
307
d5dac4a6
UKK
308 imx27_add_imx_uart1(&uart_pdata);
309 imx27_add_imx_uart2(&uart_pdata);
2d66c780 310#if !defined(MACH_EUKREA_CPUIMX27_USEUART4)
2dcf78c0 311 imx27_add_imx_uart3(&uart_pdata);
2d66c780 312#endif
a961bf38 313
ad851bff 314 imx27_add_imx_fb(&eukrea_mbimx27_fb_data);
9d3d945a 315 imx27_add_mxc_mmc(0, &sdhc_pdata);
a961bf38 316
d2195d52
EB
317 i2c_register_board_info(0, eukrea_mbimx27_i2c_devices,
318 ARRAY_SIZE(eukrea_mbimx27_i2c_devices));
319
4697bb92 320 imx27_add_imx_ssi(0, &eukrea_mbimx27_ssi_pdata);
d2195d52 321
62d725b1 322#if defined(CONFIG_TOUCHSCREEN_ADS7846) \
a961bf38 323 || defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
62d725b1 324 /* ADS7846 Touchscreen controller init */
a961bf38 325 mxc_gpio_mode(GPIO_PORTD | 25 | GPIO_GPIO | GPIO_IN);
62d725b1
EB
326 ads7846_dev_init();
327#endif
328
62d725b1
EB
329 /* SPI_CS0 init */
330 mxc_gpio_mode(GPIO_PORTD | 28 | GPIO_GPIO | GPIO_OUT);
7536cf99 331 imx27_add_spi_imx0(&eukrea_mbimx27_spi0_data);
a961bf38
EB
332 spi_register_board_info(eukrea_mbimx27_spi_board_info,
333 ARRAY_SIZE(eukrea_mbimx27_spi_board_info));
a961bf38
EB
334
335 /* Leds configuration */
336 mxc_gpio_mode(GPIO_PORTF | 16 | GPIO_GPIO | GPIO_OUT);
337 mxc_gpio_mode(GPIO_PORTF | 19 | GPIO_GPIO | GPIO_OUT);
338 /* Backlight */
339 mxc_gpio_mode(GPIO_PORTE | 5 | GPIO_GPIO | GPIO_OUT);
fc04ad0e
EB
340 gpio_request(GPIO_PORTE | 5, "backlight");
341 platform_device_register(&eukrea_mbimx27_bl_dev);
342 /* LCD Reset */
343 mxc_gpio_mode(GPIO_PORTA | 25 | GPIO_GPIO | GPIO_OUT);
344 gpio_request(GPIO_PORTA | 25, "lcd_enable");
345 platform_device_register(&eukrea_mbimx27_lcd_powerdev);
a961bf38 346
3f880141 347 imx27_add_imx_keypad(&eukrea_mbimx27_keymap_data);
5203b99c 348
47e837b5 349 gpio_led_register_device(-1, &eukrea_mbimx27_gpio_led_info);
a961bf38 350}
This page took 0.224464 seconds and 5 git commands to generate.