summaryrefslogtreecommitdiff
path: root/driver/battery/max17055.c
diff options
context:
space:
mode:
authorPhilip Chen <philipchen@google.com>2017-10-23 21:24:07 -0700
committerchrome-bot <chrome-bot@chromium.org>2017-10-24 07:29:43 -0700
commita109ebc3b1abf53980cb8cdca4feb6b9ce61ffd7 (patch)
treee5f7d1c0cc3b8d234df8b44a99cbfa358f37eac3 /driver/battery/max17055.c
parent6b516eda69f92cbc9f06b33cdf2c34cf1114ca16 (diff)
downloadchrome-ec-a109ebc3b1abf53980cb8cdca4feb6b9ce61ffd7.tar.gz
battery/max17055: Measure temperature using external thermistor
By default max17055 measures from internal temperature sensor. BUG=b:68170538 BRANCH=none TEST=place a heat source on top of the battery pack and see temperature rise from 'battery' command Change-Id: I1c0bb981e366a8a73d2e14e6c1fc92327069e8f1 Signed-off-by: Philip Chen <philipchen@google.com> Reviewed-on: https://chromium-review.googlesource.com/735080 Commit-Ready: Philip Chen <philipchen@chromium.org> Tested-by: Philip Chen <philipchen@chromium.org> Reviewed-by: Shawn N <shawnn@chromium.org>
Diffstat (limited to 'driver/battery/max17055.c')
-rw-r--r--driver/battery/max17055.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/driver/battery/max17055.c b/driver/battery/max17055.c
index bd7e23cb30..b425e828b4 100644
--- a/driver/battery/max17055.c
+++ b/driver/battery/max17055.c
@@ -50,6 +50,9 @@
#define STATUS_POR 0x0002
#define STATUS_BST 0x0008
+/* Config reg (0x1d) flags */
+#define CONF_TSEL 0x8000
+
/* FStat reg (0x3d) flags */
#define FSTAT_DNR 0x0001
@@ -378,6 +381,16 @@ static void max17055_init(void)
return;
}
+ /* Set CONFIG.TSEL to measure temperature using external thermistor */
+ if (max17055_read(REG_CONFIG, &reg)) {
+ CPRINTS("%s: failed to read reg %02x", __func__, REG_CONFIG);
+ return;
+ }
+ if (max17055_write(REG_CONFIG, (reg | CONF_TSEL))) {
+ CPRINTS("%s: failed to write reg %02x", __func__, REG_CONFIG);
+ return;
+ }
+
CPRINTS("max17055 configuration succeeded!");
}
DECLARE_HOOK(HOOK_INIT, max17055_init, HOOK_PRIO_DEFAULT);