From 88c55d7290b7c360075557c40fdf65ceeeaf0c4b Mon Sep 17 00:00:00 2001 From: Rafaël Carré Date: Mon, 17 May 2010 20:53:25 +0000 Subject: as3514/as3543 fixes - Enable end of charge monitoring once, it doesn't need to be disabled - Acknowledge the first (wrong) end of charge interrupt on charger enable (this had been broken in r25299) - Centralize reads to ENRD* registers and cache the results when needed - on PP it is not needed because reads are atomic, we only check for end of charge when the charging, and for charger presence when discharging as3525v2 (using as3543) specifics - I got the datasheet today from AMS, thanks to them for being so fast and not require me to sign tons of papers! - USB detection now works on as3525v2 using the as3543. Clip+ won't reboot to OF yet, it needs mkamsboot support first (usbstack disabled) - Charging should work, the CHARGER register is at a different place, it is an extended PMU register -> use ascodec_read/write_charger() to access it - real interrupts are not used yet for ENRD, we get thousands of interrupts per second, apparently only limited by the i2c clock. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26116 a1c6a512-1295-4272-9138-f99709370657 --- firmware/target/arm/as3525/ascodec-target.h | 66 ++++++++++++++++++++--------- 1 file changed, 45 insertions(+), 21 deletions(-) (limited to 'firmware/target/arm/as3525/ascodec-target.h') diff --git a/firmware/target/arm/as3525/ascodec-target.h b/firmware/target/arm/as3525/ascodec-target.h index 37947541c2..8ce9a428d3 100644 --- a/firmware/target/arm/as3525/ascodec-target.h +++ b/firmware/target/arm/as3525/ascodec-target.h @@ -52,7 +52,7 @@ /* * How many bytes we using in struct ascodec_request for the data buffer. * 4 fits the alignment best right now. - * We don't actually use more than 2 at the moment (in adc_read). + * We don't actually use more than 3 at the moment (when reading interrupts) * Upper limit would be 255 since DACNT is 8 bits! */ #define ASCODEC_REQ_MAXLEN 4 @@ -74,19 +74,6 @@ void ascodec_init(void); int ascodec_write(unsigned int index, unsigned int value); -#if CONFIG_CPU == AS3525v2 -static inline void ascodec_write_pmu(unsigned int index, unsigned int subreg, - unsigned int value) -{ - /* we disable interrupts to make sure no operation happen on the i2c bus - * between selecting the sub register and writing to it */ - int oldstatus = disable_irq_save(); - ascodec_write(AS3543_PMU_ENABLE, 8|subreg); - ascodec_write(index, value); - restore_irq(oldstatus); -} -#endif - int ascodec_read(unsigned int index); int ascodec_readbytes(unsigned int index, unsigned int len, unsigned char *data); @@ -119,18 +106,55 @@ void ascodec_lock(void); void ascodec_unlock(void); -#if CONFIG_CPU == AS3525 void ascodec_wait_adc_finished(void); -#else -static inline void ascodec_wait_adc_finished(void) + +static inline void ascodec_monitor_endofch(void) {} /* already enabled */ + +bool ascodec_endofch(void); + +bool ascodec_chg_status(void); + +#if CONFIG_CPU == AS3525v2 +static inline void ascodec_write_pmu(unsigned int index, unsigned int subreg, + unsigned int value) +{ + /* we disable interrupts to make sure no operation happen on the i2c bus + * between selecting the sub register and writing to it */ + int oldstatus = disable_irq_save(); + ascodec_write(AS3543_PMU_ENABLE, 8|subreg); + ascodec_write(index, value); + restore_irq(oldstatus); +} + +static inline int ascodec_read_pmu(unsigned int index, unsigned int subreg) { - /* FIXME: Doesn't work yet on AS3525v2 */ + /* we disable interrupts to make sure no operation happen on the i2c bus + * between selecting the sub register and reading it */ + int oldstatus = disable_irq_save(); + ascodec_write(AS3543_PMU_ENABLE, 8|subreg); + int ret = ascodec_read(index); + restore_irq(oldstatus); + return ret; } -#endif +#endif /* CONFIG_CPU == AS3525v2 */ -void ascodec_enable_endofch_irq(void); +static inline void ascodec_write_charger(int value) +{ +#if CONFIG_CPU == AS3525 + ascodec_write(AS3514_CHARGER, value); +#else + ascodec_write_pmu(AS3543_CHARGER, 1, value); +#endif +} -void ascodec_disable_endofch_irq(void); +static inline int ascodec_read_charger(void) +{ +#if CONFIG_CPU == AS3525 + return ascodec_read(AS3514_CHARGER); +#else + return ascodec_read_pmu(AS3543_CHARGER, 1); +#endif +} #endif /* !SIMULATOR */ -- cgit v1.2.3