diff options
author | Jens Arnold <amiconn@rockbox.org> | 2006-10-29 13:48:57 +0000 |
---|---|---|
committer | Jens Arnold <amiconn@rockbox.org> | 2006-10-29 13:48:57 +0000 |
commit | 85c9a05c56a290a0dd1686808d5bdb966d72f9a5 (patch) | |
tree | 4c05a7348210ed469e7ee0104f782c5e27378979 /firmware/target/coldfire/iriver/h300/pcf50606-h300.c | |
parent | c4c4709d82e91f21283721eefcebe18182d901be (diff) | |
download | rockbox-85c9a05c56a290a0dd1686808d5bdb966d72f9a5.tar.gz rockbox-85c9a05c56a290a0dd1686808d5bdb966d72f9a5.zip |
H300: Don't read the button ADC as long as no button is pressed, utilising the PCF50606 accessory detect feature. Ported from X5.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11383 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/coldfire/iriver/h300/pcf50606-h300.c')
-rw-r--r-- | firmware/target/coldfire/iriver/h300/pcf50606-h300.c | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/firmware/target/coldfire/iriver/h300/pcf50606-h300.c b/firmware/target/coldfire/iriver/h300/pcf50606-h300.c index c990f5ddcb..3a67d541d3 100644 --- a/firmware/target/coldfire/iriver/h300/pcf50606-h300.c +++ b/firmware/target/coldfire/iriver/h300/pcf50606-h300.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #include "system.h" | 20 | #include "system.h" |
21 | #include "kernel.h" | 21 | #include "kernel.h" |
22 | #include "pcf50606.h" | 22 | #include "pcf50606.h" |
23 | #include "button-target.h" | ||
23 | 24 | ||
24 | /* These voltages were determined by measuring the output of the PCF50606 | 25 | /* These voltages were determined by measuring the output of the PCF50606 |
25 | on a running H300, and verified by disassembling the original firmware */ | 26 | on a running H300, and verified by disassembling the original firmware */ |
@@ -37,10 +38,44 @@ static void set_voltages(void) | |||
37 | pcf50606_write_multiple(0x23, buf, 5); | 38 | pcf50606_write_multiple(0x23, buf, 5); |
38 | } | 39 | } |
39 | 40 | ||
41 | static void init_pmu_interrupts(void) | ||
42 | { | ||
43 | /* inital data is interrupt masks */ | ||
44 | unsigned char data[3] = | ||
45 | { | ||
46 | ~0x00, | ||
47 | ~0x00, | ||
48 | ~0x06, /* unmask ACDREM, ACDINS */ | ||
49 | }; | ||
50 | |||
51 | /* make sure GPI6 interrupt is off before unmasking anything */ | ||
52 | and_l(~0x0f000000, &INTPRI5); /* INT38 - Priority 0 (Off) */ | ||
53 | |||
54 | /* unmask the PMU interrupts we want to service */ | ||
55 | pcf50606_write_multiple(0x05, data, 3); | ||
56 | /* clear INT1-3 as these are left set after standby */ | ||
57 | pcf50606_read_multiple(0x02, data, 3); | ||
58 | |||
59 | /* Set to read pcf50606 INT but keep GPI6 off until init completes */ | ||
60 | and_l(~0x00000040, &GPIO_ENABLE); | ||
61 | or_l(0x00000040, &GPIO_FUNCTION); | ||
62 | or_l(0x00004000, &GPIO_INT_EN); /* GPI6 H-L */ | ||
63 | } | ||
64 | |||
65 | static inline void enable_pmu_interrupts(void) | ||
66 | { | ||
67 | /* clear pending GPI6 interrupts first or it may miss the first | ||
68 | H-L transition */ | ||
69 | or_l(0x00004000, &GPIO_INT_CLEAR); | ||
70 | or_l(0x03000000, &INTPRI5); /* INT38 - Priority 3 */ | ||
71 | } | ||
72 | |||
40 | void pcf50606_init(void) | 73 | void pcf50606_init(void) |
41 | { | 74 | { |
42 | pcf50606_i2c_init(); | 75 | pcf50606_i2c_init(); |
43 | 76 | ||
77 | /* initialize pmu interrupts but don't service them yet */ | ||
78 | init_pmu_interrupts(); | ||
44 | set_voltages(); | 79 | set_voltages(); |
45 | 80 | ||
46 | pcf50606_write(0x08, 0x60); /* Wake on USB and charger insertion */ | 81 | pcf50606_write(0x08, 0x60); /* Wake on USB and charger insertion */ |
@@ -49,4 +84,30 @@ void pcf50606_init(void) | |||
49 | 84 | ||
50 | pcf50606_write(0x35, 0x13); /* Backlight PWM = 512Hz 50/50 */ | 85 | pcf50606_write(0x35, 0x13); /* Backlight PWM = 512Hz 50/50 */ |
51 | pcf50606_write(0x3a, 0x3b); /* PWM output on GPOOD1 */ | 86 | pcf50606_write(0x3a, 0x3b); /* PWM output on GPOOD1 */ |
87 | |||
88 | pcf50606_write(0x33, 0x8c); /* Accessory detect: ACDAPE=1, THRSHLD=2.20V */ | ||
89 | |||
90 | enable_pmu_interrupts(); /* allow GPI6 interrupts from PMU now */ | ||
91 | } | ||
92 | |||
93 | /* PMU interrupt */ | ||
94 | void GPI6(void) __attribute__ ((interrupt_handler)); | ||
95 | void GPI6(void) | ||
96 | { | ||
97 | unsigned char data[3]; /* 0 = INT1, 1 = INT2, 2 = INT3 */ | ||
98 | |||
99 | /* Clear pending GPI6 interrupts */ | ||
100 | or_l(0x00004000, &GPIO_INT_CLEAR); | ||
101 | |||
102 | /* clear pending interrupts from pcf50606 */ | ||
103 | pcf50606_read_multiple(0x02, data, 3); | ||
104 | |||
105 | if (data[2] & 0x06) | ||
106 | { | ||
107 | /* ACDINS/ACDREM */ | ||
108 | /* Check if the button driver should actually scan main buttons or not | ||
109 | - bias towards "yes" out of paranoia. */ | ||
110 | button_enable_scan((data[2] & 0x02) != 0 || | ||
111 | (pcf50606_read(0x33) & 0x01) != 0); | ||
112 | } | ||
52 | } | 113 | } |