diff options
Diffstat (limited to 'meta-facebook/meta-yosemite4/recipes-phosphor/dbus/phosphor-dbus-monitor/switch-nic-main-or-aux-mode')
-rw-r--r-- | meta-facebook/meta-yosemite4/recipes-phosphor/dbus/phosphor-dbus-monitor/switch-nic-main-or-aux-mode | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/meta-facebook/meta-yosemite4/recipes-phosphor/dbus/phosphor-dbus-monitor/switch-nic-main-or-aux-mode b/meta-facebook/meta-yosemite4/recipes-phosphor/dbus/phosphor-dbus-monitor/switch-nic-main-or-aux-mode new file mode 100644 index 0000000000..d82733e5e1 --- /dev/null +++ b/meta-facebook/meta-yosemite4/recipes-phosphor/dbus/phosphor-dbus-monitor/switch-nic-main-or-aux-mode @@ -0,0 +1,34 @@ +#!/bin/sh +set -e + +SLOT=$1 +MODE=$2 +GPIO_CHIP=$(basename "/sys/bus/i2c/devices/28-0024/"*gpiochip*) + +if [ "$MODE" = "main" ] +then + gpio_val=1 +elif [ "$MODE" = "aux" ] +then + gpio_val=0 +else + echo "Mode must be either main or aux instead of \"$MODE\"." + exit 255 +fi + +if test -z "$SLOT" +then + echo "Slot number(1st parameter) is required." + exit 255 +elif [ "$SLOT" -gt 4 ] +then + echo "Slot number must between 1~4." + exit 255 +fi + +# nic1~4 = gpio pin 4~7 +gpio_pin=$(( SLOT + 3 )) + +gpioset "$GPIO_CHIP" $gpio_pin=$gpio_val + +exit 0 |