diff options
author | Grazvydas Ignotas <notasas@gmail.com> | 2009-05-28 17:15:44 -0400 |
---|---|---|
committer | Tony Lindgren <tony@atomide.com> | 2009-05-28 17:15:44 -0400 |
commit | 7419045016e5002b3ccee72b28e41bf53dca68f2 (patch) | |
tree | dd36e0de4cc360b42a9ae9d04f1a94a602f9abe8 /arch | |
parent | 1bfc3738c414a34a6cb81a2f2fddea8e131afa89 (diff) |
ARM: OMAP3: pandora: add support for mode devices
Add support for keypad, GPIO keys and LEDs. Also enable hardware
debounce feature for GPIO keys.
Signed-off-by: Grazvydas Ignotas <notasas@gmail.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/arm/mach-omap2/board-omap3pandora.c | 149 |
1 files changed, 149 insertions, 0 deletions
diff --git a/arch/arm/mach-omap2/board-omap3pandora.c b/arch/arm/mach-omap2/board-omap3pandora.c index 2ab24975b685..e32aa23ce962 100644 --- a/arch/arm/mach-omap2/board-omap3pandora.c +++ b/arch/arm/mach-omap2/board-omap3pandora.c | |||
@@ -25,6 +25,9 @@ | |||
25 | #include <linux/spi/ads7846.h> | 25 | #include <linux/spi/ads7846.h> |
26 | #include <linux/regulator/machine.h> | 26 | #include <linux/regulator/machine.h> |
27 | #include <linux/i2c/twl4030.h> | 27 | #include <linux/i2c/twl4030.h> |
28 | #include <linux/leds.h> | ||
29 | #include <linux/input.h> | ||
30 | #include <linux/gpio_keys.h> | ||
28 | 31 | ||
29 | #include <asm/mach-types.h> | 32 | #include <asm/mach-types.h> |
30 | #include <asm/mach/arch.h> | 33 | #include <asm/mach/arch.h> |
@@ -36,12 +39,154 @@ | |||
36 | #include <mach/hardware.h> | 39 | #include <mach/hardware.h> |
37 | #include <mach/mcspi.h> | 40 | #include <mach/mcspi.h> |
38 | #include <mach/usb.h> | 41 | #include <mach/usb.h> |
42 | #include <mach/keypad.h> | ||
39 | 43 | ||
40 | #include "sdram-micron-mt46h32m32lf-6.h" | 44 | #include "sdram-micron-mt46h32m32lf-6.h" |
41 | #include "mmc-twl4030.h" | 45 | #include "mmc-twl4030.h" |
42 | 46 | ||
43 | #define OMAP3_PANDORA_TS_GPIO 94 | 47 | #define OMAP3_PANDORA_TS_GPIO 94 |
44 | 48 | ||
49 | /* hardware debounce: (value + 1) * 31us */ | ||
50 | #define GPIO_DEBOUNCE_TIME 127 | ||
51 | |||
52 | static struct gpio_led pandora_gpio_leds[] = { | ||
53 | { | ||
54 | .name = "pandora::sd1", | ||
55 | .default_trigger = "mmc0", | ||
56 | .gpio = 128, | ||
57 | }, { | ||
58 | .name = "pandora::sd2", | ||
59 | .default_trigger = "mmc1", | ||
60 | .gpio = 129, | ||
61 | }, { | ||
62 | .name = "pandora::bluetooth", | ||
63 | .gpio = 158, | ||
64 | }, { | ||
65 | .name = "pandora::wifi", | ||
66 | .gpio = 159, | ||
67 | }, | ||
68 | }; | ||
69 | |||
70 | static struct gpio_led_platform_data pandora_gpio_led_data = { | ||
71 | .leds = pandora_gpio_leds, | ||
72 | .num_leds = ARRAY_SIZE(pandora_gpio_leds), | ||
73 | }; | ||
74 | |||
75 | static struct platform_device pandora_leds_gpio = { | ||
76 | .name = "leds-gpio", | ||
77 | .id = -1, | ||
78 | .dev = { | ||
79 | .platform_data = &pandora_gpio_led_data, | ||
80 | }, | ||
81 | }; | ||
82 | |||
83 | #define GPIO_BUTTON(gpio_num, ev_type, ev_code, act_low, descr) \ | ||
84 | { \ | ||
85 | .gpio = gpio_num, \ | ||
86 | .type = ev_type, \ | ||
87 | .code = ev_code, \ | ||
88 | .active_low = act_low, \ | ||
89 | .desc = "btn " descr, \ | ||
90 | } | ||
91 | |||
92 | #define GPIO_BUTTON_LOW(gpio_num, event_code, description) \ | ||
93 | GPIO_BUTTON(gpio_num, EV_KEY, event_code, 1, description) | ||
94 | |||
95 | static struct gpio_keys_button pandora_gpio_keys[] = { | ||
96 | GPIO_BUTTON_LOW(110, KEY_UP, "up"), | ||
97 | GPIO_BUTTON_LOW(103, KEY_DOWN, "down"), | ||
98 | GPIO_BUTTON_LOW(96, KEY_LEFT, "left"), | ||
99 | GPIO_BUTTON_LOW(98, KEY_RIGHT, "right"), | ||
100 | GPIO_BUTTON_LOW(111, BTN_A, "a"), | ||
101 | GPIO_BUTTON_LOW(106, BTN_B, "b"), | ||
102 | GPIO_BUTTON_LOW(109, BTN_X, "x"), | ||
103 | GPIO_BUTTON_LOW(101, BTN_Y, "y"), | ||
104 | GPIO_BUTTON_LOW(102, BTN_TL, "l"), | ||
105 | GPIO_BUTTON_LOW(97, BTN_TL2, "l2"), | ||
106 | GPIO_BUTTON_LOW(105, BTN_TR, "r"), | ||
107 | GPIO_BUTTON_LOW(107, BTN_TR2, "r2"), | ||
108 | GPIO_BUTTON_LOW(104, KEY_LEFTCTRL, "ctrl"), | ||
109 | GPIO_BUTTON_LOW(99, KEY_MENU, "menu"), | ||
110 | GPIO_BUTTON_LOW(176, KEY_COFFEE, "hold"), | ||
111 | GPIO_BUTTON(100, EV_KEY, KEY_LEFTALT, 0, "alt"), | ||
112 | GPIO_BUTTON(108, EV_SW, SW_LID, 1, "lid"), | ||
113 | }; | ||
114 | |||
115 | static struct gpio_keys_platform_data pandora_gpio_key_info = { | ||
116 | .buttons = pandora_gpio_keys, | ||
117 | .nbuttons = ARRAY_SIZE(pandora_gpio_keys), | ||
118 | }; | ||
119 | |||
120 | static struct platform_device pandora_keys_gpio = { | ||
121 | .name = "gpio-keys", | ||
122 | .id = -1, | ||
123 | .dev = { | ||
124 | .platform_data = &pandora_gpio_key_info, | ||
125 | }, | ||
126 | }; | ||
127 | |||
128 | static void __init pandora_keys_gpio_init(void) | ||
129 | { | ||
130 | /* set debounce time for GPIO banks 4 and 6 */ | ||
131 | omap_set_gpio_debounce_time(32 * 3, GPIO_DEBOUNCE_TIME); | ||
132 | omap_set_gpio_debounce_time(32 * 5, GPIO_DEBOUNCE_TIME); | ||
133 | } | ||
134 | |||
135 | static int pandora_keypad_map[] = { | ||
136 | /* col, row, code */ | ||
137 | KEY(0, 0, KEY_9), | ||
138 | KEY(0, 1, KEY_0), | ||
139 | KEY(0, 2, KEY_BACKSPACE), | ||
140 | KEY(0, 3, KEY_O), | ||
141 | KEY(0, 4, KEY_P), | ||
142 | KEY(0, 5, KEY_K), | ||
143 | KEY(0, 6, KEY_L), | ||
144 | KEY(0, 7, KEY_ENTER), | ||
145 | KEY(1, 0, KEY_8), | ||
146 | KEY(1, 1, KEY_7), | ||
147 | KEY(1, 2, KEY_6), | ||
148 | KEY(1, 3, KEY_5), | ||
149 | KEY(1, 4, KEY_4), | ||
150 | KEY(1, 5, KEY_3), | ||
151 | KEY(1, 6, KEY_2), | ||
152 | KEY(1, 7, KEY_1), | ||
153 | KEY(2, 0, KEY_I), | ||
154 | KEY(2, 1, KEY_U), | ||
155 | KEY(2, 2, KEY_Y), | ||
156 | KEY(2, 3, KEY_T), | ||
157 | KEY(2, 4, KEY_R), | ||
158 | KEY(2, 5, KEY_E), | ||
159 | KEY(2, 6, KEY_W), | ||
160 | KEY(2, 7, KEY_Q), | ||
161 | KEY(3, 0, KEY_J), | ||
162 | KEY(3, 1, KEY_H), | ||
163 | KEY(3, 2, KEY_G), | ||
164 | KEY(3, 3, KEY_F), | ||
165 | KEY(3, 4, KEY_D), | ||
166 | KEY(3, 5, KEY_S), | ||
167 | KEY(3, 6, KEY_A), | ||
168 | KEY(3, 7, KEY_LEFTSHIFT), | ||
169 | KEY(4, 0, KEY_N), | ||
170 | KEY(4, 1, KEY_B), | ||
171 | KEY(4, 2, KEY_V), | ||
172 | KEY(4, 3, KEY_C), | ||
173 | KEY(4, 4, KEY_X), | ||
174 | KEY(4, 5, KEY_Z), | ||
175 | KEY(4, 6, KEY_DOT), | ||
176 | KEY(4, 7, KEY_COMMA), | ||
177 | KEY(5, 0, KEY_M), | ||
178 | KEY(5, 1, KEY_SPACE), | ||
179 | KEY(5, 2, KEY_FN), | ||
180 | }; | ||
181 | |||
182 | static struct twl4030_keypad_data pandora_kp_data = { | ||
183 | .rows = 8, | ||
184 | .cols = 6, | ||
185 | .keymap = pandora_keypad_map, | ||
186 | .keymapsize = ARRAY_SIZE(pandora_keypad_map), | ||
187 | .rep = 1, | ||
188 | }; | ||
189 | |||
45 | static struct twl4030_hsmmc_info omap3pandora_mmc[] = { | 190 | static struct twl4030_hsmmc_info omap3pandora_mmc[] = { |
46 | { | 191 | { |
47 | .mmc = 1, | 192 | .mmc = 1, |
@@ -142,6 +287,7 @@ static struct twl4030_platform_data omap3pandora_twldata = { | |||
142 | .usb = &omap3pandora_usb_data, | 287 | .usb = &omap3pandora_usb_data, |
143 | .vmmc1 = &pandora_vmmc1, | 288 | .vmmc1 = &pandora_vmmc1, |
144 | .vmmc2 = &pandora_vmmc2, | 289 | .vmmc2 = &pandora_vmmc2, |
290 | .keypad = &pandora_kp_data, | ||
145 | }; | 291 | }; |
146 | 292 | ||
147 | static struct i2c_board_info __initdata omap3pandora_i2c_boardinfo[] = { | 293 | static struct i2c_board_info __initdata omap3pandora_i2c_boardinfo[] = { |
@@ -234,6 +380,8 @@ static struct omap_board_config_kernel omap3pandora_config[] __initdata = { | |||
234 | 380 | ||
235 | static struct platform_device *omap3pandora_devices[] __initdata = { | 381 | static struct platform_device *omap3pandora_devices[] __initdata = { |
236 | &omap3pandora_lcd_device, | 382 | &omap3pandora_lcd_device, |
383 | &pandora_leds_gpio, | ||
384 | &pandora_keys_gpio, | ||
237 | }; | 385 | }; |
238 | 386 | ||
239 | static void __init omap3pandora_init(void) | 387 | static void __init omap3pandora_init(void) |
@@ -247,6 +395,7 @@ static void __init omap3pandora_init(void) | |||
247 | spi_register_board_info(omap3pandora_spi_board_info, | 395 | spi_register_board_info(omap3pandora_spi_board_info, |
248 | ARRAY_SIZE(omap3pandora_spi_board_info)); | 396 | ARRAY_SIZE(omap3pandora_spi_board_info)); |
249 | omap3pandora_ads7846_init(); | 397 | omap3pandora_ads7846_init(); |
398 | pandora_keys_gpio_init(); | ||
250 | usb_musb_init(); | 399 | usb_musb_init(); |
251 | } | 400 | } |
252 | 401 | ||