Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 350610
b: refs/heads/master
c: defbfa9
h: refs/heads/master
v: v3
  • Loading branch information
Paer-Olof Haakansson authored and Anton Vorontsov committed Jan 16, 2013
1 parent a44696c commit a9888c2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: c4f3422630464d231c14c8b9e585c23fcfe3436c
refs/heads/master: defbfa9cf879c8e7dde6f7ee9aa95a010efa2e34
23 changes: 11 additions & 12 deletions trunk/drivers/power/ab8500_charger.c
Original file line number Diff line number Diff line change
Expand Up @@ -270,20 +270,19 @@ static enum power_supply_property ab8500_charger_usb_props[] = {
POWER_SUPPLY_PROP_CURRENT_NOW,
};

/**
* ab8500_power_loss_handling - set how we handle powerloss.
* @di: pointer to the ab8500_charger structure
*
* Magic nummbers are from STE HW department.
/*
* Function for enabling and disabling sw fallback mode
* should always be disabled when no charger is connected.
*/
static void ab8500_power_loss_handling(struct ab8500_charger *di)
static void ab8500_enable_disable_sw_fallback(struct ab8500_charger *di,
bool fallback)
{
u8 reg;
int ret;

dev_dbg(di->dev, "Autopower : %d\n", di->autopower);
dev_dbg(di->dev, "SW Fallback: %d\n", fallback);

/* read the autopower register */
/* read the register containing fallback bit */
ret = abx500_get_register_interruptible(di->dev, 0x15, 0x00, &reg);
if (ret) {
dev_err(di->dev, "%d write failed\n", __LINE__);
Expand All @@ -297,12 +296,12 @@ static void ab8500_power_loss_handling(struct ab8500_charger *di)
return;
}

if (di->autopower)
if (fallback)
reg |= 0x8;
else
reg &= ~0x8;

/* write back the changed value to autopower reg */
/* write back the changed fallback bit value to register */
ret = abx500_set_register_interruptible(di->dev, 0x15, 0x00, reg);
if (ret) {
dev_err(di->dev, "%d write failed\n", __LINE__);
Expand Down Expand Up @@ -332,12 +331,12 @@ static void ab8500_power_supply_changed(struct ab8500_charger *di,
!di->ac.charger_connected &&
di->autopower) {
di->autopower = false;
ab8500_power_loss_handling(di);
ab8500_enable_disable_sw_fallback(di, false);
} else if (!di->autopower &&
(di->ac.charger_connected ||
di->usb.charger_connected)) {
di->autopower = true;
ab8500_power_loss_handling(di);
ab8500_enable_disable_sw_fallback(di, true);
}
}
power_supply_changed(psy);
Expand Down

0 comments on commit a9888c2

Please sign in to comment.