diff options
author | Shawn Nematbakhsh <shawnn@chromium.org> | 2015-07-15 17:13:22 -0700 |
---|---|---|
committer | ChromeOS Commit Bot <chromeos-commit-bot@chromium.org> | 2015-07-16 05:15:29 +0000 |
commit | 78016324acf20e06abebd9b82a9a88b1eed2bdf6 (patch) | |
tree | fb09f9d63c2bfdce77b45fe3dd49128a43217ae4 /chip | |
parent | e7bebf7c805e160bfd633da5c8357527a4fee9f6 (diff) | |
download | chrome-ec-78016324acf20e06abebd9b82a9a88b1eed2bdf6.tar.gz |
mec1322: Allow multiple hibernate wake sources
Allow multiple GPIOs to wake the EC from hibernate by requiring boards
to define hibernate_wake_pins and hibernate_wake_pins_used. In addition,
clean up the GPIO-skipping hibernate code, and skip setting PCH_RTCRST
as an input due to a bug on certain boards.
BUG=chrome-os-partner:42104
TEST=Manual on Glados. Run 'hibernate' from EC console, verify that EC
wakes with power button press or with "dut-control lid_open:no".
BRANCH=None
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: I13a6e062393cab8ed7129eda253585951f771109
Reviewed-on: https://chromium-review.googlesource.com/285924
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Diffstat (limited to 'chip')
-rw-r--r-- | chip/mec1322/registers.h | 4 | ||||
-rw-r--r-- | chip/mec1322/system.c | 56 |
2 files changed, 37 insertions, 23 deletions
diff --git a/chip/mec1322/registers.h b/chip/mec1322/registers.h index d1d88d20ac..aab3da935c 100644 --- a/chip/mec1322/registers.h +++ b/chip/mec1322/registers.h @@ -479,4 +479,8 @@ typedef volatile struct mec1322_dma_regs mec1322_dma_regs_t; #define MEC1322_IRQ_RTC 91 #define MEC1322_IRQ_RTC_ALARM 92 +/* Wake pin definitions, defined at board-level */ +extern const enum gpio_signal hibernate_wake_pins[]; +extern const int hibernate_wake_pins_used; + #endif /* __CROS_EC_REGISTERS_H */ diff --git a/chip/mec1322/system.c b/chip/mec1322/system.c index c753a0ad43..2ab4aa1356 100644 --- a/chip/mec1322/system.c +++ b/chip/mec1322/system.c @@ -188,21 +188,27 @@ static void system_set_gpio_power(int enabled, uint32_t *backup_gpio_ctl) uint32_t val; int want_skip; - const int pins[16][2] = {{0, 7}, {1, 7}, {2, 7}, {3, 6}, {4, 7}, {5, 7}, - {6, 7}, {10, 7}, {11, 7}, {12, 7}, {13, 6}, - {14, 7}, {15, 7}, {16, 5}, {20, 6}, {21, 1} }; - - const int skip[5][2] = {{13, 1}, /* VCC1_nRST */ - {6, 3}, /* VCC_PWRGD */ - {12, 1}, /* nRESET_OUT */ - {14, 3}, /* RSMRST# */ - {20, 5}, /* Not exist */ + const int pins[][2] = { + {0, 7}, {1, 7}, {2, 7}, {3, 6}, {4, 7}, {5, 7}, + {6, 7}, {10, 7}, {11, 7}, {12, 7}, {13, 6}, + {14, 7}, {15, 7}, {16, 5}, {20, 6}, {21, 1} }; - for (i = 0; i < 16; ++i) { + const int skip[][2] = { +#if defined(BOARD_GLADOS) || defined(BOARD_KUNIMITSU) + /* + * TODO(crosbug.com/p/42774): Remove this + * once we have a pull-down on PCH_RTCRST. + */ + {16, 3}, /* Leave PCH_RTCRST deasserted */ +#endif + {20, 5}, /* GPIO 205 doesn't exist */ + }; + + for (i = 0; i < ARRAY_SIZE(pins); ++i) { for (j = 0; j <= pins[i][1]; ++j) { want_skip = 0; - for (k = 0; k < 5; ++k) + for (k = 0; k < ARRAY_SIZE(skip); ++k) if (skip[k][0] == pins[i][0] && skip[k][1] == j) want_skip = 1; @@ -295,18 +301,22 @@ void system_hibernate(uint32_t seconds, uint32_t microseconds) backup_gpio_ctl = NULL; system_set_gpio_power(0, (uint32_t *)backup_gpio_ctl); -#ifdef CONFIG_WAKE_PIN - gpio_set_flags_by_mask(gpio_list[CONFIG_WAKE_PIN].port, - gpio_list[CONFIG_WAKE_PIN].mask, - gpio_list[CONFIG_WAKE_PIN].flags); - gpio_enable_interrupt(CONFIG_WAKE_PIN); - interrupt_enable(); - task_enable_irq(MEC1322_IRQ_GIRQ8); - task_enable_irq(MEC1322_IRQ_GIRQ9); - task_enable_irq(MEC1322_IRQ_GIRQ10); - task_enable_irq(MEC1322_IRQ_GIRQ11); - task_enable_irq(MEC1322_IRQ_GIRQ20); -#endif + if (hibernate_wake_pins_used > 0) { + for (i = 0; i < hibernate_wake_pins_used; ++i) { + const enum gpio_signal *pin = &hibernate_wake_pins[i]; + gpio_set_flags_by_mask(gpio_list[*pin].port, + gpio_list[*pin].mask, + gpio_list[*pin].flags); + gpio_enable_interrupt(*pin); + } + + interrupt_enable(); + task_enable_irq(MEC1322_IRQ_GIRQ8); + task_enable_irq(MEC1322_IRQ_GIRQ9); + task_enable_irq(MEC1322_IRQ_GIRQ10); + task_enable_irq(MEC1322_IRQ_GIRQ11); + task_enable_irq(MEC1322_IRQ_GIRQ20); + } if (seconds || microseconds) { MEC1322_INT_BLK_EN |= 1 << 17; |