summaryrefslogtreecommitdiff
path: root/firmware/target/arm/imx31/gigabeat-s/button-gigabeat-s.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm/imx31/gigabeat-s/button-gigabeat-s.c')
-rw-r--r--firmware/target/arm/imx31/gigabeat-s/button-gigabeat-s.c33
1 files changed, 13 insertions, 20 deletions
diff --git a/firmware/target/arm/imx31/gigabeat-s/button-gigabeat-s.c b/firmware/target/arm/imx31/gigabeat-s/button-gigabeat-s.c
index 90db00dcc3..11d1d5a0b4 100644
--- a/firmware/target/arm/imx31/gigabeat-s/button-gigabeat-s.c
+++ b/firmware/target/arm/imx31/gigabeat-s/button-gigabeat-s.c
@@ -35,7 +35,7 @@
35static bool initialized = false; 35static bool initialized = false;
36#endif 36#endif
37 37
38static int ext_btn = BUTTON_NONE; /* Buttons not on KPP */ 38static unsigned long ext_btn = BUTTON_NONE; /* Buttons not on KPP */
39static bool hold_button = false; 39static bool hold_button = false;
40#ifndef BOOTLOADER 40#ifndef BOOTLOADER
41static bool hold_button_old = false; 41static bool hold_button_old = false;
@@ -150,24 +150,16 @@ int button_read_device(void)
150#endif 150#endif
151} 151}
152 152
153/* This is called from the mc13783 interrupt thread */ 153/* Helper to update the power button status */
154void button_power_event(void) 154static void power_button_update(bool pressed)
155{ 155{
156 bool pressed = 156 bitmod32(&ext_btn, pressed ? BUTTON_POWER : 0, BUTTON_POWER);
157 (mc13783_read(MC13783_INTERRUPT_SENSE1) & MC13783_ONOFD1S) == 0; 157}
158
159 int oldlevel = disable_irq_save();
160
161 if (pressed)
162 {
163 ext_btn |= BUTTON_POWER;
164 }
165 else
166 {
167 ext_btn &= ~BUTTON_POWER;
168 }
169 158
170 restore_irq(oldlevel); 159/* Power button event - called from PMIC ISR */
160void button_power_event(void)
161{
162 power_button_update(!mc13783_event_sense(MC13783_ONOFD1_EVENT));
171} 163}
172 164
173void button_init_device(void) 165void button_init_device(void)
@@ -203,8 +195,9 @@ void button_init_device(void)
203 * 6. Set the KDIE control bit bit. */ 195 * 6. Set the KDIE control bit bit. */
204 KPP_KPSR = KPP_KPSR_KRSS | KPP_KPSR_KDSC | KPP_KPSR_KPKD; 196 KPP_KPSR = KPP_KPSR_KRSS | KPP_KPSR_KDSC | KPP_KPSR_KPKD;
205 197
206 button_power_event(); 198 power_button_update(!(mc13783_read(MC13783_INTERRUPT_SENSE1)
207 mc13783_enable_event(MC13783_ONOFD1_EVENT); 199 & MC13783_ONOFD1S));
200 mc13783_enable_event(MC13783_ONOFD1_EVENT, true);
208 201
209#ifdef HAVE_HEADPHONE_DETECTION 202#ifdef HAVE_HEADPHONE_DETECTION
210 headphone_init(); 203 headphone_init();
@@ -220,7 +213,7 @@ void button_close_device(void)
220 /* Assumes HP detection is not available */ 213 /* Assumes HP detection is not available */
221 initialized = false; 214 initialized = false;
222 215
223 mc13783_disable_event(MC13783_ONOFD1_EVENT); 216 mc13783_enable_event(MC13783_ONOFD1_EVENT, true);
224 ext_btn = BUTTON_NONE; 217 ext_btn = BUTTON_NONE;
225} 218}
226#endif /* BUTTON_DRIVER_CLOSE */ 219#endif /* BUTTON_DRIVER_CLOSE */