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