]>
Commit | Line | Data |
---|---|---|
da177247 GI |
1 | /* |
2 | * board-omap3pandora.c (Pandora Handheld Console) | |
3 | * | |
4 | * This program is free software; you can redistribute it and/or | |
5 | * modify it under the terms of the GNU General Public License | |
6 | * version 2 as published by the Free Software Foundation. | |
7 | * | |
8 | * This program is distributed in the hope that it will be useful, but | |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
11 | * General Public License for more details. | |
12 | * | |
13 | * You should have received a copy of the GNU General Public License | |
14 | * along with this program; if not, write to the Free Software | |
15 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | |
16 | * 02110-1301 USA | |
17 | * | |
18 | */ | |
19 | ||
20 | #include <linux/init.h> | |
21 | #include <linux/kernel.h> | |
22 | #include <linux/platform_device.h> | |
23 | ||
24 | #include <linux/spi/spi.h> | |
25 | #include <linux/spi/ads7846.h> | |
64f535a8 | 26 | #include <linux/regulator/machine.h> |
da177247 | 27 | #include <linux/i2c/twl4030.h> |
74190450 GI |
28 | #include <linux/leds.h> |
29 | #include <linux/input.h> | |
30 | #include <linux/gpio_keys.h> | |
da177247 GI |
31 | |
32 | #include <asm/mach-types.h> | |
33 | #include <asm/mach/arch.h> | |
34 | #include <asm/mach/map.h> | |
35 | ||
36 | #include <mach/board.h> | |
37 | #include <mach/common.h> | |
38 | #include <mach/gpio.h> | |
39 | #include <mach/hardware.h> | |
40 | #include <mach/mcspi.h> | |
18cb7aca | 41 | #include <mach/usb.h> |
74190450 | 42 | #include <mach/keypad.h> |
9fb97412 | 43 | #include <mach/mux.h> |
da177247 | 44 | |
2e12bd7e | 45 | #include "sdram-micron-mt46h32m32lf-6.h" |
90c62bf0 TL |
46 | #include "mmc-twl4030.h" |
47 | ||
da177247 GI |
48 | #define OMAP3_PANDORA_TS_GPIO 94 |
49 | ||
74190450 GI |
50 | /* hardware debounce: (value + 1) * 31us */ |
51 | #define GPIO_DEBOUNCE_TIME 127 | |
52 | ||
53 | static struct gpio_led pandora_gpio_leds[] = { | |
54 | { | |
55 | .name = "pandora::sd1", | |
56 | .default_trigger = "mmc0", | |
57 | .gpio = 128, | |
58 | }, { | |
59 | .name = "pandora::sd2", | |
60 | .default_trigger = "mmc1", | |
61 | .gpio = 129, | |
62 | }, { | |
63 | .name = "pandora::bluetooth", | |
64 | .gpio = 158, | |
65 | }, { | |
66 | .name = "pandora::wifi", | |
67 | .gpio = 159, | |
68 | }, | |
69 | }; | |
70 | ||
71 | static struct gpio_led_platform_data pandora_gpio_led_data = { | |
72 | .leds = pandora_gpio_leds, | |
73 | .num_leds = ARRAY_SIZE(pandora_gpio_leds), | |
74 | }; | |
75 | ||
76 | static struct platform_device pandora_leds_gpio = { | |
77 | .name = "leds-gpio", | |
78 | .id = -1, | |
79 | .dev = { | |
80 | .platform_data = &pandora_gpio_led_data, | |
81 | }, | |
82 | }; | |
83 | ||
84 | #define GPIO_BUTTON(gpio_num, ev_type, ev_code, act_low, descr) \ | |
85 | { \ | |
86 | .gpio = gpio_num, \ | |
87 | .type = ev_type, \ | |
88 | .code = ev_code, \ | |
89 | .active_low = act_low, \ | |
90 | .desc = "btn " descr, \ | |
91 | } | |
92 | ||
93 | #define GPIO_BUTTON_LOW(gpio_num, event_code, description) \ | |
94 | GPIO_BUTTON(gpio_num, EV_KEY, event_code, 1, description) | |
95 | ||
96 | static struct gpio_keys_button pandora_gpio_keys[] = { | |
97 | GPIO_BUTTON_LOW(110, KEY_UP, "up"), | |
98 | GPIO_BUTTON_LOW(103, KEY_DOWN, "down"), | |
99 | GPIO_BUTTON_LOW(96, KEY_LEFT, "left"), | |
100 | GPIO_BUTTON_LOW(98, KEY_RIGHT, "right"), | |
101 | GPIO_BUTTON_LOW(111, BTN_A, "a"), | |
102 | GPIO_BUTTON_LOW(106, BTN_B, "b"), | |
103 | GPIO_BUTTON_LOW(109, BTN_X, "x"), | |
104 | GPIO_BUTTON_LOW(101, BTN_Y, "y"), | |
105 | GPIO_BUTTON_LOW(102, BTN_TL, "l"), | |
106 | GPIO_BUTTON_LOW(97, BTN_TL2, "l2"), | |
107 | GPIO_BUTTON_LOW(105, BTN_TR, "r"), | |
108 | GPIO_BUTTON_LOW(107, BTN_TR2, "r2"), | |
109 | GPIO_BUTTON_LOW(104, KEY_LEFTCTRL, "ctrl"), | |
110 | GPIO_BUTTON_LOW(99, KEY_MENU, "menu"), | |
111 | GPIO_BUTTON_LOW(176, KEY_COFFEE, "hold"), | |
112 | GPIO_BUTTON(100, EV_KEY, KEY_LEFTALT, 0, "alt"), | |
113 | GPIO_BUTTON(108, EV_SW, SW_LID, 1, "lid"), | |
114 | }; | |
115 | ||
116 | static struct gpio_keys_platform_data pandora_gpio_key_info = { | |
117 | .buttons = pandora_gpio_keys, | |
118 | .nbuttons = ARRAY_SIZE(pandora_gpio_keys), | |
119 | }; | |
120 | ||
121 | static struct platform_device pandora_keys_gpio = { | |
122 | .name = "gpio-keys", | |
123 | .id = -1, | |
124 | .dev = { | |
125 | .platform_data = &pandora_gpio_key_info, | |
126 | }, | |
127 | }; | |
128 | ||
129 | static void __init pandora_keys_gpio_init(void) | |
130 | { | |
131 | /* set debounce time for GPIO banks 4 and 6 */ | |
132 | omap_set_gpio_debounce_time(32 * 3, GPIO_DEBOUNCE_TIME); | |
133 | omap_set_gpio_debounce_time(32 * 5, GPIO_DEBOUNCE_TIME); | |
134 | } | |
135 | ||
136 | static int pandora_keypad_map[] = { | |
137 | /* col, row, code */ | |
138 | KEY(0, 0, KEY_9), | |
139 | KEY(0, 1, KEY_0), | |
140 | KEY(0, 2, KEY_BACKSPACE), | |
141 | KEY(0, 3, KEY_O), | |
142 | KEY(0, 4, KEY_P), | |
143 | KEY(0, 5, KEY_K), | |
144 | KEY(0, 6, KEY_L), | |
145 | KEY(0, 7, KEY_ENTER), | |
146 | KEY(1, 0, KEY_8), | |
147 | KEY(1, 1, KEY_7), | |
148 | KEY(1, 2, KEY_6), | |
149 | KEY(1, 3, KEY_5), | |
150 | KEY(1, 4, KEY_4), | |
151 | KEY(1, 5, KEY_3), | |
152 | KEY(1, 6, KEY_2), | |
153 | KEY(1, 7, KEY_1), | |
154 | KEY(2, 0, KEY_I), | |
155 | KEY(2, 1, KEY_U), | |
156 | KEY(2, 2, KEY_Y), | |
157 | KEY(2, 3, KEY_T), | |
158 | KEY(2, 4, KEY_R), | |
159 | KEY(2, 5, KEY_E), | |
160 | KEY(2, 6, KEY_W), | |
161 | KEY(2, 7, KEY_Q), | |
162 | KEY(3, 0, KEY_J), | |
163 | KEY(3, 1, KEY_H), | |
164 | KEY(3, 2, KEY_G), | |
165 | KEY(3, 3, KEY_F), | |
166 | KEY(3, 4, KEY_D), | |
167 | KEY(3, 5, KEY_S), | |
168 | KEY(3, 6, KEY_A), | |
169 | KEY(3, 7, KEY_LEFTSHIFT), | |
170 | KEY(4, 0, KEY_N), | |
171 | KEY(4, 1, KEY_B), | |
172 | KEY(4, 2, KEY_V), | |
173 | KEY(4, 3, KEY_C), | |
174 | KEY(4, 4, KEY_X), | |
175 | KEY(4, 5, KEY_Z), | |
176 | KEY(4, 6, KEY_DOT), | |
177 | KEY(4, 7, KEY_COMMA), | |
178 | KEY(5, 0, KEY_M), | |
179 | KEY(5, 1, KEY_SPACE), | |
180 | KEY(5, 2, KEY_FN), | |
181 | }; | |
182 | ||
183 | static struct twl4030_keypad_data pandora_kp_data = { | |
184 | .rows = 8, | |
185 | .cols = 6, | |
186 | .keymap = pandora_keypad_map, | |
187 | .keymapsize = ARRAY_SIZE(pandora_keypad_map), | |
188 | .rep = 1, | |
189 | }; | |
190 | ||
90c62bf0 TL |
191 | static struct twl4030_hsmmc_info omap3pandora_mmc[] = { |
192 | { | |
193 | .mmc = 1, | |
194 | .wires = 4, | |
195 | .gpio_cd = -EINVAL, | |
196 | .gpio_wp = 126, | |
197 | .ext_clock = 0, | |
198 | }, | |
199 | { | |
200 | .mmc = 2, | |
201 | .wires = 4, | |
202 | .gpio_cd = -EINVAL, | |
203 | .gpio_wp = 127, | |
204 | .ext_clock = 1, | |
0329c377 | 205 | .transceiver = true, |
90c62bf0 | 206 | }, |
07d83cc9 GI |
207 | { |
208 | .mmc = 3, | |
209 | .wires = 4, | |
210 | .gpio_cd = -EINVAL, | |
211 | .gpio_wp = -EINVAL, | |
212 | }, | |
90c62bf0 TL |
213 | {} /* Terminator */ |
214 | }; | |
215 | ||
64f535a8 GI |
216 | static struct regulator_consumer_supply pandora_vmmc1_supply = { |
217 | .supply = "vmmc", | |
218 | }; | |
219 | ||
220 | static struct regulator_consumer_supply pandora_vmmc2_supply = { | |
221 | .supply = "vmmc", | |
222 | }; | |
223 | ||
90c62bf0 TL |
224 | static int omap3pandora_twl_gpio_setup(struct device *dev, |
225 | unsigned gpio, unsigned ngpio) | |
226 | { | |
227 | /* gpio + {0,1} is "mmc{0,1}_cd" (input/IRQ) */ | |
228 | omap3pandora_mmc[0].gpio_cd = gpio + 0; | |
229 | omap3pandora_mmc[1].gpio_cd = gpio + 1; | |
230 | twl4030_mmc_init(omap3pandora_mmc); | |
231 | ||
64f535a8 GI |
232 | /* link regulators to MMC adapters */ |
233 | pandora_vmmc1_supply.dev = omap3pandora_mmc[0].dev; | |
234 | pandora_vmmc2_supply.dev = omap3pandora_mmc[1].dev; | |
235 | ||
90c62bf0 TL |
236 | return 0; |
237 | } | |
238 | ||
da177247 GI |
239 | static struct twl4030_gpio_platform_data omap3pandora_gpio_data = { |
240 | .gpio_base = OMAP_MAX_GPIO_LINES, | |
241 | .irq_base = TWL4030_GPIO_IRQ_BASE, | |
242 | .irq_end = TWL4030_GPIO_IRQ_END, | |
90c62bf0 | 243 | .setup = omap3pandora_twl_gpio_setup, |
da177247 GI |
244 | }; |
245 | ||
64f535a8 GI |
246 | /* VMMC1 for MMC1 pins CMD, CLK, DAT0..DAT3 (20 mA, plus card == max 220 mA) */ |
247 | static struct regulator_init_data pandora_vmmc1 = { | |
248 | .constraints = { | |
249 | .min_uV = 1850000, | |
250 | .max_uV = 3150000, | |
251 | .valid_modes_mask = REGULATOR_MODE_NORMAL | |
252 | | REGULATOR_MODE_STANDBY, | |
253 | .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE | |
254 | | REGULATOR_CHANGE_MODE | |
255 | | REGULATOR_CHANGE_STATUS, | |
256 | }, | |
257 | .num_consumer_supplies = 1, | |
258 | .consumer_supplies = &pandora_vmmc1_supply, | |
259 | }; | |
260 | ||
261 | /* VMMC2 for MMC2 pins CMD, CLK, DAT0..DAT3 (max 100 mA) */ | |
262 | static struct regulator_init_data pandora_vmmc2 = { | |
263 | .constraints = { | |
264 | .min_uV = 1850000, | |
265 | .max_uV = 3150000, | |
266 | .valid_modes_mask = REGULATOR_MODE_NORMAL | |
267 | | REGULATOR_MODE_STANDBY, | |
268 | .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE | |
269 | | REGULATOR_CHANGE_MODE | |
270 | | REGULATOR_CHANGE_STATUS, | |
271 | }, | |
272 | .num_consumer_supplies = 1, | |
273 | .consumer_supplies = &pandora_vmmc2_supply, | |
274 | }; | |
275 | ||
da177247 GI |
276 | static struct twl4030_usb_data omap3pandora_usb_data = { |
277 | .usb_mode = T2_USB_MODE_ULPI, | |
278 | }; | |
279 | ||
280 | static struct twl4030_platform_data omap3pandora_twldata = { | |
281 | .irq_base = TWL4030_IRQ_BASE, | |
282 | .irq_end = TWL4030_IRQ_END, | |
283 | .gpio = &omap3pandora_gpio_data, | |
284 | .usb = &omap3pandora_usb_data, | |
64f535a8 GI |
285 | .vmmc1 = &pandora_vmmc1, |
286 | .vmmc2 = &pandora_vmmc2, | |
74190450 | 287 | .keypad = &pandora_kp_data, |
da177247 GI |
288 | }; |
289 | ||
290 | static struct i2c_board_info __initdata omap3pandora_i2c_boardinfo[] = { | |
291 | { | |
292 | I2C_BOARD_INFO("tps65950", 0x48), | |
293 | .flags = I2C_CLIENT_WAKE, | |
294 | .irq = INT_34XX_SYS_NIRQ, | |
295 | .platform_data = &omap3pandora_twldata, | |
296 | }, | |
297 | }; | |
298 | ||
299 | static int __init omap3pandora_i2c_init(void) | |
300 | { | |
301 | omap_register_i2c_bus(1, 2600, omap3pandora_i2c_boardinfo, | |
302 | ARRAY_SIZE(omap3pandora_i2c_boardinfo)); | |
303 | /* i2c2 pins are not connected */ | |
304 | omap_register_i2c_bus(3, 400, NULL, 0); | |
305 | return 0; | |
306 | } | |
307 | ||
308 | static void __init omap3pandora_init_irq(void) | |
309 | { | |
58cda884 JP |
310 | omap2_init_common_hw(mt46h32m32lf6_sdrc_params, |
311 | mt46h32m32lf6_sdrc_params); | |
da177247 GI |
312 | omap_init_irq(); |
313 | omap_gpio_init(); | |
314 | } | |
315 | ||
316 | static void __init omap3pandora_ads7846_init(void) | |
317 | { | |
318 | int gpio = OMAP3_PANDORA_TS_GPIO; | |
319 | int ret; | |
320 | ||
321 | ret = gpio_request(gpio, "ads7846_pen_down"); | |
322 | if (ret < 0) { | |
323 | printk(KERN_ERR "Failed to request GPIO %d for " | |
324 | "ads7846 pen down IRQ\n", gpio); | |
325 | return; | |
326 | } | |
327 | ||
328 | gpio_direction_input(gpio); | |
329 | } | |
330 | ||
331 | static int ads7846_get_pendown_state(void) | |
332 | { | |
333 | return !gpio_get_value(OMAP3_PANDORA_TS_GPIO); | |
334 | } | |
335 | ||
336 | static struct ads7846_platform_data ads7846_config = { | |
337 | .x_max = 0x0fff, | |
338 | .y_max = 0x0fff, | |
339 | .x_plate_ohms = 180, | |
340 | .pressure_max = 255, | |
341 | .debounce_max = 10, | |
342 | .debounce_tol = 3, | |
343 | .debounce_rep = 1, | |
344 | .get_pendown_state = ads7846_get_pendown_state, | |
345 | .keep_vref_on = 1, | |
346 | }; | |
347 | ||
348 | static struct omap2_mcspi_device_config ads7846_mcspi_config = { | |
349 | .turbo_mode = 0, | |
350 | .single_channel = 1, /* 0: slave, 1: master */ | |
351 | }; | |
352 | ||
353 | static struct spi_board_info omap3pandora_spi_board_info[] __initdata = { | |
354 | { | |
355 | .modalias = "ads7846", | |
356 | .bus_num = 1, | |
357 | .chip_select = 0, | |
358 | .max_speed_hz = 1500000, | |
359 | .controller_data = &ads7846_mcspi_config, | |
360 | .irq = OMAP_GPIO_IRQ(OMAP3_PANDORA_TS_GPIO), | |
361 | .platform_data = &ads7846_config, | |
362 | } | |
363 | }; | |
364 | ||
365 | static struct platform_device omap3pandora_lcd_device = { | |
366 | .name = "pandora_lcd", | |
367 | .id = -1, | |
368 | }; | |
369 | ||
370 | static struct omap_lcd_config omap3pandora_lcd_config __initdata = { | |
371 | .ctrl_name = "internal", | |
372 | }; | |
373 | ||
374 | static struct omap_board_config_kernel omap3pandora_config[] __initdata = { | |
da177247 GI |
375 | { OMAP_TAG_LCD, &omap3pandora_lcd_config }, |
376 | }; | |
377 | ||
378 | static struct platform_device *omap3pandora_devices[] __initdata = { | |
379 | &omap3pandora_lcd_device, | |
74190450 GI |
380 | &pandora_leds_gpio, |
381 | &pandora_keys_gpio, | |
da177247 GI |
382 | }; |
383 | ||
384 | static void __init omap3pandora_init(void) | |
385 | { | |
386 | omap3pandora_i2c_init(); | |
387 | platform_add_devices(omap3pandora_devices, | |
388 | ARRAY_SIZE(omap3pandora_devices)); | |
389 | omap_board_config = omap3pandora_config; | |
390 | omap_board_config_size = ARRAY_SIZE(omap3pandora_config); | |
391 | omap_serial_init(); | |
392 | spi_register_board_info(omap3pandora_spi_board_info, | |
393 | ARRAY_SIZE(omap3pandora_spi_board_info)); | |
394 | omap3pandora_ads7846_init(); | |
74190450 | 395 | pandora_keys_gpio_init(); |
18cb7aca | 396 | usb_musb_init(); |
9fb97412 JP |
397 | |
398 | /* Ensure SDRC pins are mux'd for self-refresh */ | |
399 | omap_cfg_reg(H16_34XX_SDRC_CKE0); | |
400 | omap_cfg_reg(H17_34XX_SDRC_CKE1); | |
da177247 GI |
401 | } |
402 | ||
403 | static void __init omap3pandora_map_io(void) | |
404 | { | |
405 | omap2_set_globals_343x(); | |
406 | omap2_map_common_io(); | |
407 | } | |
408 | ||
409 | MACHINE_START(OMAP3_PANDORA, "Pandora Handheld Console") | |
410 | .phys_io = 0x48000000, | |
411 | .io_pg_offst = ((0xd8000000) >> 18) & 0xfffc, | |
412 | .boot_params = 0x80000100, | |
413 | .map_io = omap3pandora_map_io, | |
414 | .init_irq = omap3pandora_init_irq, | |
415 | .init_machine = omap3pandora_init, | |
416 | .timer = &omap_timer, | |
417 | MACHINE_END |