summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Staaf <robotboy@chromium.org>2016-03-02 13:42:18 -0800
committerchrome-bot <chrome-bot@chromium.org>2016-03-21 13:16:35 -0700
commitfa1653d240e7635b1cbf03e1e786f16a4ea7e95f (patch)
tree4d41752eb464f4a254ecc5095d2adfa4bc93da9c
parent952b2a54e12bfbf6635a5eb225ad777814ca9c92 (diff)
downloadchrome-ec-fa1653d240e7635b1cbf03e1e786f16a4ea7e95f.tar.gz
GPIO: Rename and move board_set_gpio_hibernate_state
This function is no longer GPIO specific and fits better as part of the system API, so this moves it there and renames it board_hibernate_late. Signed-off-by: Anton Staaf <robotboy@chromium.org> BRANCH=None BUG=None TEST=make buildall -j Change-Id: I39d3ecedadaaa22142cc82c79f5d25c891f3f38c Reviewed-on: https://chromium-review.googlesource.com/330124 Commit-Ready: Anton Staaf <robotboy@chromium.org> Tested-by: Anton Staaf <robotboy@chromium.org> Reviewed-by: Shawn N <shawnn@chromium.org>
-rw-r--r--board/glados/board.c2
-rw-r--r--board/wheatley/board.c2
-rw-r--r--chip/mec1322/system.c4
-rw-r--r--chip/npcx/system.c11
-rw-r--r--include/gpio.h3
-rw-r--r--include/system.h8
6 files changed, 16 insertions, 14 deletions
diff --git a/board/glados/board.c b/board/glados/board.c
index 70ed60a5bb..37e00dbc06 100644
--- a/board/glados/board.c
+++ b/board/glados/board.c
@@ -428,7 +428,7 @@ static void board_chipset_suspend(void)
}
DECLARE_HOOK(HOOK_CHIPSET_SUSPEND, board_chipset_suspend, HOOK_PRIO_DEFAULT);
-void board_set_gpio_hibernate_state(void)
+void board_hibernate_late(void)
{
/* Turn off LEDs in hibernate */
gpio_set_level(GPIO_CHARGE_LED_1, 0);
diff --git a/board/wheatley/board.c b/board/wheatley/board.c
index 537214b0d7..987bc6db6d 100644
--- a/board/wheatley/board.c
+++ b/board/wheatley/board.c
@@ -376,7 +376,7 @@ static void board_chipset_suspend(void)
}
DECLARE_HOOK(HOOK_CHIPSET_SUSPEND, board_chipset_suspend, HOOK_PRIO_DEFAULT);
-void board_set_gpio_hibernate_state(void)
+void board_hibernate_late(void)
{
int i;
const uint32_t hibernate_pins[][2] = {
diff --git a/chip/mec1322/system.c b/chip/mec1322/system.c
index c199332f57..0090c6b862 100644
--- a/chip/mec1322/system.c
+++ b/chip/mec1322/system.c
@@ -253,8 +253,8 @@ void system_hibernate(uint32_t seconds, uint32_t microseconds)
CPU_SCB_SYSCTRL |= 0x4;
/* Setup GPIOs for hibernate */
- if (board_set_gpio_hibernate_state)
- board_set_gpio_hibernate_state();
+ if (board_hibernate_late)
+ board_hibernate_late();
#ifdef CONFIG_USB_PD_PORT_COUNT
/*
diff --git a/chip/npcx/system.c b/chip/npcx/system.c
index dd4ca3dbed..270531226a 100644
--- a/chip/npcx/system.c
+++ b/chip/npcx/system.c
@@ -315,10 +315,6 @@ void system_set_gpios_and_wakeup_inputs_hibernate(void)
/* Enable wake-up inputs of hibernate_wake_pins array */
for (i = 0; i < hibernate_wake_pins_used; i++)
gpio_reset(hibernate_wake_pins[i]);
-
- /* board-level function to set GPIOs state in hibernate */
- if (board_set_gpio_hibernate_state)
- board_set_gpio_hibernate_state();
}
/**
@@ -383,6 +379,13 @@ void __enter_hibernate(uint32_t seconds, uint32_t microseconds)
*/
system_set_gpios_and_wakeup_inputs_hibernate();
+ /*
+ * Give the board a chance to do any late stage hibernation work.
+ * This is likely going to configure GPIOs for hibernation.
+ */
+ if (board_hibernate_late)
+ board_hibernate_late();
+
/* Clear all pending IRQ otherwise wfi will have no affect */
for (i = NPCX_IRQ_0 ; i < NPCX_IRQ_COUNT ; i++)
task_clear_pending_irq(i);
diff --git a/include/gpio.h b/include/gpio.h
index 741f41f3d7..52638e4222 100644
--- a/include/gpio.h
+++ b/include/gpio.h
@@ -225,7 +225,4 @@ void gpio_set_flags_by_mask(uint32_t port, uint32_t mask, uint32_t flags);
*/
void gpio_set_alternate_function(uint32_t port, uint32_t mask, int func);
-/* Optional board-level function to set hibernate GPIO states. */
-void board_set_gpio_hibernate_state(void) __attribute__((weak));
-
#endif /* __CROS_EC_GPIO_H */
diff --git a/include/system.h b/include/system.h
index d3c720a12c..b47cbac240 100644
--- a/include/system.h
+++ b/include/system.h
@@ -268,11 +268,13 @@ int system_set_vbnvcontext(const uint8_t *block);
void system_hibernate(uint32_t seconds, uint32_t microseconds);
/**
- * Optional board-level callback function called prior to initiating chip-level
- * hibernate sequence. This function may or may not return, depending if the
- * board implements an alternate hibernate method.
+ * Optional board-level callback functions called before and after initiating
+ * chip-level hibernate sequence. These function may or may not return,
+ * depending if the board implements an alternate hibernate method. The _late
+ * version is called after interrupts are disabled.
*/
void board_hibernate(void) __attribute__((weak));
+void board_hibernate_late(void) __attribute__((weak));
/* Minimum duration to get proper hibernation */
#define SYSTEM_HIB_MINIMUM_DURATION 0, 150000