diff options
author | Patrick Williams <patrick@stwcx.xyz> | 2023-04-16 04:05:21 +0300 |
---|---|---|
committer | Patrick Williams <patrick@stwcx.xyz> | 2023-04-27 19:16:12 +0300 |
commit | 8c2262344c1fc1f8708f4a44af395ea8c49f12e2 (patch) | |
tree | c77f039128cd588f75b89a2272248960b3482baf /meta-quanta/meta-gsj/recipes-gsj/quanta-nvme-powerctrl/files/nvme_powerctrl_library.sh | |
parent | bd58e95482128fa5aefb97125613e6b23723e85e (diff) | |
download | openbmc-8c2262344c1fc1f8708f4a44af395ea8c49f12e2.tar.xz |
meta-quanta: fix shellcheck issues
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: I189baf142cc86d44ebbf615edd3bb0ec1785be8d
Diffstat (limited to 'meta-quanta/meta-gsj/recipes-gsj/quanta-nvme-powerctrl/files/nvme_powerctrl_library.sh')
-rw-r--r-- | meta-quanta/meta-gsj/recipes-gsj/quanta-nvme-powerctrl/files/nvme_powerctrl_library.sh | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/meta-quanta/meta-gsj/recipes-gsj/quanta-nvme-powerctrl/files/nvme_powerctrl_library.sh b/meta-quanta/meta-gsj/recipes-gsj/quanta-nvme-powerctrl/files/nvme_powerctrl_library.sh index 3737aacc10..0ee436debd 100644 --- a/meta-quanta/meta-gsj/recipes-gsj/quanta-nvme-powerctrl/files/nvme_powerctrl_library.sh +++ b/meta-quanta/meta-gsj/recipes-gsj/quanta-nvme-powerctrl/files/nvme_powerctrl_library.sh @@ -1,42 +1,44 @@ #!/bin/bash -U2_PRESENT=( 148 149 150 151 152 153 154 155 ) -POWER_U2=( 195 196 202 199 198 197 127 126 ) -PWRGD_U2=( 161 162 163 164 165 166 167 168 ) -RST_BMC_U2=( 72 73 74 75 76 77 78 79 ) -PLUGGED=0 -I2C_BUS=8 -CHIP_ADDR=0x68 +export U2_PRESENT=( 148 149 150 151 152 153 154 155 ) +export POWER_U2=( 195 196 202 199 198 197 127 126 ) +export PWRGD_U2=( 161 162 163 164 165 166 167 168 ) +export RST_BMC_U2=( 72 73 74 75 76 77 78 79 ) +export PLUGGED=0 +export I2C_BUS=8 +export CHIP_ADDR=0x68 +export CLOCK_GEN_VALUE= + CLOCK_GEN_VALUE=$(i2cget -y $I2C_BUS $CHIP_ADDR 0 i 2|cut -f3 -d' ') function set_gpio_direction() { #$1 gpio pin, $2 'in','high','low' - echo $2 > /sys/class/gpio/gpio$1/direction + echo "$2" > "/sys/class/gpio/gpio$1/direction" } function read_gpio_input() { #$1 read input gpio pin - echo $(cat /sys/class/gpio/gpio$1/value) + cat "/sys/class/gpio/gpio$1/value" } function enable_nvme_power() { set_gpio_direction "${POWER_U2[$1]}" "high" sleep 0.04 - check_powergood $1 + check_powergood "$1" } function check_powergood() { - if [ $(read_gpio_input ${PWRGD_U2[$1]}) == 1 ];then + if [ "$(read_gpio_input "${PWRGD_U2[$1]}")" == 1 ];then sleep 0.005 - update_clock_gen_chip_register $1 1 + update_clock_gen_chip_register "$1" 1 sleep 0.1 set_gpio_direction "${RST_BMC_U2[$1]}" "high" else - disable_nvme_power $1 + disable_nvme_power "$1" fi } @@ -44,7 +46,7 @@ function disable_nvme_power() { set_gpio_direction "${RST_BMC_U2[$1]}" "low" sleep 0.1 - update_clock_gen_chip_register $1 0 + update_clock_gen_chip_register "$1" 0 sleep 0.005 set_gpio_direction "${POWER_U2[$1]}" "low" } @@ -52,12 +54,12 @@ function disable_nvme_power() function update_clock_gen_chip_register(){ #$1 nvme slot number, $2 enable/disable update_value=$(printf '%x\n' "$((0x01 <<$1))") - if [ $2 -eq 1 ];then + if [ "$2" -eq 1 ];then CLOCK_GEN_VALUE=$(printf '0x%x\n' \ - "$(($CLOCK_GEN_VALUE | 0x$update_value))") + "$((CLOCK_GEN_VALUE | 0x$update_value))") else CLOCK_GEN_VALUE=$(printf '0x%x\n' \ - "$(($CLOCK_GEN_VALUE & ~0x$update_value))") + "$((CLOCK_GEN_VALUE & ~0x$update_value))") fi - i2cset -y $I2C_BUS $CHIP_ADDR 0 $CLOCK_GEN_VALUE s + i2cset -y $I2C_BUS $CHIP_ADDR 0 "$CLOCK_GEN_VALUE" s } |