1#!/bin/bash 2source /usr/sbin/gpio-defs.sh 3source /usr/sbin/gpio-lib.sh 4 5function usage() { 6 echo "usage: ampere_gpio_utils.sh [power] [on|off]"; 7} 8 9set_gpio_power_off() { 10 echo "Setting GPIO before Power off" 11 gpio_configure_output $OCP_AUX_PWREN 1 12 gpio_configure_output $OCP_MAIN_PWREN 0 13 gpio_configure_output $SPI0_PROGRAM_SEL 0 14} 15 16set_gpio_power_on() { 17 echo "Setting GPIO before Power on" 18 gpio_configure_output $OCP_AUX_PWREN 1 19 gpio_configure_output $OCP_MAIN_PWREN 1 20 gpio_configure_output $SPI0_PROGRAM_SEL 1 21 gpio_configure_output $SPI0_BACKUP_SEL 0 22} 23 24if [ $# -lt 2 ]; then 25 echo "Total number of parameter=$#" 26 echo "Insufficient parameter" 27 usage; 28 exit 0; 29fi 30 31if [ $1 == "power" ]; then 32 if [ $2 == "on" ]; then 33 set_gpio_power_on 34 elif [ $2 == "off" ]; then 35 set_gpio_power_off 36 fi 37 exit 0; 38else 39 echo "Invalid parameter1=$1" 40 usage; 41 exit 0; 42fi 43exit 0; 44