summaryrefslogtreecommitdiffstats
path: root/firmware/target/arm/imx31
diff options
context:
space:
mode:
authorNils Wallménius <nils@rockbox.org>2008-04-13 10:04:21 +0000
committerNils Wallménius <nils@rockbox.org>2008-04-13 10:04:21 +0000
commit8c5d552ebdadd00a3f1610110afb6eb4fa77071a (patch)
tree0af146dd372ea8110e89fe474ad9e419af762533 /firmware/target/arm/imx31
parentd715f79ed6f8aa113c529b8a1ac5d8d82b69670f (diff)
downloadrockbox-8c5d552ebdadd00a3f1610110afb6eb4fa77071a.tar.gz
rockbox-8c5d552ebdadd00a3f1610110afb6eb4fa77071a.tar.bz2
rockbox-8c5d552ebdadd00a3f1610110afb6eb4fa77071a.zip
Charger detection for Gigabeat S
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17093 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/arm/imx31')
-rw-r--r--firmware/target/arm/imx31/gigabeat-s/mc13783-imx31.c16
-rw-r--r--firmware/target/arm/imx31/gigabeat-s/power-imx31.c10
-rw-r--r--firmware/target/arm/imx31/gigabeat-s/power-imx31.h21
3 files changed, 44 insertions, 3 deletions
diff --git a/firmware/target/arm/imx31/gigabeat-s/mc13783-imx31.c b/firmware/target/arm/imx31/gigabeat-s/mc13783-imx31.c
index a04cd7f893..fdb214a33d 100644
--- a/firmware/target/arm/imx31/gigabeat-s/mc13783-imx31.c
+++ b/firmware/target/arm/imx31/gigabeat-s/mc13783-imx31.c
@@ -24,6 +24,7 @@
#include "debug.h"
#include "kernel.h"
+#include "power-imx31.h"
#include "button-target.h"
/* This is all based on communicating with the MC13783 PMU which is on
@@ -64,11 +65,15 @@ static __attribute__((noreturn)) void mc13783_interrupt_thread(void)
gpio_enable_event(MC13783_GPIO_NUM, MC13783_EVENT_ID);
/* Check initial states */
+ value = mc13783_read(MC13783_INTERRUPT_SENSE0);
+ set_charger_inserted(value & MC13783_CHGDET);
+
value = mc13783_read(MC13783_INTERRUPT_SENSE1);
button_power_set_state((value & MC13783_ON1B) == 0);
set_headphones_inserted((value & MC13783_ON2B) == 0);
/* Enable desired PMIC interrupts */
+ mc13783_clear(MC13783_INTERRUPT_MASK0, MC13783_CHGDET);
mc13783_clear(MC13783_INTERRUPT_MASK1, MC13783_ON1B | MC13783_ON2B);
while (1)
@@ -78,12 +83,19 @@ static __attribute__((noreturn)) void mc13783_interrupt_thread(void)
mc13783_read_regset(status_regs, pending, 2);
mc13783_write_regset(status_regs, pending, 2);
-#if 0
+
if (pending[0])
{
/* Handle ...PENDING0 */
+ if (pending[0] & MC13783_CHGDET)
+ {
+ value = mc13783_read(MC13783_INTERRUPT_SENSE0);
+
+ if (pending[0] & MC13783_CHGDET)
+ set_charger_inserted(value & MC13783_CHGDET);
+ }
}
-#endif
+
if (pending[1])
{
diff --git a/firmware/target/arm/imx31/gigabeat-s/power-imx31.c b/firmware/target/arm/imx31/gigabeat-s/power-imx31.c
index f57c55a70b..e51318d16f 100644
--- a/firmware/target/arm/imx31/gigabeat-s/power-imx31.c
+++ b/firmware/target/arm/imx31/gigabeat-s/power-imx31.c
@@ -26,13 +26,21 @@
#ifndef SIMULATOR
+static bool charger_detect = false;
+
void power_init(void)
{
}
+/* This is called from the mc13783 interrupt thread */
+void set_charger_inserted(bool inserted)
+{
+ charger_detect = inserted;
+}
+
bool charger_inserted(void)
{
- return false;
+ return charger_detect;
}
/* Returns true if the unit is charging the batteries. */
diff --git a/firmware/target/arm/imx31/gigabeat-s/power-imx31.h b/firmware/target/arm/imx31/gigabeat-s/power-imx31.h
new file mode 100644
index 0000000000..f2f6ef8a73
--- /dev/null
+++ b/firmware/target/arm/imx31/gigabeat-s/power-imx31.h
@@ -0,0 +1,21 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id:$
+ *
+ * Copyright (C) 2008 by Nils Wallménius
+ *
+ * All files in this archive are subject to the GNU General Public License.
+ * See the file COPYING in the source tree root for full license agreement.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+void set_charger_inserted(bool inserted);
+