diff --git a/board/eve_fp/board.c b/board/eve_fp/board.c index 5846f304ee..7ad2ab50b4 100644 --- a/board/eve_fp/board.c +++ b/board/eve_fp/board.c @@ -7,7 +7,9 @@ #include "console.h" #include "gpio.h" #include "hooks.h" +#include "host_command.h" #include "spi.h" +#include "system.h" #include "registers.h" #include "gpio_list.h" @@ -41,3 +43,35 @@ static void board_init(void) hook_notify(HOOK_CHIPSET_RESUME); } DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT); + +static int fp_command_passthru(struct host_cmd_handler_args *args) +{ + const struct ec_params_fp_passthru *params = args->params; + void *out = args->response; + int rc; + int ret = EC_RES_SUCCESS; + + if (system_is_locked()) + return EC_RES_ACCESS_DENIED; + + if (params->len > args->params_size + + offsetof(struct ec_params_fp_passthru, data) || + params->len > args->response_max) + return EC_RES_INVALID_PARAM; + + rc = spi_transaction_async(&spi_devices[0], params->data, + params->len, out, SPI_READBACK_ALL); + if (params->flags & EC_FP_FLAG_NOT_COMPLETE) + rc |= spi_transaction_wait(&spi_devices[0]); + else + rc |= spi_transaction_flush(&spi_devices[0]); + + if (rc == EC_ERROR_TIMEOUT) + ret = EC_RES_TIMEOUT; + else if (rc) + ret = EC_RES_ERROR; + + args->response_size = params->len; + return ret; +} +DECLARE_HOST_COMMAND(EC_CMD_FP_PASSTHRU, fp_command_passthru, EC_VER_MASK(0)); diff --git a/include/ec_commands.h b/include/ec_commands.h index ca91290fcb..6d641b5657 100644 --- a/include/ec_commands.h +++ b/include/ec_commands.h @@ -4039,6 +4039,20 @@ struct __ec_align2 ec_response_pd_chip_info { #define EC_CMD_CR51_BASE 0x0300 #define EC_CMD_CR51_LAST 0x03FF +/*****************************************************************************/ +/* Fingerprint MCU commands: range 0x0400-0x040x */ + +/* Fingerprint SPI sensor passthru command */ +#define EC_CMD_FP_PASSTHRU 0x0400 + +#define EC_FP_FLAG_NOT_COMPLETE 0x1 + +struct __ec_align2 ec_params_fp_passthru { + uint16_t len; /* Number of bytes to write then read */ + uint16_t flags; /* EC_FP_FLAG_xxx */ + uint8_t data[]; /* Data to send */ +}; + /*****************************************************************************/ /* * Reserve a range of host commands for board-specific, experimental, or