nm-scripts: add some wrappers
This commit is contained in:
parent
7de0db61b8
commit
8dafa07cd6
|
|
@ -0,0 +1,32 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
slot=$1
|
||||||
|
on=$2
|
||||||
|
|
||||||
|
usage()
|
||||||
|
{
|
||||||
|
echo "power-pcie-slot.sh slot on"
|
||||||
|
echo " slot: pcie slot to reset"
|
||||||
|
echo " on: 0 off, 1 on"
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ "$slot" = "" ]; then
|
||||||
|
usage
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$on" = "" ]; then
|
||||||
|
usage
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
power_slot()
|
||||||
|
{
|
||||||
|
slot=$1
|
||||||
|
on=$2
|
||||||
|
pwr_path="/sys/class/leds/pcie$slot:pwr/brightness"
|
||||||
|
echo $on > $pwr_path
|
||||||
|
}
|
||||||
|
|
||||||
|
power_slot $slot $on
|
||||||
|
|
@ -0,0 +1,24 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
slot=$1
|
||||||
|
|
||||||
|
usage()
|
||||||
|
{
|
||||||
|
echo "reset-pcie-slot.sh slot"
|
||||||
|
echo " slot: pcie slot to reset"
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ "$slot" = "" ]; then
|
||||||
|
usage
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
reset_slot()
|
||||||
|
{
|
||||||
|
reset_path="/sys/class/leds/pcie$slot:rst/brightness"
|
||||||
|
echo 1 > $reset_path
|
||||||
|
sleep 1
|
||||||
|
echo 0 > $reset_path
|
||||||
|
}
|
||||||
|
|
||||||
|
reset_slot $slot
|
||||||
|
|
@ -0,0 +1,124 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
hw=$1
|
||||||
|
sim=$2
|
||||||
|
slot=$3
|
||||||
|
|
||||||
|
usage()
|
||||||
|
{
|
||||||
|
echo "switch-sim.sh fpga sim slot"
|
||||||
|
echo " fpga: "
|
||||||
|
echo " 0 means FPGA on hw14/08"
|
||||||
|
echo " 1 means FPGA on hw17/hw18"
|
||||||
|
echo " sim: simcard slot starting with 1"
|
||||||
|
echo " slot: pcie slot to connect sim to. Starting with 1, 0 means disable"
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ "$hw" = "" ]; then
|
||||||
|
usage
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$sim" = "" ]; then
|
||||||
|
usage
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$slot" = "" ]; then
|
||||||
|
usage
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
switch_fpga_0()
|
||||||
|
{
|
||||||
|
sim=$1
|
||||||
|
slot=$2
|
||||||
|
|
||||||
|
if [ $sim -lt 1 -o $sim -gt 4 ]; then
|
||||||
|
echo "SIM should be between 1 and 4"
|
||||||
|
return 2
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ $slot -lt 0 -o $slot -gt 6 ]; then
|
||||||
|
echo "SLOT should be between 0 and 4"
|
||||||
|
return 3
|
||||||
|
fi
|
||||||
|
|
||||||
|
simbus_path="/sys/class/leds/simbus"
|
||||||
|
# set bitwise
|
||||||
|
case $slot in
|
||||||
|
1)
|
||||||
|
echo 1 > $simbus_path"13:en/brightness"
|
||||||
|
echo 0 > $simbus_path"13:sel/brightness"
|
||||||
|
slot=1
|
||||||
|
;;
|
||||||
|
3)
|
||||||
|
echo 1 > $simbus_path"13:en/brightness"
|
||||||
|
echo 1 > $simbus_path"13:sel/brightness"
|
||||||
|
slot=1
|
||||||
|
;;
|
||||||
|
5)
|
||||||
|
echo 1 > $simbus_path"56:en/brightness"
|
||||||
|
echo 0 > $simbus_path"56:sel/brightness"
|
||||||
|
slot=4
|
||||||
|
;;
|
||||||
|
6)
|
||||||
|
echo 1 > $simbus_path"56:en/brightness"
|
||||||
|
echo 1 > $simbus_path"56:sel/brightness"
|
||||||
|
slot=4
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
sim_path="/sys/class/leds/sim$sim"
|
||||||
|
if [ $sim -eq 0 ]; then
|
||||||
|
echo 0 > "$sim_path:en"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# set bitwise
|
||||||
|
sim_path="/sys/class/leds/sim$sim:sel"
|
||||||
|
slot=$(($slot - 1))
|
||||||
|
for i in $(seq 0 1); do
|
||||||
|
# inverse logic test returns 0 on success
|
||||||
|
test 0 -eq $(($slot & (2**$i)))
|
||||||
|
val=$?
|
||||||
|
echo $slot: $i: $val
|
||||||
|
echo $val > "$sim_path$i/brightness"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
switch_fpga_1()
|
||||||
|
{
|
||||||
|
sim=$1
|
||||||
|
slot=$2
|
||||||
|
|
||||||
|
if [ $sim -lt 1 -o $sim -gt 4 ]; then
|
||||||
|
echo "SIM should be between 1 and 4"
|
||||||
|
return 2
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ $slot -lt 0 -o $slot -gt 4 ]; then
|
||||||
|
echo "SLOT should be between 0 and 4"
|
||||||
|
return 3
|
||||||
|
fi
|
||||||
|
|
||||||
|
# set bitwise
|
||||||
|
sim_path="/sys/class/leds/sim$sim:sel"
|
||||||
|
for i in $(seq 0 2); do
|
||||||
|
# inverse logic test returns 0 on success
|
||||||
|
test 0 -eq $(($slot & (2**$i)))
|
||||||
|
val=$?
|
||||||
|
echo $val > "$sim_path$i/brightness"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
case $hw in
|
||||||
|
0)
|
||||||
|
switch_fpga_0 $sim $slot
|
||||||
|
;;
|
||||||
|
1)
|
||||||
|
switch_fpga_1 $sim $slot
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
usage
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
@ -0,0 +1,29 @@
|
||||||
|
SUMMARY = "Some scripts from netmodule"
|
||||||
|
DESCRIPTION = "This are some helper scripts provided by netmodule"
|
||||||
|
PR = "r1"
|
||||||
|
LICENSE = "GPLv2"
|
||||||
|
LIC_FILES_CHKSUM = "file://${COREBASE}/LICENSE;md5=4d92cd373abda3937c2bc47fbc49d690 \
|
||||||
|
file://${COREBASE}/meta/COPYING.GPLv2;md5=3da9cfbcb788c80a0384361b4de20420"
|
||||||
|
|
||||||
|
SRC_URI = "file://power-pcie-slot.sh \
|
||||||
|
file://reset-pcie-slot.sh \
|
||||||
|
file://switch-sim.sh \
|
||||||
|
"
|
||||||
|
|
||||||
|
S = "${WORKDIR}"
|
||||||
|
|
||||||
|
PACKAGES =+ "${PN}-fpga"
|
||||||
|
|
||||||
|
do_install () {
|
||||||
|
install -d -m 755 ${D}${bindir}/
|
||||||
|
|
||||||
|
install -m 755 *.sh ${D}${bindir}/
|
||||||
|
}
|
||||||
|
|
||||||
|
FILES_${PN}-fpga = " \
|
||||||
|
${bindir}/reset-pcie-slot.sh \
|
||||||
|
${bindir}/power-pcie-slot.sh \
|
||||||
|
${bindir}/switch-sim.sh \
|
||||||
|
"
|
||||||
|
|
||||||
|
INHIBIT_PACKAGE_DEBUG_SPLIT = "1"
|
||||||
Loading…
Reference in New Issue