summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHsu Henry <Henry.Hsu@quantatw.com>2015-03-30 09:26:05 +0800
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-03-31 08:45:30 +0000
commit00c04527514aeec91dc7f97f956144194b4b69b4 (patch)
treec2d81420d099693032825fe449b3e2f3def0ebec
parente4fbf6f654bd00f26c94f1445ab04edf0cce10c7 (diff)
downloadchrome-ec-00c04527514aeec91dc7f97f956144194b4b69b4.tar.gz
Smart battery: Add delay time for battery read/write
Some battery pack can't response ec command. Adding some dealy will improve it. BUG=chrome-os-partner:37842 BRANCH=banjo TEST=test with banjo, 100us. With the particular battery, no error occurs. Change-Id: Ia40dc7d5286525d54641893d900dfe3a345a2156 Signed-off-by: Henry Hsu <Henry.Hsu@quantatw.com> Reviewed-on: https://chromium-review.googlesource.com/262853 Reviewed-by: Sheng-liang Song <ssl@google.com>
-rw-r--r--driver/battery/smart.c6
-rwxr-xr-xinclude/config.h5
2 files changed, 11 insertions, 0 deletions
diff --git a/driver/battery/smart.c b/driver/battery/smart.c
index 2d314e5e6f..2a0278cee5 100644
--- a/driver/battery/smart.c
+++ b/driver/battery/smart.c
@@ -24,11 +24,17 @@ test_mockable int sbc_write(int cmd, int param)
int sb_read(int cmd, int *param)
{
+#ifdef CONFIG_BATTERY_I2C_ACCESS_DELAY_TIME
+ usleep(CONFIG_BATTERY_I2C_ACCESS_DELAY_TIME);
+#endif
return i2c_read16(I2C_PORT_BATTERY, BATTERY_ADDR, cmd, param);
}
int sb_write(int cmd, int param)
{
+#ifdef CONFIG_BATTERY_I2C_ACCESS_DELAY_TIME
+ usleep(CONFIG_BATTERY_I2C_ACCESS_DELAY_TIME);
+#endif
return i2c_write16(I2C_PORT_BATTERY, BATTERY_ADDR, cmd, param);
}
diff --git a/include/config.h b/include/config.h
index 4048733ac1..cb59fdfcab 100755
--- a/include/config.h
+++ b/include/config.h
@@ -99,6 +99,11 @@
#undef CONFIG_BATTERY_CUT_OFF
/*
+ * Delay time for smart battery command.
+ */
+#undef CONFIG_BATTERY_I2C_ACCESS_DELAY_TIME
+
+/*
* Battery percent thresholds to notify the host or shut down the system.
* If not specified, default values are set in include/battery.h.
*/