rendered paste bodyIndex: firmware/export/mc13783.h
===================================================================
--- firmware/export/mc13783.h (revision 17091)
+++ firmware/export/mc13783.h (arbetskopia)
@@ -88,6 +88,9 @@
MC13783_NUM_REGS,
};
+/* INTERRUPT_STATUS0, INTERRUPT_MASK0, INTERRUPT_SENSE0 */
+#define MC13783_CHGDET (1 << 6)
+
/* INTERRUPT_STATUS1, INTERRUPT_MASK1, INTERRUPT_SENSE1 */
#define MC13783_HSL (1 << 0)
#define MC13783_ON1B (1 << 3)
Index: firmware/target/arm/imx31/gigabeat-s/mc13783-imx31.c
===================================================================
--- firmware/target/arm/imx31/gigabeat-s/mc13783-imx31.c (revision 17091)
+++ firmware/target/arm/imx31/gigabeat-s/mc13783-imx31.c (arbetskopia)
@@ -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 @@
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,13 +83,20 @@
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])
{
/* Handle ...PENDING1 */
Index: firmware/target/arm/imx31/gigabeat-s/power-imx31.c
===================================================================
--- firmware/target/arm/imx31/gigabeat-s/power-imx31.c (revision 17091)
+++ firmware/target/arm/imx31/gigabeat-s/power-imx31.c (arbetskopia)
@@ -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. */