1
0
Fork 0

power: supply: sbs-battery: Add delay when changing capacity mode bit

At least with the Inspired Energy compatible batteries a delay is required
after setting the capacity mode bit from amp to watts or the reverse.
Setting the bit and then immediately pooling the status register results
in an unknown error being returned in the register. Add the delay results
in and ok status being return. This was also seen when reading the charge
and energy registers where the wrong value was returned for the requested
mode.

Signed-off-by: Phil Reid <preid@electromag.com.au>
Tested-by: Michael Heinemann <committed@heine.so>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
zero-colors
Phil Reid 2017-07-11 17:43:43 +08:00 committed by Sebastian Reichel
parent b70f0a2896
commit adcf04c9f8
1 changed files with 3 additions and 0 deletions

View File

@ -14,6 +14,7 @@
* more details.
*/
#include <linux/delay.h>
#include <linux/err.h>
#include <linux/gpio/consumer.h>
#include <linux/i2c.h>
@ -527,6 +528,8 @@ static enum sbs_battery_mode sbs_set_battery_mode(struct i2c_client *client,
if (ret < 0)
return ret;
usleep_range(1000, 2000);
return original_val & BATTERY_MODE_MASK;
}