diff options
author | Rafaël Carré <rafael.carre@gmail.com> | 2010-05-17 20:53:25 +0000 |
---|---|---|
committer | Rafaël Carré <rafael.carre@gmail.com> | 2010-05-17 20:53:25 +0000 |
commit | 88c55d7290b7c360075557c40fdf65ceeeaf0c4b (patch) | |
tree | 29cf685626bf8c01bb64ed9456850f62e4a57d7d /firmware/target/arm/powermgmt-ascodec.c | |
parent | 2ed7745ddefc084ca7030d48b251882e94fa2f9c (diff) | |
download | rockbox-88c55d7290b7c360075557c40fdf65ceeeaf0c4b.tar.gz rockbox-88c55d7290b7c360075557c40fdf65ceeeaf0c4b.zip |
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
Diffstat (limited to 'firmware/target/arm/powermgmt-ascodec.c')
-rw-r--r-- | firmware/target/arm/powermgmt-ascodec.c | 22 |
1 files changed, 9 insertions, 13 deletions
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) | |||
94 | /* Disable charger and minimize all settings. Reset timers, etc. */ | 94 | /* Disable charger and minimize all settings. Reset timers, etc. */ |
95 | static void disable_charger(void) | 95 | static void disable_charger(void) |
96 | { | 96 | { |
97 | ascodec_disable_endofch_irq(); | 97 | ascodec_write_charger(TMPSUP_OFF | CHG_I_50MA | CHG_V_3_90V | CHG_OFF); |
98 | ascodec_write(AS3514_CHARGER, | ||
99 | TMPSUP_OFF | CHG_I_50MA | CHG_V_3_90V | CHG_OFF); | ||
100 | 98 | ||
101 | if (charge_state > DISCHARGING) | 99 | if (charge_state > DISCHARGING) |
102 | charge_state = DISCHARGING; /* Not an error state already */ | 100 | charge_state = DISCHARGING; /* Not an error state already */ |
@@ -108,14 +106,13 @@ static void disable_charger(void) | |||
108 | /* Enable charger with specified settings. Start timers, etc. */ | 106 | /* Enable charger with specified settings. Start timers, etc. */ |
109 | static void enable_charger(void) | 107 | static void enable_charger(void) |
110 | { | 108 | { |
111 | ascodec_write(AS3514_CHARGER, BATT_CHG_I | BATT_CHG_V); | 109 | ascodec_write_charger(BATT_CHG_I | BATT_CHG_V); |
112 | /* Watch for end of charge. Temperature supervision is handled in | ||
113 | * hardware. Charger status can be read and has no interrupt enable. */ | ||
114 | ascodec_enable_endofch_irq(); | ||
115 | 110 | ||
116 | sleep(HZ/10); /* Allow charger turn-on time (it could be gradual). */ | 111 | sleep(HZ/10); /* Allow charger turn-on time (it could be gradual). */ |
117 | 112 | ||
118 | ascodec_disable_endofch_irq(); | 113 | /* acknowledge first end of charging interrupt, it seems to happen both |
114 | * at charger plug and charger unplug */ | ||
115 | ascodec_endofch(); | ||
119 | 116 | ||
120 | charge_state = CHARGING; | 117 | charge_state = CHARGING; |
121 | charger_total_timer = CHARGER_TOTAL_TIMER; | 118 | charger_total_timer = CHARGER_TOTAL_TIMER; |
@@ -125,9 +122,8 @@ static void enable_charger(void) | |||
125 | void powermgmt_init_target(void) | 122 | void powermgmt_init_target(void) |
126 | { | 123 | { |
127 | /* Everything CHARGER, OFF! */ | 124 | /* Everything CHARGER, OFF! */ |
128 | ascodec_disable_endofch_irq(); | 125 | ascodec_monitor_endofch(); |
129 | ascodec_write(AS3514_CHARGER, | 126 | ascodec_write_charger(TMPSUP_OFF | CHG_I_50MA | CHG_V_3_90V | CHG_OFF); |
130 | TMPSUP_OFF | CHG_I_50MA | CHG_V_3_90V | CHG_OFF); | ||
131 | } | 127 | } |
132 | 128 | ||
133 | static inline void charger_plugged(void) | 129 | static inline void charger_plugged(void) |
@@ -148,7 +144,7 @@ static inline void charger_control(void) | |||
148 | if (BATT_FULL_VOLTAGE == thresh) | 144 | if (BATT_FULL_VOLTAGE == thresh) |
149 | { | 145 | { |
150 | /* Wait for CHG_status to be indicated. */ | 146 | /* Wait for CHG_status to be indicated. */ |
151 | if ((ascodec_read(AS3514_IRQ_ENRD0) & CHG_STATUS) == 0) | 147 | if (!ascodec_chg_status()) |
152 | break; | 148 | break; |
153 | 149 | ||
154 | batt_threshold = BATT_VAUTO_RECHARGE; | 150 | batt_threshold = BATT_VAUTO_RECHARGE; |
@@ -163,7 +159,7 @@ static inline void charger_control(void) | |||
163 | 159 | ||
164 | case CHARGING: | 160 | case CHARGING: |
165 | { | 161 | { |
166 | if ((ascodec_read(AS3514_IRQ_ENRD0) & CHG_ENDOFCH) == 0) | 162 | if (!ascodec_endofch()) |
167 | { | 163 | { |
168 | if (--charger_total_timer > 0) | 164 | if (--charger_total_timer > 0) |
169 | break; | 165 | break; |