blob: bbf4564bd05076d7ead9dc6211fc2ccf90b72ca0 [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>
Eric Bénardef93f142010-07-23 16:11:19 +020021#include <linux/i2c/tsc2007.h>
22#include <linux/leds.h>
Eric Bénardef93f142010-07-23 16:11:19 +020023
24#include <mach/common.h>
25#include <mach/hardware.h>
Eric Bénardef93f142010-07-23 16:11:19 +020026#include <mach/iomux-mx51.h>
27
28#include <asm/mach/arch.h>
29
Uwe Kleine-König04b73b152010-08-11 22:23:06 +020030#include "devices-imx51.h"
Eric Bénardef93f142010-07-23 16:11:19 +020031#include "devices.h"
32
Arnaud Patard (Rtp)96886c42010-11-26 15:20:52 +010033#define MBIMX51_TSC2007_GPIO IMX_GPIO_NR(3, 30)
Arnaud Patard (Rtp)96886c42010-11-26 15:20:52 +010034#define MBIMX51_LED0 IMX_GPIO_NR(3, 5)
35#define MBIMX51_LED1 IMX_GPIO_NR(3, 6)
36#define MBIMX51_LED2 IMX_GPIO_NR(3, 7)
37#define MBIMX51_LED3 IMX_GPIO_NR(3, 8)
Eric Bénardef93f142010-07-23 16:11:19 +020038
Uwe Kleine-König5b8d6282011-05-28 21:05:02 +020039static const struct gpio_led mbimx51_leds[] __initconst = {
Eric Bénardef93f142010-07-23 16:11:19 +020040 {
41 .name = "led0",
42 .default_trigger = "heartbeat",
43 .active_low = 1,
44 .gpio = MBIMX51_LED0,
45 },
46 {
47 .name = "led1",
48 .default_trigger = "nand-disk",
49 .active_low = 1,
50 .gpio = MBIMX51_LED1,
51 },
52 {
53 .name = "led2",
54 .default_trigger = "mmc0",
55 .active_low = 1,
56 .gpio = MBIMX51_LED2,
57 },
58 {
59 .name = "led3",
60 .default_trigger = "default-on",
61 .active_low = 1,
62 .gpio = MBIMX51_LED3,
63 },
64};
65
Uwe Kleine-König5b8d6282011-05-28 21:05:02 +020066static const struct gpio_led_platform_data mbimx51_leds_info __initconst = {
Eric Bénardef93f142010-07-23 16:11:19 +020067 .leds = mbimx51_leds,
68 .num_leds = ARRAY_SIZE(mbimx51_leds),
69};
70
Lothar Waßmann8f5260c2010-10-26 14:28:31 +020071static iomux_v3_cfg_t mbimx51_pads[] = {
Eric Bénardef93f142010-07-23 16:11:19 +020072 /* UART2 */
73 MX51_PAD_UART2_RXD__UART2_RXD,
74 MX51_PAD_UART2_TXD__UART2_TXD,
75
76 /* UART3 */
77 MX51_PAD_UART3_RXD__UART3_RXD,
78 MX51_PAD_UART3_TXD__UART3_TXD,
79 MX51_PAD_KEY_COL4__UART3_RTS,
80 MX51_PAD_KEY_COL5__UART3_CTS,
81
82 /* TSC2007 IRQ */
Sascha Haueree1ae4d2010-12-15 09:56:35 +010083 MX51_PAD_NANDF_D10__GPIO3_30,
Eric Bénardef93f142010-07-23 16:11:19 +020084
85 /* LEDS */
Sascha Haueree1ae4d2010-12-15 09:56:35 +010086 MX51_PAD_DISPB2_SER_DIN__GPIO3_5,
87 MX51_PAD_DISPB2_SER_DIO__GPIO3_6,
88 MX51_PAD_DISPB2_SER_CLK__GPIO3_7,
89 MX51_PAD_DISPB2_SER_RS__GPIO3_8,
Eric Bénardef93f142010-07-23 16:11:19 +020090
91 /* KPP */
92 MX51_PAD_KEY_ROW0__KEY_ROW0,
93 MX51_PAD_KEY_ROW1__KEY_ROW1,
94 MX51_PAD_KEY_ROW2__KEY_ROW2,
95 MX51_PAD_KEY_ROW3__KEY_ROW3,
96 MX51_PAD_KEY_COL0__KEY_COL0,
97 MX51_PAD_KEY_COL1__KEY_COL1,
98 MX51_PAD_KEY_COL2__KEY_COL2,
99 MX51_PAD_KEY_COL3__KEY_COL3,
Eric Bénarda3927412010-10-12 16:29:20 +0200100
101 /* SD 1 */
102 MX51_PAD_SD1_CMD__SD1_CMD,
103 MX51_PAD_SD1_CLK__SD1_CLK,
104 MX51_PAD_SD1_DATA0__SD1_DATA0,
105 MX51_PAD_SD1_DATA1__SD1_DATA1,
106 MX51_PAD_SD1_DATA2__SD1_DATA2,
107 MX51_PAD_SD1_DATA3__SD1_DATA3,
108
109 /* SD 2 */
110 MX51_PAD_SD2_CMD__SD2_CMD,
111 MX51_PAD_SD2_CLK__SD2_CLK,
112 MX51_PAD_SD2_DATA0__SD2_DATA0,
113 MX51_PAD_SD2_DATA1__SD2_DATA1,
114 MX51_PAD_SD2_DATA2__SD2_DATA2,
115 MX51_PAD_SD2_DATA3__SD2_DATA3,
Eric Bénardef93f142010-07-23 16:11:19 +0200116};
117
Uwe Kleine-König04b73b152010-08-11 22:23:06 +0200118static const struct imxuart_platform_data uart_pdata __initconst = {
Eric Bénardef93f142010-07-23 16:11:19 +0200119 .flags = IMXUART_HAVE_RTSCTS,
120};
121
122static int mbimx51_keymap[] = {
123 KEY(0, 0, KEY_1),
124 KEY(0, 1, KEY_2),
125 KEY(0, 2, KEY_3),
126 KEY(0, 3, KEY_UP),
127
128 KEY(1, 0, KEY_4),
129 KEY(1, 1, KEY_5),
130 KEY(1, 2, KEY_6),
131 KEY(1, 3, KEY_LEFT),
132
133 KEY(2, 0, KEY_7),
134 KEY(2, 1, KEY_8),
135 KEY(2, 2, KEY_9),
136 KEY(2, 3, KEY_RIGHT),
137
138 KEY(3, 0, KEY_0),
139 KEY(3, 1, KEY_DOWN),
140 KEY(3, 2, KEY_ESC),
141 KEY(3, 3, KEY_ENTER),
142};
143
Fabio Estevama5fcfef2010-12-01 11:11:47 -0200144static const struct matrix_keymap_data mbimx51_map_data __initconst = {
Eric Bénardef93f142010-07-23 16:11:19 +0200145 .keymap = mbimx51_keymap,
146 .keymap_size = ARRAY_SIZE(mbimx51_keymap),
147};
148
149static int tsc2007_get_pendown_state(void)
150{
151 return !gpio_get_value(MBIMX51_TSC2007_GPIO);
152}
153
154struct tsc2007_platform_data tsc2007_data = {
155 .model = 2007,
156 .x_plate_ohms = 180,
157 .get_pendown_state = tsc2007_get_pendown_state,
158};
159
160static struct i2c_board_info mbimx51_i2c_devices[] = {
161 {
Eric Bénarda3927412010-10-12 16:29:20 +0200162 I2C_BOARD_INFO("tsc2007", 0x49),
Sascha Hauer7cf73812011-05-11 11:31:54 +0200163 .irq = gpio_to_irq(MBIMX51_TSC2007_GPIO),
Eric Bénardef93f142010-07-23 16:11:19 +0200164 .platform_data = &tsc2007_data,
Eric Bénarda3927412010-10-12 16:29:20 +0200165 }, {
166 I2C_BOARD_INFO("tlv320aic23", 0x1a),
Eric Bénardef93f142010-07-23 16:11:19 +0200167 },
168};
169
170/*
171 * baseboard initialization.
172 */
173void __init eukrea_mbimx51_baseboard_init(void)
174{
175 mxc_iomux_v3_setup_multiple_pads(mbimx51_pads,
176 ARRAY_SIZE(mbimx51_pads));
177
Uwe Kleine-König04b73b152010-08-11 22:23:06 +0200178 imx51_add_imx_uart(1, NULL);
179 imx51_add_imx_uart(2, &uart_pdata);
Eric Bénardef93f142010-07-23 16:11:19 +0200180
181 gpio_request(MBIMX51_LED0, "LED0");
182 gpio_direction_output(MBIMX51_LED0, 1);
183 gpio_free(MBIMX51_LED0);
184 gpio_request(MBIMX51_LED1, "LED1");
185 gpio_direction_output(MBIMX51_LED1, 1);
186 gpio_free(MBIMX51_LED1);
187 gpio_request(MBIMX51_LED2, "LED2");
188 gpio_direction_output(MBIMX51_LED2, 1);
189 gpio_free(MBIMX51_LED2);
190 gpio_request(MBIMX51_LED3, "LED3");
191 gpio_direction_output(MBIMX51_LED3, 1);
192 gpio_free(MBIMX51_LED3);
193
Uwe Kleine-König5b8d6282011-05-28 21:05:02 +0200194 gpio_led_register_device(-1, &mbimx51_leds_info);
Eric Bénardef93f142010-07-23 16:11:19 +0200195
Fabio Estevama5fcfef2010-12-01 11:11:47 -0200196 imx51_add_imx_keypad(&mbimx51_map_data);
Eric Bénardef93f142010-07-23 16:11:19 +0200197
198 gpio_request(MBIMX51_TSC2007_GPIO, "tsc2007_irq");
199 gpio_direction_input(MBIMX51_TSC2007_GPIO);
Sascha Hauer7cf73812011-05-11 11:31:54 +0200200 irq_set_irq_type(gpio_to_irq(MBIMX51_TSC2007_GPIO),
201 IRQF_TRIGGER_FALLING);
Eric Bénardef93f142010-07-23 16:11:19 +0200202 i2c_register_board_info(1, mbimx51_i2c_devices,
203 ARRAY_SIZE(mbimx51_i2c_devices));
Eric Bénarda3927412010-10-12 16:29:20 +0200204
Uwe Kleine-König124bf942010-11-19 21:03:33 +0100205 imx51_add_sdhci_esdhc_imx(0, NULL);
206 imx51_add_sdhci_esdhc_imx(1, NULL);
Eric Bénardef93f142010-07-23 16:11:19 +0200207}