diff options
author | Allen Yu <alleny@nvidia.com> | 2012-08-08 14:50:40 +0800 |
---|---|---|
committer | Varun Wadekar <vwadekar@nvidia.com> | 2012-08-16 16:25:53 +0530 |
commit | 59a585544837da7b628ae5d0fa96ddce7db135d6 (patch) | |
tree | eda099aa14c9e098c4dd4886d620b29c32c8abbc /drivers/power | |
parent | cce631097ae30c5f69defda29a60335856b7f89e (diff) |
power: smb349: correct charger status
When tegra-otg suspends with charger cable connected, the charger
state and type should not be changed, neither should the charger
callback be executed.
SMB349 has a debounce delay of ~20ms +/- 3 after cable is unpluged
and will stop all I2C functions for 2.3ms when getting reset to POR.
Add 50ms' delay before reading charger status to avoid I2C error and
make sure we get the right charger state.
Bug 1024735
Change-Id: I1667b23df768b46b524c6578c4bee09e131d9f96
Signed-off-by: Allen Yu <alleny@nvidia.com>
Reviewed-on: http://git-master/r/120905
Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>
GVS: Gerrit_Virtual_Submit
Diffstat (limited to 'drivers/power')
-rw-r--r-- | drivers/power/smb349-charger.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/drivers/power/smb349-charger.c b/drivers/power/smb349-charger.c index 713f32ae7568..080d1ac72aba 100644 --- a/drivers/power/smb349-charger.c +++ b/drivers/power/smb349-charger.c @@ -406,6 +406,19 @@ static int smb349_enable_charging(struct regulator_dev *rdev, int ret; if (!max_uA) { + /* Wait for SMB349 to debounce and get reset to POR when cable is unpluged */ + msleep(50); + + ret = smb349_read(client, SMB349_STS_REG_C); + if (ret < 0) { + dev_err(&client->dev, "%s(): Failed in reading register" + "0x%02x\n", __func__, SMB349_STS_REG_C); + return ret; + } + + if (ret & CHARGING) + return 0; + charger->state = stopped; charger->chrg_type = NONE; } else { |