diff options
Diffstat (limited to 'common/pmu_tps65090.c')
-rw-r--r-- | common/pmu_tps65090.c | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/common/pmu_tps65090.c b/common/pmu_tps65090.c index 1d121b6a4e..b0391d42d5 100644 --- a/common/pmu_tps65090.c +++ b/common/pmu_tps65090.c @@ -6,6 +6,7 @@ */ #include "board.h" +#include "clock.h" #include "console.h" #include "common.h" #include "hooks.h" @@ -45,8 +46,11 @@ #define CG_NOITERM (1 << 5) /* IRQ events */ -#define EVENT_VACG (1 << 1) -#define EVENT_VBATG (1 << 3) +#define EVENT_VACG (1 << 1) /* AC voltage good */ +#define EVENT_VSYSG (1 << 2) /* System voltage good */ +#define EVENT_VBATG (1 << 3) /* Battery voltage good */ +#define EVENT_CGACT (1 << 4) /* Charging status */ +#define EVENT_CGCPL (1 << 5) /* Charging complete */ /* Charger alarm */ #define CHARGER_ALARM 3 @@ -219,9 +223,9 @@ int pmu_low_current_charging(int enable) void pmu_irq_handler(enum gpio_signal signal) { - CPRINTF("Charger IRQ received.\n"); gpio_set_level(GPIO_AC_STATUS, pmu_get_ac()); task_wake(TASK_ID_PMU_TPS65090_CHARGER); + CPRINTF("Charger IRQ received.\n"); } int pmu_get_ac(void) @@ -265,9 +269,18 @@ void pmu_init(void) pmu_write(CG_CTRL3, 0xbb); #endif /* Enable interrupts */ + pmu_write(IRQ1MASK, + EVENT_VACG | /* AC voltage good */ + EVENT_VSYSG | /* System voltage good */ + EVENT_VBATG | /* Battery voltage good */ + EVENT_CGACT | /* Charging status */ + EVENT_CGCPL); /* Charging complete */ + pmu_write(IRQ2MASK, 0); pmu_clear_irq(); - pmu_write(IRQ1MASK, 0xff); - pmu_write(IRQ2MASK, 0xff); + + /* Enable charger interrupt. */ + gpio_enable_interrupt(GPIO_CHARGER_INT); + } /* Initializes PMU when power is turned on. This is necessary because the TPS' @@ -304,6 +317,7 @@ static int command_pmu(int argc, char **argv) int repeat = 1; int rv = 0; int loop; + int value; char *e; if (argc > 1) { @@ -319,6 +333,12 @@ static int command_pmu(int argc, char **argv) usleep(1000); } + rv = pmu_read(IRQ1_REG, &value); + if (rv) + return rv; + CPRINTF("pmu events b%08b\n", value); + CPRINTF("ac gpio %d\n", pmu_get_ac()); + if (rv) ccprintf("Failed - error %d\n", rv); |