diff options
author | Pali Rohár <pali.rohar@gmail.com> | 2010-05-24 14:52:13 -0400 |
---|---|---|
committer | Lars-Peter Clausen <lars@metafoo.de> | 2011-02-22 05:02:39 -0500 |
commit | a2e5118c370e78c3841606e7edc7677c986325fa (patch) | |
tree | d733f4420cdca08ff36f417e91e8efb233f51fca /drivers | |
parent | 0e9f30497e88600ba52013665270f543bb94f0d8 (diff) |
bq27x00: Fix CURRENT_NOW property
According to the bq27000 datasheet the current should be calculated by
the following formula:
current = AI * 3570 / 20
This patch adjust the drivers code accordingly.
Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Acked-by: Rodolfo Giometti <giometti@linux.it>
Tested-by: Grazvydas Ignotas <notasas@gmail.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/power/bq27x00_battery.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/drivers/power/bq27x00_battery.c b/drivers/power/bq27x00_battery.c index 4f7465999c86..1b06134e0ae8 100644 --- a/drivers/power/bq27x00_battery.c +++ b/drivers/power/bq27x00_battery.c | |||
@@ -44,6 +44,8 @@ | |||
44 | #define BQ27500_FLAG_DSC BIT(0) | 44 | #define BQ27500_FLAG_DSC BIT(0) |
45 | #define BQ27500_FLAG_FC BIT(9) | 45 | #define BQ27500_FLAG_FC BIT(9) |
46 | 46 | ||
47 | #define BQ27000_RS 20 /* Resistor sense */ | ||
48 | |||
47 | /* If the system has several batteries we need a different name for each | 49 | /* If the system has several batteries we need a different name for each |
48 | * of them... | 50 | * of them... |
49 | */ | 51 | */ |
@@ -149,7 +151,7 @@ static int bq27x00_battery_current(struct bq27x00_device_info *di) | |||
149 | 151 | ||
150 | if (di->chip == BQ27500) { | 152 | if (di->chip == BQ27500) { |
151 | /* bq27500 returns signed value */ | 153 | /* bq27500 returns signed value */ |
152 | curr = (int)(s16)curr; | 154 | curr = (int)((s16)curr) * 1000; |
153 | } else { | 155 | } else { |
154 | ret = bq27x00_read(BQ27x00_REG_FLAGS, &flags, 0, di); | 156 | ret = bq27x00_read(BQ27x00_REG_FLAGS, &flags, 0, di); |
155 | if (ret < 0) { | 157 | if (ret < 0) { |
@@ -160,9 +162,10 @@ static int bq27x00_battery_current(struct bq27x00_device_info *di) | |||
160 | dev_dbg(di->dev, "negative current!\n"); | 162 | dev_dbg(di->dev, "negative current!\n"); |
161 | curr = -curr; | 163 | curr = -curr; |
162 | } | 164 | } |
165 | curr = curr * 3570 / BQ27000_RS; | ||
163 | } | 166 | } |
164 | 167 | ||
165 | return curr * 1000; | 168 | return curr; |
166 | } | 169 | } |
167 | 170 | ||
168 | /* | 171 | /* |