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>
30 #include <asm/mach/arch.h>
32 #include <mach/common.h>
33 #include <mach/iomux-mx27.h>
34 #include <mach/hardware.h>
36 #include "devices-imx27.h"
38 static const int eukrea_mbimx27_pins
[] __initconst
= {
50 #if !defined(MACH_EUKREA_CPUIMX27_USEUART4)
92 #if defined(CONFIG_SND_SOC_EUKREA_TLV320) \
93 || defined(CONFIG_SND_SOC_EUKREA_TLV320_MODULE)
95 PC17_PF_SSI4_RXD
| GPIO_PUEN
,
96 PC18_PF_SSI4_TXD
| GPIO_PUEN
,
101 static const uint32_t eukrea_mbimx27_keymap
[] = {
104 KEY(1, 0, KEY_RIGHT
),
108 static const struct matrix_keymap_data
109 eukrea_mbimx27_keymap_data __initconst
= {
110 .keymap
= eukrea_mbimx27_keymap
,
111 .keymap_size
= ARRAY_SIZE(eukrea_mbimx27_keymap
),
114 static const struct gpio_led eukrea_mbimx27_gpio_leds
[] __initconst
= {
117 .default_trigger
= "heartbeat",
119 .gpio
= GPIO_PORTF
| 16,
123 .default_trigger
= "none",
125 .gpio
= GPIO_PORTF
| 19,
129 static 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
),
135 static struct imx_fb_videomode eukrea_mbimx27_modes
[] = {
187 static const struct imx_fb_platform_data eukrea_mbimx27_fb_data __initconst
= {
188 .mode
= eukrea_mbimx27_modes
,
189 .num_modes
= ARRAY_SIZE(eukrea_mbimx27_modes
),
196 static void eukrea_mbimx27_bl_set_intensity(int intensity
)
199 gpio_direction_output(GPIO_PORTE
| 5, 1);
201 gpio_direction_output(GPIO_PORTE
| 5, 0);
204 static 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
,
211 static struct platform_device eukrea_mbimx27_bl_dev
= {
212 .name
= "generic-bl",
215 .platform_data
= &eukrea_mbimx27_bl_info
,
219 static void eukrea_mbimx27_lcd_power_set(struct plat_lcd_data
*pd
,
223 gpio_direction_output(GPIO_PORTA
| 25, 1);
225 gpio_direction_output(GPIO_PORTA
| 25, 0);
228 static struct plat_lcd_data eukrea_mbimx27_lcd_power_data
= {
229 .set_power
= eukrea_mbimx27_lcd_power_set
,
232 static struct platform_device eukrea_mbimx27_lcd_powerdev
= {
233 .name
= "platform-lcd",
234 .dev
.platform_data
= &eukrea_mbimx27_lcd_power_data
,
237 static const struct imxuart_platform_data uart_pdata __initconst
= {
238 .flags
= IMXUART_HAVE_RTSCTS
,
241 #define ADS7846_PENDOWN (GPIO_PORTD | 25)
243 static void __maybe_unused
ads7846_dev_init(void)
245 if (gpio_request(ADS7846_PENDOWN
, "ADS7846 pendown") < 0) {
246 printk(KERN_ERR
"can't get ads7846 pen down GPIO\n");
249 gpio_direction_input(ADS7846_PENDOWN
);
252 static int ads7846_get_pendown_state(void)
254 return !gpio_get_value(ADS7846_PENDOWN
);
257 static struct ads7846_platform_data ads7846_config __initdata
= {
258 .get_pendown_state
= ads7846_get_pendown_state
,
262 static struct spi_board_info __maybe_unused
263 eukrea_mbimx27_spi_board_info
[] __initdata
= {
265 .modalias
= "ads7846",
268 .max_speed_hz
= 1500000,
269 /* irq number is run-time assigned */
270 .platform_data
= &ads7846_config
,
275 static int eukrea_mbimx27_spi_cs
[] = {GPIO_PORTD
| 28};
277 static const struct spi_imx_master eukrea_mbimx27_spi0_data __initconst
= {
278 .chipselect
= eukrea_mbimx27_spi_cs
,
279 .num_chipselect
= ARRAY_SIZE(eukrea_mbimx27_spi_cs
),
282 static struct i2c_board_info eukrea_mbimx27_i2c_devices
[] = {
284 I2C_BOARD_INFO("tlv320aic23", 0x1a),
288 static const struct imxmmc_platform_data sdhc_pdata __initconst
= {
289 .dat3_card_detect
= 1,
293 struct imx_ssi_platform_data eukrea_mbimx27_ssi_pdata __initconst
= {
294 .flags
= IMX_SSI_DMA
| IMX_SSI_USE_I2S_SLAVE
,
298 * system init for baseboard usage. Will be called by cpuimx27 init.
300 * Add platform devices present on this baseboard and init
301 * them from CPU side as far as required to use them later on
303 void __init
eukrea_mbimx27_baseboard_init(void)
305 mxc_gpio_setup_multiple_pins(eukrea_mbimx27_pins
,
306 ARRAY_SIZE(eukrea_mbimx27_pins
), "MBIMX27");
308 imx27_add_imx_uart1(&uart_pdata
);
309 imx27_add_imx_uart2(&uart_pdata
);
310 #if !defined(MACH_EUKREA_CPUIMX27_USEUART4)
311 imx27_add_imx_uart3(&uart_pdata
);
314 imx27_add_imx_fb(&eukrea_mbimx27_fb_data
);
315 imx27_add_mxc_mmc(0, &sdhc_pdata
);
317 i2c_register_board_info(0, eukrea_mbimx27_i2c_devices
,
318 ARRAY_SIZE(eukrea_mbimx27_i2c_devices
));
320 imx27_add_imx_ssi(0, &eukrea_mbimx27_ssi_pdata
);
322 #if defined(CONFIG_TOUCHSCREEN_ADS7846) \
323 || defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
324 /* ADS7846 Touchscreen controller init */
325 mxc_gpio_mode(GPIO_PORTD
| 25 | GPIO_GPIO
| GPIO_IN
);
330 mxc_gpio_mode(GPIO_PORTD
| 28 | GPIO_GPIO
| GPIO_OUT
);
331 imx27_add_spi_imx0(&eukrea_mbimx27_spi0_data
);
332 eukrea_mbimx27_spi_board_info
[0].irq
= gpio_to_irq(IMX_GPIO_NR(4, 25));
333 spi_register_board_info(eukrea_mbimx27_spi_board_info
,
334 ARRAY_SIZE(eukrea_mbimx27_spi_board_info
));
336 /* Leds configuration */
337 mxc_gpio_mode(GPIO_PORTF
| 16 | GPIO_GPIO
| GPIO_OUT
);
338 mxc_gpio_mode(GPIO_PORTF
| 19 | GPIO_GPIO
| GPIO_OUT
);
340 mxc_gpio_mode(GPIO_PORTE
| 5 | GPIO_GPIO
| GPIO_OUT
);
341 gpio_request(GPIO_PORTE
| 5, "backlight");
342 platform_device_register(&eukrea_mbimx27_bl_dev
);
344 mxc_gpio_mode(GPIO_PORTA
| 25 | GPIO_GPIO
| GPIO_OUT
);
345 gpio_request(GPIO_PORTA
| 25, "lcd_enable");
346 platform_device_register(&eukrea_mbimx27_lcd_powerdev
);
348 imx27_add_imx_keypad(&eukrea_mbimx27_keymap_data
);
350 gpio_led_register_device(-1, &eukrea_mbimx27_gpio_led_info
);