Lines Matching +full:chip +full:- +full:to +full:- +full:chip
2 # SPDX-License-Identifier: GPL-2.0
6 CONFIGFS_DIR="/sys/kernel/config/gpio-sim"
7 MODULE="gpio-sim"
22 local CHIP=$1
24 for FILE in $CONFIGFS_DIR/$CHIP/*; do
26 if [ "$BANK" = "live" -o "$BANK" = "dev_name" ]; then
30 LINES=`ls $CONFIGFS_DIR/$CHIP/$BANK/ | grep -E ^line`
33 if [ -e $CONFIGFS_DIR/$CHIP/$BANK/$LINE/hog ]; then
34 rmdir $CONFIGFS_DIR/$CHIP/$BANK/$LINE/hog || \
35 fail "Unable to remove the hog"
38 rmdir $CONFIGFS_DIR/$CHIP/$BANK/$LINE || \
39 fail "Unable to remove the line"
43 rmdir $CONFIGFS_DIR/$CHIP/$BANK
46 rmdir $CONFIGFS_DIR/$CHIP || fail "Unable to remove the chip"
50 local CHIP=$1
52 mkdir $CONFIGFS_DIR/$CHIP
56 local CHIP=$1
59 mkdir $CONFIGFS_DIR/$CHIP/$BANK
63 local CHIP=$1
67 echo $LABEL > $CONFIGFS_DIR/$CHIP/$BANK/label || fail "Unable to set the chip label"
71 local CHIP=$1
75 echo $NUM_LINES > $CONFIGFS_DIR/$CHIP/$BANK/num_lines || \
76 fail "Unable to set the number of lines"
80 local CHIP=$1
84 local LINE_DIR=$CONFIGFS_DIR/$CHIP/$BANK/line$OFFSET
86 test -d $LINE_DIR || mkdir $LINE_DIR
87 echo $NAME > $LINE_DIR/name || fail "Unable to set the line name"
91 local CHIP=$1
93 echo 1 > $CONFIGFS_DIR/$CHIP/live || fail "Unable to enable the chip"
97 local CHIP=$1
99 echo 0 > $CONFIGFS_DIR/$CHIP/live || fail "Unable to disable the chip"
103 for CHIP in `ls $CONFIGFS_DIR/`; do
104 disable_chip $CHIP
105 remove_chip $CHIP
110 local CHIP=$1
113 cat $CONFIGFS_DIR/$CHIP/$BANK/chip_name 2> /dev/null || \
114 fail "unable to read the chip name from configfs"
118 local CHIP=$1
120 cat $CONFIGFS_DIR/$CHIP/dev_name 2> /dev/null || \
121 fail "unable to read the device name from configfs"
125 local CHIP=$1
128 $BASE_DIR/gpio-chip-info /dev/`configfs_chip_name $CHIP $BANK` num-lines || \
129 fail "unable to read the number of lines from the character device"
133 local CHIP=$1
136 $BASE_DIR/gpio-chip-info /dev/`configfs_chip_name $CHIP $BANK` label || \
137 fail "unable to read the chip label from the character device"
141 local CHIP=$1
145 $BASE_DIR/gpio-line-name /dev/`configfs_chip_name $CHIP $BANK` $OFFSET || \
146 fail "unable to read the line name from the character device"
158 echo $PULL > $SYSFS_PATH || fail "Unable to set line pull in sysfs"
161 # Load the gpio-sim module. This will pull in configfs if needed too.
162 modprobe gpio-sim || skip "unable to load the gpio-sim module"
165 if [ "$IDX" -eq "5" ]; then
169 mountpoint -q /sys/kernel/config && break
180 echo "1.1. Chip name is communicated to user"
181 create_chip chip
182 create_bank chip bank
183 enable_chip chip
184 test -n `cat $CONFIGFS_DIR/chip/bank/chip_name` || fail "chip_name doesn't work"
185 disable_chip chip
186 remove_chip chip
188 echo "1.2. chip_name returns 'none' if the chip is still pending"
189 create_chip chip
190 create_bank chip bank
191 test "`cat $CONFIGFS_DIR/chip/bank/chip_name`" = "none" || \
192 fail "chip_name doesn't return 'none' for a pending chip"
193 remove_chip chip
195 echo "1.3. Device name is communicated to user"
196 create_chip chip
197 create_bank chip bank
198 enable_chip chip
199 test -n `cat $CONFIGFS_DIR/chip/dev_name` || fail "dev_name doesn't work"
200 disable_chip chip
201 remove_chip chip
206 create_chip chip
207 create_bank chip bank
208 enable_chip chip
209 test "`get_chip_num_lines chip bank`" = "1" || fail "default number of lines is not 1"
210 disable_chip chip
211 remove_chip chip
214 create_chip chip
215 create_bank chip bank
216 set_num_lines chip bank 16
217 enable_chip chip
218 test "`get_chip_num_lines chip bank`" = "16" || fail "number of lines is not 16"
219 disable_chip chip
220 remove_chip chip
223 create_chip chip
224 create_bank chip bank
225 set_label chip bank foobar
226 enable_chip chip
227 test "`get_chip_label chip bank`" = "foobar" || fail "label is incorrect"
228 disable_chip chip
229 remove_chip chip
232 create_chip chip
233 create_bank chip bank
234 enable_chip chip
235 test -z "`cat $CONFIGFS_DIR/chip/bank/label`" || fail "label is not empty"
236 disable_chip chip
237 remove_chip chip
240 create_chip chip
241 create_bank chip bank
242 set_num_lines chip bank 16
243 set_line_name chip bank 0 foo
244 set_line_name chip bank 2 bar
245 enable_chip chip
246 test "`get_line_name chip bank 0`" = "foo" || fail "line name is incorrect"
247 test "`get_line_name chip bank 2`" = "bar" || fail "line name is incorrect"
248 disable_chip chip
249 remove_chip chip
252 create_chip chip
253 create_bank chip bank
254 set_num_lines chip bank 2
255 set_line_name chip bank 5 foobar
256 enable_chip chip
257 test "`get_line_name chip bank 0`" = "" || fail "line name is incorrect"
258 test "`get_line_name chip bank 1`" = "" || fail "line name is incorrect"
259 disable_chip chip
260 remove_chip chip
263 create_chip chip
264 create_bank chip bank
265 mkdir $CONFIGFS_DIR/chip/bank/line12foobar 2> /dev/null && \
267 mkdir $CONFIGFS_DIR/chip/bank/line_no_offset 2> /dev/null && \
269 remove_chip chip
273 for CHIP in $CHIPS; do
274 create_chip $CHIP
275 create_bank $CHIP bank
276 enable_chip $CHIP
278 for CHIP in $CHIPS; do
279 disable_chip $CHIP
280 remove_chip $CHIP
283 echo "2.9. Can't modify settings when chip is live"
284 create_chip chip
285 create_bank chip bank
286 enable_chip chip
287 echo foobar > $CONFIGFS_DIR/chip/bank/label 2> /dev/null && \
288 fail "Setting label of a live chip should fail"
289 echo 8 > $CONFIGFS_DIR/chip/bank/num_lines 2> /dev/null && \
290 fail "Setting number of lines of a live chip should fail"
291 disable_chip chip
292 remove_chip chip
294 echo "2.10. Can't create line items when chip is live"
295 create_chip chip
296 create_bank chip bank
297 enable_chip chip
298 mkdir $CONFIGFS_DIR/chip/bank/line0 2> /dev/null && fail "Creating line item should fail"
299 disable_chip chip
300 remove_chip chip
302 echo "2.11. Probe errors are propagated to user-space"
303 create_chip chip
304 create_bank chip bank
305 set_num_lines chip bank 99999
306 echo 1 > $CONFIGFS_DIR/chip/live 2> /dev/null && fail "Probe error was not propagated"
307 remove_chip chip
309 echo "2.12. Cannot enable a chip without any GPIO banks"
310 create_chip chip
311 echo 1 > $CONFIGFS_DIR/chip/live 2> /dev/null && fail "Chip enabled without any GPIO banks"
312 remove_chip chip
314 echo "2.13. Duplicate chip labels are not allowed"
315 create_chip chip
316 create_bank chip bank0
317 set_label chip bank0 foobar
318 create_bank chip bank1
319 set_label chip bank1 foobar
320 echo 1 > $CONFIGFS_DIR/chip/live 2> /dev/null && fail "Duplicate chip labels were not rejected"
321 remove_chip chip
324 create_chip chip
325 create_bank chip bank
326 set_num_lines chip bank 8
327 mkdir -p $CONFIGFS_DIR/chip/bank/line4/hog
328 enable_chip chip
329 $BASE_DIR/gpio-mockup-cdev -s 1 /dev/`configfs_chip_name chip bank` 4 2> /dev/null && \
331 disable_chip chip
332 remove_chip chip
337 create_chip chip
338 create_bank chip bank
339 set_num_lines chip bank 8
340 enable_chip chip
341 sysfs_set_pull chip bank 0 pull-up
342 $BASE_DIR/gpio-mockup-cdev /dev/`configfs_chip_name chip bank` 0
344 sysfs_set_pull chip bank 0 pull-down
345 $BASE_DIR/gpio-mockup-cdev /dev/`configfs_chip_name chip bank` 1
347 disable_chip chip
348 remove_chip chip
351 create_chip chip
352 create_bank chip bank
353 set_num_lines chip bank 8
354 enable_chip chip
355 DEVNAME=`configfs_dev_name chip`
356 CHIPNAME=`configfs_chip_name chip bank`
358 test `cat $SYSFS_PATH` = "pull-down" || fail "reading the pull failed"
359 sysfs_set_pull chip bank 0 pull-up
360 test `cat $SYSFS_PATH` = "pull-up" || fail "reading the pull failed"
361 disable_chip chip
362 remove_chip chip
365 create_chip chip
366 create_bank chip bank
367 set_num_lines chip bank 8
368 enable_chip chip
369 DEVNAME=`configfs_dev_name chip`
370 CHIPNAME=`configfs_chip_name chip bank`
373 disable_chip chip
374 remove_chip chip
376 echo "3.4. Can't write to value"
377 create_chip chip
378 create_bank chip bank
379 enable_chip chip
380 DEVNAME=`configfs_dev_name chip`
381 CHIPNAME=`configfs_chip_name chip bank`
383 echo 1 > $SYSFS_PATH 2> /dev/null && fail "writing to 'value' succeeded unexpectedly"
384 disable_chip chip
385 remove_chip chip
390 create_chip chip
391 create_bank chip bank
392 set_num_lines chip bank 8
393 enable_chip chip
394 DEVNAME=`configfs_dev_name chip`
395 CHIPNAME=`configfs_chip_name chip bank`
398 $BASE_DIR/gpio-mockup-cdev -s 1 /dev/`configfs_chip_name chip bank` 0 &
402 disable_chip chip
403 remove_chip chip
406 create_chip chip
407 create_bank chip bank
408 set_num_lines chip bank 8
409 enable_chip chip
410 DEVNAME=`configfs_dev_name chip`
411 CHIPNAME=`configfs_chip_name chip bank`
413 $BASE_DIR/gpio-mockup-cdev -b pull-up /dev/`configfs_chip_name chip bank` 0
415 disable_chip chip
416 remove_chip chip