diff options
-rw-r--r-- | board/nocturne_fp/board.c | 37 | ||||
-rw-r--r-- | board/nocturne_fp/board.h | 2 | ||||
-rw-r--r-- | board/nocturne_fp/board_ro.c | 77 | ||||
-rw-r--r-- | board/nocturne_fp/board_rw.c | 16 | ||||
-rw-r--r-- | board/nocturne_fp/board_rw.h | 3 | ||||
-rw-r--r-- | board/nocturne_fp/build.mk | 6 | ||||
-rw-r--r-- | board/nocturne_fp/gpio.inc | 3 | ||||
-rw-r--r-- | board/nocturne_fp/gpio_rw.inc | 3 |
8 files changed, 102 insertions, 45 deletions
diff --git a/board/nocturne_fp/board.c b/board/nocturne_fp/board.c deleted file mode 100644 index 819c1c53e0..0000000000 --- a/board/nocturne_fp/board.c +++ /dev/null @@ -1,37 +0,0 @@ -/* Copyright 2017 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ -/* Meowth Fingerprint MCU configuration */ - -#include "common.h" -#include "hooks.h" -#include "registers.h" -#include "spi.h" -#include "system.h" -#include "task.h" - -/** - * Disable restricted commands when the system is locked. - * - * @see console.h system.c - */ -int console_is_restricted(void) -{ - return system_is_locked(); -} - -#include "gpio_list.h" - -/* Initialize board. */ -static void board_init(void) -{ - if (IS_ENABLED(SECTION_IS_RW)) { - board_init_rw(); - } else { - /* No suspend-based power management in RO. */ - disable_sleep(SLEEP_MASK_AP_RUN); - hook_notify(HOOK_CHIPSET_RESUME); - } -} -DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT); diff --git a/board/nocturne_fp/board.h b/board/nocturne_fp/board.h index c30b4b76e0..6da68130df 100644 --- a/board/nocturne_fp/board.h +++ b/board/nocturne_fp/board.h @@ -186,6 +186,8 @@ #include "gpio_signal.h" #include "board_rw.h" +void slp_event(enum gpio_signal signal); + #endif /* !__ASSEMBLER__ */ #endif /* __BOARD_H */ diff --git a/board/nocturne_fp/board_ro.c b/board/nocturne_fp/board_ro.c new file mode 100644 index 0000000000..7f20002435 --- /dev/null +++ b/board/nocturne_fp/board_ro.c @@ -0,0 +1,77 @@ +/* Copyright 2017 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ +/* Meowth Fingerprint MCU configuration */ + +#include "common.h" +#include "hooks.h" +#include "registers.h" +#include "spi.h" +#include "system.h" +#include "task.h" + +#ifndef SECTION_IS_RO +#error "This file should only be built for RO." +#endif + + +/** + * Disable restricted commands when the system is locked. + * + * @see console.h system.c + */ +int console_is_restricted(void) +{ + return system_is_locked(); +} + +#include "gpio_list.h" + +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 X 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); + + if (running) { /* AP is S0 */ + disable_sleep(SLEEP_MASK_AP_RUN); + hook_notify(HOOK_CHIPSET_RESUME); + } else { /* AP is suspend/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); +} + +void board_init(void) +{ + /* Enable interrupt on PCH power signals */ + gpio_enable_interrupt(GPIO_SLP_ALT_L); + gpio_enable_interrupt(GPIO_SLP_L); + + /* + * 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); diff --git a/board/nocturne_fp/board_rw.c b/board/nocturne_fp/board_rw.c index 657f155a4a..0a7b38b97d 100644 --- a/board/nocturne_fp/board_rw.c +++ b/board/nocturne_fp/board_rw.c @@ -19,6 +19,18 @@ #error "This file should only be built for RW." #endif +/** + * Disable restricted commands when the system is locked. + * + * @see console.h system.c + */ +int console_is_restricted(void) +{ + return system_is_locked(); +} + +#include "gpio_list.h" + /* SPI devices */ struct spi_device_t spi_devices[] = { /* Fingerprint sensor (SCLK at 4Mhz) */ @@ -84,7 +96,7 @@ static void spi_configure(enum fp_sensor_spi_select spi_select) spi_enable(&spi_devices[0], 1); } -void board_init_rw(void) +void board_init(void) { enum fp_sensor_spi_select spi_select = get_fp_sensor_spi_select(); @@ -111,6 +123,7 @@ void board_init_rw(void) /* Enable interrupt on PCH power signals */ gpio_enable_interrupt(gpio_slp_alt_l); gpio_enable_interrupt(GPIO_SLP_L); + /* * Enable the SPI slave interface if the PCH is up. * Do not use hook_call_deferred(), because ap_deferred() will be @@ -118,3 +131,4 @@ void board_init_rw(void) */ ap_deferred(); } +DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT); diff --git a/board/nocturne_fp/board_rw.h b/board/nocturne_fp/board_rw.h index 29e304f115..6ef7cc29b4 100644 --- a/board/nocturne_fp/board_rw.h +++ b/board/nocturne_fp/board_rw.h @@ -7,11 +7,8 @@ #define __CROS_EC_BOARD_NOCTURNE_FP_BOARD_RW_H void fps_event(enum gpio_signal signal); -void slp_event(enum gpio_signal signal); /* Defined in ro_workarounds.c */ void wp_event(enum gpio_signal signal); -void board_init_rw(void); - #endif /* __CROS_EC_BOARD_NOCTURNE_FP_BOARD_RW_H */ diff --git a/board/nocturne_fp/build.mk b/board/nocturne_fp/build.mk index f6fd9fe3d9..2091acc101 100644 --- a/board/nocturne_fp/build.mk +++ b/board/nocturne_fp/build.mk @@ -9,8 +9,12 @@ CHIP:=stm32 CHIP_FAMILY:=stm32h7 CHIP_VARIANT:=stm32h7x3 +# Don't forget that the board build.mk is included more than once to allow +# conditional variables to be realized. This means that we need to redefine all +# variable or the "+=" lines will compound. +board-y= board-rw=ro_workarounds.o board_rw.o -board-y=board.o +board-ro=board_ro.o # If we're mocking the sensor detection for testing (so we can test # sensor/transport permutations in the unit tests), don't build the real sensor # detection. diff --git a/board/nocturne_fp/gpio.inc b/board/nocturne_fp/gpio.inc index 7e90ef0da4..ff94e4f8f7 100644 --- a/board/nocturne_fp/gpio.inc +++ b/board/nocturne_fp/gpio.inc @@ -5,6 +5,9 @@ */ /* Interrupts */ +GPIO_INT(SLP_L, PIN(D,13), GPIO_INT_BOTH, slp_event) +GPIO_INT(SLP_ALT_L, PIN(A,11), GPIO_INT_BOTH, slp_event) +GPIO_INT(SLP_ALT_DEV_L, PIN(D,14), GPIO_INT_BOTH, slp_event) GPIO_INT(SPI1_NSS, PIN(A, 4), GPIO_INPUT, spi_event) /* Inputs */ diff --git a/board/nocturne_fp/gpio_rw.inc b/board/nocturne_fp/gpio_rw.inc index 65036abe14..088ce22f32 100644 --- a/board/nocturne_fp/gpio_rw.inc +++ b/board/nocturne_fp/gpio_rw.inc @@ -10,9 +10,6 @@ /* Interrupts */ GPIO_INT(FPS_INT, PIN(A, 0), GPIO_INT_RISING, fps_event) -GPIO_INT(SLP_L, PIN(D,13), GPIO_INT_BOTH, slp_event) -GPIO_INT(SLP_ALT_L, PIN(A,11), GPIO_INT_BOTH, slp_event) -GPIO_INT(SLP_ALT_DEV_L, PIN(D,14), GPIO_INT_BOTH, slp_event) #ifdef APPLY_RESET_LOOP_FIX GPIO_INT(WP, PIN(B, 7), GPIO_INT_BOTH, wp_event) |