From: Phil Reid <preid@electromag.com.au>
To: sre@kernel.org, preid@electromag.com.au,
linux-pm@vger.kernel.org, posted@heine.so
Subject: [PATCH v2 3/3] power: supply: sbs-battery: Add delay when changing capacity mode bit
Date: Tue, 11 Jul 2017 17:43:43 +0800 [thread overview]
Message-ID: <1499766223-130934-4-git-send-email-preid@electromag.com.au> (raw)
In-Reply-To: <1499766223-130934-1-git-send-email-preid@electromag.com.au>
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>
---
drivers/power/supply/sbs-battery.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/power/supply/sbs-battery.c b/drivers/power/supply/sbs-battery.c
index 4594ed1..3473b45 100644
--- a/drivers/power/supply/sbs-battery.c
+++ b/drivers/power/supply/sbs-battery.c
@@ -14,6 +14,7 @@
* more details.
*/
+#include <linux/delay.h>
#include <linux/err.h>
#include <linux/gpio/consumer.h>
#include <linux/i2c.h>
@@ -511,6 +512,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;
}
--
1.8.3.1
next prev parent reply other threads:[~2017-07-11 9:43 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-11 9:43 [PATCH v2 0/3] power: supply: sbs-battery: Add delay when changing capacity mode Phil Reid
2017-07-11 9:43 ` [PATCH v2 1/3] power: supply: sbs-battery: Remove FSF mailing address from comments Phil Reid
2017-07-11 9:43 ` [PATCH v2 2/3] power: supply: sbs-battery: sort includes Phil Reid
2017-07-11 9:43 ` Phil Reid [this message]
2017-07-11 11:31 ` [PATCH v2 3/3] power: supply: sbs-battery: Add delay when changing capacity mode bit Michael Heinemann
2017-07-19 2:16 ` Phil Reid
2017-07-25 9:32 ` [PATCH v2 0/3] power: supply: sbs-battery: Add delay when changing capacity mode Sebastian Reichel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1499766223-130934-4-git-send-email-preid@electromag.com.au \
--to=preid@electromag.com.au \
--cc=linux-pm@vger.kernel.org \
--cc=posted@heine.so \
--cc=sre@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox