summaryrefslogtreecommitdiff
path: root/firmware/target/arm/imx233/sansa-fuzeplus/button-fuzeplus.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm/imx233/sansa-fuzeplus/button-fuzeplus.c')
-rw-r--r--firmware/target/arm/imx233/sansa-fuzeplus/button-fuzeplus.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/firmware/target/arm/imx233/sansa-fuzeplus/button-fuzeplus.c b/firmware/target/arm/imx233/sansa-fuzeplus/button-fuzeplus.c
index 7f37d67d43..4882f243aa 100644
--- a/firmware/target/arm/imx233/sansa-fuzeplus/button-fuzeplus.c
+++ b/firmware/target/arm/imx233/sansa-fuzeplus/button-fuzeplus.c
@@ -19,6 +19,9 @@
*
****************************************************************************/
#include "button-target.h"
+#include "system.h"
+#include "system-target.h"
+#include "pinctrl-imx233.h"
void button_init_device(void)
{
@@ -26,5 +29,19 @@ void button_init_device(void)
int button_read_device(void)
{
- return 0;
+ int res = 0;
+ if(!imx233_get_gpio_input_mask(1, 0x40000000))
+ res |= BUTTON_VOL_DOWN;
+ /* The imx233 uses the voltage on the PSWITCH pin to detect power up/down
+ * events as well as recovery mode. Since the power button is the power button
+ * and the volume up button is recovery, it is not possible to know whether
+ * power button is down when volume up is down (except if there is another
+ * method but volume up and power don't seem to be wired to GPIO pins). */
+ switch((HW_POWER_STS & HW_POWER_STS__PSWITCH_BM) >> HW_POWER_STS__PSWITCH_BP)
+ {
+ case 1: res |= BUTTON_POWER; break;
+ case 3: res |= BUTTON_VOL_UP; break;
+ default: break;
+ }
+ return res;
}