summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBill Richardson <wfrichar@chromium.org>2013-10-16 01:52:06 -0700
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2013-10-22 21:41:09 +0000
commit2f327fbfa6757d887f1b4261bff070e1807d9039 (patch)
treeeae641b59a4c2fada4a6bee169facea430f70c11
parent99d52c8874b515938f8f6ae8fefc8e7c918b0ba2 (diff)
downloadchrome-ec-2f327fbfa6757d887f1b4261bff070e1807d9039.tar.gz
samus: Use analog BAT_TEMP as presence indicator
There is an analog temperature line on the Samus battery connector. We don't yet know what it means, but there's a pull-up on it, so if it's reading close to ADC_READ_MAX, we can probably assume there's no battery. This change says that any reading within 90% of ADC_READ_MAX means the battery pack is not present, so we can go ahead and boot without trying to wake it up first. BUG=chrome-os-partner:23449 BRANCH=none TEST=manual Connect the battery, boot. It should happen quickly. Disconnect the battery, boot. It should STILL happen quickly. Running "adc" on the EC console should show an entry for "BatteryTemp". If no battery is connected, it should read somewhere close to 4095. Change-Id: I1e41bccb2a988d34de09192ebb0a68b91b1b0b24 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/174046 Reviewed-by: Duncan Laurie <dlaurie@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
-rw-r--r--board/samus/board.c10
-rw-r--r--board/samus/board.h3
2 files changed, 10 insertions, 3 deletions
diff --git a/board/samus/board.c b/board/samus/board.c
index 5961a937c9..753f71e9ee 100644
--- a/board/samus/board.c
+++ b/board/samus/board.c
@@ -73,7 +73,6 @@ const struct gpio_info gpio_list[] = {
{"USB1_STATUS_L", LM4_GPIO_E, (1<<6), GPIO_INPUT, NULL},
{"USB2_OC_L", LM4_GPIO_E, (1<<0), GPIO_INPUT, NULL},
{"USB2_STATUS_L", LM4_GPIO_D, (1<<7), GPIO_INPUT, NULL},
- {"BAT_DETECT_L", LM4_GPIO_B, (1<<4), GPIO_INPUT, NULL},
/* Not yet sure if this will need to be handled as an interrupt */
{"CAPSENSE_INT_L", LM4_GPIO_N, (1<<0), GPIO_INPUT, NULL},
@@ -176,6 +175,13 @@ const struct adc_t adc_channels[] = {
*/
{"ChargerCurrent", LM4_ADC_SEQ1, 33000, ADC_READ_MAX * 4, 0,
LM4_AIN(11), 0x06 /* IE0 | END0 */, LM4_GPIO_B, (1<<5)},
+
+ /* FIXME: We don't know what to expect here, but it's an analog input
+ * that's pulled high. We're using it as a battery presence indicator
+ * for now. We'll return just 0 - ADC_READ_MAX for now.
+ */
+ {"BatteryTemp", LM4_ADC_SEQ2, 1, 1, 0,
+ LM4_AIN(10), 0x06 /* IE0 | END0 */, LM4_GPIO_B, (1<<4)},
};
BUILD_ASSERT(ARRAY_SIZE(adc_channels) == ADC_CH_COUNT);
@@ -278,5 +284,5 @@ struct keyboard_scan_config keyscan_config = {
*/
int battery_is_connected(void)
{
- return (gpio_get_level(GPIO_BAT_DETECT_L) == 0);
+ return adc_read_channel(ADC_CH_BAT_TEMP) < (9 * ADC_READ_MAX / 10);
}
diff --git a/board/samus/board.h b/board/samus/board.h
index 4f20537c36..a05f22a70f 100644
--- a/board/samus/board.h
+++ b/board/samus/board.h
@@ -114,7 +114,6 @@ enum gpio_signal {
GPIO_USB1_STATUS_L, /* USB charger port 1 status output */
GPIO_USB2_OC_L, /* USB port overcurrent warning */
GPIO_USB2_STATUS_L, /* USB charger port 2 status output */
- GPIO_BAT_DETECT_L, /* Battery detect from BAT_TEMP */
GPIO_CAPSENSE_INT_L, /* Capsense interrupt (through EC_WAKE_L) */
/* Outputs */
@@ -186,6 +185,8 @@ enum adc_channel {
ADC_CH_EC_TEMP = 0,
/* Charger current in mA. */
ADC_CH_CHARGER_CURRENT,
+ /* BAT_TEMP */
+ ADC_CH_BAT_TEMP,
ADC_CH_COUNT
};