forked from analogdevicesinc/linux_image_ADI-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_ensm_pinctrl.sh
executable file
·131 lines (101 loc) · 2.37 KB
/
test_ensm_pinctrl.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#!/bin/sh
find_zynq_base_gpio () {
for i in /sys/class/gpio/gpiochip*; do
if [ "zynq_gpio" = `cat $i/label` ]; then
return `echo $i | sed 's/^[^0-9]\+//'`
break
fi
done
return -1
}
fdd_pin_control_test () {
echo Running FDD Pin Control Test
while true; do
echo high > $ENABLE # RX&TX ON
sleep 1
echo low > $ENABLE # RX&TX OFF
sleep 1
done
}
fdd_independant_mode_pin_control_test () {
echo Running FDD Independant Pin Control Test
while true; do
echo high > $ENABLE # RX ON
echo low > $TXNRX # TX OFF
sleep 1
echo high > $TXNRX #TX ON
sleep 1
done
}
tdd_pin_control_test () {
echo Running TDD Pin Control Test
while true; do
# RX
echo low > $ENABLE
echo low > $TXNRX
echo low > $TXNRX # add some extra delay required for VCO cal in single synthesizer mode.
echo high > $ENABLE
sleep 1
# TX
echo low > $ENABLE
echo high > $TXNRX
echo high > $TXNRX # add some extra delay required for VCO cal in single synthesizer mode.
echo high > $ENABLE
sleep 1
done
}
if [ `id -u` != "0" ]
then
echo "This script must be run as root" 1>&2
exit 1
fi
for i in $(find -L /sys/bus/iio/devices -maxdepth 2 -name name)
do
dev_name=$(cat $i)
if [ "$dev_name" = "ad9361-phy" ]; then
phy_path=$(echo $i | sed 's:/name$::')
ensm_modes=$(cat $phy_path/ensm_mode_available)
break
fi
done
if [ "$dev_name" != "ad9361-phy" ]; then
echo "This test if for FMCOMMS2/3/4 only"
exit
fi
find_zynq_base_gpio
GPIO_BASE=$?
cd /sys/class/gpio
if [ $GPIO_BASE -ge 0 ]
then
GPIO_ENABLE=`expr $GPIO_BASE + 101`
GPIO_TXNRX=`expr $GPIO_BASE + 102`
#Export the CTRL_IN GPIOs
echo $GPIO_ENABLE > export 2> /dev/null
echo $GPIO_TXNRX > export 2> /dev/null
else
echo ERROR: Wrong board?
exit
fi
ENABLE=gpio${GPIO_ENABLE}/direction
TXNRX=gpio${GPIO_TXNRX}/direction
echo low > $ENABLE
echo low > $TXNRX
echo Press CTRL-C to exit
case "$ensm_modes" in
*fdd*)
echo "Type: 0 for FDD Pin Control Mode"
echo "Type: 1 for FDD Independant Pin Control Mode"
read mode
if [ $mode = "1" ]; then
echo pinctrl_fdd_indep > $phy_path/ensm_mode #Enable Pincontrol Mode
fdd_independant_mode_pin_control_test
else
echo pinctrl > $phy_path/ensm_mode #Enable Pincontrol Mode
fdd_pin_control_test
fi
;;
*rx*)
echo pinctrl > $phy_path/ensm_mode #Enable Pincontrol Mode
tdd_pin_control_test
;;
esac