• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src-rt-6.x.4708/linux/linux-2.6.36/arch/arm/mach-mx5/
1/*
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>
24#include <linux/input/matrix_keypad.h>
25
26#include <mach/common.h>
27#include <mach/hardware.h>
28#include <mach/imx-uart.h>
29#include <mach/iomux-mx51.h>
30
31#include <asm/mach/arch.h>
32
33#include "devices.h"
34
35#define MBIMX51_TSC2007_GPIO	(2*32 + 30)
36#define MBIMX51_TSC2007_IRQ	(MXC_INTERNAL_IRQS + MBIMX51_TSC2007_GPIO)
37#define MBIMX51_LED0		(2*32 + 5)
38#define MBIMX51_LED1		(2*32 + 6)
39#define MBIMX51_LED2		(2*32 + 7)
40#define MBIMX51_LED3		(2*32 + 8)
41
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
86static struct pad_desc mbimx51_pads[] = {
87	/* 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 */
98	MX51_PAD_NANDF_D10__GPIO_3_30,
99
100	/* LEDS */
101	MX51_PAD_DISPB2_SER_DIN__GPIO_3_5,
102	MX51_PAD_DISPB2_SER_DIO__GPIO_3_6,
103	MX51_PAD_DISPB2_SER_CLK__GPIO_3_7,
104	MX51_PAD_DISPB2_SER_RS__GPIO_3_8,
105
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,
115};
116
117static struct imxuart_platform_data uart_pdata = {
118	.flags = IMXUART_HAVE_RTSCTS,
119};
120
121static int mbimx51_keymap[] = {
122	KEY(0, 0, KEY_1),
123	KEY(0, 1, KEY_2),
124	KEY(0, 2, KEY_3),
125	KEY(0, 3, KEY_UP),
126
127	KEY(1, 0, KEY_4),
128	KEY(1, 1, KEY_5),
129	KEY(1, 2, KEY_6),
130	KEY(1, 3, KEY_LEFT),
131
132	KEY(2, 0, KEY_7),
133	KEY(2, 1, KEY_8),
134	KEY(2, 2, KEY_9),
135	KEY(2, 3, KEY_RIGHT),
136
137	KEY(3, 0, KEY_0),
138	KEY(3, 1, KEY_DOWN),
139	KEY(3, 2, KEY_ESC),
140	KEY(3, 3, KEY_ENTER),
141};
142
143static struct matrix_keymap_data mbimx51_map_data = {
144	.keymap		= mbimx51_keymap,
145	.keymap_size	= ARRAY_SIZE(mbimx51_keymap),
146};
147
148static int tsc2007_get_pendown_state(void)
149{
150	return !gpio_get_value(MBIMX51_TSC2007_GPIO);
151}
152
153struct tsc2007_platform_data tsc2007_data = {
154	.model = 2007,
155	.x_plate_ohms = 180,
156	.get_pendown_state = tsc2007_get_pendown_state,
157};
158
159static struct i2c_board_info mbimx51_i2c_devices[] = {
160	{
161		I2C_BOARD_INFO("tsc2007", 0x48),
162		.irq  = MBIMX51_TSC2007_IRQ,
163		.platform_data = &tsc2007_data,
164	},
165};
166
167/*
168 * baseboard initialization.
169 */
170void __init eukrea_mbimx51_baseboard_init(void)
171{
172	mxc_iomux_v3_setup_multiple_pads(mbimx51_pads,
173					ARRAY_SIZE(mbimx51_pads));
174
175	mxc_register_device(&mxc_uart_device1, NULL);
176	mxc_register_device(&mxc_uart_device2, &uart_pdata);
177
178	gpio_request(MBIMX51_LED0, "LED0");
179	gpio_direction_output(MBIMX51_LED0, 1);
180	gpio_free(MBIMX51_LED0);
181	gpio_request(MBIMX51_LED1, "LED1");
182	gpio_direction_output(MBIMX51_LED1, 1);
183	gpio_free(MBIMX51_LED1);
184	gpio_request(MBIMX51_LED2, "LED2");
185	gpio_direction_output(MBIMX51_LED2, 1);
186	gpio_free(MBIMX51_LED2);
187	gpio_request(MBIMX51_LED3, "LED3");
188	gpio_direction_output(MBIMX51_LED3, 1);
189	gpio_free(MBIMX51_LED3);
190
191	platform_add_devices(devices, ARRAY_SIZE(devices));
192
193	mxc_register_device(&mxc_keypad_device, &mbimx51_map_data);
194
195	gpio_request(MBIMX51_TSC2007_GPIO, "tsc2007_irq");
196	gpio_direction_input(MBIMX51_TSC2007_GPIO);
197	set_irq_type(MBIMX51_TSC2007_IRQ, IRQF_TRIGGER_FALLING);
198	i2c_register_board_info(1, mbimx51_i2c_devices,
199				ARRAY_SIZE(mbimx51_i2c_devices));
200}
201