summaryrefslogtreecommitdiff
path: root/include/battery.h
diff options
context:
space:
mode:
authorParth Malkan <parthmalkan@google.com>2022-05-25 18:02:06 -0700
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-06-03 01:29:41 +0000
commit8f2fa112010f6f52413975c72e7a22a3ecdbfdbe (patch)
tree18f5bbd56259d6968e5043e20ec185a158e1aade /include/battery.h
parent18fc3aab5262dc0e66f0b84f4feaebbacfd818a1 (diff)
downloadchrome-ec-8f2fa112010f6f52413975c72e7a22a3ecdbfdbe.tar.gz
zephyr: LED: Define battery-level property as int range
Currently battery-level property is defined using enums. This patch changes this to use int range instead. BRANCH=None BUG=b:233953617 TEST=Manual test on Lazor by modifying nodes to include battery-level range, use battfake to set different levels and observe LED behavior. Cq-Depend: chromium:3669089, chromium:3669090 Signed-off-by: Parth Malkan <parthmalkan@google.com> Change-Id: Idfe516addfe20d5141e5106afd338b49f10a6349 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3669088 Reviewed-by: Wai-Hong Tam <waihong@google.com>
Diffstat (limited to 'include/battery.h')
-rw-r--r--include/battery.h24
1 files changed, 18 insertions, 6 deletions
diff --git a/include/battery.h b/include/battery.h
index 7817794e98..9daf1ce981 100644
--- a/include/battery.h
+++ b/include/battery.h
@@ -12,12 +12,15 @@
#include "compiler.h"
#include "host_command.h"
-/* Battery index, only used with CONFIG_BATTERY_V2. */
-enum battery_index {
- BATT_IDX_INVALID = -1,
- BATT_IDX_MAIN = 0,
- BATT_IDX_BASE = 1,
-};
+/*
+ * If compiling with Zephyr, include the BATTERY_LEVEL_ definitions that are
+ * shared with device tree
+ */
+#ifdef CONFIG_ZEPHYR
+
+#include "dt-bindings/battery.h"
+
+#else /* !CONFIG_ZEPHYR */
/* Stop charge when charging and battery level >= this percentage */
#define BATTERY_LEVEL_FULL 100
@@ -47,9 +50,18 @@ enum battery_index {
*/
#define BATTERY_LEVEL_SHUTDOWN 3
+#endif /* CONFIG_ZEPHYR */
+
/* Full-capacity change reqd for host event */
#define LFCC_EVENT_THRESH 5
+/* Battery index, only used with CONFIG_BATTERY_V2. */
+enum battery_index {
+ BATT_IDX_INVALID = -1,
+ BATT_IDX_MAIN = 0,
+ BATT_IDX_BASE = 1,
+};
+
/*
* Sometimes we have hardware to detect battery present, sometimes we have to
* wait until we've been able to talk to the battery.