2 * Copyright (C) 2009 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/imxfb.h>
35 #include <mach/hardware.h>
37 #include <mach/imx-uart.h>
42 static int eukrea_mbimx27_pins
[] = {
54 #if !defined(MACH_EUKREA_CPUIMX27_USEUART4)
97 static struct gpio_led gpio_leds
[] = {
100 .default_trigger
= "heartbeat",
102 .gpio
= GPIO_PORTF
| 16,
106 .default_trigger
= "none",
108 .gpio
= GPIO_PORTF
| 19,
112 static struct gpio_led_platform_data gpio_led_info
= {
114 .num_leds
= ARRAY_SIZE(gpio_leds
),
117 static struct platform_device leds_gpio
= {
121 .platform_data
= &gpio_led_info
,
125 static struct imx_fb_videomode eukrea_mbimx27_modes
[] = {
177 static struct imx_fb_platform_data eukrea_mbimx27_fb_data
= {
178 .mode
= eukrea_mbimx27_modes
,
179 .num_modes
= ARRAY_SIZE(eukrea_mbimx27_modes
),
186 static void eukrea_mbimx27_bl_set_intensity(int intensity
)
189 gpio_direction_output(GPIO_PORTE
| 5, 1);
191 gpio_direction_output(GPIO_PORTE
| 5, 0);
194 static 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
,
201 static struct platform_device eukrea_mbimx27_bl_dev
= {
202 .name
= "generic-bl",
205 .platform_data
= &eukrea_mbimx27_bl_info
,
209 static void eukrea_mbimx27_lcd_power_set(struct plat_lcd_data
*pd
,
213 gpio_direction_output(GPIO_PORTA
| 25, 1);
215 gpio_direction_output(GPIO_PORTA
| 25, 0);
218 static struct plat_lcd_data eukrea_mbimx27_lcd_power_data
= {
219 .set_power
= eukrea_mbimx27_lcd_power_set
,
222 static struct platform_device eukrea_mbimx27_lcd_powerdev
= {
223 .name
= "platform-lcd",
224 .dev
.platform_data
= &eukrea_mbimx27_lcd_power_data
,
227 static struct imxuart_platform_data uart_pdata
[] = {
229 .flags
= IMXUART_HAVE_RTSCTS
,
232 .flags
= IMXUART_HAVE_RTSCTS
,
235 .flags
= IMXUART_HAVE_RTSCTS
,
239 #if defined(CONFIG_TOUCHSCREEN_ADS7846) \
240 || defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
242 #define ADS7846_PENDOWN (GPIO_PORTD | 25)
244 static void ads7846_dev_init(void)
246 if (gpio_request(ADS7846_PENDOWN
, "ADS7846 pendown") < 0) {
247 printk(KERN_ERR
"can't get ads746 pen down GPIO\n");
250 gpio_direction_input(ADS7846_PENDOWN
);
253 static int ads7846_get_pendown_state(void)
255 return !gpio_get_value(ADS7846_PENDOWN
);
258 static struct ads7846_platform_data ads7846_config __initdata
= {
259 .get_pendown_state
= ads7846_get_pendown_state
,
264 #if defined(CONFIG_SPI_IMX) || defined(CONFIG_SPI_IMX_MODULE)
265 static struct spi_board_info eukrea_mbimx27_spi_board_info
[] __initdata
= {
267 .modalias
= "ads7846",
270 .max_speed_hz
= 1500000,
271 .irq
= IRQ_GPIOD(25),
272 .platform_data
= &ads7846_config
,
277 static int eukrea_mbimx27_spi_cs
[] = {GPIO_PORTD
| 28};
279 static struct spi_imx_master eukrea_mbimx27_spi_0_data
= {
280 .chipselect
= eukrea_mbimx27_spi_cs
,
281 .num_chipselect
= ARRAY_SIZE(eukrea_mbimx27_spi_cs
),
285 static struct platform_device
*platform_devices
[] __initdata
= {
289 static struct imxmmc_platform_data sdhc_pdata
= {
290 .dat3_card_detect
= 1,
294 * system init for baseboard usage. Will be called by cpuimx27 init.
296 * Add platform devices present on this baseboard and init
297 * them from CPU side as far as required to use them later on
299 void __init
eukrea_mbimx27_baseboard_init(void)
301 mxc_gpio_setup_multiple_pins(eukrea_mbimx27_pins
,
302 ARRAY_SIZE(eukrea_mbimx27_pins
), "MBIMX27");
304 mxc_register_device(&mxc_uart_device1
, &uart_pdata
[0]);
305 mxc_register_device(&mxc_uart_device2
, &uart_pdata
[1]);
306 #if !defined(MACH_EUKREA_CPUIMX27_USEUART4)
307 mxc_register_device(&mxc_uart_device3
, &uart_pdata
[2]);
310 mxc_register_device(&mxc_fb_device
, &eukrea_mbimx27_fb_data
);
311 mxc_register_device(&mxc_sdhc_device0
, &sdhc_pdata
);
313 #if defined(CONFIG_TOUCHSCREEN_ADS7846) \
314 || defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
315 /* ADS7846 Touchscreen controller init */
316 mxc_gpio_mode(GPIO_PORTD
| 25 | GPIO_GPIO
| GPIO_IN
);
320 #if defined(CONFIG_SPI_IMX) || defined(CONFIG_SPI_IMX_MODULE)
322 mxc_gpio_mode(GPIO_PORTD
| 28 | GPIO_GPIO
| GPIO_OUT
);
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
));
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
);
332 mxc_gpio_mode(GPIO_PORTE
| 5 | GPIO_GPIO
| GPIO_OUT
);
333 gpio_request(GPIO_PORTE
| 5, "backlight");
334 platform_device_register(&eukrea_mbimx27_bl_dev
);
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
);
340 platform_add_devices(platform_devices
, ARRAY_SIZE(platform_devices
));