diff options
author | Syed Rafiuddin <srafiuddin@nvidia.com> | 2012-06-07 11:42:28 +0530 |
---|---|---|
committer | Rohan Somvanshi <rsomvanshi@nvidia.com> | 2012-06-13 01:41:42 -0700 |
commit | 6a42ac50db6ff2832ff616f586fe7217b885df14 (patch) | |
tree | 69d2a6baac6f653562a837afb39057d2958ed964 /drivers/power | |
parent | ff5d25f4a5847c664a123ca02ad981df699d50b6 (diff) |
power: smb349: fix I2C error when unplug ext power
When unplug the external power, SMB349 will reload the OTP setting.
It sometimes caused I2c errors. See bug 996103 and 991401.
Add a 50ms delay when hotplugging the external power to fix the
issue.
SMB349 might mistakenly detect dedicated USB charger as standard
USB device if plug in the USB at low speed. See Bug 996108.
Add a 500ms delay to fix the issue.
Bug 996103
Bug 996108
Bug 991401
Change-Id: I008a45fa221e9a566af64afb1988bbbd7a9f5c79
Signed-off-by: Chandler Zhang <chazhang@nvidia.com>
Signed-off-by: Syed Rafiuddin <srafiuddin@nvidia.com>
Reviewed-on: http://git-master/r/106684
Reviewed-by: Rohan Somvanshi <rsomvanshi@nvidia.com>
Tested-by: Rohan Somvanshi <rsomvanshi@nvidia.com>
Diffstat (limited to 'drivers/power')
-rw-r--r-- | drivers/power/smb349-charger.c | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/drivers/power/smb349-charger.c b/drivers/power/smb349-charger.c index 59ee98418354..118a409c505e 100644 --- a/drivers/power/smb349-charger.c +++ b/drivers/power/smb349-charger.c @@ -392,16 +392,28 @@ static int smb349_enable_charging(struct regulator_dev *rdev, int ret; if (!max_uA) { - charger->state = stopped; - /* Disable charger */ - ret = smb349_configure_charger(client, 0); + /* Wait for SMB349 to reload OTP*/ + msleep(50); + ret = smb349_read(client, SMB349_STS_REG_D); if (ret < 0) { - dev_err(&client->dev, "%s() error in configuring" - "charger..\n", __func__); - return ret; + dev_err(&client->dev, "%s(): Failed in reading register" + "0x%02x\n", __func__, SMB349_STS_REG_D); + } else if (ret == 0) { + + charger->state = stopped; + /* Disable charger */ + ret = smb349_configure_charger(client, 0); + if (ret < 0) { + dev_err(&client->dev, "%s() error in configuring" + "charger..\n", __func__); + return ret; + } + charger->chrg_type = NONE; } - charger->chrg_type = NONE; } else { + /* Wait for SMB349 to reload OTP setting and detect type*/ + msleep(500); + ret = smb349_read(client, SMB349_STS_REG_D); if (ret < 0) { dev_err(&client->dev, "%s(): Failed in reading register" |