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>

authored by Andrzej Zaborowski and committed by Tony Lindgren d7730cc0 1ed16a86

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