aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/power/ab8500_charger.c
diff options
context:
space:
mode:
authorPaer-Olof Haakansson <par-olof.hakansson@stericsson.com>2013-01-11 08:12:49 -0500
committerAnton Vorontsov <anton@enomsg.org>2013-01-15 20:10:16 -0500
commitdefbfa9cf879c8e7dde6f7ee9aa95a010efa2e34 (patch)
treee0eba16415ae15256e5917c42510a6048fef34be /drivers/power/ab8500_charger.c
parentc4f3422630464d231c14c8b9e585c23fcfe3436c (diff)
ab8500_charger: Rename the power_loss function
Rename the ab8500_power_loss_handling function to a more descriptive name ab8500_enable_disable_sw_fallback Signed-off-by: Lee Jones <lee.jones@linaro.org> Signed-off-by: Robert Marklund <robert.marklund@stericsson.com> Reviewed-by: Par-Olof HAKANSSON <par-olof.hakansson@stericsson.com> Reviewed-by: Karl KOMIEROWSKI <karl.komierowski@stericsson.com> Tested-by: Par-Olof HAKANSSON <par-olof.hakansson@stericsson.com> Signed-off-by: Anton Vorontsov <anton@enomsg.org>
Diffstat (limited to 'drivers/power/ab8500_charger.c')
-rw-r--r--drivers/power/ab8500_charger.c23
1 files changed, 11 insertions, 12 deletions
diff --git a/drivers/power/ab8500_charger.c b/drivers/power/ab8500_charger.c
index c342f79cb588..a941e6a66996 100644
--- a/drivers/power/ab8500_charger.c
+++ b/drivers/power/ab8500_charger.c
@@ -270,20 +270,19 @@ static enum power_supply_property ab8500_charger_usb_props[] = {
270 POWER_SUPPLY_PROP_CURRENT_NOW, 270 POWER_SUPPLY_PROP_CURRENT_NOW,
271}; 271};
272 272
273/** 273/*
274 * ab8500_power_loss_handling - set how we handle powerloss. 274 * Function for enabling and disabling sw fallback mode
275 * @di: pointer to the ab8500_charger structure 275 * should always be disabled when no charger is connected.
276 *
277 * Magic nummbers are from STE HW department.
278 */ 276 */
279static void ab8500_power_loss_handling(struct ab8500_charger *di) 277static void ab8500_enable_disable_sw_fallback(struct ab8500_charger *di,
278 bool fallback)
280{ 279{
281 u8 reg; 280 u8 reg;
282 int ret; 281 int ret;
283 282
284 dev_dbg(di->dev, "Autopower : %d\n", di->autopower); 283 dev_dbg(di->dev, "SW Fallback: %d\n", fallback);
285 284
286 /* read the autopower register */ 285 /* read the register containing fallback bit */
287 ret = abx500_get_register_interruptible(di->dev, 0x15, 0x00, &reg); 286 ret = abx500_get_register_interruptible(di->dev, 0x15, 0x00, &reg);
288 if (ret) { 287 if (ret) {
289 dev_err(di->dev, "%d write failed\n", __LINE__); 288 dev_err(di->dev, "%d write failed\n", __LINE__);
@@ -297,12 +296,12 @@ static void ab8500_power_loss_handling(struct ab8500_charger *di)
297 return; 296 return;
298 } 297 }
299 298
300 if (di->autopower) 299 if (fallback)
301 reg |= 0x8; 300 reg |= 0x8;
302 else 301 else
303 reg &= ~0x8; 302 reg &= ~0x8;
304 303
305 /* write back the changed value to autopower reg */ 304 /* write back the changed fallback bit value to register */
306 ret = abx500_set_register_interruptible(di->dev, 0x15, 0x00, reg); 305 ret = abx500_set_register_interruptible(di->dev, 0x15, 0x00, reg);
307 if (ret) { 306 if (ret) {
308 dev_err(di->dev, "%d write failed\n", __LINE__); 307 dev_err(di->dev, "%d write failed\n", __LINE__);
@@ -332,12 +331,12 @@ static void ab8500_power_supply_changed(struct ab8500_charger *di,
332 !di->ac.charger_connected && 331 !di->ac.charger_connected &&
333 di->autopower) { 332 di->autopower) {
334 di->autopower = false; 333 di->autopower = false;
335 ab8500_power_loss_handling(di); 334 ab8500_enable_disable_sw_fallback(di, false);
336 } else if (!di->autopower && 335 } else if (!di->autopower &&
337 (di->ac.charger_connected || 336 (di->ac.charger_connected ||
338 di->usb.charger_connected)) { 337 di->usb.charger_connected)) {
339 di->autopower = true; 338 di->autopower = true;
340 ab8500_power_loss_handling(di); 339 ab8500_enable_disable_sw_fallback(di, true);
341 } 340 }
342 } 341 }
343 power_supply_changed(psy); 342 power_supply_changed(psy);