summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorCraig Hesling <hesling@chromium.org>2021-04-29 23:37:31 -0700
committerCommit Bot <commit-bot@chromium.org>2021-05-01 01:53:49 +0000
commit3e63b8a30cbd5fe423e976cd7c5975b96e890420 (patch)
tree596bf9b87fd9d2b09eb896f0f086e40d01e3f4d8 /util
parentbf9979b91599ffc76018d60e780d19fa8d266ac0 (diff)
downloadchrome-ec-3e63b8a30cbd5fe423e976cd7c5975b96e890420.tar.gz
flash_fp_mcu: Factor out gpio chip check
This somewhat simplified the exit on failure. It is possible that future gpio systems won't use this interface, but can still be conveyed through variable configs. BRANCH=none BUG=none TEST=# dut1 is a dratini device scp util/flash_fp_mcu dut1:/usr/local/bin/flash_fp_mcu ssh dut1 flash_fp_mcu --hello; echo "Status $?" Signed-off-by: Craig Hesling <hesling@chromium.org> Change-Id: Icd163b59f08d8366be08ea9f3ee2726be0f3185b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2862547 Reviewed-by: Tom Hughes <tomhughes@chromium.org>
Diffstat (limited to 'util')
-rw-r--r--util/flash_fp_mcu35
1 files changed, 13 insertions, 22 deletions
diff --git a/util/flash_fp_mcu b/util/flash_fp_mcu
index 0a75a1f5b2..b25832b8a7 100644
--- a/util/flash_fp_mcu
+++ b/util/flash_fp_mcu
@@ -177,14 +177,6 @@ get_platform_name() {
echo "${platform_name}"
}
-check_gpio_chip_exists() {
- local gpiochip="$1"
- if [[ ! -e "/sys/class/gpio/${gpiochip}" ]]; then
- echo "Cannot find GPIO chip: ${gpiochip}"
- exit 1
- fi
-}
-
flash_fp_mcu_stm32() {
local transport="${1}"
local device="${2}"
@@ -377,8 +369,6 @@ flash_fp_mcu_stm32() {
}
config_hatch() {
- check_gpio_chip_exists "gpiochip200"
-
readonly TRANSPORT="SPI"
readonly DEVICE="/dev/spidev1.1"
# See
@@ -386,6 +376,7 @@ config_hatch() {
# for pin name to number mapping.
# Examine `cat /sys/kernel/debug/pinctrl/INT34BB:00/gpio-ranges` on a hatch
# device to determine gpio number from pin number.
+ readonly GPIO_CHIP="gpiochip200"
# FPMCU RST_ODL is on GPP_A12 = 200 + 12 = 212
readonly GPIO_NRST=212
# FPMCU BOOT0 is on GPP_A22 = 200 + 22 = 222
@@ -396,11 +387,10 @@ config_hatch() {
config_nami() {
- check_gpio_chip_exists "gpiochip360"
-
readonly TRANSPORT="SPI"
readonly DEVICE="/dev/spidev32765.0"
+ readonly GPIO_CHIP="gpiochip360"
# FPMCU RST_ODL is on GPP_C9 = 360 + 57 = 417
readonly GPIO_NRST=417
# FPMCU BOOT0 is on GPP_D5 = 360 + 77 = 437
@@ -410,11 +400,10 @@ config_nami() {
}
config_nocturne() {
- check_gpio_chip_exists "gpiochip360"
-
readonly TRANSPORT="SPI"
readonly DEVICE="/dev/spidev32765.0"
+ readonly GPIO_CHIP="gpiochip360"
# FPMCU RST_ODL is on GPP_C10 = 360 + 58 = 418
readonly GPIO_NRST=418
# FPMCU BOOT0 is on GPP_C8 = 360 + 56 = 416
@@ -424,13 +413,12 @@ config_nocturne() {
}
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"
+ readonly GPIO_CHIP="gpiochip392"
# 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
@@ -441,8 +429,6 @@ config_strongbad() {
}
config_volteer() {
- check_gpio_chip_exists "gpiochip152"
-
readonly TRANSPORT="SPI"
readonly DEVICE="/dev/spidev1.0"
@@ -454,6 +440,7 @@ config_volteer() {
# the pin number is 194. From the gpio-ranges, the gpio value is
# 408 + (194-171) = 431
+ readonly GPIO_CHIP="gpiochip152"
# FPMCU RST_ODL is on GPP_C23 = 408 + (194 - 171) = 431
readonly GPIO_NRST=431
# FPMCU BOOT0 is on GPP_C22 = 408 + (193 - 171) = 430
@@ -463,11 +450,10 @@ config_volteer() {
}
config_zork() {
- check_gpio_chip_exists "gpiochip256"
-
readonly TRANSPORT="UART"
readonly DEVICE="/dev/ttyS1"
+ readonly GPIO_CHIP="gpiochip256"
# FPMCU RST_ODL is on AGPIO 11 = 256 + 11 = 267
readonly GPIO_NRST=267
# FPMCU BOOT0 is on AGPIO 69 = 256 + 69 = 325
@@ -478,12 +464,11 @@ config_zork() {
}
config_guybrush() {
- check_gpio_chip_exists "gpiochip256"
-
readonly TRANSPORT="UART"
readonly DEVICE="/dev/ttyS1"
+ readonly GPIO_CHIP="gpiochip256"
# FPMCU RST_ODL is on AGPIO 11 = 256 + 11 = 267
readonly GPIO_NRST=267
# FPMCU BOOT0 is on AGPIO 144 = 256 + 144 = 400
@@ -530,6 +515,12 @@ main() {
exit 1
fi
+ # Check that the gpiochip exists
+ if [[ ! -e "/sys/class/gpio/${GPIO_CHIP}" ]]; then
+ echo "Cannot find GPIO chip: ${GPIO_CHIP}"
+ exit 1
+ fi
+
flash_fp_mcu_stm32 \
"${TRANSPORT}" \
"${DEVICE}" \