diff options
author | Cory Maccarrone <darkstar6262@gmail.com> | 2010-08-18 00:35:46 -0400 |
---|---|---|
committer | Tony Lindgren <tony@atomide.com> | 2010-09-23 14:05:17 -0400 |
commit | 493c32a0de2bfbcc33d52f32a39f3c301c6ffd62 (patch) | |
tree | fce354416bc6eafcf41f55791b6e93339af4b43c /arch/arm/mach-omap1/board-htcherald.c | |
parent | b30a3f6257ed2105259b404d419b4964e363928c (diff) |
HTCHERALD: MMC, I2C, HTCPLD, SPI, TSC2046
This change adds in MMC and I2C support to the HTC Herald board, as well
as adding the HTCPLD driver for the PLD used on this phone. It also
adds in the gpio-keys entries for the front directional keys and
selector and the cursor keys on the slide-out keyboard, and gpio-leds
support for the LEDs attached to the htcpld.
Additionally, SPI bus support (using the spi100k driver) and
touchscreen support (using the ads7846 driver) were added.
Signed-off-by: Cory Maccarrone <darkstar6262@gmail.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
Diffstat (limited to 'arch/arm/mach-omap1/board-htcherald.c')
-rw-r--r-- | arch/arm/mach-omap1/board-htcherald.c | 322 |
1 files changed, 316 insertions, 6 deletions
diff --git a/arch/arm/mach-omap1/board-htcherald.c b/arch/arm/mach-omap1/board-htcherald.c index 311899ff5ff..7ea75c11653 100644 --- a/arch/arm/mach-omap1/board-htcherald.c +++ b/arch/arm/mach-omap1/board-htcherald.c | |||
@@ -30,6 +30,13 @@ | |||
30 | #include <linux/input.h> | 30 | #include <linux/input.h> |
31 | #include <linux/io.h> | 31 | #include <linux/io.h> |
32 | #include <linux/gpio.h> | 32 | #include <linux/gpio.h> |
33 | #include <linux/gpio_keys.h> | ||
34 | #include <linux/i2c.h> | ||
35 | #include <linux/i2c-gpio.h> | ||
36 | #include <linux/htcpld.h> | ||
37 | #include <linux/leds.h> | ||
38 | #include <linux/spi/spi.h> | ||
39 | #include <linux/spi/ads7846.h> | ||
33 | 40 | ||
34 | #include <asm/mach-types.h> | 41 | #include <asm/mach-types.h> |
35 | #include <asm/mach/arch.h> | 42 | #include <asm/mach/arch.h> |
@@ -39,6 +46,7 @@ | |||
39 | #include <plat/board.h> | 46 | #include <plat/board.h> |
40 | #include <plat/keypad.h> | 47 | #include <plat/keypad.h> |
41 | #include <plat/usb.h> | 48 | #include <plat/usb.h> |
49 | #include <plat/mmc.h> | ||
42 | 50 | ||
43 | #include <mach/irqs.h> | 51 | #include <mach/irqs.h> |
44 | 52 | ||
@@ -52,13 +60,123 @@ | |||
52 | #define OMAP_LCDC_CTRL_LCD_EN (1 << 0) | 60 | #define OMAP_LCDC_CTRL_LCD_EN (1 << 0) |
53 | #define OMAP_LCDC_STAT_DONE (1 << 0) | 61 | #define OMAP_LCDC_STAT_DONE (1 << 0) |
54 | 62 | ||
55 | static struct omap_lcd_config htcherald_lcd_config __initdata = { | 63 | /* GPIO definitions for the power button and keyboard slide switch */ |
56 | .ctrl_name = "internal", | 64 | #define HTCHERALD_GPIO_POWER 139 |
57 | }; | 65 | #define HTCHERALD_GPIO_SLIDE 174 |
66 | #define HTCHERALD_GIRQ_BTNS 141 | ||
58 | 67 | ||
59 | static struct omap_board_config_kernel htcherald_config[] __initdata = { | 68 | /* GPIO definitions for the touchscreen */ |
60 | { OMAP_TAG_LCD, &htcherald_lcd_config }, | 69 | #define HTCHERALD_GPIO_TS 76 |
61 | }; | 70 | |
71 | /* HTCPLD definitions */ | ||
72 | |||
73 | /* | ||
74 | * CPLD Logic | ||
75 | * | ||
76 | * Chip 3 - 0x03 | ||
77 | * | ||
78 | * Function 7 6 5 4 3 2 1 0 | ||
79 | * ------------------------------------ | ||
80 | * DPAD light x x x x x x x 1 | ||
81 | * SoundDev x x x x 1 x x x | ||
82 | * Screen white 1 x x x x x x x | ||
83 | * MMC power on x x x x x 1 x x | ||
84 | * Happy times (n) 0 x x x x 1 x x | ||
85 | * | ||
86 | * Chip 4 - 0x04 | ||
87 | * | ||
88 | * Function 7 6 5 4 3 2 1 0 | ||
89 | * ------------------------------------ | ||
90 | * Keyboard light x x x x x x x 1 | ||
91 | * LCD Bright (4) x x x x x 1 1 x | ||
92 | * LCD Bright (3) x x x x x 0 1 x | ||
93 | * LCD Bright (2) x x x x x 1 0 x | ||
94 | * LCD Bright (1) x x x x x 0 0 x | ||
95 | * LCD Off x x x x 0 x x x | ||
96 | * LCD image (fb) 1 x x x x x x x | ||
97 | * LCD image (white) 0 x x x x x x x | ||
98 | * Caps lock LED x x 1 x x x x x | ||
99 | * | ||
100 | * Chip 5 - 0x05 | ||
101 | * | ||
102 | * Function 7 6 5 4 3 2 1 0 | ||
103 | * ------------------------------------ | ||
104 | * Red (solid) x x x x x 1 x x | ||
105 | * Red (flash) x x x x x x 1 x | ||
106 | * Green (GSM flash) x x x x 1 x x x | ||
107 | * Green (GSM solid) x x x 1 x x x x | ||
108 | * Green (wifi flash) x x 1 x x x x x | ||
109 | * Blue (bt flash) x 1 x x x x x x | ||
110 | * DPAD Int Enable 1 x x x x x x 0 | ||
111 | * | ||
112 | * (Combinations of the above can be made for different colors.) | ||
113 | * The direction pad interrupt enable must be set each time the | ||
114 | * interrupt is handled. | ||
115 | * | ||
116 | * Chip 6 - 0x06 | ||
117 | * | ||
118 | * Function 7 6 5 4 3 2 1 0 | ||
119 | * ------------------------------------ | ||
120 | * Vibrator x x x x 1 x x x | ||
121 | * Alt LED x x x 1 x x x x | ||
122 | * Screen white 1 x x x x x x x | ||
123 | * Screen white x x 1 x x x x x | ||
124 | * Screen white x 0 x x x x x x | ||
125 | * Enable kbd dpad x x x x x x 0 x | ||
126 | * Happy Times 0 1 0 x x x 0 x | ||
127 | */ | ||
128 | |||
129 | /* | ||
130 | * HTCPLD GPIO lines start 16 after OMAP_MAX_GPIO_LINES to account | ||
131 | * for the 16 MPUIO lines. | ||
132 | */ | ||
133 | #define HTCPLD_GPIO_START_OFFSET (OMAP_MAX_GPIO_LINES + 16) | ||
134 | #define HTCPLD_IRQ(chip, offset) (OMAP_IRQ_END + 8 * (chip) + (offset)) | ||
135 | #define HTCPLD_BASE(chip, offset) \ | ||
136 | (HTCPLD_GPIO_START_OFFSET + 8 * (chip) + (offset)) | ||
137 | |||
138 | #define HTCPLD_GPIO_LED_DPAD HTCPLD_BASE(0, 0) | ||
139 | #define HTCPLD_GPIO_LED_KBD HTCPLD_BASE(1, 0) | ||
140 | #define HTCPLD_GPIO_LED_CAPS HTCPLD_BASE(1, 5) | ||
141 | #define HTCPLD_GPIO_LED_RED_FLASH HTCPLD_BASE(2, 1) | ||
142 | #define HTCPLD_GPIO_LED_RED_SOLID HTCPLD_BASE(2, 2) | ||
143 | #define HTCPLD_GPIO_LED_GREEN_FLASH HTCPLD_BASE(2, 3) | ||
144 | #define HTCPLD_GPIO_LED_GREEN_SOLID HTCPLD_BASE(2, 4) | ||
145 | #define HTCPLD_GPIO_LED_WIFI HTCPLD_BASE(2, 5) | ||
146 | #define HTCPLD_GPIO_LED_BT HTCPLD_BASE(2, 6) | ||
147 | #define HTCPLD_GPIO_LED_VIBRATE HTCPLD_BASE(3, 3) | ||
148 | #define HTCPLD_GPIO_LED_ALT HTCPLD_BASE(3, 4) | ||
149 | |||
150 | #define HTCPLD_GPIO_RIGHT_KBD HTCPLD_BASE(6, 7) | ||
151 | #define HTCPLD_GPIO_UP_KBD HTCPLD_BASE(6, 6) | ||
152 | #define HTCPLD_GPIO_LEFT_KBD HTCPLD_BASE(6, 5) | ||
153 | #define HTCPLD_GPIO_DOWN_KBD HTCPLD_BASE(6, 4) | ||
154 | |||
155 | #define HTCPLD_GPIO_RIGHT_DPAD HTCPLD_BASE(7, 7) | ||
156 | #define HTCPLD_GPIO_UP_DPAD HTCPLD_BASE(7, 6) | ||
157 | #define HTCPLD_GPIO_LEFT_DPAD HTCPLD_BASE(7, 5) | ||
158 | #define HTCPLD_GPIO_DOWN_DPAD HTCPLD_BASE(7, 4) | ||
159 | #define HTCPLD_GPIO_ENTER_DPAD HTCPLD_BASE(7, 3) | ||
160 | |||
161 | /* | ||
162 | * The htcpld chip requires a gpio write to a specific line | ||
163 | * to re-enable interrupts after one has occurred. | ||
164 | */ | ||
165 | #define HTCPLD_GPIO_INT_RESET_HI HTCPLD_BASE(2, 7) | ||
166 | #define HTCPLD_GPIO_INT_RESET_LO HTCPLD_BASE(2, 0) | ||
167 | |||
168 | /* Chip 5 */ | ||
169 | #define HTCPLD_IRQ_RIGHT_KBD HTCPLD_IRQ(0, 7) | ||
170 | #define HTCPLD_IRQ_UP_KBD HTCPLD_IRQ(0, 6) | ||
171 | #define HTCPLD_IRQ_LEFT_KBD HTCPLD_IRQ(0, 5) | ||
172 | #define HTCPLD_IRQ_DOWN_KBD HTCPLD_IRQ(0, 4) | ||
173 | |||
174 | /* Chip 6 */ | ||
175 | #define HTCPLD_IRQ_RIGHT_DPAD HTCPLD_IRQ(1, 7) | ||
176 | #define HTCPLD_IRQ_UP_DPAD HTCPLD_IRQ(1, 6) | ||
177 | #define HTCPLD_IRQ_LEFT_DPAD HTCPLD_IRQ(1, 5) | ||
178 | #define HTCPLD_IRQ_DOWN_DPAD HTCPLD_IRQ(1, 4) | ||
179 | #define HTCPLD_IRQ_ENTER_DPAD HTCPLD_IRQ(1, 3) | ||
62 | 180 | ||
63 | /* Keyboard definition */ | 181 | /* Keyboard definition */ |
64 | 182 | ||
@@ -140,6 +258,129 @@ static struct platform_device kp_device = { | |||
140 | .resource = kp_resources, | 258 | .resource = kp_resources, |
141 | }; | 259 | }; |
142 | 260 | ||
261 | /* GPIO buttons for keyboard slide and power button */ | ||
262 | static struct gpio_keys_button herald_gpio_keys_table[] = { | ||
263 | {BTN_0, HTCHERALD_GPIO_POWER, 1, "POWER", EV_KEY, 1, 20}, | ||
264 | {SW_LID, HTCHERALD_GPIO_SLIDE, 0, "SLIDE", EV_SW, 1, 20}, | ||
265 | |||
266 | {KEY_LEFT, HTCPLD_GPIO_LEFT_KBD, 1, "LEFT", EV_KEY, 1, 20}, | ||
267 | {KEY_RIGHT, HTCPLD_GPIO_RIGHT_KBD, 1, "RIGHT", EV_KEY, 1, 20}, | ||
268 | {KEY_UP, HTCPLD_GPIO_UP_KBD, 1, "UP", EV_KEY, 1, 20}, | ||
269 | {KEY_DOWN, HTCPLD_GPIO_DOWN_KBD, 1, "DOWN", EV_KEY, 1, 20}, | ||
270 | |||
271 | {KEY_LEFT, HTCPLD_GPIO_LEFT_DPAD, 1, "DLEFT", EV_KEY, 1, 20}, | ||
272 | {KEY_RIGHT, HTCPLD_GPIO_RIGHT_DPAD, 1, "DRIGHT", EV_KEY, 1, 20}, | ||
273 | {KEY_UP, HTCPLD_GPIO_UP_DPAD, 1, "DUP", EV_KEY, 1, 20}, | ||
274 | {KEY_DOWN, HTCPLD_GPIO_DOWN_DPAD, 1, "DDOWN", EV_KEY, 1, 20}, | ||
275 | {KEY_ENTER, HTCPLD_GPIO_ENTER_DPAD, 1, "DENTER", EV_KEY, 1, 20}, | ||
276 | }; | ||
277 | |||
278 | static struct gpio_keys_platform_data herald_gpio_keys_data = { | ||
279 | .buttons = herald_gpio_keys_table, | ||
280 | .nbuttons = ARRAY_SIZE(herald_gpio_keys_table), | ||
281 | .rep = 1, | ||
282 | }; | ||
283 | |||
284 | static struct platform_device herald_gpiokeys_device = { | ||
285 | .name = "gpio-keys", | ||
286 | .id = -1, | ||
287 | .dev = { | ||
288 | .platform_data = &herald_gpio_keys_data, | ||
289 | }, | ||
290 | }; | ||
291 | |||
292 | /* LEDs for the Herald. These connect to the HTCPLD GPIO device. */ | ||
293 | static struct gpio_led gpio_leds[] = { | ||
294 | {"dpad", NULL, HTCPLD_GPIO_LED_DPAD, 0, 0, LEDS_GPIO_DEFSTATE_OFF}, | ||
295 | {"kbd", NULL, HTCPLD_GPIO_LED_KBD, 0, 0, LEDS_GPIO_DEFSTATE_OFF}, | ||
296 | {"vibrate", NULL, HTCPLD_GPIO_LED_VIBRATE, 0, 0, LEDS_GPIO_DEFSTATE_OFF}, | ||
297 | {"green_solid", NULL, HTCPLD_GPIO_LED_GREEN_SOLID, 0, 0, LEDS_GPIO_DEFSTATE_OFF}, | ||
298 | {"green_flash", NULL, HTCPLD_GPIO_LED_GREEN_FLASH, 0, 0, LEDS_GPIO_DEFSTATE_OFF}, | ||
299 | {"red_solid", "mmc0", HTCPLD_GPIO_LED_RED_SOLID, 0, 0, LEDS_GPIO_DEFSTATE_OFF}, | ||
300 | {"red_flash", NULL, HTCPLD_GPIO_LED_RED_FLASH, 0, 0, LEDS_GPIO_DEFSTATE_OFF}, | ||
301 | {"wifi", NULL, HTCPLD_GPIO_LED_WIFI, 0, 0, LEDS_GPIO_DEFSTATE_OFF}, | ||
302 | {"bt", NULL, HTCPLD_GPIO_LED_BT, 0, 0, LEDS_GPIO_DEFSTATE_OFF}, | ||
303 | {"caps", NULL, HTCPLD_GPIO_LED_CAPS, 0, 0, LEDS_GPIO_DEFSTATE_OFF}, | ||
304 | {"alt", NULL, HTCPLD_GPIO_LED_ALT, 0, 0, LEDS_GPIO_DEFSTATE_OFF}, | ||
305 | }; | ||
306 | |||
307 | static struct gpio_led_platform_data gpio_leds_data = { | ||
308 | .leds = gpio_leds, | ||
309 | .num_leds = ARRAY_SIZE(gpio_leds), | ||
310 | }; | ||
311 | |||
312 | static struct platform_device gpio_leds_device = { | ||
313 | .name = "leds-gpio", | ||
314 | .id = 0, | ||
315 | .dev = { | ||
316 | .platform_data = &gpio_leds_data, | ||
317 | }, | ||
318 | }; | ||
319 | |||
320 | /* HTC PLD chips */ | ||
321 | |||
322 | static struct resource htcpld_resources[] = { | ||
323 | [0] = { | ||
324 | .start = OMAP_GPIO_IRQ(HTCHERALD_GIRQ_BTNS), | ||
325 | .end = OMAP_GPIO_IRQ(HTCHERALD_GIRQ_BTNS), | ||
326 | .flags = IORESOURCE_IRQ, | ||
327 | }, | ||
328 | }; | ||
329 | |||
330 | struct htcpld_chip_platform_data htcpld_chips[] = { | ||
331 | [0] = { | ||
332 | .addr = 0x03, | ||
333 | .reset = 0x04, | ||
334 | .num_gpios = 8, | ||
335 | .gpio_out_base = HTCPLD_BASE(0, 0), | ||
336 | .gpio_in_base = HTCPLD_BASE(4, 0), | ||
337 | }, | ||
338 | [1] = { | ||
339 | .addr = 0x04, | ||
340 | .reset = 0x8e, | ||
341 | .num_gpios = 8, | ||
342 | .gpio_out_base = HTCPLD_BASE(1, 0), | ||
343 | .gpio_in_base = HTCPLD_BASE(5, 0), | ||
344 | }, | ||
345 | [2] = { | ||
346 | .addr = 0x05, | ||
347 | .reset = 0x80, | ||
348 | .num_gpios = 8, | ||
349 | .gpio_out_base = HTCPLD_BASE(2, 0), | ||
350 | .gpio_in_base = HTCPLD_BASE(6, 0), | ||
351 | .irq_base = HTCPLD_IRQ(0, 0), | ||
352 | .num_irqs = 8, | ||
353 | }, | ||
354 | [3] = { | ||
355 | .addr = 0x06, | ||
356 | .reset = 0x40, | ||
357 | .num_gpios = 8, | ||
358 | .gpio_out_base = HTCPLD_BASE(3, 0), | ||
359 | .gpio_in_base = HTCPLD_BASE(7, 0), | ||
360 | .irq_base = HTCPLD_IRQ(1, 0), | ||
361 | .num_irqs = 8, | ||
362 | }, | ||
363 | }; | ||
364 | |||
365 | struct htcpld_core_platform_data htcpld_pfdata = { | ||
366 | .int_reset_gpio_hi = HTCPLD_GPIO_INT_RESET_HI, | ||
367 | .int_reset_gpio_lo = HTCPLD_GPIO_INT_RESET_LO, | ||
368 | .i2c_adapter_id = 1, | ||
369 | |||
370 | .chip = htcpld_chips, | ||
371 | .num_chip = ARRAY_SIZE(htcpld_chips), | ||
372 | }; | ||
373 | |||
374 | static struct platform_device htcpld_device = { | ||
375 | .name = "i2c-htcpld", | ||
376 | .id = -1, | ||
377 | .resource = htcpld_resources, | ||
378 | .num_resources = ARRAY_SIZE(htcpld_resources), | ||
379 | .dev = { | ||
380 | .platform_data = &htcpld_pfdata, | ||
381 | }, | ||
382 | }; | ||
383 | |||
143 | /* USB Device */ | 384 | /* USB Device */ |
144 | static struct omap_usb_config htcherald_usb_config __initdata = { | 385 | static struct omap_usb_config htcherald_usb_config __initdata = { |
145 | .otg = 0, | 386 | .otg = 0, |
@@ -150,14 +391,72 @@ static struct omap_usb_config htcherald_usb_config __initdata = { | |||
150 | }; | 391 | }; |
151 | 392 | ||
152 | /* LCD Device resources */ | 393 | /* LCD Device resources */ |
394 | static struct omap_lcd_config htcherald_lcd_config __initdata = { | ||
395 | .ctrl_name = "internal", | ||
396 | }; | ||
397 | |||
398 | static struct omap_board_config_kernel htcherald_config[] __initdata = { | ||
399 | { OMAP_TAG_LCD, &htcherald_lcd_config }, | ||
400 | }; | ||
401 | |||
153 | static struct platform_device lcd_device = { | 402 | static struct platform_device lcd_device = { |
154 | .name = "lcd_htcherald", | 403 | .name = "lcd_htcherald", |
155 | .id = -1, | 404 | .id = -1, |
156 | }; | 405 | }; |
157 | 406 | ||
407 | /* MMC Card */ | ||
408 | #if defined(CONFIG_MMC_OMAP) || defined(CONFIG_MMC_OMAP_MODULE) | ||
409 | static struct omap_mmc_platform_data htc_mmc1_data = { | ||
410 | .nr_slots = 1, | ||
411 | .switch_slot = NULL, | ||
412 | .slots[0] = { | ||
413 | .ocr_mask = MMC_VDD_28_29 | MMC_VDD_30_31 | | ||
414 | MMC_VDD_32_33 | MMC_VDD_33_34, | ||
415 | .name = "mmcblk", | ||
416 | .nomux = 1, | ||
417 | .wires = 4, | ||
418 | .switch_pin = -1, | ||
419 | }, | ||
420 | }; | ||
421 | |||
422 | static struct omap_mmc_platform_data *htc_mmc_data[1]; | ||
423 | #endif | ||
424 | |||
425 | |||
426 | /* Platform devices for the Herald */ | ||
158 | static struct platform_device *devices[] __initdata = { | 427 | static struct platform_device *devices[] __initdata = { |
159 | &kp_device, | 428 | &kp_device, |
160 | &lcd_device, | 429 | &lcd_device, |
430 | &htcpld_device, | ||
431 | &gpio_leds_device, | ||
432 | &herald_gpiokeys_device, | ||
433 | }; | ||
434 | |||
435 | /* | ||
436 | * Touchscreen | ||
437 | */ | ||
438 | static const struct ads7846_platform_data htcherald_ts_platform_data = { | ||
439 | .model = 7846, | ||
440 | .keep_vref_on = 1, | ||
441 | .x_plate_ohms = 496, | ||
442 | .gpio_pendown = HTCHERALD_GPIO_TS, | ||
443 | .pressure_max = 100000, | ||
444 | .pressure_min = 5000, | ||
445 | .x_min = 528, | ||
446 | .x_max = 3760, | ||
447 | .y_min = 624, | ||
448 | .y_max = 3760, | ||
449 | }; | ||
450 | |||
451 | static struct spi_board_info __initdata htcherald_spi_board_info[] = { | ||
452 | { | ||
453 | .modalias = "ads7846", | ||
454 | .platform_data = &htcherald_ts_platform_data, | ||
455 | .irq = OMAP_GPIO_IRQ(HTCHERALD_GPIO_TS), | ||
456 | .max_speed_hz = 2500000, | ||
457 | .bus_num = 2, | ||
458 | .chip_select = 1, | ||
459 | } | ||
161 | }; | 460 | }; |
162 | 461 | ||
163 | /* | 462 | /* |
@@ -278,6 +577,7 @@ static void __init htcherald_init(void) | |||
278 | { | 577 | { |
279 | printk(KERN_INFO "HTC Herald init.\n"); | 578 | printk(KERN_INFO "HTC Herald init.\n"); |
280 | 579 | ||
580 | /* Do board initialization before we register all the devices */ | ||
281 | omap_gpio_init(); | 581 | omap_gpio_init(); |
282 | 582 | ||
283 | omap_board_config = htcherald_config; | 583 | omap_board_config = htcherald_config; |
@@ -288,6 +588,16 @@ static void __init htcherald_init(void) | |||
288 | 588 | ||
289 | htcherald_usb_enable(); | 589 | htcherald_usb_enable(); |
290 | omap1_usb_init(&htcherald_usb_config); | 590 | omap1_usb_init(&htcherald_usb_config); |
591 | |||
592 | spi_register_board_info(htcherald_spi_board_info, | ||
593 | ARRAY_SIZE(htcherald_spi_board_info)); | ||
594 | |||
595 | omap_register_i2c_bus(1, 100, NULL, 0); | ||
596 | |||
597 | #if defined(CONFIG_MMC_OMAP) || defined(CONFIG_MMC_OMAP_MODULE) | ||
598 | htc_mmc_data[0] = &htc_mmc1_data; | ||
599 | omap1_init_mmc(htc_mmc_data, 1); | ||
600 | #endif | ||
291 | } | 601 | } |
292 | 602 | ||
293 | static void __init htcherald_init_irq(void) | 603 | static void __init htcherald_init_irq(void) |