2 # SPDX-License-Identifier: GPL-2.0
7 active_low_sysfs
=`cat $GPIO_SYSFS/gpio$nr/active_low`
8 val_sysfs
=`cat $GPIO_SYSFS/gpio$nr/value`
9 dir_sysfs
=`cat $GPIO_SYSFS/gpio$nr/direction`
11 gpio_this_debugfs
=`cat $GPIO_DEBUGFS |grep "gpio-$nr" | sed "s/(.*)//g"`
12 dir_debugfs
=`echo $gpio_this_debugfs | awk '{print $2}'`
13 val_debugfs
=`echo $gpio_this_debugfs | awk '{print $3}'`
14 if [ $val_debugfs = "lo" ]; then
16 elif [ $val_debugfs = "hi" ]; then
20 if [ $active_low_sysfs = "1" ]; then
21 if [ $val = "0" ]; then
28 if [ $val_sysfs = $val ] && [ $dir_sysfs = $dir_debugfs ]; then
31 echo "test fail, exit"
43 echo $direction > $GPIO_SYSFS/gpio
$nr/direction
44 echo $active_low > $GPIO_SYSFS/gpio
$nr/active_low
45 if [ $direction = "out" ]; then
46 echo $value > $GPIO_SYSFS/gpio
$nr/value
55 echo -n "test pin<$nr>"
57 echo $nr > $GPIO_SYSFS/export 2>/dev
/null
59 if [ X$?
!= X0
]; then
60 echo "test GPIO pin $nr failed"
64 #"Checking if the sysfs is consistent with debugfs: "
67 #"Checking the logic of active_low: "
68 test_pin_logic
$nr out
1 1
69 test_pin_logic
$nr out
1 0
70 test_pin_logic
$nr out
0 1
71 test_pin_logic
$nr out
0 0
73 #"Checking the logic of direction: "
74 test_pin_logic
$nr in 1 1
75 test_pin_logic
$nr out
1 0
76 test_pin_logic
$nr low
0 1
77 test_pin_logic
$nr high
0 0
79 echo $nr > $GPIO_SYSFS/unexport
88 echo $nr > $GPIO_SYSFS/export 2>/dev
/null
90 if [ X$?
!= X0
]; then
91 echo "test invalid pin $nr successful"
93 echo "test invalid pin $nr failed"
94 echo $nr > $GPIO_SYSFS/unexport
2>/dev
/null
101 echo `ls -d $GPIO_DRV_SYSFS/gpiochip* 2>/dev/null`
107 name
=`basename $chip`
108 base
=`cat $chip/base`
109 ngpio
=`cat $chip/ngpio`
110 printf "%-10s %-5s %-5s\n" $name $base $ngpio
111 if [ $ngpio = "0" ]; then
112 echo "number of gpio is zero is not allowed".
115 test_one_pin $
(($base + $ngpio - 1))
116 test_one_pin $
((( RANDOM
% $ngpio ) + $base ))
121 gpiochip
=`list_chip $module`
122 if [ X
"$gpiochip" = X
]; then
123 if [ X
"$valid" = Xfalse
]; then
130 for chip
in $gpiochip; do