summaryrefslogtreecommitdiff
path: root/board/hatch_fp/board.c
diff options
context:
space:
mode:
authorCraig Hesling <hesling@chromium.org>2021-07-07 22:23:22 -0700
committerCommit Bot <commit-bot@chromium.org>2021-08-09 18:45:02 +0000
commit580dad3d9956d55565ed5db9e5de9851df9c437b (patch)
tree102a2295602f423675250506a5eadf320edd1be1 /board/hatch_fp/board.c
parent8a9102efc3506b14b0ce275d0e2a05653587cfc5 (diff)
downloadchrome-ec-580dad3d9956d55565ed5db9e5de9851df9c437b.tar.gz
bloonchipper: Reintroduce sleep lines to RO
Change https://crrev.com/c/2673909 removed the sleep lines from RO in an effort to minimize the RO complexity. Most notably, this isolated the deep-sleep/low-power-idle logic to RW only. Unfortunately, the sleep lines also control whether the SPI host interface is listening, which allows it to ignore spurious communication. It seems safer to reinstate the the sleep line with low power idle active and directly disable CONFIG_LOW_POWER_IDLE in subsequent CL. We reinstate the sleep line gpio logic from the following: https://crrev.com/c5545464431669029f42829d542fa491d767ee5f/board/hatch_fp/board.c This is the parent commit to the CL that refactors the sleep lines. BRANCH=none BUG=b:178746753 TEST=make -j tests-bloonchipper TEST=# Connect servo_micro to a dragonclaw board. make proj-bloonchipper -j sudo servod --board=dragonclaw ./util/flash_ec --board=bloonchipper dut-control fpmcu_slp:off fpmcu_slp_alt:off dut-control pp3300_dx_mcu_mw # Should be around 20mw dut-control fpmcu_slp:on fpmcu_slp_alt:off dut-control pp3300_dx_mcu_mw # Should be less the 5mw dut-control fpmcu_slp:off fpmcu_slp_alt:on dut-control pp3300_dx_mcu_mw # Should be less the 5mw dut-control fpmcu_slp:on fpmcu_slp_alt:on dut-control pp3300_dx_mcu_mw # Should be less the 5mw dut-control fpmcu_slp:off fpmcu_slp_alt:off minicom -D$(dut-control -o raw_fpmcu_console_uart_pty) > reboot ro # Ctrl-A Q dut-control fpmcu_slp:off fpmcu_slp_alt:off dut-control pp3300_dx_mcu_mw # Should be around 20mw dut-control fpmcu_slp:on fpmcu_slp_alt:off dut-control pp3300_dx_mcu_mw # Should be less the 5mw dut-control fpmcu_slp:off fpmcu_slp_alt:on dut-control pp3300_dx_mcu_mw # Should be less the 5mw dut-control fpmcu_slp:on fpmcu_slp_alt:on dut-control pp3300_dx_mcu_mw # Should be less the 5mw dut-control fpmcu_slp:off fpmcu_slp_alt:off minicom -D$(dut-control -o raw_fpmcu_console_uart_pty) > reboot > fpenroll > fpmatch > reboot # Ctrl-A Q Signed-off-by: Craig Hesling <hesling@chromium.org> Change-Id: Ibb9e1aac4d242a70ed39e043daef39bab9ccc4d6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3078823 Reviewed-by: Josie Nordrum <josienordrum@google.com>
Diffstat (limited to 'board/hatch_fp/board.c')
-rw-r--r--board/hatch_fp/board.c66
1 files changed, 62 insertions, 4 deletions
diff --git a/board/hatch_fp/board.c b/board/hatch_fp/board.c
index c2a2e32107..b48dce2b7e 100644
--- a/board/hatch_fp/board.c
+++ b/board/hatch_fp/board.c
@@ -26,6 +26,45 @@ int console_is_restricted(void)
#include "gpio_list.h"
+/*
+ * Some platforms have a broken SLP_S0_L signal (stuck to 0 in S0)
+ * if set, ignore it and only uses SLP_S3_L for the AP state.
+ */
+static bool broken_slp;
+
+static void ap_deferred(void)
+{
+ /*
+ * Behavior:
+ * AP Active (ex. Intel S0): SLP_L is 1
+ * AP Suspend (ex. Intel S0ix): SLP_L is 0
+ * The alternative SLP_ALT_L should be pulled high at all the times.
+ *
+ * Legacy Intel behavior:
+ * in S3: SLP_ALT_L is 0 and SLP_L is X.
+ * in S0ix: SLP_ALT_L is 1 and SLP_L is 0.
+ * in S0: SLP_ALT_L is 1 and SLP_L is 1.
+ * in S5/G3, the FP MCU should not be running.
+ */
+ int running = gpio_get_level(GPIO_SLP_ALT_L) &&
+ (gpio_get_level(GPIO_SLP_L) || broken_slp);
+
+ if (running) { /* S0 */
+ disable_sleep(SLEEP_MASK_AP_RUN);
+ hook_notify(HOOK_CHIPSET_RESUME);
+ } else { /* S0ix/S3 */
+ hook_notify(HOOK_CHIPSET_SUSPEND);
+ enable_sleep(SLEEP_MASK_AP_RUN);
+ }
+}
+DECLARE_DEFERRED(ap_deferred);
+
+/* PCH power state changes */
+void slp_event(enum gpio_signal signal)
+{
+ hook_call_deferred(&ap_deferred_data, 0);
+}
+
static void board_init_transport(void)
{
enum fp_transport_type ret_transport = get_fp_transport_type();
@@ -35,6 +74,15 @@ static void board_init_transport(void)
/* Initialize transport based on bootstrap */
switch (ret_transport) {
case FP_TRANSPORT_TYPE_UART:
+ /*
+ * The Zork variants currently have a broken SLP_S0_L signal
+ * (stuck to 0 in S0). For now, unconditionally ignore it here
+ * as they are the only UART users and the AP has no S0ix state.
+ * TODO(b/174695987) once the RW AP firmware has been updated
+ * on all those machines, remove this workaround.
+ */
+ broken_slp = true;
+
/* Check if CONFIG_USART_HOST_COMMAND is enabled. */
if (IS_ENABLED(CONFIG_USART_HOST_COMMAND))
usart_host_command_init();
@@ -61,13 +109,23 @@ static void board_init_transport(void)
/* Initialize board. */
static void board_init(void)
{
- /* Run until the first S3 entry.
- * No suspend-based power management in RO.
- */
+ /* Run until the first S3 entry */
disable_sleep(SLEEP_MASK_AP_RUN);
- hook_notify(HOOK_CHIPSET_RESUME);
+
board_init_transport();
+
+ /* Enable interrupt on PCH power signals */
+ gpio_enable_interrupt(GPIO_SLP_ALT_L);
+ gpio_enable_interrupt(GPIO_SLP_L);
+
if (IS_ENABLED(SECTION_IS_RW))
board_init_rw();
+
+ /*
+ * Enable the SPI slave interface if the PCH is up.
+ * Do not use hook_call_deferred(), because ap_deferred() will be
+ * called after tasks with priority higher than HOOK task (very late).
+ */
+ ap_deferred();
}
DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT);