diff options
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; |