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/powermgmt-ascodec.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) (limited to 'firmware/target/arm/powermgmt-ascodec.c') diff --git a/firmware/target/arm/powermgmt-ascodec.c b/firmware/target/arm/powermgmt-ascodec.c index b463486346..e50367fe93 100644 --- a/firmware/target/arm/powermgmt-ascodec.c +++ b/firmware/target/arm/powermgmt-ascodec.c @@ -94,9 +94,7 @@ static void battery_voltage_sync(void) /* Disable charger and minimize all settings. Reset timers, etc. */ static void disable_charger(void) { - ascodec_disable_endofch_irq(); - ascodec_write(AS3514_CHARGER, - TMPSUP_OFF | CHG_I_50MA | CHG_V_3_90V | CHG_OFF); + ascodec_write_charger(TMPSUP_OFF | CHG_I_50MA | CHG_V_3_90V | CHG_OFF); if (charge_state > DISCHARGING) charge_state = DISCHARGING; /* Not an error state already */ @@ -108,14 +106,13 @@ static void disable_charger(void) /* Enable charger with specified settings. Start timers, etc. */ static void enable_charger(void) { - ascodec_write(AS3514_CHARGER, BATT_CHG_I | BATT_CHG_V); - /* Watch for end of charge. Temperature supervision is handled in - * hardware. Charger status can be read and has no interrupt enable. */ - ascodec_enable_endofch_irq(); + ascodec_write_charger(BATT_CHG_I | BATT_CHG_V); sleep(HZ/10); /* Allow charger turn-on time (it could be gradual). */ - ascodec_disable_endofch_irq(); + /* acknowledge first end of charging interrupt, it seems to happen both + * at charger plug and charger unplug */ + ascodec_endofch(); charge_state = CHARGING; charger_total_timer = CHARGER_TOTAL_TIMER; @@ -125,9 +122,8 @@ static void enable_charger(void) void powermgmt_init_target(void) { /* Everything CHARGER, OFF! */ - ascodec_disable_endofch_irq(); - ascodec_write(AS3514_CHARGER, - TMPSUP_OFF | CHG_I_50MA | CHG_V_3_90V | CHG_OFF); + ascodec_monitor_endofch(); + ascodec_write_charger(TMPSUP_OFF | CHG_I_50MA | CHG_V_3_90V | CHG_OFF); } static inline void charger_plugged(void) @@ -148,7 +144,7 @@ static inline void charger_control(void) if (BATT_FULL_VOLTAGE == thresh) { /* Wait for CHG_status to be indicated. */ - if ((ascodec_read(AS3514_IRQ_ENRD0) & CHG_STATUS) == 0) + if (!ascodec_chg_status()) break; batt_threshold = BATT_VAUTO_RECHARGE; @@ -163,7 +159,7 @@ static inline void charger_control(void) case CHARGING: { - if ((ascodec_read(AS3514_IRQ_ENRD0) & CHG_ENDOFCH) == 0) + if (!ascodec_endofch()) { if (--charger_total_timer > 0) break; -- cgit v1.2.3