summaryrefslogtreecommitdiff
path: root/common/battery.c
diff options
context:
space:
mode:
authorChromeOS Developer <dparker@chromium.org>2014-01-14 21:23:50 -0800
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-02-06 01:22:17 +0000
commitc35251d662ad91cdb680cb9de1b09c7b2d16f069 (patch)
treead0d09eac9a8a924dc6817efcd88fd5e265ea651 /common/battery.c
parent7c588a329203987af1f959d49683574a839f0a0f (diff)
downloadchrome-ec-c35251d662ad91cdb680cb9de1b09c7b2d16f069.tar.gz
Add configs for battery detect via gpio or custom function
BUG=chrome-os-partner:24649 BRANCH=baytrail TEST=Boot target device w/o battery. There should be no 30 second delay prior to boot. Change-Id: If7a60919701d1c241670d0b32e04f3e188a643f1 Signed-off-by: Dave Parker <dparker@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/182921 Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'common/battery.c')
-rw-r--r--common/battery.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/common/battery.c b/common/battery.c
index 8794027562..7f318646a3 100644
--- a/common/battery.c
+++ b/common/battery.c
@@ -6,11 +6,27 @@
*/
#include "battery.h"
+#include "common.h"
#include "console.h"
+#include "gpio.h"
#include "timer.h"
#include "util.h"
#include "watchdog.h"
+#ifdef CONFIG_BATTERY_PRESENT_GPIO
+#ifdef CONFIG_BATTERY_PRESENT_CUSTOM
+#error "Don't define both CONFIG_BATTERY_PRESENT_CUSTOM and" \
+ "CONFIG_BATTERY_PRESENT_GPIO"
+#endif
+/**
+ * Physical detection of battery.
+ */
+int battery_is_present(void)
+{
+ return (gpio_get_level(CONFIG_BATTERY_PRESENT_GPIO) == 0);
+}
+#endif
+
static const char *get_error_text(int rv)
{
if (rv == EC_ERROR_UNIMPLEMENTED)