drivers/linuxgpiod: Migrate to adapter gpio commands
[fw/openocd] / testing / test-linuxgpiod-deprecated-commands.cfg
1 # SPDX-License-Identifier: GPL-2.0-or-later
2
3 # OpenOCD script to test that the deprecated "linuxgpiod *" and "linuxgpiod_*"
4 # commands produce the expected results. Run this command as:
5 # openocd -f <path>/test-linuxgpiod-deprecated-commands.cfg
6
7 # Raise an error if the "actual" value does not match the "expected" value. Trim
8 # whitespace (including newlines) from strings before comparing.
9 proc expected_value {expected actual} {
10         if {[string trim $expected] ne [string trim $actual]} {
11                 error [puts "ERROR: '${actual}' != '${expected}'"]
12         }
13 }
14
15 adapter driver linuxgpiod
16 puts "Driver is '[adapter name]'"
17 expected_value "linuxgpiod" [adapter name]
18 echo [adapter gpio]
19
20 #####################################
21 # Test the "linuxgpiod *" commands
22
23 # Change the GPIO chip for all signals. Don't check directly here, do so when
24 # each signal command is tested.
25 linuxgpiod gpiochip 0
26
27 linuxgpiod jtag_nums 1 2 3 4
28 expected_value "adapter gpio tck (output): num 1, chip 0, active-high, push-pull, pull-none, init-state inactive" [eval adapter gpio tck]
29 expected_value "adapter gpio tms (output): num 2, chip 0, active-high, push-pull, pull-none, init-state active" [eval adapter gpio tms]
30 expected_value "adapter gpio tdi (output): num 3, chip 0, active-high, push-pull, pull-none, init-state inactive" [eval adapter gpio tdi]
31 expected_value "adapter gpio tdo (input): num 4, chip 0, active-high, pull-none, init-state input" [eval adapter gpio tdo]
32
33 linuxgpiod tck_num 5
34 expected_value "adapter gpio tck (output): num 5, chip 0, active-high, push-pull, pull-none, init-state inactive" [eval adapter gpio tck]
35
36 linuxgpiod tms_num 6
37 expected_value "adapter gpio tms (output): num 6, chip 0, active-high, push-pull, pull-none, init-state active" [eval adapter gpio tms]
38
39 linuxgpiod tdi_num 7
40 expected_value "adapter gpio tdi (output): num 7, chip 0, active-high, push-pull, pull-none, init-state inactive" [eval adapter gpio tdi]
41
42 linuxgpiod tdo_num 8
43 expected_value "adapter gpio tdo (input): num 8, chip 0, active-high, pull-none, init-state input" [eval adapter gpio tdo]
44
45 linuxgpiod swd_nums 9 10
46 expected_value "adapter gpio swclk (output): num 9, chip 0, active-high, push-pull, pull-none, init-state inactive" [eval adapter gpio swclk]
47 expected_value "adapter gpio swdio (bidirectional): num 10, chip 0, active-high, push-pull, pull-none, init-state inactive" [eval adapter gpio swdio]
48
49 linuxgpiod swclk_num 11
50 expected_value "adapter gpio swclk (output): num 11, chip 0, active-high, push-pull, pull-none, init-state inactive" [eval adapter gpio swclk]
51
52 linuxgpiod swdio_num 12
53 expected_value "adapter gpio swdio (bidirectional): num 12, chip 0, active-high, push-pull, pull-none, init-state inactive" [eval adapter gpio swdio]
54
55 linuxgpiod swdio_dir_num 13
56 expected_value "adapter gpio swdio_dir (output): num 13, chip 0, active-high, push-pull, pull-none" [eval adapter gpio swdio_dir]
57
58 linuxgpiod srst_num 14
59 expected_value "adapter gpio srst (output): num 14, chip 0, active-low, pull-none, init-state inactive" [eval adapter gpio srst]
60
61 linuxgpiod trst_num 15
62 expected_value "adapter gpio trst (output): num 15, chip 0, active-low, pull-none, init-state inactive" [eval adapter gpio trst]
63
64 linuxgpiod led_num 16
65 expected_value "adapter gpio led (output): num 16, chip 0, active-high, push-pull, pull-none, init-state inactive" [eval adapter gpio led]
66
67 #####################################
68 # Test the old linuxgpiod_* commands
69
70 # Change the GPIO chip for all signals. Don't check directly here, do so when
71 # each signal command is tested.
72 linuxgpiod_gpiochip 1
73
74 linuxgpiod_jtag_nums 17 18 19 20
75 expected_value "adapter gpio tck (output): num 17, chip 1, active-high, push-pull, pull-none, init-state inactive" [eval adapter gpio tck]
76 expected_value "adapter gpio tms (output): num 18, chip 1, active-high, push-pull, pull-none, init-state active" [eval adapter gpio tms]
77 expected_value "adapter gpio tdi (output): num 19, chip 1, active-high, push-pull, pull-none, init-state inactive" [eval adapter gpio tdi]
78 expected_value "adapter gpio tdo (input): num 20, chip 1, active-high, pull-none, init-state input" [eval adapter gpio tdo]
79
80 linuxgpiod_tck_num 21
81 expected_value "adapter gpio tck (output): num 21, chip 1, active-high, push-pull, pull-none, init-state inactive" [eval adapter gpio tck]
82
83 linuxgpiod_tms_num 22
84 expected_value "adapter gpio tms (output): num 22, chip 1, active-high, push-pull, pull-none, init-state active" [eval adapter gpio tms]
85
86 linuxgpiod_tdi_num 23
87 expected_value "adapter gpio tdi (output): num 23, chip 1, active-high, push-pull, pull-none, init-state inactive" [eval adapter gpio tdi]
88
89 linuxgpiod_tdo_num 24
90 expected_value "adapter gpio tdo (input): num 24, chip 1, active-high, pull-none, init-state input" [eval adapter gpio tdo]
91
92 linuxgpiod_swd_nums 25 26
93 expected_value "adapter gpio swclk (output): num 25, chip 1, active-high, push-pull, pull-none, init-state inactive" [eval adapter gpio swclk]
94 expected_value "adapter gpio swdio (bidirectional): num 26, chip 1, active-high, push-pull, pull-none, init-state inactive" [eval adapter gpio swdio]
95
96 linuxgpiod_swclk_num 27
97 expected_value "adapter gpio swclk (output): num 27, chip 1, active-high, push-pull, pull-none, init-state inactive" [eval adapter gpio swclk]
98
99 linuxgpiod_swdio_num 28
100 expected_value "adapter gpio swdio (bidirectional): num 28, chip 1, active-high, push-pull, pull-none, init-state inactive" [eval adapter gpio swdio]
101
102 linuxgpiod_led_num 29
103 expected_value "adapter gpio led (output): num 29, chip 1, active-high, push-pull, pull-none, init-state inactive" [eval adapter gpio led]
104
105 puts "SUCCESS"