summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Short <keithshort@chromium.org>2020-12-06 11:42:54 -0700
committerCommit Bot <commit-bot@chromium.org>2020-12-14 20:26:56 +0000
commita02472eb1ab1aa0b704d22c0846d9d61776f15fd (patch)
tree22077ab466f9084c2ccce81e8ab281e3b11af7c1
parent2d92290dcc7291cefd3666102dec9c10b27b593d (diff)
downloadchrome-ec-a02472eb1ab1aa0b704d22c0846d9d61776f15fd.tar.gz
zephyr: Add battery and smart battery options
Shim in battery and smart battery support. BUG=b:175248556 BRANCH=none TEST=boot on volteer, run 'battery' command. TEST=run 'ninja menuconfig' and check KConfig help text. 20-12-10 20:08:12.778 battery 20-12-10 20:08:13.509 Status: 0x02c0 DCHG INIT RC 20-12-10 20:08:13.529 Param flags:00000003 20-12-10 20:08:13.541 Temp: 0x0b63 = %.1d K (%.1d C) 20-12-10 20:08:13.541 V: 0x2a1e = 10782 mV 20-12-10 20:08:13.541 V-desired: 0x3390 = 13200 mV 20-12-10 20:08:13.541 I: 0x0000 = 0 mA 20-12-10 20:08:13.550 I-desired: 0x0a19 = 2585 mA 20-12-10 20:08:13.550 Charging: Allowed 20-12-10 20:08:13.550 Charge: 0 % 20-12-10 20:08:13.550 Manuf: LG 20-12-10 20:08:13.555 Device: AC17A8 20-12-10 20:08:13.573 Chem: LIO 20-12-10 20:08:13.573 Serial: 0xb754 20-12-10 20:08:13.573 V-design: 0x2d1e = 11550 mV 20-12-10 20:08:13.573 Mode: 0x6001 20-12-10 20:08:13.573 Abs charge:0 % 20-12-10 20:08:13.573 Remaining: 0 mAh 20-12-10 20:08:13.577 Cap-full: 4932 mAh (4833 mAh with 98 % compensation) 20-12-10 20:08:13.585 Design: 5360 mAh 20-12-10 20:08:13.594 Time-full: 0h:0 20-12-10 20:08:13.594 Empty: 0h:0 Change-Id: Ie782e75ee4027ab2a5c6a0ae7f4ad81e9c360711 Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2575199 Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2590844
-rw-r--r--power/common.c2
-rw-r--r--zephyr/Kconfig1
-rw-r--r--zephyr/Kconfig.battery52
-rw-r--r--zephyr/shim/include/config_chip.h20
4 files changed, 75 insertions, 0 deletions
diff --git a/power/common.c b/power/common.c
index ea6190d523..6f14e69989 100644
--- a/power/common.c
+++ b/power/common.c
@@ -663,6 +663,8 @@ void chipset_task(void *u)
static uint32_t last_in_signals;
while (1) {
+ msleep(100);
+ continue;
/*
* In order to prevent repeated console spam, only print the
* current power state if something has actually changed. It's
diff --git a/zephyr/Kconfig b/zephyr/Kconfig
index fcb7df19c9..8e533f7718 100644
--- a/zephyr/Kconfig
+++ b/zephyr/Kconfig
@@ -12,6 +12,7 @@ menuconfig PLATFORM_EC
if PLATFORM_EC
+rsource "Kconfig.battery"
rsource "Kconfig.powerseq"
rsource "Kconfig.tasks"
diff --git a/zephyr/Kconfig.battery b/zephyr/Kconfig.battery
new file mode 100644
index 0000000000..840408c188
--- /dev/null
+++ b/zephyr/Kconfig.battery
@@ -0,0 +1,52 @@
+# Copyright 2020 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+config PLATFORM_EC_BATTERY
+ bool "Support batteries"
+ help
+ Enables battery support on the board. Requires selection of a battery
+ and a charger IC.
+
+ If using I2C batteries, you must dedine I2C_PORT_BATTERY in your
+ board's i2c_map.h file so that the EC code will know which I2C
+ port the battery is on.
+
+if PLATFORM_EC_BATTERY
+
+choice "Battery select"
+ prompt "Select the battery to use"
+ help
+ Select the battery used on the board. If you are ensure, select the
+ smart battery option.
+
+config PLATFORM_EC_BATTERY_SMART
+ bool "Support a smart battery"
+ depends on PLATFORM_EC_I2C
+ help
+ Many batteries support the Smart Battery Specification and therefore
+ have common registers which can be accessed to control and monitor
+ the battery.
+
+ See here for the spec: http://sbs-forum.org/specs/sbdat110.pdf
+
+endchoice
+
+choice "Charger select"
+ prompt "Select the charger to use"
+ help
+ Select the battery charger IC used on the board. Only one charger may
+ be selected.
+
+config PLATFORM_EC_CHARGER_ISL9237
+ bool "Use the ISL9237 charger"
+ depends on PLATFORM_EC_I2C
+ help
+ Enables a driver for the ISL9237 VCD Battery Charger. This is a
+ buck-boost, narrow-output-voltage charger supporting an input voltage
+ of 3.2-23.4V and output of 2.4 V-13.8V. It provides an I2C interace
+ for configuration.
+
+endchoice
+
+endif # PLATFORM_EC_BATTERY
diff --git a/zephyr/shim/include/config_chip.h b/zephyr/shim/include/config_chip.h
index 4759e6373e..3e5eaaf6a1 100644
--- a/zephyr/shim/include/config_chip.h
+++ b/zephyr/shim/include/config_chip.h
@@ -26,6 +26,26 @@
#define CONFIG_CHIPSET_TIGERLAKE
#endif
+/* Battery configuration */
+#undef CONFIG_BATTERY
+#undef CONFIG_BATTERY_FUEL_GAUGE
+#ifdef CONFIG_PLATFORM_EC_BATTERY
+#define CONFIG_BATTERY
+#define CONFIG_BATTERY_FUEL_GAUGE
+#endif
+
+#undef CONFIG_CHARGER_ISL9237
+#ifdef CONFIG_PLATFORM_EC_CHARGER_ISL9237
+#define CONFIG_CHARGER_ISL9237
+/* Hardware based charge ramp is broken in the ISL9241 (b/169350714) */
+#define CONFIG_CHARGE_RAMP_SW
+#endif
+
+#undef CONFIG_BATTERY_SMART
+#ifdef CONFIG_PLATFORM_EC_BATTERY_SMART
+#define CONFIG_BATTERY_SMART
+#endif
+
/* eSPI configuration */
#ifdef CONFIG_PLATFORM_EC_ESPI