2 * Copyright (C) 2009-2010 Eric Benard - eric@eukrea.com
4 * Based on pcm970-baseboard.c which is :
5 * Copyright (C) 2008 Juergen Beisert (kernel@pengutronix.de)
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.
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,
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>
27 #include <linux/backlight.h>
28 #include <video/platform_lcd.h>
29 #include <linux/input/matrix_keypad.h>
31 #include <asm/mach/arch.h>
33 #include <mach/common.h>
34 #include <mach/iomux-mx27.h>
35 #include <mach/imxfb.h>
36 #include <mach/hardware.h>
38 #include <mach/imx-uart.h>
41 #include <mach/audmux.h>
45 static int eukrea_mbimx27_pins
[] = {
57 #if !defined(MACH_EUKREA_CPUIMX27_USEUART4)
99 #if defined(CONFIG_SND_SOC_EUKREA_TLV320) \
100 || defined(CONFIG_SND_SOC_EUKREA_TLV320_MODULE)
102 PC17_PF_SSI4_RXD
| GPIO_PUEN
,
103 PC18_PF_SSI4_TXD
| GPIO_PUEN
,
108 static const uint32_t eukrea_mbimx27_keymap
[] = {
111 KEY(1, 0, KEY_RIGHT
),
115 static struct matrix_keymap_data eukrea_mbimx27_keymap_data
= {
116 .keymap
= eukrea_mbimx27_keymap
,
117 .keymap_size
= ARRAY_SIZE(eukrea_mbimx27_keymap
),
120 static struct gpio_led gpio_leds
[] = {
123 .default_trigger
= "heartbeat",
125 .gpio
= GPIO_PORTF
| 16,
129 .default_trigger
= "none",
131 .gpio
= GPIO_PORTF
| 19,
135 static struct gpio_led_platform_data gpio_led_info
= {
137 .num_leds
= ARRAY_SIZE(gpio_leds
),
140 static struct platform_device leds_gpio
= {
144 .platform_data
= &gpio_led_info
,
148 static struct imx_fb_videomode eukrea_mbimx27_modes
[] = {
200 static struct imx_fb_platform_data eukrea_mbimx27_fb_data
= {
201 .mode
= eukrea_mbimx27_modes
,
202 .num_modes
= ARRAY_SIZE(eukrea_mbimx27_modes
),
209 static void eukrea_mbimx27_bl_set_intensity(int intensity
)
212 gpio_direction_output(GPIO_PORTE
| 5, 1);
214 gpio_direction_output(GPIO_PORTE
| 5, 0);
217 static struct generic_bl_info eukrea_mbimx27_bl_info
= {
218 .name
= "eukrea_mbimx27-bl",
219 .max_intensity
= 0xff,
220 .default_intensity
= 0xff,
221 .set_bl_intensity
= eukrea_mbimx27_bl_set_intensity
,
224 static struct platform_device eukrea_mbimx27_bl_dev
= {
225 .name
= "generic-bl",
228 .platform_data
= &eukrea_mbimx27_bl_info
,
232 static void eukrea_mbimx27_lcd_power_set(struct plat_lcd_data
*pd
,
236 gpio_direction_output(GPIO_PORTA
| 25, 1);
238 gpio_direction_output(GPIO_PORTA
| 25, 0);
241 static struct plat_lcd_data eukrea_mbimx27_lcd_power_data
= {
242 .set_power
= eukrea_mbimx27_lcd_power_set
,
245 static struct platform_device eukrea_mbimx27_lcd_powerdev
= {
246 .name
= "platform-lcd",
247 .dev
.platform_data
= &eukrea_mbimx27_lcd_power_data
,
250 static struct imxuart_platform_data uart_pdata
[] = {
252 .flags
= IMXUART_HAVE_RTSCTS
,
255 .flags
= IMXUART_HAVE_RTSCTS
,
258 .flags
= IMXUART_HAVE_RTSCTS
,
262 #if defined(CONFIG_TOUCHSCREEN_ADS7846) \
263 || defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
265 #define ADS7846_PENDOWN (GPIO_PORTD | 25)
267 static void ads7846_dev_init(void)
269 if (gpio_request(ADS7846_PENDOWN
, "ADS7846 pendown") < 0) {
270 printk(KERN_ERR
"can't get ads746 pen down GPIO\n");
273 gpio_direction_input(ADS7846_PENDOWN
);
276 static int ads7846_get_pendown_state(void)
278 return !gpio_get_value(ADS7846_PENDOWN
);
281 static struct ads7846_platform_data ads7846_config __initdata
= {
282 .get_pendown_state
= ads7846_get_pendown_state
,
287 #if defined(CONFIG_SPI_IMX) || defined(CONFIG_SPI_IMX_MODULE)
288 static struct spi_board_info eukrea_mbimx27_spi_board_info
[] __initdata
= {
290 .modalias
= "ads7846",
293 .max_speed_hz
= 1500000,
294 .irq
= IRQ_GPIOD(25),
295 .platform_data
= &ads7846_config
,
300 static struct i2c_board_info eukrea_mbimx27_i2c_devices
[] = {
302 I2C_BOARD_INFO("tlv320aic23", 0x1a),
306 static int eukrea_mbimx27_spi_cs
[] = {GPIO_PORTD
| 28};
308 static struct spi_imx_master eukrea_mbimx27_spi_0_data
= {
309 .chipselect
= eukrea_mbimx27_spi_cs
,
310 .num_chipselect
= ARRAY_SIZE(eukrea_mbimx27_spi_cs
),
314 static struct platform_device
*platform_devices
[] __initdata
= {
318 static struct imxmmc_platform_data sdhc_pdata
= {
319 .dat3_card_detect
= 1,
322 struct imx_ssi_platform_data eukrea_mbimx27_ssi_pdata
= {
323 .flags
= IMX_SSI_DMA
| IMX_SSI_USE_I2S_SLAVE
,
327 * system init for baseboard usage. Will be called by cpuimx27 init.
329 * Add platform devices present on this baseboard and init
330 * them from CPU side as far as required to use them later on
332 void __init
eukrea_mbimx27_baseboard_init(void)
334 mxc_gpio_setup_multiple_pins(eukrea_mbimx27_pins
,
335 ARRAY_SIZE(eukrea_mbimx27_pins
), "MBIMX27");
337 #if defined(CONFIG_SND_SOC_EUKREA_TLV320) \
338 || defined(CONFIG_SND_SOC_EUKREA_TLV320_MODULE)
339 /* SSI unit master I2S codec connected to SSI_PINS_4*/
340 mxc_audmux_v1_configure_port(MX27_AUDMUX_HPCR1_SSI0
,
341 MXC_AUDMUX_V1_PCR_SYN
|
342 MXC_AUDMUX_V1_PCR_TFSDIR
|
343 MXC_AUDMUX_V1_PCR_TCLKDIR
|
344 MXC_AUDMUX_V1_PCR_RFSDIR
|
345 MXC_AUDMUX_V1_PCR_RCLKDIR
|
346 MXC_AUDMUX_V1_PCR_TFCSEL(MX27_AUDMUX_HPCR3_SSI_PINS_4
) |
347 MXC_AUDMUX_V1_PCR_RFCSEL(MX27_AUDMUX_HPCR3_SSI_PINS_4
) |
348 MXC_AUDMUX_V1_PCR_RXDSEL(MX27_AUDMUX_HPCR3_SSI_PINS_4
)
350 mxc_audmux_v1_configure_port(MX27_AUDMUX_HPCR3_SSI_PINS_4
,
351 MXC_AUDMUX_V1_PCR_SYN
|
352 MXC_AUDMUX_V1_PCR_RXDSEL(MX27_AUDMUX_HPCR1_SSI0
)
356 mxc_register_device(&mxc_uart_device1
, &uart_pdata
[0]);
357 mxc_register_device(&mxc_uart_device2
, &uart_pdata
[1]);
358 #if !defined(MACH_EUKREA_CPUIMX27_USEUART4)
359 mxc_register_device(&mxc_uart_device3
, &uart_pdata
[2]);
362 mxc_register_device(&mxc_fb_device
, &eukrea_mbimx27_fb_data
);
363 mxc_register_device(&mxc_sdhc_device0
, &sdhc_pdata
);
365 i2c_register_board_info(0, eukrea_mbimx27_i2c_devices
,
366 ARRAY_SIZE(eukrea_mbimx27_i2c_devices
));
368 mxc_register_device(&imx_ssi_device0
, &eukrea_mbimx27_ssi_pdata
);
370 #if defined(CONFIG_TOUCHSCREEN_ADS7846) \
371 || defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
372 /* ADS7846 Touchscreen controller init */
373 mxc_gpio_mode(GPIO_PORTD
| 25 | GPIO_GPIO
| GPIO_IN
);
377 #if defined(CONFIG_SPI_IMX) || defined(CONFIG_SPI_IMX_MODULE)
379 mxc_gpio_mode(GPIO_PORTD
| 28 | GPIO_GPIO
| GPIO_OUT
);
380 mxc_register_device(&mxc_spi_device0
, &eukrea_mbimx27_spi_0_data
);
381 spi_register_board_info(eukrea_mbimx27_spi_board_info
,
382 ARRAY_SIZE(eukrea_mbimx27_spi_board_info
));
385 /* Leds configuration */
386 mxc_gpio_mode(GPIO_PORTF
| 16 | GPIO_GPIO
| GPIO_OUT
);
387 mxc_gpio_mode(GPIO_PORTF
| 19 | GPIO_GPIO
| GPIO_OUT
);
389 mxc_gpio_mode(GPIO_PORTE
| 5 | GPIO_GPIO
| GPIO_OUT
);
390 gpio_request(GPIO_PORTE
| 5, "backlight");
391 platform_device_register(&eukrea_mbimx27_bl_dev
);
393 mxc_gpio_mode(GPIO_PORTA
| 25 | GPIO_GPIO
| GPIO_OUT
);
394 gpio_request(GPIO_PORTA
| 25, "lcd_enable");
395 platform_device_register(&eukrea_mbimx27_lcd_powerdev
);
397 mxc_register_device(&imx_kpp_device
, &eukrea_mbimx27_keymap_data
);
399 platform_add_devices(platform_devices
, ARRAY_SIZE(platform_devices
));