diff options
Diffstat (limited to 'meta-ampere/meta-jade/recipes-ampere/platform/mtjade-gpio-config/ampere_gpio_utils.sh')
-rw-r--r-- | meta-ampere/meta-jade/recipes-ampere/platform/mtjade-gpio-config/ampere_gpio_utils.sh | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-gpio-config/ampere_gpio_utils.sh b/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-gpio-config/ampere_gpio_utils.sh new file mode 100644 index 000000000..8e4f455bf --- /dev/null +++ b/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-gpio-config/ampere_gpio_utils.sh @@ -0,0 +1,43 @@ +#!/bin/bash +source /usr/sbin/gpio-defs.sh +source /usr/sbin/gpio-lib.sh + +function usage() { + echo "usage: ampere_gpio_utils.sh [power] [on|off]"; +} + +set_gpio_power_off() { + echo "Setting GPIO before Power off" + gpio_configure_output $OCP_AUX_PWREN 1 + gpio_configure_output $OCP_MAIN_PWREN 0 + gpio_configure_output $SPI0_PROGRAM_SEL 0 +} + +set_gpio_power_on() { + echo "Setting GPIO before Power on" + gpio_configure_output $OCP_AUX_PWREN 1 + gpio_configure_output $OCP_MAIN_PWREN 1 + gpio_configure_output $SPI0_PROGRAM_SEL 1 + gpio_configure_output $SPI0_BACKUP_SEL 0 +} + +if [ $# -lt 2 ]; then + echo "Total number of parameter=$#" + echo "Insufficient parameter" + usage; + exit 0; +fi + +if [ $1 == "power" ]; then + if [ $2 == "on" ]; then + set_gpio_power_on + elif [ $2 == "off" ]; then + set_gpio_power_off + fi + exit 0; +else + echo "Invalid parameter1=$1" + usage; + exit 0; +fi +exit 0; |