summaryrefslogtreecommitdiff
path: root/firmware/target/arm/imx31/gigabeat-s/button-imx31.c
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2008-04-12 16:56:45 +0000
committerMichael Sevakis <jethead71@rockbox.org>2008-04-12 16:56:45 +0000
commita7af9e4a7f25f5a32306c74e95a677e6c85f399e (patch)
tree5df60e8382b69cf943840852269ea9387d42ea46 /firmware/target/arm/imx31/gigabeat-s/button-imx31.c
parentddfd787c54d78104dac4ed144ff6cb6df8617a0e (diff)
Add GPIO manager. Get the PMIC interrupt handling working (along with power button and HP detect). Add some reg field defined instead of using raw numbers. Add PMIC info to debug ports screen. Refine PMIC driver ops a little bit.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17086 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/arm/imx31/gigabeat-s/button-imx31.c')
-rw-r--r--firmware/target/arm/imx31/gigabeat-s/button-imx31.c38
1 files changed, 36 insertions, 2 deletions
diff --git a/firmware/target/arm/imx31/gigabeat-s/button-imx31.c b/firmware/target/arm/imx31/gigabeat-s/button-imx31.c
index 602f41abb9..c85fe5e37e 100644
--- a/firmware/target/arm/imx31/gigabeat-s/button-imx31.c
+++ b/firmware/target/arm/imx31/gigabeat-s/button-imx31.c
@@ -29,7 +29,8 @@
/* Most code in here is taken from the Linux BSP provided by Freescale
* Copyright 2004-2006 Freescale Semiconductor, Inc. All Rights Reserved. */
-static uint32_t int_btn = BUTTON_NONE;
+static bool headphones_detect = false;
+static uint32_t int_btn = BUTTON_NONE;
static bool hold_button = false;
static bool hold_button_old = false;
#define _button_hold() (GPIO3_DR & 0x10)
@@ -48,7 +49,8 @@ static __attribute__((interrupt("IRQ"))) void KPP_HANDLER(void)
unsigned short reg_val;
int col, row;
int i;
- int button = BUTTON_NONE;
+ /* Power button is handled separately on PMIC */
+ int button = int_btn & BUTTON_POWER;
/* 1. Disable both (depress and release) keypad interrupts. */
KPP_KPSR &= ~(KPP_KPSR_KRIE | KPP_KPSR_KDIE);
@@ -161,3 +163,35 @@ int button_read_device(void)
/* If hold, ignore any pressed button */
return hold_button ? BUTTON_NONE : int_btn;
}
+
+/* This is called from the mc13783 interrupt thread */
+void button_power_set_state(bool pressed)
+{
+ /* Prevent KPP_HANDLER from changing things */
+ int oldlevel = disable_irq_save();
+
+ if (pressed)
+ {
+ int_btn |= BUTTON_POWER;
+ }
+ else
+ {
+ int_btn &= ~BUTTON_POWER;
+ }
+
+ restore_irq(oldlevel);
+}
+
+/* This is called from the mc13783 interrupt thread */
+void set_headphones_inserted(bool inserted)
+{
+ headphones_detect = inserted;
+}
+
+/* This is called from the mc13783 interrupt thread */
+/* TODO: Just do a post to the button queue directly - implement the
+ * appropriate variant in the driver. */
+bool headphones_inserted(void)
+{
+ return headphones_detect;
+}