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/ascodec-target.h | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'firmware/target/arm/ascodec-target.h') diff --git a/firmware/target/arm/ascodec-target.h b/firmware/target/arm/ascodec-target.h index c87d869ebb..68d9905a6b 100644 --- a/firmware/target/arm/ascodec-target.h +++ b/firmware/target/arm/ascodec-target.h @@ -59,14 +59,19 @@ static inline void ascodec_unlock(void) i2c_unlock(); } -static inline void ascodec_enable_endofch_irq(void) +static inline bool ascodec_chg_status(void) { - ascodec_write(AS3514_IRQ_ENRD0, IRQ_ENDOFCH); + return ascodec_read(AS3514_IRQ_ENRD0) & CHG_STATUS; +} + +static inline bool ascodec_endofch(void) +{ + return ascodec_read(AS3514_IRQ_ENRD0) & CHG_ENDOFCH; } -static inline void ascodec_disable_endofch_irq(void) +static inline void ascodec_monitor_endofch(void) { - ascodec_write(AS3514_IRQ_ENRD0, 0); + ascodec_write(AS3514_IRQ_ENRD0, IRQ_ENDOFCH); } static inline void ascodec_wait_adc_finished(void) @@ -81,6 +86,16 @@ static inline void ascodec_wait_adc_finished(void) */ } +static inline void ascodec_write_charger(int value) +{ + ascodec_write(AS3514_CHARGER, value); +} + +static inline int ascodec_read_charger(void) +{ + return ascodec_read(AS3514_CHARGER); +} + extern void ascodec_suppressor_on(bool on); #endif /* CPU_PP */ -- cgit v1.2.3