diff options
author | Yicheng Li <yichengli@chromium.org> | 2021-03-02 15:38:17 -0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-04-02 23:16:12 +0000 |
commit | ac08c9d1dbc9f587df3ee6b15d58c0203f7e356e (patch) | |
tree | 04cd12d6787ce1b0b99b1d4e0aff504ccfa2c35e /board | |
parent | e3cbbc3461c83d2d97b78447c53db1c6540cb3be (diff) | |
download | chrome-ec-ac08c9d1dbc9f587df3ee6b15d58c0203f7e356e.tar.gz |
fpsensor: Support building firmware that works for both sensors
This is a refactoring to allow building FPMCU firmware that works for
one FPC sensor and one ELAN sensor.
1. When both drivers implement our common functions, e.g. fp_sensor_init(),
rename them to fp_sensor_init_fpc() and fp_sensor_init_elan().
2. There are a few functions implemented not in FPC driver but in FPC
private library, e.g. fp_sensor_finger_status(). I kept this as-is for
FPC but renamed the one in ELAN driver to fp_sensor_finger_status_elan()
3. If building for ELAN, need to hardcode elan=1 in hatch_fp/board.c
because the sensor type GPIO always says FPC.
BRANCH=none
BUG=b:175158241
TEST=make run-fpsensor; make run-fpsensor_status;
make run-fpsensor_crypto
TEST=make -j BOARD=dartmonkey
TEST=add CONFIG_FP_SENSOR_ELAN515 to board/hatch_fp/board.h;
make -j BOARD=bloonchipper
Firmware binary fully works on Dragonair (FPC) and Voema (ELAN)
TEST=run device tests with http://crrev/c/2750547 and
http://crrev/i/3654297 on Dragonclaw, all pass
Change-Id: I789090dbdfe35ac6aefd6a629fa4c7bde89dc437
Signed-off-by: Yicheng Li <yichengli@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2727971
Reviewed-by: Tom Hughes <tomhughes@chromium.org>
Commit-Queue: Tom Hughes <tomhughes@chromium.org>
Diffstat (limited to 'board')
-rw-r--r-- | board/hatch_fp/board_rw.c | 21 | ||||
-rw-r--r-- | board/nocturne_fp/board_rw.c | 4 |
2 files changed, 25 insertions, 0 deletions
diff --git a/board/hatch_fp/board_rw.c b/board/hatch_fp/board_rw.c index 40ab5092a7..a3dbcbf84f 100644 --- a/board/hatch_fp/board_rw.c +++ b/board/hatch_fp/board_rw.c @@ -5,7 +5,10 @@ #include "common.h" #include "console.h" +#include "fpsensor.h" #include "fpsensor_detect.h" +#include "fpsensor_elan.h" +#include "fpsensor_fpc.h" #include "gpio.h" #include "hooks.h" #include "registers.h" @@ -76,6 +79,24 @@ static void configure_fp_sensor_spi(void) void board_init_rw(void) { enum fp_transport_type ret_transport = get_fp_transport_type(); + enum fp_sensor_type sensor_type = get_fp_sensor_type(); + + if (sensor_type == FP_SENSOR_TYPE_ELAN) { + if (IS_ENABLED(CONFIG_FP_SENSOR_ELAN80) || + IS_ENABLED(CONFIG_FP_SENSOR_ELAN515)) { + fp_driver = &fp_driver_elan; + } + } else if (sensor_type == FP_SENSOR_TYPE_FPC) { + if (IS_ENABLED(CONFIG_FP_SENSOR_FPC1025) || + IS_ENABLED(CONFIG_FP_SENSOR_FPC1035) || + IS_ENABLED(CONFIG_FP_SENSOR_FPC1145)) { + fp_driver = &fp_driver_fpc; + } + } + + if (fp_driver == NULL) { + ccprints("Failed to get sensor type!"); + } if (ret_transport == FP_TRANSPORT_TYPE_UART) { /* diff --git a/board/nocturne_fp/board_rw.c b/board/nocturne_fp/board_rw.c index d0927f29ec..cafe972e8a 100644 --- a/board/nocturne_fp/board_rw.c +++ b/board/nocturne_fp/board_rw.c @@ -5,7 +5,9 @@ #include "common.h" #include "console.h" +#include "fpsensor.h" #include "fpsensor_detect.h" +#include "fpsensor_fpc.h" #include "gpio.h" #include "hooks.h" #include "registers.h" @@ -98,4 +100,6 @@ void board_init_rw(void) gpio_enable_interrupt(GPIO_PCH_SLP_S0_L); /* enable the SPI slave interface if the PCH is up */ hook_call_deferred(&ap_deferred_data, 0); + + fp_driver = &fp_driver_fpc; } |