summaryrefslogtreecommitdiffstats
path: root/meta-facebook/meta-wedge/recipes-wedge/fbutils/files/ast-functions
diff options
context:
space:
mode:
Diffstat (limited to 'meta-facebook/meta-wedge/recipes-wedge/fbutils/files/ast-functions')
-rw-r--r--meta-facebook/meta-wedge/recipes-wedge/fbutils/files/ast-functions222
1 files changed, 0 insertions, 222 deletions
diff --git a/meta-facebook/meta-wedge/recipes-wedge/fbutils/files/ast-functions b/meta-facebook/meta-wedge/recipes-wedge/fbutils/files/ast-functions
deleted file mode 100644
index dd53ad1..0000000
--- a/meta-facebook/meta-wedge/recipes-wedge/fbutils/files/ast-functions
+++ /dev/null
@@ -1,222 +0,0 @@
-# Copyright 2014-present Facebook. All Rights Reserved.
-DEVMEM=/sbin/devmem
-
-devmem_set_bit() {
- local addr
- local val
- addr=$1
- val=$($DEVMEM $addr)
- val=$((val | (0x1 << $2)))
- $DEVMEM $addr 32 $val
-}
-
-devmem_clear_bit() {
- local addr
- local val
- addr=$1
- val=$($DEVMEM $addr)
- val=$((val & ~(0x1 << $2)))
- $DEVMEM $addr 32 $val
-}
-
-scu_addr() {
- echo $((0x1E6E2000 + 0x$1))
-}
-
-GPIODIR="/sys/class/gpio"
-GPIOEXPORT="$GPIODIR/export"
-
-gpio_dir() {
- echo "$GPIODIR/gpio$1"
-}
-
-gpio_name2value() {
- local first remaining base val
- remaining=$1
- val=0
- while [ -n "$remaining" ]; do
- first=${remaining:0:1}
- case "$first" in
- [[:lower:]])
- base=$(printf "%d" "'$first'")
- base=$((base - 96))
- val=$((val * 26 + base))
- ;;
- [[:upper:]])
- base=$(printf "%d" "'$first'")
- base=$((base - 64))
- val=$((val * 26 + base))
- ;;
- *)
- if [ $val -gt 0 ]; then
- val=$((val-1))
- fi
- val=$((val * 8 + $remaining))
- break
- ;;
- esac
- remaining=${remaining:1}
- done
- echo "$val"
-}
-
-gpio_export() {
- local gpio
- gpio=$(gpio_name2value $1)
- dir=$(gpio_dir $gpio)
- if [ ! -d ${dir} ]; then
- echo $gpio > $GPIOEXPORT
- fi
-}
-
-gpio_set() {
- local gpio
- local val
- gpio=$(gpio_name2value $1)
- val=$2
- dir=$(gpio_dir $gpio)
- if [ ! -d ${dir} ]; then
- echo $gpio > $GPIOEXPORT
- fi
- echo out > ${dir}/direction
- echo $val > ${dir}/value
-}
-
-gpio_get() {
- local gpio
- local val
- gpio=$(gpio_name2value $1)
- dir=$(gpio_dir $gpio)
- if [ ! -d ${dir} ]; then
- echo $gpio > $GPIOEXPORT
- fi
- echo in > ${dir}/direction
- cat ${dir}/value
-}
-
-wedge_iso_buf_enable() {
- # GPIOC2 (18) to low, SCU90[0] and SCU90[24] must be 0
- devmem_clear_bit $(scu_addr 90) 0
- devmem_clear_bit $(scu_addr 90) 24
- gpio_set 18 0
-}
-
-wedge_iso_buf_disable() {
- # GPIOC2 (18) to low, SCU90[0] and SCU90[24] must be 0
- devmem_clear_bit $(scu_addr 90) 0
- devmem_clear_bit $(scu_addr 90) 24
- gpio_set 18 1
-}
-
-wedge_is_us_on() {
- local val n retries prog
- if [ $# -gt 0 ]; then
- retries="$1"
- else
- retries=1
- fi
- if [ $# -gt 1 ]; then
- prog="$2"
- else
- prog=""
- fi
- n=1
- while true; do
- val=$(cat /sys/class/i2c-adapter/i2c-4/4-0040/gpio_inputs 2>/dev/null)
- if [ -n "$val" ]; then
- break
- fi
- n=$((n+1))
- if [ $n -gt $retries ]; then
- echo -n " failed to read GPIO. "
- val=0
- break
- fi
- echo -n "$prog"
- sleep 1
- done
- if [ "$((val & (0x1 << 14)))" != "0" ]; then
- # powered on already
- return 0
- else
- return 1
- fi
-}
-
-
-# Return the board type, 'LC', 'FC-LEFT', 'FC-RIGHT', or, 'WEDGE'
-wedge_board_type() {
- local pn
- pn=$(/usr/bin/weutil 2> /dev/null | grep -i '^Location on Fabric:')
- case "$pn" in
- *LEFT*)
- echo 'FC-LEFT'
- ;;
- *RIGHT*)
- echo 'FC-RIGHT'
- ;;
- *LC*)
- echo 'LC'
- ;;
- *)
- echo 'WEDGE'
- ;;
- esac
-}
-
-# On FC, FAB_SLOT_ID (GPIOU0), low == FC0; high == FC1
-# On LC, Wedge,
-# board rev < 3:
-# GPIOU0(ID0), GPIOU1(ID1), GPIOU2(ID2), GPIOU3(ID3)
-# else:
-# GPIOU6(ID0), GPIOU7(ID1), GPIOV0(ID2), GPIOV1(ID3)
-#
-# ID[2:0] ID3 Slot#
-# 000 0 1
-# 000 1 2
-# 001 0 3
-# 001 1 4
-# 010 0 5
-# 010 1 6
-# 011 0 7
-# 011 1 8
-
-wedge_slot_id() {
- local type slot id3 id2 id1 id0 FC_CARD_BASE board_rev
- FC_CARD_BASE=65
- if [ "$1" = "FC-LEFT" ]; then
- # fabric card left
- slot=$(gpio_get U0)
- slot=$((FC_CARD_BASE + slot * 2))
- elif [ "$1" = "FC-RIGHT" ]; then
- # fabric card right
- slot=$(gpio_get U0)
- slot=$((FC_CARD_BASE + slot * 2 + 1))
- else
- # either edge or LC
- # need to check the board rev
- board_rev=$(wedge_board_rev)
- if [ $board_rev -lt 3 ]; then
- id0=$(gpio_get U0)
- id1=$(gpio_get U1)
- id2=$(gpio_get U2)
- id3=$(gpio_get U3)
- else
- id0=$(gpio_get U6)
- id1=$(gpio_get U7)
- id2=$(gpio_get V0)
- id3=$(gpio_get V1)
- fi
- slot=$(((id2 * 4 + id1 * 2 + id0) * 2 + id3 + 1))
- fi
- echo "$slot"
-}
-
-# wedge_board_rev() is only valid after GPIO Y0, Y1, and Y2 are enabled
-wedge_board_rev() {
- local val0 val1 val2
- val0=$(cat /sys/class/gpio/gpio192/value 2>/dev/null)
- val1=$(cat /sys/class/gpio/gpio193/value 2>/dev/null)
- val2=$(cat /sys/class/gpio/gpio194/value 2>/dev/null)
- echo $((val0 | (val1 << 1) | (val2 << 2)))
-}
OpenPOWER on IntegriCloud