summaryrefslogtreecommitdiffstats
path: root/firmware
diff options
context:
space:
mode:
Diffstat (limited to 'firmware')
-rw-r--r--firmware/target/arm/imx233/sansa-fuzeplus/button-fuzeplus.c19
-rw-r--r--firmware/target/arm/imx233/sansa-fuzeplus/button-target.h1
-rw-r--r--firmware/target/arm/imx233/system-imx233.c24
-rw-r--r--firmware/target/arm/imx233/system-target.h27
4 files changed, 45 insertions, 26 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;
}
diff --git a/firmware/target/arm/imx233/sansa-fuzeplus/button-target.h b/firmware/target/arm/imx233/sansa-fuzeplus/button-target.h
index b5d27bb176..81bbc34511 100644
--- a/firmware/target/arm/imx233/sansa-fuzeplus/button-target.h
+++ b/firmware/target/arm/imx233/sansa-fuzeplus/button-target.h
@@ -29,7 +29,6 @@ int button_read_device(void);
/* Main unit's buttons */
#define BUTTON_POWER 0x00000001
-
#define BUTTON_VOL_UP 0x00000002
#define BUTTON_VOL_DOWN 0x00000004
diff --git a/firmware/target/arm/imx233/system-imx233.c b/firmware/target/arm/imx233/system-imx233.c
index bcccce194c..aedffd1cf6 100644
--- a/firmware/target/arm/imx233/system-imx233.c
+++ b/firmware/target/arm/imx233/system-imx233.c
@@ -30,30 +30,6 @@
#include "lcd.h"
#include "backlight-target.h"
-#define HW_POWER_BASE 0x80044000
-
-#define HW_POWER_RESET (*(volatile uint32_t *)(HW_POWER_BASE + 0x100))
-#define HW_POWER_RESET__UNLOCK 0x3E770000
-#define HW_POWER_RESET__PWD 0x1
-
-#define HW_ICOLL_BASE 0x80000000
-
-#define HW_ICOLL_VECTOR (*(volatile uint32_t *)(HW_ICOLL_BASE + 0x0))
-
-#define HW_ICOLL_LEVELACK (*(volatile uint32_t *)(HW_ICOLL_BASE + 0x10))
-#define HW_ICOLL_LEVELACK__LEVEL0 0x1
-
-#define HW_ICOLL_CTRL (*(volatile uint32_t *)(HW_ICOLL_BASE + 0x20))
-#define HW_ICOLL_CTRL__IRQ_FINAL_ENABLE (1 << 16)
-#define HW_ICOLL_CTRL__ARM_RSE_MODE (1 << 18)
-
-#define HW_ICOLL_VBASE (*(volatile uint32_t *)(HW_ICOLL_BASE + 0x40))
-#define HW_ICOLL_INTERRUPT(i) (*(volatile uint32_t *)(HW_ICOLL_BASE + 0x120 + (i) * 0x10))
-#define HW_ICOLL_INTERRUPT__PRIORITY_BM 0x3
-#define HW_ICOLL_INTERRUPT__ENABLE 0x4
-#define HW_ICOLL_INTERRUPT__SOFTIRQ 0x8
-#define HW_ICOLL_INTERRUPT__ENFIQ 0x10
-
#define default_interrupt(name) \
extern __attribute__((weak, alias("UIRQ"))) void name(void)
diff --git a/firmware/target/arm/imx233/system-target.h b/firmware/target/arm/imx233/system-target.h
index 675adb448b..4d767b3a9f 100644
--- a/firmware/target/arm/imx233/system-target.h
+++ b/firmware/target/arm/imx233/system-target.h
@@ -30,6 +30,33 @@
#define HW_DIGCTL_BASE 0x8001C000
#define HW_DIGCTL_MICROSECONDS (*(volatile uint32_t *)(HW_DIGCTL_BASE + 0xC0))
+#define HW_POWER_BASE 0x80044000
+#define HW_POWER_STS (*(volatile uint32_t *)(HW_POWER_BASE + 0xc0))
+#define HW_POWER_STS__PSWITCH_BP 20
+#define HW_POWER_STS__PSWITCH_BM (3 << 20)
+
+#define HW_POWER_RESET (*(volatile uint32_t *)(HW_POWER_BASE + 0x100))
+#define HW_POWER_RESET__UNLOCK 0x3E770000
+#define HW_POWER_RESET__PWD 0x1
+
+#define HW_ICOLL_BASE 0x80000000
+
+#define HW_ICOLL_VECTOR (*(volatile uint32_t *)(HW_ICOLL_BASE + 0x0))
+
+#define HW_ICOLL_LEVELACK (*(volatile uint32_t *)(HW_ICOLL_BASE + 0x10))
+#define HW_ICOLL_LEVELACK__LEVEL0 0x1
+
+#define HW_ICOLL_CTRL (*(volatile uint32_t *)(HW_ICOLL_BASE + 0x20))
+#define HW_ICOLL_CTRL__IRQ_FINAL_ENABLE (1 << 16)
+#define HW_ICOLL_CTRL__ARM_RSE_MODE (1 << 18)
+
+#define HW_ICOLL_VBASE (*(volatile uint32_t *)(HW_ICOLL_BASE + 0x40))
+#define HW_ICOLL_INTERRUPT(i) (*(volatile uint32_t *)(HW_ICOLL_BASE + 0x120 + (i) * 0x10))
+#define HW_ICOLL_INTERRUPT__PRIORITY_BM 0x3
+#define HW_ICOLL_INTERRUPT__ENABLE 0x4
+#define HW_ICOLL_INTERRUPT__SOFTIRQ 0x8
+#define HW_ICOLL_INTERRUPT__ENFIQ 0x10
+
#define INT_SRC_USB_CTRL 11
#define INT_SRC_TIMER(nr) (28 + (nr))
#define INT_SRC_LCDIF_DMA 45