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-06-30 03:02:02 +0000
commitd1805fb560364fd7db94bcb331ae0a70c6463712 (patch)
treefca6a8d75c613f0cdb4098fe3bc319a9671f9257
parentc133f29727a20d2fc93d9a8c56596445b336a52c (diff)
downloadchrome-ec-d1805fb560364fd7db94bcb331ae0a70c6463712.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> (cherry picked from commit 00c04527514aeec91dc7f97f956144194b4b69b4) Reviewed-on: https://chromium-review.googlesource.com/274724 Reviewed-by: Mohammed Habibulla <moch@google.com> Commit-Queue: 挺倫 林 <jimmy.lin@quantatw.com> Tested-by: 挺倫 林 <jimmy.lin@quantatw.com>
-rw-r--r--driver/battery/smart.c6
-rw-r--r--include/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 d9da27867a..c79f0208dd 100644
--- 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.
*/