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>
28 #include <asm/mach/arch.h>
30 #include <mach/common.h>
31 #include <mach/iomux.h>
32 #include <mach/imxfb.h>
33 #include <mach/hardware.h>
35 #include <mach/imx-uart.h>
39 static int eukrea_mbimx27_pins
[] = {
93 static struct gpio_led gpio_leds
[] = {
96 .default_trigger
= "heartbeat",
98 .gpio
= GPIO_PORTF
| 16,
102 .default_trigger
= "none",
104 .gpio
= GPIO_PORTF
| 19,
108 .default_trigger
= "backlight",
110 .gpio
= GPIO_PORTE
| 5,
114 static struct gpio_led_platform_data gpio_led_info
= {
116 .num_leds
= ARRAY_SIZE(gpio_leds
),
119 static struct platform_device leds_gpio
= {
123 .platform_data
= &gpio_led_info
,
127 static struct imx_fb_videomode eukrea_mbimx27_modes
[] = {
147 static struct imx_fb_platform_data eukrea_mbimx27_fb_data
= {
148 .mode
= eukrea_mbimx27_modes
,
149 .num_modes
= ARRAY_SIZE(eukrea_mbimx27_modes
),
156 static struct imxuart_platform_data uart_pdata
[] = {
158 .flags
= IMXUART_HAVE_RTSCTS
,
161 .flags
= IMXUART_HAVE_RTSCTS
,
165 #if defined(CONFIG_TOUCHSCREEN_ADS7846)
166 || defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE
)
168 #define ADS7846_PENDOWN (GPIO_PORTD | 25)
170 static void ads7846_dev_init(void)
172 if (gpio_request(ADS7846_PENDOWN
, "ADS7846 pendown") < 0) {
173 printk(KERN_ERR
"can't get ads746 pen down GPIO\n");
177 gpio_direction_input(ADS7846_PENDOWN
);
180 static int ads7846_get_pendown_state(void)
182 return !gpio_get_value(ADS7846_PENDOWN
);
185 static struct ads7846_platform_data ads7846_config __initdata
= {
186 .get_pendown_state
= ads7846_get_pendown_state
,
190 static struct spi_board_info eukrea_mbimx27_spi_board_info
[] __initdata
= {
192 .modalias
= "ads7846",
195 .max_speed_hz
= 1500000,
196 .irq
= IRQ_GPIOD(25),
197 .platform_data
= &ads7846_config
,
202 static int eukrea_mbimx27_spi_cs
[] = {GPIO_PORTD
| 28};
204 static struct spi_imx_master eukrea_mbimx27_spi_0_data
= {
205 .chipselect
= eukrea_mbimx27_spi_cs
,
206 .num_chipselect
= ARRAY_SIZE(eukrea_mbimx27_spi_cs
),
210 static struct platform_device
*platform_devices
[] __initdata
= {
215 * system init for baseboard usage. Will be called by cpuimx27 init.
217 * Add platform devices present on this baseboard and init
218 * them from CPU side as far as required to use them later on
220 void __init
eukrea_mbimx27_baseboard_init(void)
222 mxc_gpio_setup_multiple_pins(eukrea_mbimx27_pins
,
223 ARRAY_SIZE(eukrea_mbimx27_pins
), "MBIMX27");
225 mxc_register_device(&mxc_uart_device1
, &uart_pdata
[0]);
226 mxc_register_device(&mxc_uart_device2
, &uart_pdata
[1]);
228 mxc_register_device(&mxc_fb_device
, &eukrea_mbimx27_fb_data
);
229 mxc_register_device(&mxc_sdhc_device0
, NULL
);
231 #if defined(CONFIG_TOUCHSCREEN_ADS7846)
232 || defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE
)
233 /* SPI and ADS7846 Touchscreen controler init */
234 mxc_gpio_mode(GPIO_PORTD
| 28 | GPIO_GPIO
| GPIO_OUT
);
235 mxc_gpio_mode(GPIO_PORTD
| 25 | GPIO_GPIO
| GPIO_IN
);
236 mxc_register_device(&mxc_spi_device0
, &eukrea_mbimx27_spi_0_data
);
237 spi_register_board_info(eukrea_mbimx27_spi_board_info
,
238 ARRAY_SIZE(eukrea_mbimx27_spi_board_info
));
242 /* Leds configuration */
243 mxc_gpio_mode(GPIO_PORTF
| 16 | GPIO_GPIO
| GPIO_OUT
);
244 mxc_gpio_mode(GPIO_PORTF
| 19 | GPIO_GPIO
| GPIO_OUT
);
246 mxc_gpio_mode(GPIO_PORTE
| 5 | GPIO_GPIO
| GPIO_OUT
);
248 platform_add_devices(platform_devices
, ARRAY_SIZE(platform_devices
));