aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorAndrzej Zaborowski <balrog@zabor.org>2006-12-07 20:13:51 -0500
committerTony Lindgren <tony@atomide.com>2008-02-08 13:38:01 -0500
commitd7730cc01f703b1e3c43127bd38fb042c0efdb71 (patch)
tree5dbed4185042fb32fb6b478279d65856fb3c4dad /arch
parent1ed16a86b47fd7dd9125fc8f6df482cc6edc9b20 (diff)
ARM: OMAP1: Palm Tungsten E board clean-up
Mostly gpio clean-up. Signed-off-by: Andrzej Zaborowski <balrog@zabor.org> Signed-off-by: Tony Lindgren <tony@atomide.com>
Diffstat (limited to 'arch')
-rw-r--r--arch/arm/mach-omap1/board-palmte.c83
1 files changed, 22 insertions, 61 deletions
diff --git a/arch/arm/mach-omap1/board-palmte.c b/arch/arm/mach-omap1/board-palmte.c
index f392f5a014ea..ca1a4bf78a10 100644
--- a/arch/arm/mach-omap1/board-palmte.c
+++ b/arch/arm/mach-omap1/board-palmte.c
@@ -10,6 +10,8 @@
10 * Maintainers : http://palmtelinux.sf.net 10 * Maintainers : http://palmtelinux.sf.net
11 * palmtelinux-developpers@lists.sf.net 11 * palmtelinux-developpers@lists.sf.net
12 * 12 *
13 * Copyright (c) 2006 Andrzej Zaborowski <balrog@zabor.org>
14 *
13 * This program is free software; you can redistribute it and/or modify 15 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License version 2 as 16 * it under the terms of the GNU General Public License version 2 as
15 * published by the Free Software Foundation. 17 * published by the Free Software Foundation.
@@ -24,8 +26,8 @@
24#include <linux/spi/spi.h> 26#include <linux/spi/spi.h>
25#include <linux/spi/tsc2102.h> 27#include <linux/spi/tsc2102.h>
26#include <linux/interrupt.h> 28#include <linux/interrupt.h>
29#include <linux/apm-emulation.h>
27 30
28#include <asm/apm.h>
29#include <asm/hardware.h> 31#include <asm/hardware.h>
30#include <asm/mach-types.h> 32#include <asm/mach-types.h>
31#include <asm/mach/arch.h> 33#include <asm/mach/arch.h>
@@ -51,11 +53,11 @@ static void __init omap_palmte_init_irq(void)
51 omap_gpio_init(); 53 omap_gpio_init();
52} 54}
53 55
54static int palmte_keymap[] = { 56static const int palmte_keymap[] = {
55 KEY(0, 0, KEY_F1), 57 KEY(0, 0, KEY_F1), /* Calendar */
56 KEY(0, 1, KEY_F2), 58 KEY(0, 1, KEY_F2), /* Contacts */
57 KEY(0, 2, KEY_F3), 59 KEY(0, 2, KEY_F3), /* Tasks List */
58 KEY(0, 3, KEY_F4), 60 KEY(0, 3, KEY_F4), /* Note Pad */
59 KEY(0, 4, KEY_POWER), 61 KEY(0, 4, KEY_POWER),
60 KEY(1, 0, KEY_LEFT), 62 KEY(1, 0, KEY_LEFT),
61 KEY(1, 1, KEY_DOWN), 63 KEY(1, 1, KEY_DOWN),
@@ -68,7 +70,7 @@ static int palmte_keymap[] = {
68static struct omap_kp_platform_data palmte_kp_data = { 70static struct omap_kp_platform_data palmte_kp_data = {
69 .rows = 8, 71 .rows = 8,
70 .cols = 8, 72 .cols = 8,
71 .keymap = palmte_keymap, 73 .keymap = (int *) palmte_keymap,
72 .rep = 1, 74 .rep = 1,
73 .delay = 12, 75 .delay = 12,
74}; 76};
@@ -180,7 +182,7 @@ static struct platform_device palmte_irda_device = {
180 .resource = palmte_irda_resources, 182 .resource = palmte_irda_resources,
181}; 183};
182 184
183static struct platform_device *devices[] __initdata = { 185static struct platform_device *palmte_devices[] __initdata = {
184 &palmte_rom_device, 186 &palmte_rom_device,
185 &palmte_kp_device, 187 &palmte_kp_device,
186 &palmte_lcd_device, 188 &palmte_lcd_device,
@@ -273,7 +275,7 @@ static void palmte_get_power_status(struct apm_power_info *info, int *battery)
273 info->time = 0; 275 info->time = 0;
274 } else { 276 } else {
275 while (hi > lo + 1) { 277 while (hi > lo + 1) {
276 mid = (hi + lo) >> 2; 278 mid = (hi + lo) >> 1;
277 if (batt <= palmte_battery_sample[mid]) 279 if (batt <= palmte_battery_sample[mid])
278 lo = mid; 280 lo = mid;
279 else 281 else
@@ -321,7 +323,7 @@ static struct tsc2102_config palmte_tsc2102_config = {
321 .alsa_config = &palmte_alsa_config, 323 .alsa_config = &palmte_alsa_config,
322}; 324};
323 325
324static struct omap_board_config_kernel palmte_config[] = { 326static struct omap_board_config_kernel palmte_config[] __initdata = {
325 { OMAP_TAG_USB, &palmte_usb_config }, 327 { OMAP_TAG_USB, &palmte_usb_config },
326 { OMAP_TAG_MMC, &palmte_mmc_config }, 328 { OMAP_TAG_MMC, &palmte_mmc_config },
327 { OMAP_TAG_LCD, &palmte_lcd_config }, 329 { OMAP_TAG_LCD, &palmte_lcd_config },
@@ -339,74 +341,34 @@ static struct spi_board_info palmte_spi_info[] __initdata = {
339 }, 341 },
340}; 342};
341 343
342/* Periodically check for changes on important input pins */ 344static void palmte_headphones_detect(void *data, int state)
343struct timer_list palmte_pin_timer; 345{
344int prev_power, prev_headphones; 346 if (state) {
345
346static void palmte_pin_handler(unsigned long data) {
347 int power, headphones;
348
349 power = !omap_get_gpio_datain(PALMTE_DC_GPIO);
350 headphones = omap_get_gpio_datain(PALMTE_HEADPHONES_GPIO);
351
352 if (power && !prev_power)
353 printk(KERN_INFO "PM: cable connected\n");
354 else if (!power && prev_power)
355 printk(KERN_INFO "PM: cable disconnected\n");
356
357 if (headphones && !prev_headphones) {
358 /* Headphones connected, disable speaker */ 347 /* Headphones connected, disable speaker */
359 omap_set_gpio_dataout(PALMTE_SPEAKER_GPIO, 0); 348 omap_set_gpio_dataout(PALMTE_SPEAKER_GPIO, 0);
360 printk(KERN_INFO "PM: speaker off\n"); 349 printk(KERN_INFO "PM: speaker off\n");
361 } else if (!headphones && prev_headphones) { 350 } else {
362 /* Headphones unplugged, re-enable speaker */ 351 /* Headphones unplugged, re-enable speaker */
363 omap_set_gpio_dataout(PALMTE_SPEAKER_GPIO, 1); 352 omap_set_gpio_dataout(PALMTE_SPEAKER_GPIO, 1);
364 printk(KERN_INFO "PM: speaker on\n"); 353 printk(KERN_INFO "PM: speaker on\n");
365 } 354 }
366
367 prev_power = power;
368 prev_headphones = headphones;
369 mod_timer(&palmte_pin_timer, jiffies + msecs_to_jiffies(500));
370} 355}
371 356
372static void __init palmte_gpio_setup(void) 357static void __init palmte_misc_gpio_setup(void)
373{ 358{
374 /* Set TSC2102 PINTDAV pin as input */ 359 /* Set TSC2102 PINTDAV pin as input (used by TSC2102 driver) */
375 if (omap_request_gpio(PALMTE_PINTDAV_GPIO)) { 360 if (omap_request_gpio(PALMTE_PINTDAV_GPIO)) {
376 printk(KERN_ERR "Could not reserve PINTDAV GPIO!\n"); 361 printk(KERN_ERR "Could not reserve PINTDAV GPIO!\n");
377 return; 362 return;
378 } 363 }
379 omap_set_gpio_direction(PALMTE_PINTDAV_GPIO, 1); 364 omap_set_gpio_direction(PALMTE_PINTDAV_GPIO, 1);
380 365
381 /* Monitor cable-connected signals */ 366 /* Set USB-or-DC-IN pin as input (unused) */
382 if (omap_request_gpio(PALMTE_DC_GPIO) || 367 if (omap_request_gpio(PALMTE_USB_OR_DC_GPIO)) {
383 omap_request_gpio(PALMTE_USB_OR_DC_GPIO) ||
384 omap_request_gpio(PALMTE_USBDETECT_GPIO)) {
385 printk(KERN_ERR "Could not reserve cable signal GPIO!\n"); 368 printk(KERN_ERR "Could not reserve cable signal GPIO!\n");
386 return; 369 return;
387 } 370 }
388 omap_set_gpio_direction(PALMTE_DC_GPIO, 1);
389 omap_set_gpio_direction(PALMTE_USB_OR_DC_GPIO, 1); 371 omap_set_gpio_direction(PALMTE_USB_OR_DC_GPIO, 1);
390 omap_set_gpio_direction(PALMTE_USBDETECT_GPIO, 1);
391
392 /* Set speaker-enable pin as output */
393 if (omap_request_gpio(PALMTE_SPEAKER_GPIO)) {
394 printk(KERN_ERR "Could not reserve speaker GPIO!\n");
395 return;
396 }
397 omap_set_gpio_direction(PALMTE_SPEAKER_GPIO, 0);
398
399 /* Monitor the headphones-connected signal */
400 if (omap_request_gpio(PALMTE_HEADPHONES_GPIO)) {
401 printk(KERN_ERR "Could not reserve headphones signal GPIO!\n");
402 return;
403 }
404 omap_set_gpio_direction(PALMTE_HEADPHONES_GPIO, 1);
405
406 prev_power = omap_get_gpio_datain(PALMTE_DC_GPIO);
407 prev_headphones = !omap_get_gpio_datain(PALMTE_HEADPHONES_GPIO);
408 setup_timer(&palmte_pin_timer, palmte_pin_handler, 0);
409 palmte_pin_handler(0);
410} 372}
411 373
412static void __init omap_palmte_init(void) 374static void __init omap_palmte_init(void)
@@ -414,13 +376,12 @@ static void __init omap_palmte_init(void)
414 omap_board_config = palmte_config; 376 omap_board_config = palmte_config;
415 omap_board_config_size = ARRAY_SIZE(palmte_config); 377 omap_board_config_size = ARRAY_SIZE(palmte_config);
416 378
417 platform_add_devices(devices, ARRAY_SIZE(devices)); 379 platform_add_devices(palmte_devices, ARRAY_SIZE(palmte_devices));
418 380
419 spi_register_board_info(palmte_spi_info, ARRAY_SIZE(palmte_spi_info)); 381 spi_register_board_info(palmte_spi_info, ARRAY_SIZE(palmte_spi_info));
420 382 palmte_misc_gpio_setup();
421 omap_serial_init(); 383 omap_serial_init();
422 omap_register_i2c_bus(1, 100, NULL, 0); 384 omap_register_i2c_bus(1, 100, NULL, 0);
423 palmte_gpio_setup();
424} 385}
425 386
426static void __init omap_palmte_map_io(void) 387static void __init omap_palmte_map_io(void)