diff options
author | Cástor Muñoz <cmvidal@gmail.com> | 2012-03-20 23:26:11 +0100 |
---|---|---|
committer | Cástor Muñoz <cmvidal@gmail.com> | 2012-03-28 00:51:22 +0200 |
commit | 7ec426e497daa1b4a6082bf4e4e3df687b11db44 (patch) | |
tree | d9f495561dc118c7f92aab8031d17bebe1549c2e | |
parent | 1d5a505019421bed322c7107169ecc82b7751687 (diff) | |
download | rockbox-7ec426e497daa1b4a6082bf4e4e3df687b11db44.tar.gz rockbox-7ec426e497daa1b4a6082bf4e4e3df687b11db44.zip |
Classic/6G: hold switch detection using GPIO
Configures GPIO ports to detect holdswitch status instead of
polling the PMU via I2C, this fixes some random crashes
Change-Id: I407c9ca4c2c9203842f9e774b1c8d0455d59048c
Reviewed-on: http://gerrit.rockbox.org/194
Reviewed-by: Michael Giacomelli <giac2000@hotmail.com>
-rw-r--r-- | firmware/target/arm/ipod/button-clickwheel.c | 35 |
1 files changed, 14 insertions, 21 deletions
diff --git a/firmware/target/arm/ipod/button-clickwheel.c b/firmware/target/arm/ipod/button-clickwheel.c index 2abe25f2e3..162ff9f246 100644 --- a/firmware/target/arm/ipod/button-clickwheel.c +++ b/firmware/target/arm/ipod/button-clickwheel.c | |||
@@ -39,7 +39,7 @@ | |||
39 | #include "serial.h" | 39 | #include "serial.h" |
40 | #include "power.h" | 40 | #include "power.h" |
41 | #include "powermgmt.h" | 41 | #include "powermgmt.h" |
42 | #if defined(IPOD_NANO2G) || defined(IPOD_6G) | 42 | #ifdef IPOD_NANO2G |
43 | #include "pmu-target.h" | 43 | #include "pmu-target.h" |
44 | #endif | 44 | #endif |
45 | 45 | ||
@@ -87,11 +87,6 @@ static int int_btn = BUTTON_NONE; | |||
87 | static struct semaphore button_init_wakeup; | 87 | static struct semaphore button_init_wakeup; |
88 | #endif | 88 | #endif |
89 | 89 | ||
90 | #if CONFIG_CPU==S5L8702 | ||
91 | static long holdswitch_last_read; | ||
92 | static bool holdswitch_last_value; | ||
93 | #endif | ||
94 | |||
95 | #ifdef CPU_PP | 90 | #ifdef CPU_PP |
96 | static void opto_i2c_init(void) | 91 | static void opto_i2c_init(void) |
97 | { | 92 | { |
@@ -367,7 +362,10 @@ static void s5l_clickwheel_init(void) | |||
367 | WHEEL04 |= 1; | 362 | WHEEL04 |= 1; |
368 | PDAT10 &= ~2; | 363 | PDAT10 &= ~2; |
369 | #elif CONFIG_CPU==S5L8702 | 364 | #elif CONFIG_CPU==S5L8702 |
370 | //TODO: Implement | 365 | /* enable external (CY8C21x34) wheel controller */ |
366 | GPIOCMD = 0xe040f; | ||
367 | |||
368 | /* TODO: enable and init internal (s5l8702) wheel controller */ | ||
371 | #endif | 369 | #endif |
372 | } | 370 | } |
373 | 371 | ||
@@ -377,8 +375,9 @@ void button_init_device(void) | |||
377 | #if CONFIG_CPU==S5L8701 | 375 | #if CONFIG_CPU==S5L8701 |
378 | INTMSK |= (1<<26); | 376 | INTMSK |= (1<<26); |
379 | #elif CONFIG_CPU==S5L8702 | 377 | #elif CONFIG_CPU==S5L8702 |
380 | holdswitch_last_read = USEC_TIMER; | 378 | /* configure GPIO E2 as pull-up input */ |
381 | holdswitch_last_value = (pmu_read(0x87) & 2) == 0; | 379 | GPIOCMD = 0xe0200; |
380 | PUNB(14) |= (1 << 2); | ||
382 | #endif | 381 | #endif |
383 | s5l_clickwheel_init(); | 382 | s5l_clickwheel_init(); |
384 | semaphore_wait(&button_init_wakeup, HZ / 10); | 383 | semaphore_wait(&button_init_wakeup, HZ / 10); |
@@ -393,15 +392,7 @@ bool button_hold(void) | |||
393 | else PCON15 = (PCON15 & ~0xffff0000) | 0x22220000; | 392 | else PCON15 = (PCON15 & ~0xffff0000) | 0x22220000; |
394 | return value; | 393 | return value; |
395 | #elif CONFIG_CPU==S5L8702 | 394 | #elif CONFIG_CPU==S5L8702 |
396 | if (USEC_TIMER - holdswitch_last_read > 100000) | 395 | return ((PDATE & (1 << 2)) == 0); |
397 | { | ||
398 | holdswitch_last_read = USEC_TIMER; | ||
399 | holdswitch_last_value = (pmu_read(0x87) & 2) == 0; | ||
400 | } | ||
401 | if (holdswitch_last_value) | ||
402 | PCON(14) = PCON(14) & ~0xffffff00; | ||
403 | else PCON(14) = (PCON(14) & ~0xffffff00) | 0x22222200; | ||
404 | return holdswitch_last_value; | ||
405 | #endif | 396 | #endif |
406 | } | 397 | } |
407 | 398 | ||
@@ -411,7 +402,6 @@ bool headphones_inserted(void) | |||
411 | return ((PDAT14 & (1 << 5)) != 0); | 402 | return ((PDAT14 & (1 << 5)) != 0); |
412 | #elif CONFIG_CPU==S5L8702 | 403 | #elif CONFIG_CPU==S5L8702 |
413 | return ((PDATA & (1 << 6)) != 0); | 404 | return ((PDATA & (1 << 6)) != 0); |
414 | return false; | ||
415 | #endif | 405 | #endif |
416 | } | 406 | } |
417 | #endif | 407 | #endif |
@@ -445,7 +435,10 @@ int button_read_device(void) | |||
445 | WHEEL10 = 0; | 435 | WHEEL10 = 0; |
446 | PWRCONEXT |= 1; | 436 | PWRCONEXT |= 1; |
447 | #elif CONFIG_CPU==S5L8702 | 437 | #elif CONFIG_CPU==S5L8702 |
448 | //TODO: Implement | 438 | /* disable external (CY8C21x34) wheel controller */ |
439 | GPIOCMD = 0xe040e; | ||
440 | |||
441 | /* TODO: disable internal (s5l8702) wheel controller */ | ||
449 | #endif | 442 | #endif |
450 | } | 443 | } |
451 | else | 444 | else |
@@ -458,7 +451,7 @@ int button_read_device(void) | |||
458 | pmu_ldo_power_on(1); /* enable clickwheel power supply */ | 451 | pmu_ldo_power_on(1); /* enable clickwheel power supply */ |
459 | s5l_clickwheel_init(); | 452 | s5l_clickwheel_init(); |
460 | #elif CONFIG_CPU==S5L8702 | 453 | #elif CONFIG_CPU==S5L8702 |
461 | //TODO: Implement | 454 | s5l_clickwheel_init(); |
462 | #endif | 455 | #endif |
463 | } | 456 | } |
464 | } | 457 | } |