summaryrefslogtreecommitdiff
path: root/board
diff options
context:
space:
mode:
authorVincent Palatin <vpalatin@chromium.org>2012-09-19 09:41:11 -0700
committerGerrit <chrome-bot@google.com>2012-09-20 07:14:18 -0700
commitc350c20f443eb69429727f2f967522e7b2817515 (patch)
tree2726920511b4b2299f330889db46f77a952f79fe /board
parent07cae3f8e1f7e8b53c8b60752d4e7d519ff01a74 (diff)
downloadchrome-ec-c350c20f443eb69429727f2f967522e7b2817515.tar.gz
tpschrome: AC detection is board specific.
the PMU VACG signal used to detect AC state is connected to a GPIO, so it's a board specific configuration. On top of that, Daisy variants have custom logic on that line which is not present on the next boards, so we need to update it before doing BSP for next-gen boards. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BUG=chrome-os-partner:14313 TEST=make BOARD=snow && make BOARD=daisy on snow EC console, type "pmu" command with AC plugge and unplugged, see that the "ac gpio" line reflects the right value. BRANCH=none Change-Id: If1e19b89b2f2de45d8dddc8340931e56c5f7f0a5 Reviewed-on: https://gerrit.chromium.org/gerrit/33630 Reviewed-by: David Hendricks <dhendrix@chromium.org> Commit-Ready: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'board')
-rw-r--r--board/daisy/board.c34
-rw-r--r--board/snow/board.c33
2 files changed, 67 insertions, 0 deletions
diff --git a/board/daisy/board.c b/board/daisy/board.c
index 2d09a79a04..f8612a1231 100644
--- a/board/daisy/board.c
+++ b/board/daisy/board.c
@@ -9,8 +9,10 @@
#include "dma.h"
#include "i2c.h"
#include "gpio.h"
+#include "pmu_tpschrome.h"
#include "registers.h"
#include "spi.h"
+#include "task.h"
#include "util.h"
/*
@@ -195,3 +197,35 @@ void board_keyboard_suppress_noise(void)
gpio_set_level(GPIO_CODEC_INT, 0);
gpio_set_level(GPIO_CODEC_INT, 1);
}
+
+int board_get_ac(void)
+{
+ /*
+ * Detect AC state using combined gpio pins
+ *
+ * On daisy and snow, there's no single gpio signal to detect AC.
+ * GPIO_AC_PWRBTN_L provides AC on and PWRBTN release.
+ * GPIO_KB_PWR_ON_L provides PWRBTN release.
+ *
+ * When AC plugged, both GPIOs will be high.
+ *
+ * One drawback of this detection is, when press-and-hold power
+ * button. AC state will be unknown. This function will fallback
+ * to PMU VACG.
+ */
+
+ int ac_good = 1, battery_good;
+
+ if (gpio_get_level(GPIO_KB_PWR_ON_L))
+ return gpio_get_level(GPIO_AC_PWRBTN_L);
+
+ /* Check PMU VACG */
+ if (!in_interrupt_context())
+ pmu_get_power_source(&ac_good, &battery_good);
+
+ /*
+ * Charging task only interacts with AP in discharging state. So
+ * return 1 when AC status can not be detected by GPIO or VACG.
+ */
+ return ac_good;
+}
diff --git a/board/snow/board.c b/board/snow/board.c
index 36dac730cd..c1423c316e 100644
--- a/board/snow/board.c
+++ b/board/snow/board.c
@@ -16,6 +16,7 @@
#include "power_led.h"
#include "registers.h"
#include "spi.h"
+#include "task.h"
#include "timer.h"
#include "util.h"
@@ -421,3 +422,35 @@ int board_pmu_init(void)
return failure ? EC_ERROR_UNKNOWN : EC_SUCCESS;
}
#endif /* CONFIG_BOARD_PMU_INIT */
+
+int board_get_ac(void)
+{
+ /*
+ * Detect AC state using combined gpio pins
+ *
+ * On daisy and snow, there's no single gpio signal to detect AC.
+ * GPIO_AC_PWRBTN_L provides AC on and PWRBTN release.
+ * GPIO_KB_PWR_ON_L provides PWRBTN release.
+ *
+ * When AC plugged, both GPIOs will be high.
+ *
+ * One drawback of this detection is, when press-and-hold power
+ * button. AC state will be unknown. This function will fallback
+ * to PMU VACG.
+ */
+
+ int ac_good = 1, battery_good;
+
+ if (gpio_get_level(GPIO_KB_PWR_ON_L))
+ return gpio_get_level(GPIO_AC_PWRBTN_L);
+
+ /* Check PMU VACG */
+ if (!in_interrupt_context())
+ pmu_get_power_source(&ac_good, &battery_good);
+
+ /*
+ * Charging task only interacts with AP in discharging state. So
+ * return 1 when AC status can not be detected by GPIO or VACG.
+ */
+ return ac_good;
+}