Lines Matching +full:3 +full:- +full:line

2 # SPDX-License-Identifier: GPL-2.0
7 CONFIGFS_SIM_DIR="/sys/kernel/config/gpio-sim"
8 CONFIGFS_AGG_DIR="/sys/kernel/config/gpio-aggregator"
9 SYSFS_AGG_DIR="/sys/bus/platform/drivers/gpio-aggregator"
10 MODULE="gpio-aggregator"
24 # gpio-sim
38 local NOCHECK=${1:-0}
41 [ -d "$CHIP_DIR" ] || continue
43 find "$CHIP_DIR" -depth -type d -exec rmdir {} \;
45 [ "$NOCHECK" -eq 1 ] && return;
46 remaining=$(find "$CONFIGFS_SIM_DIR" -mindepth 1 -type d 2> /dev/null)
47 if [ -n "$remaining" ]; then
58 $BASE_DIR/gpio-chip-info "/dev/$CHIP_NAME" label || \
62 # gpio-aggregator
72 find "$CONFIGFS_AGG_DIR/$CHIP/" -depth -type d -exec rmdir {} \; || \
78 local LINE=$2
80 mkdir "$CONFIGFS_AGG_DIR/$CHIP/$LINE"
85 local LINE=$2
87 rmdir "$CONFIGFS_AGG_DIR/$CHIP/$LINE"
92 local LINE=$2
93 local KEY=$3
95 echo "$KEY" > "$CONFIGFS_AGG_DIR/$CHIP/$LINE/key" || fail "Unable to set the lookup key"
100 local LINE=$2
101 local OFFSET=$3
103 echo "$OFFSET" > "$CONFIGFS_AGG_DIR/$CHIP/$LINE/offset" || \
109 local LINE=$2
110 local NAME=$3
112 echo "$NAME" > "$CONFIGFS_AGG_DIR/$CHIP/$LINE/name" || fail "Unable to set the line name"
128 local NOCHECK=${1:-0}
131 [ -d "$CHIP_DIR" ] || continue
133 find "$CHIP_DIR" -depth -type d -exec rmdir {} \;
135 [ "$NOCHECK" -eq 1 ] && return;
136 remaining=$(find "$CONFIGFS_AGG_DIR" -mindepth 1 -type d 2> /dev/null)
137 if [ -n "$remaining" ]; then
153 -maxdepth 1 -type d -name "gpiochip[0-9]*" 2> /dev/null)
154 local CHIP_COUNT=$(echo "$CHIP_LIST" | wc -l)
156 if [ -z "$CHIP_LIST" ]; then
158 elif [ "$CHIP_COUNT" -ne 1 ]; then
166 local N_DIR=$(ls -d $CONFIGFS_AGG_DIR/$CHIP/line[0-9]* 2> /dev/null | wc -l)
173 $BASE_DIR/gpio-chip-info \
174 "/dev/$(agg_configfs_chip_name "$CHIP")" num-lines
186 $BASE_DIR/gpio-chip-info "/dev/$(agg_configfs_chip_name "$CHIP")" label || \
193 local NAME_CONFIGFS=$(cat "$CONFIGFS_AGG_DIR/$CHIP/line${OFFSET}/name")
200 $BASE_DIR/gpio-line-name \
202 ) || fail "Unable to read the line name from the character device"
204 fail "Discrepancy between two sources for the name of line"
212 modprobe gpio-sim || skip "unable to load the gpio-sim module"
213 modprobe gpio-aggregator || skip "unable to load the gpio-aggregator module"
217 if [ "$IDX" -eq "5" ]; then
221 mountpoint -q /sys/kernel/config && break
232 # Use gpio-sim chips as the test backend
233 for CHIP in $(seq -f "chip%g" 0 1); do
235 for BANK in $(seq -f "bank%g" 0 1); do
236 mkdir -p "$CONFIGFS_SIM_DIR/$CHIP/$BANK"
243 LINE_DIR="$CONFIGFS_SIM_DIR/$CHIP/$BANK/line$IDX"
244 mkdir -p $LINE_DIR
245 echo "$LINE_NAME" > "$LINE_DIR/name" || fail "unable to set the line name"
266 test "$(agg_get_line_name agg0 0)" = "test0" || fail "line name is unset"
282 agg_set_offset agg0 line1 3
294 test "$(agg_get_line_name agg0 0)" = "test0" || fail "line name is unset"
295 test "$(agg_get_line_name agg0 1)" = "test1" || fail "line name is unset"
296 test "$(agg_get_line_name agg0 2)" = "test2" || fail "line name is unset"
297 test "$(agg_get_line_name agg0 3)" = "test3" || fail "line name is unset"
305 echo "1.1.3. Can't instantiate a chip without any line"
351 test "$(agg_get_line_name _sysfs.0 0)" = "" || fail "line name is unset"
353 test -d $CONFIGFS_AGG_DIR/_sysfs.0 && fail "_sysfs.0 unexpectedly remains"
354 test -d /dev/${CHIPNAME} && fail "/dev/${CHIPNAME} unexpectedly remains"
357 echo "chip0bank0_0 chip1_bank1 10-11" > "$SYSFS_AGG_DIR/new_device"
362 test "$(agg_get_chip_num_lines _sysfs.0)" = "3" || fail "number of lines is not 3"
363 test "$(agg_get_line_name _sysfs.0 0)" = "" || fail "line name is unset"
364 test "$(agg_get_line_name _sysfs.0 1)" = "" || fail "line name is unset"
365 test "$(agg_get_line_name _sysfs.0 2)" = "" || fail "line name is unset"
367 test -d $CONFIGFS_AGG_DIR/_sysfs.0 && fail "_sysfs.0 unexpectedly remains"
368 test -d /dev/${CHIPNAME} && fail "/dev/${CHIPNAME} unexpectedly remains"
370 echo "1.2.3. Asynchronous creation with deferred probe"
382 test "$(agg_get_line_name _sysfs.0 0)" = "" || fail "line name unexpectedly set"
384 test -d $CONFIGFS_AGG_DIR/_sysfs.0 && fail "_sysfs.0 unexpectedly remains"
385 test -d /dev/${CHIPNAME} && fail "/dev/${CHIPNAME} unexpectedly remains"
402 agg_set_offset agg0 line1 3
413 echo "2.1.1.1. Line can be added/removed"
420 test "$(agg_get_chip_num_lines agg0)" = "3" || fail "number of lines is not 1"
423 echo "2.1.1.2. Line key can be modified"
431 echo "2.1.1.3. Line name can be modified"
437 test "$(agg_get_line_name agg0 0)" = "new0" || fail "line name is unset"
438 test "$(agg_get_line_name agg0 1)" = "new1" || fail "line name is unset"
441 echo "2.1.1.4. Line offset can be modified"
449 echo "2.1.1.5. Can re-enable a chip after valid reconfiguration"
460 test "$(agg_get_chip_num_lines agg0)" = "3" || fail "number of lines is not 1"
463 echo "2.1.1.7. Can't re-enable a chip with invalid reconfiguration"
477 echo "2.1.2.1. Can't add/remove line"
479 mkdir "$CONFIGFS_AGG_DIR/agg0/line2" 2> /dev/null && fail "line unexpectedly added"
480 rmdir "$CONFIGFS_AGG_DIR/agg0/line1" 2> /dev/null && fail "line unexpectedly removed"
483 echo "2.1.2.2. Can't modify line key"
489 echo "2.1.2.3. Can't modify line name"
495 echo "2.1.2.4. Can't modify line offset"
503 echo "chip0_bank0 1 chip1_bank0 3" > "$SYSFS_AGG_DIR/new_device"
517 echo "2.2.1.2. Can't add/remove line"
519 mkdir "$CONFIGFS_AGG_DIR/_sysfs.0/line2" 2> /dev/null && fail "line unexpectedly added"
520 rmdir "$CONFIGFS_AGG_DIR/_sysfs.0/line1" 2> /dev/null && fail "line unexpectedly removed"
523 echo "2.2.1.3. Can't modify line key"
529 echo "2.2.1.4. Can't modify line name"
535 echo "2.2.1.5. Can't modify line offset"
543 echo "2.2.2.1. Can't add/remove line despite live = 0"
546 mkdir "$CONFIGFS_AGG_DIR/_sysfs.0/line2" 2> /dev/null && fail "line unexpectedly added"
547 rmdir "$CONFIGFS_AGG_DIR/_sysfs.0/line1" 2> /dev/null && fail "line unexpectedly removed"
551 echo "2.2.2.2. Can't modify line key"
559 echo "2.2.2.3. Can't modify line name"
567 echo "2.2.2.4. Can't modify line offset"
583 echo "2.2.3. While offline"
585 echo "2.2.3.1. Can't add/remove line despite live = 0"
588 mkdir "$CONFIGFS_AGG_DIR/_sysfs.0/line2" 2> /dev/null && fail "line unexpectedly added"
589 rmdir "$CONFIGFS_AGG_DIR/_sysfs.0/line1" 2> /dev/null && fail "line unexpectedly removed"
592 echo "2.2.3.2. Line key can be modified"
600 echo "2.2.3.3. Line name can be modified"
606 test "$(agg_get_line_name _sysfs.0 0)" = "new0" || fail "line name is unset"
607 test "$(agg_get_line_name _sysfs.0 1)" = "new1" || fail "line name is unset"
610 echo "2.2.3.4. Line offset can be modified"
618 echo "2.2.3.5. Can re-enable a chip with valid reconfiguration"
628 echo "2.2.3.6. Can't re-enable a chip with invalid reconfiguration"
640 echo "3. Module unload"
644 modprobe -r gpio-aggregator 2> /dev/null
645 test -d /sys/module/gpio_aggregator || fail "module unexpectedly unloaded"
649 echo "chip0_bank0 1 chip1_bank0 3" > "$SYSFS_AGG_DIR/new_device"
650 modprobe -r gpio-aggregator 2> /dev/null
651 test -d /sys/module/gpio_aggregator && fail "module unexpectedly remains to be loaded"
652 modprobe gpio-aggregator 2> /dev/null
660 CHIP=$(echo "$SETTING" | cut -d: -f1)
661 BANK=$(echo "$SETTING" | cut -d: -f2)
662 LINE=$(echo "$SETTING" | cut -d: -f3)
663 agg_create_line agg0 "line${OFFSET}"
664 agg_set_key agg0 "line${OFFSET}" "$(sim_get_chip_label "$CHIP" "$BANK")"
665 agg_set_offset agg0 "line${OFFSET}" "$LINE"
678 CHIP=$(echo "$SETTING" | cut -d: -f1)
679 BANK=$(echo "$SETTING" | cut -d: -f2)
680 LINE=$(echo "$SETTING" | cut -d: -f3)
683 VAL_PATH="/sys/devices/platform/$DEVNAME/$CHIPNAME/sim_gpio${LINE}/value"
685 $BASE_DIR/gpio-mockup-cdev -s 1 "/dev/$(agg_configfs_chip_name agg0)" "$OFFSET" &
698 CHIP=$(echo "$SETTING" | cut -d: -f1)
699 BANK=$(echo "$SETTING" | cut -d: -f2)
700 LINE=$(echo "$SETTING" | cut -d: -f3)
703 VAL_PATH="/sys/devices/platform/$DEVNAME/$CHIPNAME/sim_gpio${LINE}/value"
704 $BASE_DIR/gpio-mockup-cdev -b pull-up "/dev/$(agg_configfs_chip_name agg0)" "$OFFSET"
720 while kill -0 "$writer_pid" 2> /dev/null; do
722 modprobe gpio-aggregator
723 modprobe -r gpio-aggregator