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 | |
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')
3 files changed, 48 insertions, 44 deletions
diff --git a/meta-quanta/meta-gsj/recipes-gsj/quanta-nvme-powerctrl/files/init_once.sh b/meta-quanta/meta-gsj/recipes-gsj/quanta-nvme-powerctrl/files/init_once.sh index 08aa7a0549..c6485a4f63 100644 --- a/meta-quanta/meta-gsj/recipes-gsj/quanta-nvme-powerctrl/files/init_once.sh +++ b/meta-quanta/meta-gsj/recipes-gsj/quanta-nvme-powerctrl/files/init_once.sh @@ -1,58 +1,59 @@ #!/bin/bash +# shellcheck source=meta-quanta/meta-gsj/recipes-gsj/quanta-nvme-powerctrl/files/nvme_powerctrl_library.sh source /usr/libexec/nvme_powerctrl_library.sh function set_gpio() { #$1 gpio pin - echo $1 > /sys/class/gpio/export + echo "$1" > /sys/class/gpio/export } echo "Read Clock Gen Value is: $CLOCK_GEN_VALUE" ## Initial U2_PRESENT_N -for i in ${!U2_PRESENT[@]}; +for i in "${!U2_PRESENT[@]}"; do - set_gpio ${U2_PRESENT[$i]}; - set_gpio_direction ${U2_PRESENT[$i]} 'in'; - echo "Read $i SSD present: $(read_gpio_input ${U2_PRESENT[$i]})" + set_gpio "${U2_PRESENT[$i]}"; + set_gpio_direction "${U2_PRESENT[$i]}" 'in'; + echo "Read $i SSD present: $(read_gpio_input "${U2_PRESENT[$i]}")" done ## Initial POWER_U2_EN -for i in ${!POWER_U2[@]}; +for i in "${!POWER_U2[@]}"; do - set_gpio ${POWER_U2[$i]}; + set_gpio "${POWER_U2[$i]}"; done ## Initial PWRGD_U2 -for i in ${!PWRGD_U2[@]}; +for i in "${!PWRGD_U2[@]}"; do - set_gpio ${PWRGD_U2[$i]}; - set_gpio_direction ${PWRGD_U2[$i]} 'in'; - echo "Read $i SSD Power Good: $(read_gpio_input ${PWRGD_U2[$i]})" + set_gpio "${PWRGD_U2[$i]}"; + set_gpio_direction "${PWRGD_U2[$i]}" 'in'; + echo "Read $i SSD Power Good: $(read_gpio_input "${PWRGD_U2[$i]}")" done ## Initial RST_BMC_U2 -for i in ${!RST_BMC_U2[@]}; +for i in "${!RST_BMC_U2[@]}"; do - set_gpio ${RST_BMC_U2[$i]}; + set_gpio "${RST_BMC_U2[$i]}"; done ### Initial related Power by Present for i in {0..7}; do - update_value=$(printf '%x\n' "$((0x01 <<$i))") - if [ $(read_gpio_input ${U2_PRESENT[$i]}) == $PLUGGED ];then + update_value=$(printf '%x\n' "$((0x01 << i))") + if [ "$(read_gpio_input "${U2_PRESENT[$i]}")" == $PLUGGED ];then CLOCK_GEN_VALUE=$(printf '0x%x\n' \ - "$(($CLOCK_GEN_VALUE | 0x$update_value))") + "$((CLOCK_GEN_VALUE | 0x$update_value))") else set_gpio_direction "${RST_BMC_U2[$i]}" "low" set_gpio_direction "${POWER_U2[$i]}" "low" CLOCK_GEN_VALUE=$(printf '0x%x\n' \ - "$(($CLOCK_GEN_VALUE & ~0x$update_value))") + "$((CLOCK_GEN_VALUE & ~0x$update_value))") fi done -i2cset -y $I2C_BUS $CHIP_ADDR 0 $CLOCK_GEN_VALUE s +i2cset -y $I2C_BUS $CHIP_ADDR 0 "$CLOCK_GEN_VALUE" s echo "Read Clock Gen Value again is: $CLOCK_GEN_VALUE" exit 0; 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 } diff --git a/meta-quanta/meta-gsj/recipes-gsj/quanta-nvme-powerctrl/files/nvme_powermanager.sh b/meta-quanta/meta-gsj/recipes-gsj/quanta-nvme-powerctrl/files/nvme_powermanager.sh index 753c6c4cf5..d6d9aa66f9 100644 --- a/meta-quanta/meta-gsj/recipes-gsj/quanta-nvme-powerctrl/files/nvme_powermanager.sh +++ b/meta-quanta/meta-gsj/recipes-gsj/quanta-nvme-powerctrl/files/nvme_powermanager.sh @@ -1,5 +1,6 @@ #!/bin/bash +# shellcheck source=meta-quanta/meta-gsj/recipes-gsj/quanta-nvme-powerctrl/files/nvme_powerctrl_library.sh source /usr/libexec/nvme_powerctrl_library.sh U2_PRESENT_STATUS=( 1 1 1 1 1 1 1 1 ) @@ -9,14 +10,14 @@ function recovery_power() sleep 0.2 set_gpio_direction "${POWER_U2[$1]}" "high" sleep 0.2 - check_powergood $1 + check_powergood "$1" } ##Initial U2 present status for i in {0..7}; do - U2_PRESENT_STATUS[$i]=$(read_gpio_input ${U2_PRESENT[$i]}) + U2_PRESENT_STATUS[i]=$(read_gpio_input "${U2_PRESENT[$i]}") done ## Loop while @@ -26,21 +27,21 @@ do do ## 1 second scan all loop sleep 0.125 - read_present=$(read_gpio_input ${U2_PRESENT[$i]}) + read_present=$(read_gpio_input "${U2_PRESENT[$i]}") if [ "$read_present" != "${U2_PRESENT_STATUS[$i]}" ];then - U2_PRESENT_STATUS[$i]="$read_present" + U2_PRESENT_STATUS[i]="$read_present" if [ "$read_present" == $PLUGGED ];then echo "NVME $i Enable Power" - enable_nvme_power $i + enable_nvme_power "$i" else echo "NVME $i Disable Power" - disable_nvme_power $i + disable_nvme_power "$i" fi else if [ "${U2_PRESENT_STATUS[$i]}" == $PLUGGED ] && - [ $(read_gpio_input ${PWRGD_U2[$i]}) == 0 ];then + [ "$(read_gpio_input "${PWRGD_U2[$i]}")" == 0 ];then echo "NVME $i Recovery Power" - recovery_power $i + recovery_power "$i" fi fi done |