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>
35 #include <mach/audmux.h>
37 #include "devices-imx27.h"
39 static const int eukrea_mbimx27_pins
[] __initconst
= {
51 #if !defined(MACH_EUKREA_CPUIMX27_USEUART4)
93 #if defined(CONFIG_SND_SOC_EUKREA_TLV320) \
94 || defined(CONFIG_SND_SOC_EUKREA_TLV320_MODULE)
96 PC17_PF_SSI4_RXD
| GPIO_PUEN
,
97 PC18_PF_SSI4_TXD
| GPIO_PUEN
,
102 static const uint32_t eukrea_mbimx27_keymap
[] = {
105 KEY(1, 0, KEY_RIGHT
),
109 static const struct matrix_keymap_data
110 eukrea_mbimx27_keymap_data __initconst
= {
111 .keymap
= eukrea_mbimx27_keymap
,
112 .keymap_size
= ARRAY_SIZE(eukrea_mbimx27_keymap
),
115 static struct gpio_led gpio_leds
[] = {
118 .default_trigger
= "heartbeat",
120 .gpio
= GPIO_PORTF
| 16,
124 .default_trigger
= "none",
126 .gpio
= GPIO_PORTF
| 19,
130 static struct gpio_led_platform_data gpio_led_info
= {
132 .num_leds
= ARRAY_SIZE(gpio_leds
),
135 static struct platform_device leds_gpio
= {
139 .platform_data
= &gpio_led_info
,
143 static struct imx_fb_videomode eukrea_mbimx27_modes
[] = {
195 static const struct imx_fb_platform_data eukrea_mbimx27_fb_data __initconst
= {
196 .mode
= eukrea_mbimx27_modes
,
197 .num_modes
= ARRAY_SIZE(eukrea_mbimx27_modes
),
204 static void eukrea_mbimx27_bl_set_intensity(int intensity
)
207 gpio_direction_output(GPIO_PORTE
| 5, 1);
209 gpio_direction_output(GPIO_PORTE
| 5, 0);
212 static struct generic_bl_info eukrea_mbimx27_bl_info
= {
213 .name
= "eukrea_mbimx27-bl",
214 .max_intensity
= 0xff,
215 .default_intensity
= 0xff,
216 .set_bl_intensity
= eukrea_mbimx27_bl_set_intensity
,
219 static struct platform_device eukrea_mbimx27_bl_dev
= {
220 .name
= "generic-bl",
223 .platform_data
= &eukrea_mbimx27_bl_info
,
227 static void eukrea_mbimx27_lcd_power_set(struct plat_lcd_data
*pd
,
231 gpio_direction_output(GPIO_PORTA
| 25, 1);
233 gpio_direction_output(GPIO_PORTA
| 25, 0);
236 static struct plat_lcd_data eukrea_mbimx27_lcd_power_data
= {
237 .set_power
= eukrea_mbimx27_lcd_power_set
,
240 static struct platform_device eukrea_mbimx27_lcd_powerdev
= {
241 .name
= "platform-lcd",
242 .dev
.platform_data
= &eukrea_mbimx27_lcd_power_data
,
245 static const struct imxuart_platform_data uart_pdata __initconst
= {
246 .flags
= IMXUART_HAVE_RTSCTS
,
249 #define ADS7846_PENDOWN (GPIO_PORTD | 25)
251 static void __maybe_unused
ads7846_dev_init(void)
253 if (gpio_request(ADS7846_PENDOWN
, "ADS7846 pendown") < 0) {
254 printk(KERN_ERR
"can't get ads746 pen down GPIO\n");
257 gpio_direction_input(ADS7846_PENDOWN
);
260 static int ads7846_get_pendown_state(void)
262 return !gpio_get_value(ADS7846_PENDOWN
);
265 static struct ads7846_platform_data ads7846_config __initdata
= {
266 .get_pendown_state
= ads7846_get_pendown_state
,
270 static struct spi_board_info __maybe_unused
271 eukrea_mbimx27_spi_board_info
[] __initdata
= {
273 .modalias
= "ads7846",
276 .max_speed_hz
= 1500000,
277 .irq
= IRQ_GPIOD(25),
278 .platform_data
= &ads7846_config
,
283 static int eukrea_mbimx27_spi_cs
[] = {GPIO_PORTD
| 28};
285 static const struct spi_imx_master eukrea_mbimx27_spi0_data __initconst
= {
286 .chipselect
= eukrea_mbimx27_spi_cs
,
287 .num_chipselect
= ARRAY_SIZE(eukrea_mbimx27_spi_cs
),
290 static struct i2c_board_info eukrea_mbimx27_i2c_devices
[] = {
292 I2C_BOARD_INFO("tlv320aic23", 0x1a),
296 static struct platform_device
*platform_devices
[] __initdata
= {
300 static const struct imxmmc_platform_data sdhc_pdata __initconst
= {
301 .dat3_card_detect
= 1,
305 struct imx_ssi_platform_data eukrea_mbimx27_ssi_pdata __initconst
= {
306 .flags
= IMX_SSI_DMA
| IMX_SSI_USE_I2S_SLAVE
,
310 * system init for baseboard usage. Will be called by cpuimx27 init.
312 * Add platform devices present on this baseboard and init
313 * them from CPU side as far as required to use them later on
315 void __init
eukrea_mbimx27_baseboard_init(void)
317 mxc_gpio_setup_multiple_pins(eukrea_mbimx27_pins
,
318 ARRAY_SIZE(eukrea_mbimx27_pins
), "MBIMX27");
320 #if defined(CONFIG_SND_SOC_EUKREA_TLV320) \
321 || defined(CONFIG_SND_SOC_EUKREA_TLV320_MODULE)
322 /* SSI unit master I2S codec connected to SSI_PINS_4*/
323 mxc_audmux_v1_configure_port(MX27_AUDMUX_HPCR1_SSI0
,
324 MXC_AUDMUX_V1_PCR_SYN
|
325 MXC_AUDMUX_V1_PCR_TFSDIR
|
326 MXC_AUDMUX_V1_PCR_TCLKDIR
|
327 MXC_AUDMUX_V1_PCR_RFSDIR
|
328 MXC_AUDMUX_V1_PCR_RCLKDIR
|
329 MXC_AUDMUX_V1_PCR_TFCSEL(MX27_AUDMUX_HPCR3_SSI_PINS_4
) |
330 MXC_AUDMUX_V1_PCR_RFCSEL(MX27_AUDMUX_HPCR3_SSI_PINS_4
) |
331 MXC_AUDMUX_V1_PCR_RXDSEL(MX27_AUDMUX_HPCR3_SSI_PINS_4
)
333 mxc_audmux_v1_configure_port(MX27_AUDMUX_HPCR3_SSI_PINS_4
,
334 MXC_AUDMUX_V1_PCR_SYN
|
335 MXC_AUDMUX_V1_PCR_RXDSEL(MX27_AUDMUX_HPCR1_SSI0
)
339 imx27_add_imx_uart1(&uart_pdata
);
340 imx27_add_imx_uart2(&uart_pdata
);
341 #if !defined(MACH_EUKREA_CPUIMX27_USEUART4)
342 imx27_add_imx_uart3(&uart_pdata
);
345 imx27_add_imx_fb(&eukrea_mbimx27_fb_data
);
346 imx27_add_mxc_mmc(0, &sdhc_pdata
);
348 i2c_register_board_info(0, eukrea_mbimx27_i2c_devices
,
349 ARRAY_SIZE(eukrea_mbimx27_i2c_devices
));
351 imx27_add_imx_ssi(0, &eukrea_mbimx27_ssi_pdata
);
353 #if defined(CONFIG_TOUCHSCREEN_ADS7846) \
354 || defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
355 /* ADS7846 Touchscreen controller init */
356 mxc_gpio_mode(GPIO_PORTD
| 25 | GPIO_GPIO
| GPIO_IN
);
361 mxc_gpio_mode(GPIO_PORTD
| 28 | GPIO_GPIO
| GPIO_OUT
);
362 imx27_add_spi_imx0(&eukrea_mbimx27_spi0_data
);
363 spi_register_board_info(eukrea_mbimx27_spi_board_info
,
364 ARRAY_SIZE(eukrea_mbimx27_spi_board_info
));
366 /* Leds configuration */
367 mxc_gpio_mode(GPIO_PORTF
| 16 | GPIO_GPIO
| GPIO_OUT
);
368 mxc_gpio_mode(GPIO_PORTF
| 19 | GPIO_GPIO
| GPIO_OUT
);
370 mxc_gpio_mode(GPIO_PORTE
| 5 | GPIO_GPIO
| GPIO_OUT
);
371 gpio_request(GPIO_PORTE
| 5, "backlight");
372 platform_device_register(&eukrea_mbimx27_bl_dev
);
374 mxc_gpio_mode(GPIO_PORTA
| 25 | GPIO_GPIO
| GPIO_OUT
);
375 gpio_request(GPIO_PORTA
| 25, "lcd_enable");
376 platform_device_register(&eukrea_mbimx27_lcd_powerdev
);
378 imx27_add_imx_keypad(&eukrea_mbimx27_keymap_data
);
380 platform_add_devices(platform_devices
, ARRAY_SIZE(platform_devices
));