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>
41 static int eukrea_mbimx27_pins[] = {
95 static struct gpio_led gpio_leds[] = {
98 .default_trigger = "heartbeat",
100 .gpio = GPIO_PORTF | 16,
104 .default_trigger = "none",
106 .gpio = GPIO_PORTF | 19,
110 static struct gpio_led_platform_data gpio_led_info = {
112 .num_leds = ARRAY_SIZE(gpio_leds),
115 static struct platform_device leds_gpio = {
119 .platform_data = &gpio_led_info,
123 static struct imx_fb_videomode eukrea_mbimx27_modes[] = {
175 static struct imx_fb_platform_data eukrea_mbimx27_fb_data = {
176 .mode = eukrea_mbimx27_modes,
177 .num_modes = ARRAY_SIZE(eukrea_mbimx27_modes),
184 static void eukrea_mbimx27_bl_set_intensity(int intensity)
187 gpio_direction_output(GPIO_PORTE | 5, 1);
189 gpio_direction_output(GPIO_PORTE | 5, 0);
192 static struct generic_bl_info eukrea_mbimx27_bl_info = {
193 .name = "eukrea_mbimx27-bl",
194 .max_intensity = 0xff,
195 .default_intensity = 0xff,
196 .set_bl_intensity = eukrea_mbimx27_bl_set_intensity,
199 static struct platform_device eukrea_mbimx27_bl_dev = {
200 .name = "generic-bl",
203 .platform_data = &eukrea_mbimx27_bl_info,
207 static void eukrea_mbimx27_lcd_power_set(struct plat_lcd_data *pd,
211 gpio_direction_output(GPIO_PORTA | 25, 1);
213 gpio_direction_output(GPIO_PORTA | 25, 0);
216 static struct plat_lcd_data eukrea_mbimx27_lcd_power_data = {
217 .set_power = eukrea_mbimx27_lcd_power_set,
220 static struct platform_device eukrea_mbimx27_lcd_powerdev = {
221 .name = "platform-lcd",
222 .dev.platform_data = &eukrea_mbimx27_lcd_power_data,
225 static struct imxuart_platform_data uart_pdata[] = {
227 .flags = IMXUART_HAVE_RTSCTS,
230 .flags = IMXUART_HAVE_RTSCTS,
234 #if defined(CONFIG_TOUCHSCREEN_ADS7846)
235 || defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
237 #define ADS7846_PENDOWN (GPIO_PORTD | 25)
239 static void ads7846_dev_init(void)
241 if (gpio_request(ADS7846_PENDOWN, "ADS7846 pendown") < 0) {
242 printk(KERN_ERR "can't get ads746 pen down GPIO\n");
246 gpio_direction_input(ADS7846_PENDOWN);
249 static int ads7846_get_pendown_state(void)
251 return !gpio_get_value(ADS7846_PENDOWN);
254 static struct ads7846_platform_data ads7846_config __initdata = {
255 .get_pendown_state = ads7846_get_pendown_state,
259 static struct spi_board_info eukrea_mbimx27_spi_board_info[] __initdata = {
261 .modalias = "ads7846",
264 .max_speed_hz = 1500000,
265 .irq = IRQ_GPIOD(25),
266 .platform_data = &ads7846_config,
271 static int eukrea_mbimx27_spi_cs[] = {GPIO_PORTD | 28};
273 static struct spi_imx_master eukrea_mbimx27_spi_0_data = {
274 .chipselect = eukrea_mbimx27_spi_cs,
275 .num_chipselect = ARRAY_SIZE(eukrea_mbimx27_spi_cs),
279 static struct platform_device *platform_devices[] __initdata = {
284 * system init for baseboard usage. Will be called by cpuimx27 init.
286 * Add platform devices present on this baseboard and init
287 * them from CPU side as far as required to use them later on
289 void __init eukrea_mbimx27_baseboard_init(void)
291 mxc_gpio_setup_multiple_pins(eukrea_mbimx27_pins,
292 ARRAY_SIZE(eukrea_mbimx27_pins), "MBIMX27");
294 mxc_register_device(&mxc_uart_device1, &uart_pdata[0]);
295 mxc_register_device(&mxc_uart_device2, &uart_pdata[1]);
297 mxc_register_device(&mxc_fb_device, &eukrea_mbimx27_fb_data);
298 mxc_register_device(&mxc_sdhc_device0, NULL);
300 #if defined(CONFIG_TOUCHSCREEN_ADS7846)
301 || defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
302 /* SPI and ADS7846 Touchscreen controler init */
303 mxc_gpio_mode(GPIO_PORTD | 28 | GPIO_GPIO | GPIO_OUT);
304 mxc_gpio_mode(GPIO_PORTD | 25 | GPIO_GPIO | GPIO_IN);
305 mxc_register_device(&mxc_spi_device0, &eukrea_mbimx27_spi_0_data);
306 spi_register_board_info(eukrea_mbimx27_spi_board_info,
307 ARRAY_SIZE(eukrea_mbimx27_spi_board_info));
311 /* Leds configuration */
312 mxc_gpio_mode(GPIO_PORTF | 16 | GPIO_GPIO | GPIO_OUT);
313 mxc_gpio_mode(GPIO_PORTF | 19 | GPIO_GPIO | GPIO_OUT);
315 mxc_gpio_mode(GPIO_PORTE | 5 | GPIO_GPIO | GPIO_OUT);
316 gpio_request(GPIO_PORTE | 5, "backlight");
317 platform_device_register(&eukrea_mbimx27_bl_dev);
319 mxc_gpio_mode(GPIO_PORTA | 25 | GPIO_GPIO | GPIO_OUT);
320 gpio_request(GPIO_PORTA | 25, "lcd_enable");
321 platform_device_register(&eukrea_mbimx27_lcd_powerdev);
323 platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices));