From 985ccf1df14d90a20589d39077cb8c29d4d08e23 Mon Sep 17 00:00:00 2001 From: Patryk Duda Date: Wed, 25 Jan 2023 16:09:38 +0100 Subject: flash_fp_mcu: Dynamically determine gpiochip number for guybrush Guybrush-kernelnext uses upstream kernel which changes every week. In this case it's cumbersome to hardcode gpiochip number in the script and we should determine it dynamically. BUG=b:269985136 BRANCH=none TEST=Run `flash_fp_mcu --hello` on guybrush and guybrush-kernelnext Change-Id: Ia416b664fffdaf0dd9bf14e79da6fd6f4d9c05f0 Signed-off-by: Patryk Duda Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4271785 Commit-Queue: Patryk Duda Reviewed-by: Josie Nordrum Tested-by: Patryk Duda --- util/flash_fp_mcu | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/util/flash_fp_mcu b/util/flash_fp_mcu index b857ba82f6..8a01a074df 100644 --- a/util/flash_fp_mcu +++ b/util/flash_fp_mcu @@ -745,25 +745,24 @@ config_guybrush() { readonly TRANSPORT="UART" readonly DEVICE="/dev/ttyS1" - local gpiochip="gpiochip768" - # Support kernel version 5.10 during transition to 5.15+ - match_kernel_regex "^5\.10\." && gpiochip="gpiochip256" - readonly GPIO_CHIP="${gpiochip}" + local gpiochip_dev_path="*/platform/AMD0030\:00/gpio/*" + local gpiobase + if ! gpiobase=$(get_sysfs_gpiochip_base "${gpiochip_dev_path}"); then + echo "Unable to find gpio chip base" + return "${EXIT_PRECONDITION}" + fi - local offset=0 - # Support kernel version 5.10 during transition to 5.15+ - # v5.10 has GPIOs that are offset by -512 - match_kernel_regex "^5\.10\." && offset=512 + local GPIO_CHIP="gpiochip${gpiobase}" - # FPMCU RST_ODL is on AGPIO 11 = 768 + 11 = 779 - local gpionrst=779 - readonly GPIO_NRST=$(( gpionrst - offset )) - # FPMCU BOOT0 is on AGPIO 144 = 768 + 144 = 912 - local gpioboot=912 - readonly GPIO_BOOT0=$(( gpioboot - offset )) - # FPMCU PWR_EN is on AGPIO 3 = 768 + 3 = 771 - local gpiopwren=771 - readonly GPIO_PWREN=$(( gpiopwren - offset )) + # FPMCU RST_ODL is on AGPIO 11 + local gpionrst=11 + readonly GPIO_NRST=$(( gpionrst + gpiobase )) + # FPMCU BOOT0 is on AGPIO 144 + local gpioboot=144 + readonly GPIO_BOOT0=$(( gpioboot + gpiobase )) + # FPMCU PWR_EN is on AGPIO 3 + local gpiopwren=3 + readonly GPIO_PWREN=$(( gpiopwren + gpiobase )) } config_skyrim() { -- cgit v1.2.1