diff options
author | Tom Hughes <tomhughes@chromium.org> | 2020-01-02 15:36:04 -0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-01-08 00:47:29 +0000 |
commit | 0b838e162b35c6115de2cc049df699a65f9ee019 (patch) | |
tree | 84d4e83e193f1c884695f12673f3b0f9028ac19a /board/hatch_fp/fpsensor_detect.c | |
parent | ceaa05993490943b19cdf61bcd195cf016d31827 (diff) | |
download | chrome-ec-0b838e162b35c6115de2cc049df699a65f9ee019.tar.gz |
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>
Diffstat (limited to 'board/hatch_fp/fpsensor_detect.c')
-rw-r--r-- | board/hatch_fp/fpsensor_detect.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/board/hatch_fp/fpsensor_detect.c b/board/hatch_fp/fpsensor_detect.c new file mode 100644 index 0000000000..e737052b77 --- /dev/null +++ b/board/hatch_fp/fpsensor_detect.c @@ -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; +} |