summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShawn Nematbakhsh <shawnn@chromium.org>2015-07-15 17:13:22 -0700
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-07-16 05:15:29 +0000
commit78016324acf20e06abebd9b82a9a88b1eed2bdf6 (patch)
treefb09f9d63c2bfdce77b45fe3dd49128a43217ae4
parente7bebf7c805e160bfd633da5c8357527a4fee9f6 (diff)
downloadchrome-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>
-rw-r--r--board/cyan/board.c6
-rw-r--r--board/cyan/board.h1
-rw-r--r--board/glados/board.c8
-rw-r--r--board/glower/board.c5
-rw-r--r--board/glower/board.h1
-rw-r--r--board/kunimitsu/board.c8
-rw-r--r--board/kunimitsu/board.h1
-rw-r--r--board/mec1322_evb/board.c6
-rw-r--r--board/mec1322_evb/board.h1
-rw-r--r--board/strago/board.c5
-rw-r--r--board/strago/board.h1
-rw-r--r--chip/mec1322/registers.h4
-rw-r--r--chip/mec1322/system.c56
-rw-r--r--include/config.h4
14 files changed, 75 insertions, 32 deletions
diff --git a/board/cyan/board.c b/board/cyan/board.c
index 1dbb179feb..e35a5d4cb1 100644
--- a/board/cyan/board.c
+++ b/board/cyan/board.c
@@ -55,6 +55,12 @@ const struct i2c_port_t i2c_ports[] = {
};
const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports);
+const enum gpio_signal hibernate_wake_pins[] = {
+ GPIO_POWER_BUTTON_L,
+};
+
+const int hibernate_wake_pins_used = ARRAY_SIZE(hibernate_wake_pins);
+
/*
* Temperature sensors data; must be in same order as enum temp_sensor_id.
* Sensor index and name must match those present in coreboot:
diff --git a/board/cyan/board.h b/board/cyan/board.h
index 6d37516ba0..b0d575aad6 100644
--- a/board/cyan/board.h
+++ b/board/cyan/board.h
@@ -30,7 +30,6 @@
#define CONFIG_EXTPOWER_GPIO
#define CONFIG_I2C
#define CONFIG_PORT80_TASK_EN
-#define CONFIG_WAKE_PIN GPIO_POWER_BUTTON_L
#define CONFIG_VBOOT_HASH
#define CONFIG_CHARGER
diff --git a/board/glados/board.c b/board/glados/board.c
index de404d83ae..d28a0b3cfa 100644
--- a/board/glados/board.c
+++ b/board/glados/board.c
@@ -127,6 +127,14 @@ const struct i2c_port_t i2c_ports[] = {
};
const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports);
+const enum gpio_signal hibernate_wake_pins[] = {
+ GPIO_AC_PRESENT,
+ GPIO_LID_OPEN,
+ GPIO_POWER_BUTTON_L,
+};
+
+const int hibernate_wake_pins_used = ARRAY_SIZE(hibernate_wake_pins);
+
struct pi3usb9281_config pi3usb9281_chips[] = {
{
.i2c_port = I2C_PORT_USB_CHARGER_1,
diff --git a/board/glower/board.c b/board/glower/board.c
index 9e9c110809..6d5bc33699 100644
--- a/board/glower/board.c
+++ b/board/glower/board.c
@@ -45,3 +45,8 @@ const struct i2c_port_t i2c_ports[] = {
};
const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports);
+const enum gpio_signal hibernate_wake_pins[] = {
+ GPIO_POWER_BUTTON_L,
+};
+
+const int hibernate_wake_pins_used = ARRAY_SIZE(hibernate_wake_pins);
diff --git a/board/glower/board.h b/board/glower/board.h
index ac9e37469a..9d1de7f575 100644
--- a/board/glower/board.h
+++ b/board/glower/board.h
@@ -50,7 +50,6 @@
#define CONFIG_SYSTEM_UNLOCKED /* Allow dangerous commands */
#define CONFIG_WATCHDOG_HELP
#define CONFIG_CLOCK_CRYSTAL
-#define CONFIG_WAKE_PIN GPIO_POWER_BUTTON_L
/* 512kb SPI flash */
#define CONFIG_SPI_FLASH_SIZE 0x00080000
diff --git a/board/kunimitsu/board.c b/board/kunimitsu/board.c
index d018947e8a..cf1f6d9501 100644
--- a/board/kunimitsu/board.c
+++ b/board/kunimitsu/board.c
@@ -131,6 +131,14 @@ const struct i2c_port_t i2c_ports[] = {
};
const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports);
+const enum gpio_signal hibernate_wake_pins[] = {
+ GPIO_AC_PRESENT,
+ GPIO_LID_OPEN,
+ GPIO_POWER_BUTTON_L,
+};
+
+const int hibernate_wake_pins_used = ARRAY_SIZE(hibernate_wake_pins);
+
struct pi3usb9281_config pi3usb9281_chips[] = {
{
.i2c_port = I2C_PORT_USB_CHARGER_1,
diff --git a/board/kunimitsu/board.h b/board/kunimitsu/board.h
index f0e2419d6c..c0752b4c7f 100644
--- a/board/kunimitsu/board.h
+++ b/board/kunimitsu/board.h
@@ -97,7 +97,6 @@
/* Modules we want to exclude */
#undef CONFIG_CONSOLE_CMDHELP
#undef CONFIG_PECI
-#undef CONFIG_WAKE_PIN
#ifndef __ASSEMBLER__
diff --git a/board/mec1322_evb/board.c b/board/mec1322_evb/board.c
index e6d4add57e..55bed1a5cb 100644
--- a/board/mec1322_evb/board.c
+++ b/board/mec1322_evb/board.c
@@ -44,3 +44,9 @@ const struct i2c_port_t i2c_ports[] = {
{"port0", MEC1322_I2C0_0, 100},
};
const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports);
+
+const enum gpio_signal hibernate_wake_pins[] = {
+ GPIO_S1,
+};
+
+const int hibernate_wake_pins_used = ARRAY_SIZE(hibernate_wake_pins);
diff --git a/board/mec1322_evb/board.h b/board/mec1322_evb/board.h
index 8fbc0dcf50..991e52e667 100644
--- a/board/mec1322_evb/board.h
+++ b/board/mec1322_evb/board.h
@@ -13,7 +13,6 @@
#define CONFIG_WATCHDOG_HELP
#define CONFIG_FANS 1
#define CONFIG_ADC
-#define CONFIG_WAKE_PIN GPIO_S1
#define CONFIG_SPI_FLASH_SIZE 0x00800000
#define CONFIG_SPI_FLASH_W25Q64
#define CONFIG_SPI_PORT 0
diff --git a/board/strago/board.c b/board/strago/board.c
index ac5a8a5c7f..8dd5c0e1d9 100644
--- a/board/strago/board.c
+++ b/board/strago/board.c
@@ -65,6 +65,11 @@ const struct i2c_port_t i2c_ports[] = {
};
const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports);
+const enum gpio_signal hibernate_wake_pins[] = {
+};
+
+const int hibernate_wake_pins_used;
+
/*
* Temperature sensors data; must be in same order as enum temp_sensor_id.
* Sensor index and name must match those present in coreboot:
diff --git a/board/strago/board.h b/board/strago/board.h
index cf5132a61c..9225b38c17 100644
--- a/board/strago/board.h
+++ b/board/strago/board.h
@@ -77,7 +77,6 @@
#undef CONFIG_PECI
#undef CONFIG_FANS
#undef CONFIG_ADC
-#undef CONFIG_WAKE_PIN
#ifndef __ASSEMBLER__
#include "gpio_signal.h"
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;
diff --git a/include/config.h b/include/config.h
index 8636a07495..2606fd2787 100644
--- a/include/config.h
+++ b/include/config.h
@@ -1690,10 +1690,6 @@
/* Support computing hash of code for verified boot */
#undef CONFIG_VBOOT_HASH
-/******************************************************************************/
-/* GPIO pin to wake from hibernate. */
-#undef CONFIG_WAKE_PIN
-
/*****************************************************************************/
/* Watchdog config */