Lines Matching +full:gpio +full:- +full:width

1 #!/bin/bash -efu
2 # SPDX-License-Identifier: GPL-2.0
7 #4: skip test - including run as non-root user
13 module="gpio-mockup"
29 echo "$0 [-frv] [-t type]"
30 echo "-f: full test (minimal set run by default)"
31 echo "-r: test random lines as well as fence posts"
32 echo "-t: interface type:"
33 echo " cdev (character device ABI) - default"
36 echo "-v: verbose progress reporting"
43 echo "GPIO $module test SKIP"
49 [ $(id -u) -eq 0 ] || skip "must be run as root"
51 DEBUGFS=$(grep -w debugfs /proc/mounts | cut -f2 -d' ')
52 [ -d "$DEBUGFS" ] || skip "debugfs is not mounted"
59 modprobe -r -q $module
67 jobs -p | xargs -r kill > /dev/null 2>&1
73 echo "GPIO $module test FAIL"
79 modprobe -q $module "$1" || fail "insert $module failed with error $?"
84 [ -z "$verbose" ] || echo "$*"
90 # This implementation drives the GPIO character device (cdev) uAPI.
106 $BASE/gpio-mockup-cdev $cdev_opts /dev/$chip $offset
124 active-low)
125 active_opt="-l "
127 active-high)
130 bias-none)
133 pull-down)
134 bias_opt="-bpull-down "
136 pull-up)
137 bias_opt="-bpull-up "
150 $BASE/gpio-mockup-cdev $cdev_opts -s$val /dev/$chip $offset &
153 # allow for gpio-mockup-cdev to launch and request line
158 $BASE/gpio-mockup-cdev $cdev_opts /dev/$chip $offset || true
167 [ "$val" = "$1" ] || fail "line value is ${val:-empty} when $1 was expected"
181 [ $retry -lt 5 ] || fail "mockup $mock_line value ${val:-empty} when $1 expected"
182 sleep $(printf "%0.2f" $((backoff_wait))e-3)
190 # allow for set propagation - so we won't be in a race with set_line
208 [ -e "$mock_line" ] || fail "missing line $chip:$offset"
210 # test input active-high
212 set_line input active-high
223 set_line input pull-up
229 set_line input pull-down
234 set_line bias-none
237 # test input active-low
239 set_line active-low
246 # test output active-high
248 set_line active-high 0
256 # test output active-low
258 set_line active-low 0
271 [ ! -e "$GPIO_DEBUGFS/$1/$2" ] || fail "unexpected line $1:$2"
281 # For each gpiochip the fence post lines, 0 and n-1, are tested, and the
290 local width=
292 [ "${1:-}" ] || fail "missing ranges"
295 log "GPIO $module test with ranges: <$ranges>:"
296 # e.g. /sys/kernel/debug/gpio-mockup/gpiochip1
297 gpiochip=$(find "$DEBUGFS/$module/" -name gpiochip* -type d | sort)
300 [ "${1:-}" ] || fail "unexpected chip - $gc"
301 width=$1 ; shift
303 if [ "$random" -a $width -gt 2 ]; then
304 test_line $gc $((RANDOM % ($width - 2) + 1))
306 test_line $gc $(($width - 1))
307 test_no_line $gc $width
309 [ "${1:-}" ] && fail "missing expected chip of width $1"
332 shift $((OPTIND - 1))
334 [ "${1:-}" ] && fail "unknown argument '$1'"
343 source $BASE/gpio-mockup-sysfs.sh
344 echo "WARNING: gpio sysfs ABI is deprecated."
347 echo "WARNING: gpio cdev ABI v1 is deprecated."
348 uapi_opt="-u1 "
359 # manual gpio allocation tests fail if a physical chip already exists
360 [ "$full_test" -a -e "/dev/gpiochip0" ] && skip "full tests conflict with gpiochip0"
363 echo "1.1. dynamic allocation of gpio"
364 insmod_test "-1,32" 32
365 insmod_test "-1,23,-1,32" 23 32
366 insmod_test "-1,23,-1,26,-1,32" 23 26 32
368 echo "1.2. manual allocation of gpio"
372 echo "1.3. dynamic and manual allocation of gpio"
373 insmod_test "-1,32,32,62" 32 30
374 insmod_test "-1,22,-1,23,0,24,32,64" 22 23 24 32
375 insmod_test "-1,32,32,60,-1,29" 32 28 29
376 insmod_test "-1,32,40,64,-1,5" 32 24 5
377 insmod_test "0,32,32,44,-1,22,-1,31" 32 12 22 31
400 echo "GPIO $module test PASS"