diff options
author | Charles Boyer <Charles.Boyer@fii-usa.com> | 2022-02-09 17:32:22 +0300 |
---|---|---|
committer | Charles Boyer <Charles.Boyer@fii-usa.com> | 2022-04-21 21:37:36 +0300 |
commit | d7d3423ca60a040efcd61db301eea48c5f6635f4 (patch) | |
tree | 7e2cc147f52905789f9012f58b08f267052f0e51 /meta-fii/meta-kudo/recipes-kudo/kudo-fw-utility/kudo-fw/kudo-fw.sh | |
parent | 65ab13e0ec825b88e8fb32195127dee1cba2d579 (diff) | |
download | openbmc-d7d3423ca60a040efcd61db301eea48c5f6635f4.tar.xz |
meta-fii: meta-kudo: Use GPIO line names instead of number
Replaces hard-coded GPIO throughout the Kudo layer with a reference
to its line name from DTS.
The process to dynamically obtain the GPIO number for Get is added
to kudo-lib.sh,
1. Use `gpiofind <Line Name>` to obtain gpiochip# and pin#
2. If the gpiochip# exceeds the number of GPIO banks of Nuvoton,
then it is an I/O Expander.
a. Use `gpiodetect` and extract the I2C bus-addr
b. Obtain GPIO base value from sysfs using bus-addr
c. The GPIO number is then the (base + pin#)
3. If the gpiochip# is within Nuvoton GPIO banks, then calculate
the GPIO number as ((gpiochip#)*32 + pin#)
Then the GPIO number can be used in the export to obtain the value.
Tested with Nuvoton:
- Can read/set Nuvoton GPIO with defined line names
- Can read/set GPIO from I/O Expanders with defined line names
Signed-off-by: Charles Boyer <Charles.Boyer@fii-usa.com>
Change-Id: I651c0707a8bbc170d3c5a5fc261e5f9c62453e9f
Diffstat (limited to 'meta-fii/meta-kudo/recipes-kudo/kudo-fw-utility/kudo-fw/kudo-fw.sh')
-rw-r--r-- | meta-fii/meta-kudo/recipes-kudo/kudo-fw-utility/kudo-fw/kudo-fw.sh | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/meta-fii/meta-kudo/recipes-kudo/kudo-fw-utility/kudo-fw/kudo-fw.sh b/meta-fii/meta-kudo/recipes-kudo/kudo-fw-utility/kudo-fw/kudo-fw.sh index 6231aeb49f..6f9ec72208 100644 --- a/meta-fii/meta-kudo/recipes-kudo/kudo-fw-utility/kudo-fw/kudo-fw.sh +++ b/meta-fii/meta-kudo/recipes-kudo/kudo-fw-utility/kudo-fw/kudo-fw.sh @@ -74,23 +74,23 @@ function fwbios() { } function fwbmccpld() { - # BMC_JTAG_MUX_1 #218 0:BMC 1:MB - set_gpio_ctrl 218 out 0 + # BMC_JTAG_MUX_1 0:BMC 1:MB + set_gpio_ctrl MB_JTAG_MUX_SEL 0 if [ "$(loadsvf -d /dev/jtag0 -s $1 -m 0)" -ne 0 ]; then echo "BMC CPLD update failed" >&2 return 1 fi wait - set_gpio_ctrl 218 out 1 + set_gpio_ctrl MB_JTAG_MUX_SEL 1 return 0 } function fwmbcpld() { - # BMC_JTAG_MUX_1 #218 0:BMC 1:MB - # BMC_JTAG_SEL #164 0:BMC 1:CPU - set_gpio_ctrl 218 out 1 - set_gpio_ctrl 164 out 1 + # BMC_JTAG_MUX_1 0:BMC 1:MB + # BMC_JTAG_SEL 0:BMC 1:CPU + set_gpio_ctrl MB_JTAG_MUX_SEL 1 + set_gpio_ctrl BMC_JTAG_MUX_SEL 1 if [ "$(loadsvf -d /dev/jtag0 -s $1 -m 0)" -ne 0 ]; then echo "Mobo CPLD update failed" >&2 return 1 @@ -101,11 +101,11 @@ function fwmbcpld() { } function fwscp() { - # BMC_I2C_BACKUP_SEL #168 0:failover, 1:main - # BMC_CPU_EEPROM_I2C_SEL #85 0:BMC, 1:CPU - scp_eeprom_sel=$(get_gpio_ctrl 168) - set_gpio_ctrl 168 out 1 - set_gpio_ctrl 85 out 0 + # BMC_I2C_BACKUP_SEL 0:failover, 1:main + # BMC_CPU_EEPROM_I2C_SEL 0:BMC, 1:CPU + scp_eeprom_sel=$(get_gpio_ctrl BACKUP_SCP_SEL) + set_gpio_ctrl BACKUP_SCP_SEL 1 + set_gpio_ctrl CPU_EEPROM_SEL 0 #shellcheck disable=SC2010 I2C_BUS_DEV=$(ls -l $devpath/"13-0077/" | grep channel-0 | awk '{ print $11}' | cut -c 8-) if [ "$(ampere_eeprom_prog -b $I2C_BUS_DEV -s 0x50 -p -f $1)" -ne 0 ]; then @@ -113,18 +113,18 @@ function fwscp() { return 1 fi wait - set_gpio_ctrl 85 out 1 - set_gpio_ctrl 168 out "$scp_eeprom_sel" + set_gpio_ctrl CPU_EEPROM_SEL 1 + set_gpio_ctrl BACKUP_SCP_SEL "$scp_eeprom_sel" return 0 } function fwscpback() { - # BMC_I2C_BACKUP_SEL #168 0:failover, 1:main - # BMC_CPU_EEPROM_I2C_SEL #85 0:BMC, 1:CPU - scp_eeprom_sel=$(get_gpio_ctrl 168) - set_gpio_ctrl 168 out 0 - set_gpio_ctrl 85 out 0 + # BMC_I2C_BACKUP_SEL 0:failover, 1:main + # BMC_CPU_EEPROM_I2C_SEL 0:BMC, 1:CPU + scp_eeprom_sel=$(get_gpio_ctrl BACKUP_SCP_SEL) + set_gpio_ctrl BACKUP_SCP_SEL 0 + set_gpio_ctrl CPU_EEPROM_SEL 0 #shellcheck disable=SC2010 I2C_BUS_DEV=$(ls -l $devpath/"13-0077/" | grep channel-0 | awk '{ print $11}' | cut -c 8-) if [ "$(ampere_eeprom_prog -b $I2C_BUS_DEV -s 0x50 -p -f $1)" -ne 0 ]; then @@ -132,8 +132,8 @@ function fwscpback() { return 1 fi wait - set_gpio_ctrl 85 out 1 - set_gpio_ctrl 168 out "$scp_eeprom_sel" + set_gpio_ctrl CPU_EEPROM_SEL 1 + set_gpio_ctrl BACKUP_SCP_SEL "$scp_eeprom_sel" return 0 } |