1#!/bin/bash 2 3set_gpio() 4{ 5 local NET_NAME=$1 6 local OUT_VAL=$2 7 mapfile -t -d " " GPIO_INFO < <(gpiofind "$NET_NAME") 8 if [ "${#GPIO_INFO[@]}" -ne 2 ]; then 9 echo "set_gpio: can not find gpio, $NET_NAME" 10 return 1 11 fi 12 13 echo -n "set_gpio: set $NET_NAME = $OUT_VAL" 14 if ! gpioset "${GPIO_INFO[0]}" "${GPIO_INFO[1]%$'\n'}"="$OUT_VAL"; then 15 echo " failed" 16 return 1 17 fi 18 19 echo " success" 20 return 0 21} 22 23get_gpio() 24{ 25 local NET_NAME=$1 26 local ret=2 27 mapfile -t -d " " GPIO_INFO < <(gpiofind "$NET_NAME") 28 if [ "${#GPIO_INFO[@]}" -ne 2 ]; then 29 echo "get_gpio: can not find gpio, $NET_NAME" 30 return 2 31 fi 32 33 echo -n "get_gpio: get $NET_NAME" 34 if ! ret=$(gpioget "${GPIO_INFO[0]}" "${GPIO_INFO[1]%$'\n'}"); then 35 echo " failed" 36 return 2 37 fi 38 39 echo " success" 40 return "${ret}" 41} 42 43check_nuvoton_board() 44{ 45 set +e 46 grep nuvoton /sys/firmware/devicetree/base/compatible 47 return 0 48} 49 50get_product_version() 51{ 52 local FRU_NAME=$1 53 local PRODUCT_VERSION 54 PRODUCT_VERSION=$(busctl get-property xyz.openbmc_project.EntityManager /xyz/openbmc_project/inventory/system/board/Yosemite_4_"$FRU_NAME" xyz.openbmc_project.Inventory.Decorator.Revision Version| awk -F\" '{print $2}') 55 echo "$PRODUCT_VERSION" 56} 57