summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBill Richardson <wfrichar@chromium.org>2013-07-10 17:33:48 -0700
committerChromeBot <chrome-bot@google.com>2013-07-11 13:39:16 -0700
commita26b0dbd747386c841a31144c7fdf07b68ccb811 (patch)
tree2f064b6b88252cc719615297af9d7736fa38acac
parent4d270c1507040e1ba45b597310167c172e915ef6 (diff)
downloadchrome-ec-a26b0dbd747386c841a31144c7fdf07b68ccb811.tar.gz
Falco: AC adapter identification command
This adds a function to identify the AC adapter. We'll need this to set various battery charging limits, based on the capability. This only applies to Falco, AFAIK. BUG=chrome-os-partner:19594 BRANCH=none TEST=manual Plug in various approved adapters. From the EC console, run "adapter". It should tell you the rated power for each one. Change-Id: Id6d142fa81f20ec9233b0faa2fcb1d53cf7b7ef5 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/61515 Reviewed-by: Randall Spangler <rspangler@chromium.org>
-rw-r--r--board/falco/board.h1
-rw-r--r--common/build.mk1
-rw-r--r--common/extpower_falco.c49
3 files changed, 51 insertions, 0 deletions
diff --git a/board/falco/board.h b/board/falco/board.h
index beedb6e5f6..a2fbc8a47d 100644
--- a/board/falco/board.h
+++ b/board/falco/board.h
@@ -17,6 +17,7 @@
/* Optional features */
#define CONFIG_SMART_BATTERY
#define CONFIG_BATTERY_FALCO
+#define CONFIG_EXTPOWER_FALCO
#define CONFIG_BOARD_VERSION
#define CONFIG_CHARGER
#define CONFIG_CHARGER_BQ24738
diff --git a/common/build.mk b/common/build.mk
index 148b2ac894..9968afa041 100644
--- a/common/build.mk
+++ b/common/build.mk
@@ -26,6 +26,7 @@ common-$(CONFIG_CHIPSET_HASWELL)+=chipset_haswell.o chipset_x86_common.o
common-$(CONFIG_CHIPSET_IVYBRIDGE)+=chipset_ivybridge.o chipset_x86_common.o
common-$(CONFIG_PMU_TPS65090)+=pmu_tps65090.o
common-$(CONFIG_EOPTION)+=eoption.o
+common-$(CONFIG_EXTPOWER_FALCO)+=extpower_falco.o
common-$(CONFIG_EXTPOWER_GPIO)+=extpower_gpio.o
common-$(CONFIG_EXTPOWER_SNOW)+=extpower_snow.o
common-$(CONFIG_EXTPOWER_USB)+=extpower_usb.o
diff --git a/common/extpower_falco.c b/common/extpower_falco.c
new file mode 100644
index 0000000000..04e86abadf
--- /dev/null
+++ b/common/extpower_falco.c
@@ -0,0 +1,49 @@
+/* Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* Special AC Adapter logic for Falco */
+
+#include "adc.h"
+#include "common.h"
+#include "console.h"
+#include "util.h"
+
+enum adapter_type {
+ ADAPTER_UNKNOWN,
+ ADAPTER_45W,
+ ADAPTER_65W,
+ ADAPTER_90W,
+};
+
+static const char * const adapter_str[] = {
+ "unknown",
+ "45W",
+ "65W",
+ "90W"
+};
+
+static enum adapter_type identify_adapter(void)
+{
+ int mv;
+ mv = adc_read_channel(ADC_AC_ADAPTER_ID_VOLTAGE);
+ if (mv >= 434 && mv <= 554)
+ return ADAPTER_45W;
+ if (mv >= 561 && mv <= 717)
+ return ADAPTER_65W;
+ if (mv >= 725 && mv <= 925)
+ return ADAPTER_90W;
+
+ return ADAPTER_UNKNOWN;
+}
+
+static int command_adapter(int argc, char **argv)
+{
+ ccprintf("%s\n", adapter_str[identify_adapter()]);
+ return EC_SUCCESS;
+}
+DECLARE_CONSOLE_COMMAND(adapter, command_adapter,
+ NULL,
+ "Identify AC adapter type",
+ NULL);