3 * Copyright (C) 2010 Eric BĂ©nard <eric@eukrea.com>
5 * The code contained herein is licensed under the GNU General Public
6 * License. You may obtain a copy of the GNU General Public License
7 * Version 2 or later at the following locations:
9 * http://www.opensource.org/licenses/gpl-license.html
10 * http://www.gnu.org/copyleft/gpl.html
13 #include <linux/init.h>
14 #include <linux/platform_device.h>
15 #include <linux/serial_8250.h>
16 #include <linux/i2c.h>
17 #include <linux/gpio.h>
19 #include <linux/interrupt.h>
20 #include <linux/irq.h>
21 #include <linux/fsl_devices.h>
22 #include <linux/i2c/tsc2007.h>
23 #include <linux/leds.h>
24 #include <linux/input/matrix_keypad.h>
26 #include <mach/common.h>
27 #include <mach/hardware.h>
28 #include <mach/imx-uart.h>
29 #include <mach/iomux-mx51.h>
31 #include <asm/mach/arch.h>
33 #include "devices-imx51.h"
36 #define MBIMX51_TSC2007_GPIO IMX_GPIO_NR(3, 30)
37 #define MBIMX51_TSC2007_IRQ (MXC_INTERNAL_IRQS + MBIMX51_TSC2007_GPIO)
38 #define MBIMX51_LED0 IMX_GPIO_NR(3, 5)
39 #define MBIMX51_LED1 IMX_GPIO_NR(3, 6)
40 #define MBIMX51_LED2 IMX_GPIO_NR(3, 7)
41 #define MBIMX51_LED3 IMX_GPIO_NR(3, 8)
43 static struct gpio_led mbimx51_leds[] = {
46 .default_trigger = "heartbeat",
52 .default_trigger = "nand-disk",
58 .default_trigger = "mmc0",
64 .default_trigger = "default-on",
70 static struct gpio_led_platform_data mbimx51_leds_info = {
72 .num_leds = ARRAY_SIZE(mbimx51_leds),
75 static struct platform_device mbimx51_leds_gpio = {
79 .platform_data = &mbimx51_leds_info,
83 static struct platform_device *devices[] __initdata = {
87 static iomux_v3_cfg_t mbimx51_pads[] = {
89 MX51_PAD_UART2_RXD__UART2_RXD,
90 MX51_PAD_UART2_TXD__UART2_TXD,
93 MX51_PAD_UART3_RXD__UART3_RXD,
94 MX51_PAD_UART3_TXD__UART3_TXD,
95 MX51_PAD_KEY_COL4__UART3_RTS,
96 MX51_PAD_KEY_COL5__UART3_CTS,
99 MX51_PAD_NANDF_D10__GPIO3_30,
102 MX51_PAD_DISPB2_SER_DIN__GPIO3_5,
103 MX51_PAD_DISPB2_SER_DIO__GPIO3_6,
104 MX51_PAD_DISPB2_SER_CLK__GPIO3_7,
105 MX51_PAD_DISPB2_SER_RS__GPIO3_8,
108 MX51_PAD_KEY_ROW0__KEY_ROW0,
109 MX51_PAD_KEY_ROW1__KEY_ROW1,
110 MX51_PAD_KEY_ROW2__KEY_ROW2,
111 MX51_PAD_KEY_ROW3__KEY_ROW3,
112 MX51_PAD_KEY_COL0__KEY_COL0,
113 MX51_PAD_KEY_COL1__KEY_COL1,
114 MX51_PAD_KEY_COL2__KEY_COL2,
115 MX51_PAD_KEY_COL3__KEY_COL3,
118 MX51_PAD_SD1_CMD__SD1_CMD,
119 MX51_PAD_SD1_CLK__SD1_CLK,
120 MX51_PAD_SD1_DATA0__SD1_DATA0,
121 MX51_PAD_SD1_DATA1__SD1_DATA1,
122 MX51_PAD_SD1_DATA2__SD1_DATA2,
123 MX51_PAD_SD1_DATA3__SD1_DATA3,
126 MX51_PAD_SD2_CMD__SD2_CMD,
127 MX51_PAD_SD2_CLK__SD2_CLK,
128 MX51_PAD_SD2_DATA0__SD2_DATA0,
129 MX51_PAD_SD2_DATA1__SD2_DATA1,
130 MX51_PAD_SD2_DATA2__SD2_DATA2,
131 MX51_PAD_SD2_DATA3__SD2_DATA3,
134 static const struct imxuart_platform_data uart_pdata __initconst = {
135 .flags = IMXUART_HAVE_RTSCTS,
138 static int mbimx51_keymap[] = {
152 KEY(2, 3, KEY_RIGHT),
157 KEY(3, 3, KEY_ENTER),
160 static struct matrix_keymap_data mbimx51_map_data = {
161 .keymap = mbimx51_keymap,
162 .keymap_size = ARRAY_SIZE(mbimx51_keymap),
165 static int tsc2007_get_pendown_state(void)
167 return !gpio_get_value(MBIMX51_TSC2007_GPIO);
170 struct tsc2007_platform_data tsc2007_data = {
173 .get_pendown_state = tsc2007_get_pendown_state,
176 static struct i2c_board_info mbimx51_i2c_devices[] = {
178 I2C_BOARD_INFO("tsc2007", 0x49),
179 .irq = MBIMX51_TSC2007_IRQ,
180 .platform_data = &tsc2007_data,
182 I2C_BOARD_INFO("tlv320aic23", 0x1a),
187 * baseboard initialization.
189 void __init eukrea_mbimx51_baseboard_init(void)
191 mxc_iomux_v3_setup_multiple_pads(mbimx51_pads,
192 ARRAY_SIZE(mbimx51_pads));
194 imx51_add_imx_uart(1, NULL);
195 imx51_add_imx_uart(2, &uart_pdata);
197 gpio_request(MBIMX51_LED0, "LED0");
198 gpio_direction_output(MBIMX51_LED0, 1);
199 gpio_free(MBIMX51_LED0);
200 gpio_request(MBIMX51_LED1, "LED1");
201 gpio_direction_output(MBIMX51_LED1, 1);
202 gpio_free(MBIMX51_LED1);
203 gpio_request(MBIMX51_LED2, "LED2");
204 gpio_direction_output(MBIMX51_LED2, 1);
205 gpio_free(MBIMX51_LED2);
206 gpio_request(MBIMX51_LED3, "LED3");
207 gpio_direction_output(MBIMX51_LED3, 1);
208 gpio_free(MBIMX51_LED3);
210 platform_add_devices(devices, ARRAY_SIZE(devices));
212 mxc_register_device(&mxc_keypad_device, &mbimx51_map_data);
214 gpio_request(MBIMX51_TSC2007_GPIO, "tsc2007_irq");
215 gpio_direction_input(MBIMX51_TSC2007_GPIO);
216 set_irq_type(MBIMX51_TSC2007_IRQ, IRQF_TRIGGER_FALLING);
217 i2c_register_board_info(1, mbimx51_i2c_devices,
218 ARRAY_SIZE(mbimx51_i2c_devices));
220 imx51_add_sdhci_esdhc_imx(0, NULL);
221 imx51_add_sdhci_esdhc_imx(1, NULL);