From 619032a77c171ff11251648a4af61fb0578dd097 Mon Sep 17 00:00:00 2001 From: David Hendricks Date: Mon, 27 Aug 2012 14:54:27 -0700 Subject: snow: toggle pull-up on PA7 (SUSPEND_L) on power on/off This adds hooks to re-configure SUSPEND_L (GPIO PA7) when the system turns on/off. When the system is turned on, PA7 will have its internal pull-up enabled. This is required since SUSPEND_L is driven by an open- drain buffer. When the AP is off, we can disable the pull-up (configure PA7 as floating input) to reduce leakage. Signed-off-by: David Hendricks BRANCH=snow BUG=chrome-os-partner:12700,chrome-os-partner:13200 TEST=see notes below 1. Dump GPIO_A CRL when system is off: read 0x40010800 = 0x41484144 2. Dump GPIO_A CRL when system is on: read 0x40010800 = 0x81484144 3. Dump GPIO_A when system is put into suspend: read 0x40010800 = 0x81484144 4. Resume, see power LED react quickly. 5. Soft poweroff, dump GPIO_A CRL: read 0x40010800 = 0x41484144 Change-Id: I62f02324a2a1fbfb6eff539fc6fdc35a035fa020 Reviewed-on: https://gerrit.chromium.org/gerrit/31315 Reviewed-by: Vincent Palatin Commit-Ready: David Hendricks Tested-by: David Hendricks --- board/snow/board.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/board/snow/board.c b/board/snow/board.c index 8fe510a020..55edbedd2d 100644 --- a/board/snow/board.c +++ b/board/snow/board.c @@ -10,6 +10,7 @@ #include "console.h" #include "dma.h" #include "gpio.h" +#include "hooks.h" #include "i2c.h" #include "pmu_tpschrome.h" #include "power_led.h" @@ -21,6 +22,9 @@ #define GPIO_KB_INPUT (GPIO_INPUT | GPIO_PULL_UP | GPIO_INT_BOTH) #define GPIO_KB_OUTPUT (GPIO_OUTPUT | GPIO_OPEN_DRAIN) +#define INT_BOTH_FLOATING (GPIO_INPUT | GPIO_INT_BOTH) +#define INT_BOTH_PULL_UP (GPIO_INPUT | GPIO_PULL_UP | GPIO_INT_BOTH) + /* GPIO interrupt handlers prototypes */ #ifndef CONFIG_TASK_GAIAPOWER #define gaia_power_event NULL @@ -43,7 +47,7 @@ const struct gpio_info gpio_list[GPIO_COUNT] = { {"XPSHOLD", GPIO_A, (1<<3), GPIO_INT_BOTH, gaia_power_event}, {"CHARGER_INT", GPIO_C, (1<<4), GPIO_INT_FALLING, pmu_irq_handler}, {"LID_OPEN", GPIO_C, (1<<13), GPIO_INT_RISING, gaia_lid_event}, - {"SUSPEND_L", GPIO_A, (1<<7), GPIO_INT_BOTH, gaia_suspend_event}, + {"SUSPEND_L", GPIO_A, (1<<7), INT_BOTH_FLOATING, gaia_suspend_event}, {"WP_L", GPIO_B, (1<<4), GPIO_INPUT, NULL}, {"KB_IN00", GPIO_C, (1<<8), GPIO_KB_INPUT, matrix_interrupt}, {"KB_IN01", GPIO_C, (1<<9), GPIO_KB_INPUT, matrix_interrupt}, @@ -197,6 +201,21 @@ void board_power_led_config(enum powerled_config config) } } +static int board_startup_hook(void) +{ + gpio_set_flags(GPIO_SUSPEND_L, INT_BOTH_PULL_UP); + return 0; +} +DECLARE_HOOK(HOOK_CHIPSET_STARTUP, board_startup_hook, HOOK_PRIO_DEFAULT); + +static int board_shutdown_hook(void) +{ + /* Disable pull-up on SUSPEND_L during shutdown to prevent leakage */ + gpio_set_flags(GPIO_SUSPEND_L, INT_BOTH_FLOATING); + return 0; +} +DECLARE_HOOK(HOOK_CHIPSET_SHUTDOWN, board_shutdown_hook, HOOK_PRIO_DEFAULT); + enum { /* Time between requesting bus and deciding that we have it */ BUS_SLEW_DELAY_US = 10, -- cgit v1.2.1