summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2020-12-21 15:30:28 -0700
committerCommit Bot <commit-bot@chromium.org>2020-12-23 22:18:37 +0000
commit33e3bda073585e3d4b4bba3008b1aa32a447dafe (patch)
tree67beea0200ce1461e77ebdb592d5781f07dcf491
parent1668a5e22c7e70e6de86d66548580b22035dd248 (diff)
downloadchrome-ec-33e3bda073585e3d4b4bba3008b1aa32a447dafe.tar.gz
zephyr: Add support for battery presence
Add the battery-presence settings so that a battery can be detected. BUG=b:175248556 BRANCH=none TEST=build and run zephyr on volteer No visible change, except more code is compiled in Cq-Depend: chromium:2599491 Signed-off-by: Simon Glass <sjg@chromium.org> Change-Id: I9a7086e6df67f7e9fe3aedb6a15f891e71b58d49 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2600337 Reviewed-by: Keith Short <keithshort@chromium.org>
-rw-r--r--zephyr/Kconfig.battery30
-rw-r--r--zephyr/shim/include/config_chip.h18
2 files changed, 43 insertions, 5 deletions
diff --git a/zephyr/Kconfig.battery b/zephyr/Kconfig.battery
index 916f731d20..3bcb88d111 100644
--- a/zephyr/Kconfig.battery
+++ b/zephyr/Kconfig.battery
@@ -32,6 +32,36 @@ config PLATFORM_EC_BATTERY_SMART
endchoice
+choice "Battery presence detection"
+ prompt "Method to use to detect the battery"
+ help
+ This selects the method to use to detect the presence of a battery.
+
+ Battery detection is important since it can be used to indicate that
+ the case is open, so security features can be disabled. It is also
+ useful to report to the user when the battery is missing, e.g. with
+ a desktop icon.
+
+config PLATFORM_EC_BATTERY_PRESENT_CUSTOM
+ bool "Call a board-provided function"
+ help
+ Use this method to provide a board-provided battery_is_present()
+ function to determine whether the battery is currently present.
+ This should be implemented in the board code and can use any
+ reasonable method to detect the battery.
+
+config PLATFORM_EC_BATTERY_PRESENT_GPIO
+ bool "Check a GPIO"
+ help
+ Use this method if a GPIO signals whether the battery is present. The
+ GPIO should read low if the battery is present, high if absent,
+
+ TODO:
+ The actual GPIO to use is not defined by this option. Perhaps this
+ needs to be placed in the devicetree.
+
+endchoice # battery presence
+
choice "Charger select"
prompt "Select the charger to use"
help
diff --git a/zephyr/shim/include/config_chip.h b/zephyr/shim/include/config_chip.h
index 84f0af9b77..69b7684a75 100644
--- a/zephyr/shim/include/config_chip.h
+++ b/zephyr/shim/include/config_chip.h
@@ -34,6 +34,19 @@
#define CONFIG_BATTERY_FUEL_GAUGE
#endif
+#undef CONFIG_BATTERY_SMART
+#ifdef CONFIG_PLATFORM_EC_BATTERY_SMART
+#define CONFIG_BATTERY_SMART
+#endif
+
+#undef CONFIG_BATTERY_PRESENT_CUSTOM
+#undef CONFIG_BATTERY_PRESENT_GPIO
+#ifdef CONFIG_PLATFORM_EC_BATTERY_PRESENT_CUSTOM
+#define CONFIG_BATTERY_PRESENT_CUSTOM
+#elif defined(PLATFORM_EC_BATTERY_PRESENT_GPIO)
+#define CONFIG_BATTERY_PRESENT_GPIO
+#endif /* CONFIG_PLATFORM_EC_BATTERY_PRESENT_CUSTOM */
+
#undef CONFIG_CHARGER_ISL9241
#ifdef CONFIG_PLATFORM_EC_CHARGER_ISL9241
#define CONFIG_CHARGER_ISL9241
@@ -48,11 +61,6 @@
#define CONFIG_CHARGER_INPUT_CURRENT 512
#endif
-#undef CONFIG_BATTERY_SMART
-#ifdef CONFIG_PLATFORM_EC_BATTERY_SMART
-#define CONFIG_BATTERY_SMART
-#endif
-
/* eSPI configuration */
#ifdef CONFIG_PLATFORM_EC_ESPI