From 1d878115a26f2f583cd5d0d01a1c6cf2993b2776 Mon Sep 17 00:00:00 2001 From: Craig Hesling Date: Thu, 28 Jan 2021 20:32:33 -0800 Subject: flash_fp_mcu: Add initial support for strongbad Caveats * Need to fix modalias for strongbad * Need to fix driver binding so that the gpios are not reset * Need to fix external nrst pull BRANCH=none BUG=b:145245345, b:172966748, b:179533783, b:179530529, b:179839337 TEST=emerge-strongbad chromeos-base/ec-utils-test cros deploy dut1 chromeos-base/ec-utils-test ./flash_fp_mcu custom-strongbad-evt-image.bin Change-Id: I33d8fee21a2afbf8f5c399e6cb47c2095d833f57 Signed-off-by: Craig Hesling Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2654737 Reviewed-by: Tom Hughes Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2713553 Tested-by: Sujit Kautkar Reviewed-by: Sujit Kautkar Commit-Queue: Sujit Kautkar --- util/flash_fp_mcu | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/util/flash_fp_mcu b/util/flash_fp_mcu index b1217b171a..5fcf5b102f 100644 --- a/util/flash_fp_mcu +++ b/util/flash_fp_mcu @@ -51,6 +51,12 @@ check_hardware_write_protect_disabled() { # Get the spiid for the fingerprint sensor based on the modalias # string: https://crbug.com/955117 get_spiid() { + # TODO(b/179533783): Fix modalias on strongbad and remove this bypass. + if [[ -n "${DEVICEID}" ]]; then + echo "${DEVICEID}" + exit 0 + fi + for dev in /sys/bus/spi/devices/*; do if [[ "$(cat "${dev}/modalias")" == "${CROS_EC_SPI_MODALIAS_STR}" ]]; then echo "$(basename "${dev}")" @@ -269,6 +275,14 @@ flash_fp_mcu_stm32() { echo "WARNING: One of the drivers changed NRST pin state on bind attempt." fi + # TODO(b/179530529): Remove this hack when the drivers on strongbad stop + # setting the gpio states. + if [[ "${PLATFORM_NAME}" == "strongbad" ]]; then + echo "# Fixing GPIOs" + gpio 1 "${gpio_boot0}" + gpio 0 "${gpio_nrst}" + fi + local attempt=0 local cmd_exit_status=1 local cmd="stm32mon ${stm32mon_flags}" @@ -305,7 +319,11 @@ flash_fp_mcu_stm32() { gpio 1 "${gpio_nrst}" # Give up GPIO control - gpio in "${gpio_boot0}" "${gpio_nrst}" + # TODO(b/179839337): Remove this for Strongbad DVT, where we should have + # correct external pulls on these lines. + if [[ "${PLATFORM_NAME}" != "strongbad" ]]; then + gpio in "${gpio_boot0}" "${gpio_nrst}" + fi gpio unexport "${gpio_boot0}" "${gpio_nrst}" # wait for FP MCU to come back up (including RWSIG delay) @@ -381,6 +399,23 @@ config_nocturne() { readonly GPIO_PWREN=371 } +config_strongbad() { + check_gpio_chip_exists "gpiochip392" + + readonly TRANSPORT="SPI" + readonly DEVICE="/dev/spidev10.0" + # TODO(b/179533783): Fix modalias on strongbad and remove this bypass. + readonly DEVICEID="spi10.0" + + # FPMCU RST_ODL is $(gpiofind FP_RST_L) is gpiochip0 22 + readonly GPIO_NRST=$((392 + $(gpiofind FP_RST_L|cut -f2 -d" "))) + # FPMCU BOOT0 is $(gpiofind FPMCU_BOOT0) is gpiochip0 10 + readonly GPIO_BOOT0=$((392 + $(gpiofind FPMCU_BOOT0|cut -f2 -d" "))) + # TODO(b/179839337): Hardware currently doesn't support PWREN, but the + # next revision will. Add a comment here about the power enable gpio. + readonly GPIO_PWREN=-1 +} + config_volteer() { check_gpio_chip_exists "gpiochip152" -- cgit v1.2.1