diff options
author | Tom Hughes <tomhughes@chromium.org> | 2021-01-28 16:47:56 -0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-02-12 02:08:45 +0000 |
commit | 544eb013c83fbd2fcb3ea485cb6e271ece931083 (patch) | |
tree | afc86af1918c6cfc548733b570383ebcba27e6e5 | |
parent | d38b8844e8d8cff84bafeb1589aceb1121a2b666 (diff) | |
download | chrome-ec-544eb013c83fbd2fcb3ea485cb6e271ece931083.tar.gz |
dartmonkey: Use SPI_SEL to configure fingerprint sensor SPI
BRANCH=none
BUG=b:177908650
TEST=Fingerprint sensor works on Icetower v0.1
TEST=Fingerprint sensor works on nocturne
Signed-off-by: Tom Hughes <tomhughes@chromium.org>
Change-Id: Ie9a7acb9bf4de1295fd245eb55e12ff8e7d2524a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2645691
Reviewed-by: Craig Hesling <hesling@chromium.org>
-rw-r--r-- | board/hatch_fp/board.c | 2 | ||||
-rw-r--r-- | board/nocturne_fp/board_rw.c | 16 | ||||
-rw-r--r-- | board/nocturne_fp/gpio_rw.inc | 10 | ||||
-rw-r--r-- | board/nucleo-dartmonkey/board.c | 2 | ||||
-rw-r--r-- | include/spi.h | 6 |
5 files changed, 28 insertions, 8 deletions
diff --git a/board/hatch_fp/board.c b/board/hatch_fp/board.c index 51eeb4ce99..8bdc4cf190 100644 --- a/board/hatch_fp/board.c +++ b/board/hatch_fp/board.c @@ -67,7 +67,7 @@ void slp_event(enum gpio_signal signal) #include "gpio_list.h" /* SPI devices */ -const struct spi_device_t spi_devices[] = { +struct spi_device_t spi_devices[] = { /* Fingerprint sensor (SCLK at 4Mhz) */ { .port = CONFIG_SPI_FP_PORT, .div = 3, .gpio_cs = GPIO_SPI2_NSS } }; diff --git a/board/nocturne_fp/board_rw.c b/board/nocturne_fp/board_rw.c index 9c5454ef21..d0927f29ec 100644 --- a/board/nocturne_fp/board_rw.c +++ b/board/nocturne_fp/board_rw.c @@ -20,7 +20,7 @@ #endif /* SPI devices */ -const struct spi_device_t spi_devices[] = { +struct spi_device_t spi_devices[] = { /* Fingerprint sensor (SCLK at 4Mhz) */ { .port = CONFIG_SPI_FP_PORT, .div = 3, .gpio_cs = GPIO_SPI4_NSS } }; @@ -58,15 +58,23 @@ void slp_event(enum gpio_signal signal) hook_call_deferred(&ap_deferred_data, 0); } -static void spi_configure(void) +static void spi_configure(enum fp_sensor_spi_select spi_select) { - gpio_config_module(MODULE_SPI_MASTER, 1); + if (spi_select == FP_SENSOR_SPI_SELECT_DEVELOPMENT) { + /* SPI4 master to sensor: PE12/13/14 (CLK/MISO/MOSI) */ + gpio_set_flags_by_mask(GPIO_E, 0x7000, 0); + gpio_set_alternate_function(GPIO_E, 0x7000, GPIO_ALT_SPI); + } else { + gpio_config_module(MODULE_SPI_MASTER, 1); + } /* Set all SPI master signal pins to very high speed: pins E2/4/5/6 */ STM32_GPIO_OSPEEDR(GPIO_E) |= 0x00003f30; /* Enable clocks to SPI4 module (master) */ STM32_RCC_APB2ENR |= STM32_RCC_PB2_SPI4; + if (spi_select == FP_SENSOR_SPI_SELECT_DEVELOPMENT) + spi_devices[0].gpio_cs = GPIO_SPI4_ALT_NSS; spi_enable(&spi_devices[0], 1); } @@ -76,7 +84,7 @@ void board_init_rw(void) ccprints("FP_SPI_SEL: %s", fp_sensor_spi_select_to_str(spi_select)); - spi_configure(); + spi_configure(spi_select); ccprints("TRANSPORT_SEL: %s", fp_transport_type_to_str(get_fp_transport_type())); diff --git a/board/nocturne_fp/gpio_rw.inc b/board/nocturne_fp/gpio_rw.inc index 06dd93c9e3..ad3ebffdd5 100644 --- a/board/nocturne_fp/gpio_rw.inc +++ b/board/nocturne_fp/gpio_rw.inc @@ -33,7 +33,15 @@ GPIO(FP_SPI_SEL, PIN(E, 1), GPIO_INPUT | GPIO_PULL_UP) GPIO(DIVIDER_HIGHSIDE, PIN(B, 8), GPIO_OUT_LOW) GPIO(FP_RST_ODL, PIN(E, 0), GPIO_OUT_HIGH) GPIO(SPI4_NSS, PIN(E, 4), GPIO_OUT_HIGH) +GPIO(SPI4_ALT_NSS, PIN(E, 11), GPIO_OUT_HIGH) GPIO(USER_PRES_L, PIN(C, 5), GPIO_ODR_HIGH) -/* SPI4 master to sensor: PE2/5/6 (CLK/MISO/MOSI) */ +/* Default SPI4 master to sensor: PE2/5/6 (CLK/MISO/MOSI) */ ALTERNATE(PIN_MASK(E, 0x0064), GPIO_ALT_SPI, MODULE_SPI_MASTER, 0) + +/* See board_rw.c for the alternate configuration that we use on + * development boards, which overrides the UNUSED values below. + */ +UNUSED(PIN(E, 12)) /* Alternate SPI4 master to sensor CLK */ +UNUSED(PIN(E, 13)) /* Alternate SPI4 master to sensor MISO */ +UNUSED(PIN(E, 14)) /* Alternate SPI4 master to sensor MOSI */ diff --git a/board/nucleo-dartmonkey/board.c b/board/nucleo-dartmonkey/board.c index 5e81b37a6b..a201f69ec5 100644 --- a/board/nucleo-dartmonkey/board.c +++ b/board/nucleo-dartmonkey/board.c @@ -60,7 +60,7 @@ void fps_event(enum gpio_signal signal) #include "gpio_list.h" /* SPI devices */ -const struct spi_device_t spi_devices[] = { +struct spi_device_t spi_devices[] = { /* Fingerprint sensor (SCLK at 4Mhz) */ { .port = CONFIG_SPI_FP_PORT, .div = 3, .gpio_cs = GPIO_SPI4_NSS } }; diff --git a/include/spi.h b/include/spi.h index ae97174ec5..f1c995fbf6 100644 --- a/include/spi.h +++ b/include/spi.h @@ -47,7 +47,11 @@ struct spi_device_t { enum gpio_signal gpio_cs; }; -extern const struct spi_device_t spi_devices[]; +extern +#ifndef CONFIG_FINGERPRINT_MCU + const +#endif + struct spi_device_t spi_devices[]; extern const unsigned int spi_devices_used; /* |