From b12c69bac7a02ea161ebc02ce7323e82bebe7b23 Mon Sep 17 00:00:00 2001 From: Michael Sevakis Date: Sun, 13 Apr 2008 20:03:08 +0000 Subject: ADC driver for Gigabeat S - a bit on the general side for now. Needs to have scales set properly (what physical value a reading represents isn't clear from the docs or I'm just lazy atm). Throw-in a _bunch_ more reg defines for the PMIC. Show all 16 raw channels values in debug menu. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17100 a1c6a512-1295-4272-9138-f99709370657 --- .../target/arm/imx31/gigabeat-s/mc13783-imx31.c | 40 +++++++++++++++------- 1 file changed, 28 insertions(+), 12 deletions(-) (limited to 'firmware/target/arm/imx31/gigabeat-s/mc13783-imx31.c') diff --git a/firmware/target/arm/imx31/gigabeat-s/mc13783-imx31.c b/firmware/target/arm/imx31/gigabeat-s/mc13783-imx31.c index fdb214a33d..d62df92ac5 100644 --- a/firmware/target/arm/imx31/gigabeat-s/mc13783-imx31.c +++ b/firmware/target/arm/imx31/gigabeat-s/mc13783-imx31.c @@ -26,6 +26,7 @@ #include "power-imx31.h" #include "button-target.h" +#include "adc-target.h" /* This is all based on communicating with the MC13783 PMU which is on * CSPI2 with the chip select at 0. The LCD controller resides on @@ -64,17 +65,21 @@ static __attribute__((noreturn)) void mc13783_interrupt_thread(void) gpio_enable_event(MC13783_GPIO_NUM, MC13783_EVENT_ID); - /* Check initial states */ + /* Check initial states for events with a sense bit */ 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); + button_power_set_state((value & MC13783_ONOFD1) == 0); + set_headphones_inserted((value & MC13783_ONOFD2) == 0); - /* Enable desired PMIC interrupts */ + pending[0] = pending[1] = 0xffffff; + mc13783_write_regset(status_regs, pending, 2); + + /* Enable desired PMIC interrupts - some are unmasked in the drivers that + * handle a specific task */ mc13783_clear(MC13783_INTERRUPT_MASK0, MC13783_CHGDET); - mc13783_clear(MC13783_INTERRUPT_MASK1, MC13783_ON1B | MC13783_ON2B); + mc13783_clear(MC13783_INTERRUPT_MASK1, MC13783_ONOFD1 | MC13783_ONOFD2); while (1) { @@ -83,10 +88,16 @@ static __attribute__((noreturn)) void mc13783_interrupt_thread(void) mc13783_read_regset(status_regs, pending, 2); mc13783_write_regset(status_regs, pending, 2); - if (pending[0]) { /* Handle ...PENDING0 */ + + /* Handle interrupts without a sense bit */ + if (pending[0] & MC13783_ADCDONE) + adc_done(); + + /* Handle interrupts that have a sense bit that needs to + * be checked */ if (pending[0] & MC13783_CHGDET) { value = mc13783_read(MC13783_INTERRUPT_SENSE0); @@ -96,19 +107,24 @@ static __attribute__((noreturn)) void mc13783_interrupt_thread(void) } } - if (pending[1]) { /* Handle ...PENDING1 */ - if (pending[1] & (MC13783_ON1B | MC13783_ON2B)) + + /* Handle interrupts without a sense bit */ + /* ... */ + + /* Handle interrupts that have a sense bit that needs to + * be checked */ + if (pending[1] & (MC13783_ONOFD1 | MC13783_ONOFD2)) { value = mc13783_read(MC13783_INTERRUPT_SENSE1); - if (pending[1] & MC13783_ON1B) - button_power_set_state((value & MC13783_ON1B) == 0); + if (pending[1] & MC13783_ONOFD1) + button_power_set_state((value & MC13783_ONOFD1) == 0); - if (pending[1] & MC13783_ON2B) - set_headphones_inserted((value & MC13783_ON2B) == 0); + if (pending[1] & MC13783_ONOFD2) + set_headphones_inserted((value & MC13783_ONOFD2) == 0); } } } -- cgit v1.2.3