From 2d205f97cbfd7eecf9d6cf6b9a44c4f667e9be79 Mon Sep 17 00:00:00 2001 From: Dave Parker Date: Fri, 19 Jul 2013 23:10:17 -0700 Subject: [PATCH] Slippy: Detect physical presence of battery before waking it BUG=chrome-os-partner:21180 BRANCH=slippy TEST=Power device without battery. It should boot with no 30 second delay. The battery LED blinks orange indicating a battery error. Signed-off-by: Dave Parker Change-Id: Icabc450cd44748aed694e4ed8cb81eee152cf456 Reviewed-on: https://gerrit.chromium.org/gerrit/62850 Tested-by: Dave Parker Reviewed-by: Randall Spangler Commit-Queue: Dave Parker --- board/slippy/board.c | 1 + board/slippy/board.h | 2 ++ common/battery_slippy.c | 9 +++++++++ 3 files changed, 12 insertions(+) diff --git a/board/slippy/board.c b/board/slippy/board.c index 3f2b6a9c0e..69566ef404 100644 --- a/board/slippy/board.c +++ b/board/slippy/board.c @@ -70,6 +70,7 @@ const struct gpio_info gpio_list[GPIO_COUNT] = { {"BOARD_VERSION2", LM4_GPIO_Q, (1<<6), GPIO_INPUT, NULL}, {"BOARD_VERSION3", LM4_GPIO_Q, (1<<7), GPIO_INPUT, NULL}, {"CPU_PGOOD", LM4_GPIO_C, (1<<4), GPIO_INPUT, NULL}, + {"BAT_DETECT_L", LM4_GPIO_B, (1<<4), GPIO_INPUT, NULL}, /* Outputs; all unasserted by default except for reset signals */ {"CPU_PROCHOT", LM4_GPIO_B, (1<<1), GPIO_OUT_LOW, NULL}, diff --git a/board/slippy/board.h b/board/slippy/board.h index fe4470687a..18cc4628f2 100644 --- a/board/slippy/board.h +++ b/board/slippy/board.h @@ -17,6 +17,7 @@ /* Optional features */ #define CONFIG_SMART_BATTERY #define CONFIG_BACKLIGHT_X86 +#define CONFIG_BATTERY_CHECK_CONNECTED #define CONFIG_BATTERY_SLIPPY #define CONFIG_BOARD_VERSION #define CONFIG_CHARGER @@ -97,6 +98,7 @@ enum gpio_signal { GPIO_BOARD_VERSION2, /* Board version stuffing resistor 2 */ GPIO_BOARD_VERSION3, /* Board version stuffing resistor 3 */ GPIO_CPU_PGOOD, /* Power good to the CPU */ + GPIO_BAT_DETECT_L, /* Battery detect. Repurposed BAT_TEMP */ /* Outputs */ GPIO_CPU_PROCHOT, /* Force CPU to think it's overheated */ diff --git a/common/battery_slippy.c b/common/battery_slippy.c index 14c7b3dee4..8d9648d26d 100644 --- a/common/battery_slippy.c +++ b/common/battery_slippy.c @@ -6,6 +6,7 @@ */ #include "battery_pack.h" +#include "gpio.h" /* FIXME: We need REAL values for all this stuff */ static const struct battery_info info = { @@ -50,3 +51,11 @@ void battery_vendor_params(struct batt_params *batt) } #endif } + +/** + * Physical detection of battery connection. + */ +int battery_is_connected(void) +{ + return (gpio_get_level(GPIO_BAT_DETECT_L) == 0); +}