bloonchipper: Add transport and sensor detection
bloonchipper (aka hatch_fp aka dragonclaw) has a voltage divider that can be used to select the sensor and the transport type. Supported designs: * Dragonclaw rev 0.2 (green with Google logo): go/dragonclaw-schematic-rev-0.2 * Hatch reference v3.0: go/hatch-schematic-rev-3.0 The selection lines are connected to ADC inputs, so a future change will use the ADC to allow more than two transports or sensors. BRANCH=none BUG=b:147113851 TEST=flash dragonclaw rev 0.2 and view console output Change-Id: If2e4b150d34cfe41477be528c70e1645043d4d82 Signed-off-by: Tom Hughes <tomhughes@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1986322 Reviewed-by: Craig Hesling <hesling@chromium.org>
This commit is contained in:
parent
ceaa059934
commit
0b838e162b
|
@ -9,6 +9,6 @@ CHIP:=stm32
|
|||
CHIP_FAMILY:=stm32f4
|
||||
CHIP_VARIANT:=stm32f412
|
||||
|
||||
board-y=board.o
|
||||
board-y=board.o fpsensor_detect.o
|
||||
|
||||
test-list-y=aes sha256 sha256_unrolled
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
/* Copyright 2020 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.
|
||||
*/
|
||||
|
||||
#include "fpsensor_detect.h"
|
||||
#include "gpio.h"
|
||||
#include "timer.h"
|
||||
|
||||
enum fp_sensor_type get_fp_sensor_type(void)
|
||||
{
|
||||
enum fp_sensor_type ret;
|
||||
|
||||
gpio_set_level(GPIO_DIVIDER_HIGHSIDE, 1);
|
||||
usleep(1);
|
||||
switch (gpio_get_level(GPIO_FP_SENSOR_SEL)) {
|
||||
case 0:
|
||||
ret = FP_SENSOR_TYPE_ELAN;
|
||||
break;
|
||||
case 1:
|
||||
ret = FP_SENSOR_TYPE_FPC;
|
||||
break;
|
||||
default:
|
||||
ret = FP_SENSOR_TYPE_UNKNOWN;
|
||||
break;
|
||||
}
|
||||
gpio_set_level(GPIO_DIVIDER_HIGHSIDE, 0);
|
||||
return ret;
|
||||
}
|
||||
|
||||
enum fp_transport_type get_fp_transport_type(void)
|
||||
{
|
||||
enum fp_transport_type ret;
|
||||
|
||||
gpio_set_level(GPIO_DIVIDER_HIGHSIDE, 1);
|
||||
usleep(1);
|
||||
switch (gpio_get_level(GPIO_TRANSPORT_SEL)) {
|
||||
case 0:
|
||||
ret = FP_TRANSPORT_TYPE_UART;
|
||||
break;
|
||||
case 1:
|
||||
ret = FP_TRANSPORT_TYPE_SPI;
|
||||
break;
|
||||
default:
|
||||
ret = FP_TRANSPORT_TYPE_UNKNOWN;
|
||||
break;
|
||||
}
|
||||
gpio_set_level(GPIO_DIVIDER_HIGHSIDE, 0);
|
||||
return ret;
|
||||
}
|
|
@ -9,6 +9,6 @@ CHIP:=stm32
|
|||
CHIP_FAMILY:=stm32h7
|
||||
CHIP_VARIANT:=stm32h7x3
|
||||
|
||||
board-y=board.o
|
||||
board-y=board.o fpsensor_detect.o
|
||||
|
||||
test-list-y=aes sha256 sha256_unrolled
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
/* Copyright 2020 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.
|
||||
*/
|
||||
|
||||
#include "fpsensor_detect.h"
|
||||
|
||||
enum fp_sensor_type get_fp_sensor_type(void)
|
||||
{
|
||||
return FP_SENSOR_TYPE_FPC;
|
||||
}
|
||||
|
||||
enum fp_transport_type get_fp_transport_type(void)
|
||||
{
|
||||
return FP_TRANSPORT_TYPE_SPI;
|
||||
}
|
|
@ -10,3 +10,4 @@ _fpsensor_dir:=$(dir $(lastword $(MAKEFILE_LIST)))
|
|||
all-obj-$(HAS_TASK_FPSENSOR)+=$(_fpsensor_dir)fpsensor_state.o
|
||||
all-obj-$(HAS_TASK_FPSENSOR)+=$(_fpsensor_dir)fpsensor_crypto.o
|
||||
all-obj-$(HAS_TASK_FPSENSOR)+=$(_fpsensor_dir)fpsensor.o
|
||||
all-obj-$(HAS_TASK_FPSENSOR)+=$(_fpsensor_dir)fpsensor_detect_common.o
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include "ec_commands.h"
|
||||
#include "fpsensor.h"
|
||||
#include "fpsensor_crypto.h"
|
||||
#include "fpsensor_detect.h"
|
||||
#include "fpsensor_private.h"
|
||||
#include "fpsensor_state.h"
|
||||
#include "gpio.h"
|
||||
|
@ -203,6 +204,11 @@ void fp_task(void)
|
|||
gpio_config_module(MODULE_SPI_MASTER, 1);
|
||||
spi_enable(CONFIG_SPI_FP_PORT, 1);
|
||||
|
||||
CPRINTS("TRANSPORT_SEL: %s",
|
||||
fp_transport_type_to_str(get_fp_transport_type()));
|
||||
CPRINTS("FP_SENSOR_SEL: %s",
|
||||
fp_sensor_type_to_str(get_fp_sensor_type()));
|
||||
|
||||
#ifdef HAVE_FP_PRIVATE_DRIVER
|
||||
/* Reset and initialize the sensor IC */
|
||||
fp_sensor_init();
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
/* Copyright 2020 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.
|
||||
*/
|
||||
#include "fpsensor_detect.h"
|
||||
|
||||
const char *fp_transport_type_to_str(enum fp_transport_type type)
|
||||
{
|
||||
switch (type) {
|
||||
case FP_TRANSPORT_TYPE_UNKNOWN:
|
||||
default:
|
||||
return "UNKNOWN";
|
||||
case FP_TRANSPORT_TYPE_SPI:
|
||||
return "SPI";
|
||||
case FP_TRANSPORT_TYPE_UART:
|
||||
return "UART";
|
||||
}
|
||||
}
|
||||
|
||||
const char *fp_sensor_type_to_str(enum fp_sensor_type type)
|
||||
{
|
||||
switch (type) {
|
||||
case FP_SENSOR_TYPE_UNKNOWN:
|
||||
default:
|
||||
return "UNKNOWN";
|
||||
case FP_SENSOR_TYPE_FPC:
|
||||
return "FPC";
|
||||
case FP_SENSOR_TYPE_ELAN:
|
||||
return "ELAN";
|
||||
}
|
||||
}
|
||||
|
|
@ -5,6 +5,7 @@
|
|||
# See common/mock/README.md for more information.
|
||||
|
||||
mock-$(HAS_MOCK_FP_SENSOR) += fp_sensor_mock.o
|
||||
mock-$(HAS_MOCK_FPSENSOR_DETECT) += fpsensor_detect_mock.o
|
||||
mock-$(HAS_MOCK_MKBP_EVENTS) += mkbp_events_mock.o
|
||||
mock-$(HAS_MOCK_ROLLBACK) += rollback_mock.o
|
||||
mock-$(HAS_MOCK_TCPC) += tcpc_mock.o
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
/* Copyright 2020 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.
|
||||
*/
|
||||
|
||||
#include "mock/fpsensor_detect_mock.h"
|
||||
|
||||
struct mock_ctrl_fpsensor_detect mock_ctrl_fpsensor_detect =
|
||||
MOCK_CTRL_DEFAULT_FPSENSOR_DETECT;
|
||||
|
||||
enum fp_sensor_type get_fp_sensor_type(void)
|
||||
{
|
||||
return mock_ctrl_fpsensor_detect.get_fp_sensor_type_return;
|
||||
}
|
||||
|
||||
enum fp_transport_type get_fp_transport_type(void)
|
||||
{
|
||||
return mock_ctrl_fpsensor_detect.get_fp_transport_type_return;
|
||||
}
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include "fpc_bio_algorithm.h"
|
||||
#include "fpsensor.h"
|
||||
#include "gpio.h"
|
||||
#include "spi.h"
|
||||
#include "system.h"
|
||||
#include "util.h"
|
||||
|
@ -142,6 +143,12 @@ int fp_sensor_init(void)
|
|||
{
|
||||
int rc;
|
||||
|
||||
/* The dragonclaw development board needs this enabled to enable the
|
||||
* AND gate (U10) to CS. Production boards could disable this to save
|
||||
* power since it's only needed for initial detection on those boards.
|
||||
*/
|
||||
gpio_set_level(GPIO_DIVIDER_HIGHSIDE, 1);
|
||||
|
||||
/* Print the binary libfpbep.a library version */
|
||||
CPRINTS("FPC libfpbep.a %s", fp_sensor_get_version());
|
||||
|
||||
|
|
|
@ -5,5 +5,6 @@
|
|||
|
||||
#define CONFIG_TEST_MOCK_LIST \
|
||||
MOCK(FP_SENSOR) \
|
||||
MOCK(FPSENSOR_DETECT) \
|
||||
MOCK(MKBP_EVENTS) \
|
||||
MOCK(ROLLBACK)
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
/* Copyright 2020 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.
|
||||
*/
|
||||
|
||||
/* Fingerprint sensor detection (transport and sensor). */
|
||||
|
||||
#ifndef __CROS_EC_FPSENSOR_DETECT_H
|
||||
#define __CROS_EC_FPSENSOR_DETECT_H
|
||||
|
||||
enum fp_sensor_type {
|
||||
FP_SENSOR_TYPE_UNKNOWN = -1,
|
||||
FP_SENSOR_TYPE_FPC,
|
||||
FP_SENSOR_TYPE_ELAN,
|
||||
};
|
||||
|
||||
enum fp_transport_type {
|
||||
FP_TRANSPORT_TYPE_UNKNOWN = -1,
|
||||
FP_TRANSPORT_TYPE_SPI,
|
||||
FP_TRANSPORT_TYPE_UART
|
||||
};
|
||||
|
||||
const char *fp_transport_type_to_str(enum fp_transport_type type);
|
||||
const char *fp_sensor_type_to_str(enum fp_sensor_type type);
|
||||
enum fp_sensor_type get_fp_sensor_type(void);
|
||||
enum fp_transport_type get_fp_transport_type(void);
|
||||
|
||||
#endif /* __CROS_EC_FPSENSOR_DETECT_H */
|
|
@ -0,0 +1,23 @@
|
|||
/* Copyright 2020 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.
|
||||
*/
|
||||
|
||||
#ifndef __MOCK_FPSENSOR_DETECT_MOCK_H
|
||||
#define __MOCK_FPSENSOR_DETECT_MOCK_H
|
||||
|
||||
#include "fpsensor_detect.h"
|
||||
|
||||
struct mock_ctrl_fpsensor_detect {
|
||||
enum fp_sensor_type get_fp_sensor_type_return;
|
||||
enum fp_transport_type get_fp_transport_type_return;
|
||||
};
|
||||
|
||||
#define MOCK_CTRL_DEFAULT_FPSENSOR_DETECT { \
|
||||
.get_fp_sensor_type_return = FP_SENSOR_TYPE_UNKNOWN, \
|
||||
.get_fp_transport_type_return = FP_TRANSPORT_TYPE_UNKNOWN, \
|
||||
}
|
||||
|
||||
extern struct mock_ctrl_fpsensor_detect mock_ctrl_fpsensor_detect;
|
||||
|
||||
#endif /* __MOCK_FPSENSOR_DETECT_MOCK_H */
|
|
@ -5,5 +5,6 @@
|
|||
|
||||
#define CONFIG_TEST_MOCK_LIST \
|
||||
MOCK(FP_SENSOR) \
|
||||
MOCK(FPSENSOR_DETECT) \
|
||||
MOCK(MKBP_EVENTS) \
|
||||
MOCK(TIMER)
|
||||
|
|
Loading…
Reference in New Issue