blob: 4a8550529b04f6aa6fbb4a2c3a635da7c7467d2e [file] [log] [blame]
Eric Bénardef93f142010-07-23 16:11:19 +02001/*
2 *
3 * Copyright (C) 2010 Eric Bénard <eric@eukrea.com>
4 *
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:
8 *
9 * http://www.opensource.org/licenses/gpl-license.html
10 * http://www.gnu.org/copyleft/gpl.html
11 */
12
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>
18#include <linux/io.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>
Eric Bénardef93f142010-07-23 16:11:19 +020024
25#include <mach/common.h>
26#include <mach/hardware.h>
27#include <mach/imx-uart.h>
28#include <mach/iomux-mx51.h>
29
30#include <asm/mach/arch.h>
31
Uwe Kleine-König04b73b12010-08-11 22:23:06 +020032#include "devices-imx51.h"
Eric Bénardef93f142010-07-23 16:11:19 +020033#include "devices.h"
34
Arnaud Patard (Rtp)96886c42010-11-26 15:20:52 +010035#define MBIMX51_TSC2007_GPIO IMX_GPIO_NR(3, 30)
Eric Bénardef93f142010-07-23 16:11:19 +020036#define MBIMX51_TSC2007_IRQ (MXC_INTERNAL_IRQS + MBIMX51_TSC2007_GPIO)
Arnaud Patard (Rtp)96886c42010-11-26 15:20:52 +010037#define MBIMX51_LED0 IMX_GPIO_NR(3, 5)
38#define MBIMX51_LED1 IMX_GPIO_NR(3, 6)
39#define MBIMX51_LED2 IMX_GPIO_NR(3, 7)
40#define MBIMX51_LED3 IMX_GPIO_NR(3, 8)
Eric Bénardef93f142010-07-23 16:11:19 +020041
42static struct gpio_led mbimx51_leds[] = {
43 {
44 .name = "led0",
45 .default_trigger = "heartbeat",
46 .active_low = 1,
47 .gpio = MBIMX51_LED0,
48 },
49 {
50 .name = "led1",
51 .default_trigger = "nand-disk",
52 .active_low = 1,
53 .gpio = MBIMX51_LED1,
54 },
55 {
56 .name = "led2",
57 .default_trigger = "mmc0",
58 .active_low = 1,
59 .gpio = MBIMX51_LED2,
60 },
61 {
62 .name = "led3",
63 .default_trigger = "default-on",
64 .active_low = 1,
65 .gpio = MBIMX51_LED3,
66 },
67};
68
69static struct gpio_led_platform_data mbimx51_leds_info = {
70 .leds = mbimx51_leds,
71 .num_leds = ARRAY_SIZE(mbimx51_leds),
72};
73
74static struct platform_device mbimx51_leds_gpio = {
75 .name = "leds-gpio",
76 .id = -1,
77 .dev = {
78 .platform_data = &mbimx51_leds_info,
79 },
80};
81
82static struct platform_device *devices[] __initdata = {
83 &mbimx51_leds_gpio,
84};
85
Lothar Waßmann8f5260c2010-10-26 14:28:31 +020086static iomux_v3_cfg_t mbimx51_pads[] = {
Eric Bénardef93f142010-07-23 16:11:19 +020087 /* UART2 */
88 MX51_PAD_UART2_RXD__UART2_RXD,
89 MX51_PAD_UART2_TXD__UART2_TXD,
90
91 /* UART3 */
92 MX51_PAD_UART3_RXD__UART3_RXD,
93 MX51_PAD_UART3_TXD__UART3_TXD,
94 MX51_PAD_KEY_COL4__UART3_RTS,
95 MX51_PAD_KEY_COL5__UART3_CTS,
96
97 /* TSC2007 IRQ */
Sascha Haueree1ae4d2010-12-15 09:56:35 +010098 MX51_PAD_NANDF_D10__GPIO3_30,
Eric Bénardef93f142010-07-23 16:11:19 +020099
100 /* LEDS */
Sascha Haueree1ae4d2010-12-15 09:56:35 +0100101 MX51_PAD_DISPB2_SER_DIN__GPIO3_5,
102 MX51_PAD_DISPB2_SER_DIO__GPIO3_6,
103 MX51_PAD_DISPB2_SER_CLK__GPIO3_7,
104 MX51_PAD_DISPB2_SER_RS__GPIO3_8,
Eric Bénardef93f142010-07-23 16:11:19 +0200105
106 /* KPP */
107 MX51_PAD_KEY_ROW0__KEY_ROW0,
108 MX51_PAD_KEY_ROW1__KEY_ROW1,
109 MX51_PAD_KEY_ROW2__KEY_ROW2,
110 MX51_PAD_KEY_ROW3__KEY_ROW3,
111 MX51_PAD_KEY_COL0__KEY_COL0,
112 MX51_PAD_KEY_COL1__KEY_COL1,
113 MX51_PAD_KEY_COL2__KEY_COL2,
114 MX51_PAD_KEY_COL3__KEY_COL3,
Eric Bénarda3927412010-10-12 16:29:20 +0200115
116 /* SD 1 */
117 MX51_PAD_SD1_CMD__SD1_CMD,
118 MX51_PAD_SD1_CLK__SD1_CLK,
119 MX51_PAD_SD1_DATA0__SD1_DATA0,
120 MX51_PAD_SD1_DATA1__SD1_DATA1,
121 MX51_PAD_SD1_DATA2__SD1_DATA2,
122 MX51_PAD_SD1_DATA3__SD1_DATA3,
123
124 /* SD 2 */
125 MX51_PAD_SD2_CMD__SD2_CMD,
126 MX51_PAD_SD2_CLK__SD2_CLK,
127 MX51_PAD_SD2_DATA0__SD2_DATA0,
128 MX51_PAD_SD2_DATA1__SD2_DATA1,
129 MX51_PAD_SD2_DATA2__SD2_DATA2,
130 MX51_PAD_SD2_DATA3__SD2_DATA3,
Eric Bénardef93f142010-07-23 16:11:19 +0200131};
132
Uwe Kleine-König04b73b12010-08-11 22:23:06 +0200133static const struct imxuart_platform_data uart_pdata __initconst = {
Eric Bénardef93f142010-07-23 16:11:19 +0200134 .flags = IMXUART_HAVE_RTSCTS,
135};
136
137static int mbimx51_keymap[] = {
138 KEY(0, 0, KEY_1),
139 KEY(0, 1, KEY_2),
140 KEY(0, 2, KEY_3),
141 KEY(0, 3, KEY_UP),
142
143 KEY(1, 0, KEY_4),
144 KEY(1, 1, KEY_5),
145 KEY(1, 2, KEY_6),
146 KEY(1, 3, KEY_LEFT),
147
148 KEY(2, 0, KEY_7),
149 KEY(2, 1, KEY_8),
150 KEY(2, 2, KEY_9),
151 KEY(2, 3, KEY_RIGHT),
152
153 KEY(3, 0, KEY_0),
154 KEY(3, 1, KEY_DOWN),
155 KEY(3, 2, KEY_ESC),
156 KEY(3, 3, KEY_ENTER),
157};
158
Fabio Estevama5fcfef2010-12-01 11:11:47 -0200159static const struct matrix_keymap_data mbimx51_map_data __initconst = {
Eric Bénardef93f142010-07-23 16:11:19 +0200160 .keymap = mbimx51_keymap,
161 .keymap_size = ARRAY_SIZE(mbimx51_keymap),
162};
163
164static int tsc2007_get_pendown_state(void)
165{
166 return !gpio_get_value(MBIMX51_TSC2007_GPIO);
167}
168
169struct tsc2007_platform_data tsc2007_data = {
170 .model = 2007,
171 .x_plate_ohms = 180,
172 .get_pendown_state = tsc2007_get_pendown_state,
173};
174
175static struct i2c_board_info mbimx51_i2c_devices[] = {
176 {
Eric Bénarda3927412010-10-12 16:29:20 +0200177 I2C_BOARD_INFO("tsc2007", 0x49),
Eric Bénardef93f142010-07-23 16:11:19 +0200178 .irq = MBIMX51_TSC2007_IRQ,
179 .platform_data = &tsc2007_data,
Eric Bénarda3927412010-10-12 16:29:20 +0200180 }, {
181 I2C_BOARD_INFO("tlv320aic23", 0x1a),
Eric Bénardef93f142010-07-23 16:11:19 +0200182 },
183};
184
185/*
186 * baseboard initialization.
187 */
188void __init eukrea_mbimx51_baseboard_init(void)
189{
190 mxc_iomux_v3_setup_multiple_pads(mbimx51_pads,
191 ARRAY_SIZE(mbimx51_pads));
192
Uwe Kleine-König04b73b12010-08-11 22:23:06 +0200193 imx51_add_imx_uart(1, NULL);
194 imx51_add_imx_uart(2, &uart_pdata);
Eric Bénardef93f142010-07-23 16:11:19 +0200195
196 gpio_request(MBIMX51_LED0, "LED0");
197 gpio_direction_output(MBIMX51_LED0, 1);
198 gpio_free(MBIMX51_LED0);
199 gpio_request(MBIMX51_LED1, "LED1");
200 gpio_direction_output(MBIMX51_LED1, 1);
201 gpio_free(MBIMX51_LED1);
202 gpio_request(MBIMX51_LED2, "LED2");
203 gpio_direction_output(MBIMX51_LED2, 1);
204 gpio_free(MBIMX51_LED2);
205 gpio_request(MBIMX51_LED3, "LED3");
206 gpio_direction_output(MBIMX51_LED3, 1);
207 gpio_free(MBIMX51_LED3);
208
209 platform_add_devices(devices, ARRAY_SIZE(devices));
210
Fabio Estevama5fcfef2010-12-01 11:11:47 -0200211 imx51_add_imx_keypad(&mbimx51_map_data);
Eric Bénardef93f142010-07-23 16:11:19 +0200212
213 gpio_request(MBIMX51_TSC2007_GPIO, "tsc2007_irq");
214 gpio_direction_input(MBIMX51_TSC2007_GPIO);
Thomas Gleixner6845664a2011-03-24 13:25:22 +0100215 irq_set_irq_type(MBIMX51_TSC2007_IRQ, IRQF_TRIGGER_FALLING);
Eric Bénardef93f142010-07-23 16:11:19 +0200216 i2c_register_board_info(1, mbimx51_i2c_devices,
217 ARRAY_SIZE(mbimx51_i2c_devices));
Eric Bénarda3927412010-10-12 16:29:20 +0200218
Uwe Kleine-König124bf942010-11-19 21:03:33 +0100219 imx51_add_sdhci_esdhc_imx(0, NULL);
220 imx51_add_sdhci_esdhc_imx(1, NULL);
Eric Bénardef93f142010-07-23 16:11:19 +0200221}