diff options
author | Laxman Dewangan <ldewangan@nvidia.com> | 2012-02-24 11:51:34 +0530 |
---|---|---|
committer | Simone Willett <swillett@nvidia.com> | 2012-02-28 20:43:52 -0800 |
commit | fed567e6f3f446c30d824dc7acfa4dde17e8ddc4 (patch) | |
tree | 57838b27968f001ee2adb70e3ea40f666d447df5 /drivers/power | |
parent | 96006ccd516e23262a5de607d43f9e0061422887 (diff) |
power: tps80031: charger: Fix the charging current bits calculation
Calculation of register bits from charging current is not correct.
Fixing the calculation using lookup table.
Change-Id: I76f7612288eafd96e00ea73674556b7609d09248
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Reviewed-on: http://git-master/r/85680
Reviewed-by: Syed Rafiuddin <srafiuddin@nvidia.com>
Tested-by: Syed Rafiuddin <srafiuddin@nvidia.com>
Diffstat (limited to 'drivers/power')
-rw-r--r-- | drivers/power/tps80031-charger.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/drivers/power/tps80031-charger.c b/drivers/power/tps80031-charger.c index 3da8eef2e01e..93b283e0b04f 100644 --- a/drivers/power/tps80031-charger.c +++ b/drivers/power/tps80031-charger.c @@ -65,6 +65,11 @@ struct tps80031_charger { }; static struct tps80031_charger *charger_data; +static uint8_t charging_current_val_code[] = { + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xA, 0xB, 0xC, 0xD, 0xE, 0x27, + 0x37, 0x28, 0x38, 0x29, 0x39, 0x2A, 0x3A, 0x2B, 0x3B, 0x2C, + 0x3C, 0x2D, 0x3D, 0x2E, +}; static int set_charge_current_limit(struct regulator_dev *rdev, int min_uA, int max_uA) @@ -101,8 +106,8 @@ static int set_charge_current_limit(struct regulator_dev *rdev, if (max_vbus_current) max_vbus_current--; ret = tps80031_update(charger->dev->parent, SLAVE_ID2, - CHARGERUSB_CINLIMIT, - (uint8_t)max_vbus_current, 0x3F); + CHARGERUSB_CINLIMIT, + charging_current_val_code[max_vbus_current], 0x3F); if (ret < 0) { dev_err(charger->dev, "%s(): Failed in writing register 0x%02x\n", __func__, CHARGERUSB_CINLIMIT); |