drivers/bcm2835gpio: Migrate to adapter gpio commands
[fw/openocd] / testing / test-bcm2835gpio-deprecated-commands.cfg
1 # SPDX-License-Identifier: GPL-2.0-or-later
2
3 # OpenOCD script to test that the deprecated "bcm2835gpio *" and "bcm2835gpio_*"
4 # commands produce the expected results. Run this command as:
5 # openocd -f <path>/test-bcm2835gpio-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 set supported_signals {tdo tdi tms tck trst swdio swdio_dir swclk srst}
16
17 adapter speed 100
18 adapter driver bcm2835gpio
19 puts "Driver is '[adapter name]'"
20 expected_value "bcm2835gpio" [adapter name]
21 echo [adapter gpio]
22
23 #####################################
24 # Test the "bcm2835gpio *" commands
25
26 # Change the GPIO chip for all signals. Don't check directly here, do so when
27 # each signal command is tested.
28 # bcm2835gpio gpiochip 0
29
30 bcm2835gpio jtag_nums 1 2 3 4
31 expected_value "adapter gpio tck (output): num 1, chip 0, active-high, push-pull, pull-none, init-state inactive" [eval adapter gpio tck]
32 expected_value "adapter gpio tms (output): num 2, chip 0, active-high, push-pull, pull-none, init-state active" [eval adapter gpio tms]
33 expected_value "adapter gpio tdi (output): num 3, chip 0, active-high, push-pull, pull-none, init-state inactive" [eval adapter gpio tdi]
34 expected_value "adapter gpio tdo (input): num 4, chip 0, active-high, pull-none, init-state input" [eval adapter gpio tdo]
35
36 bcm2835gpio tck_num 5
37 expected_value "adapter gpio tck (output): num 5, chip 0, active-high, push-pull, pull-none, init-state inactive" [eval adapter gpio tck]
38
39 bcm2835gpio tms_num 6
40 expected_value "adapter gpio tms (output): num 6, chip 0, active-high, push-pull, pull-none, init-state active" [eval adapter gpio tms]
41
42 bcm2835gpio tdi_num 7
43 expected_value "adapter gpio tdi (output): num 7, chip 0, active-high, push-pull, pull-none, init-state inactive" [eval adapter gpio tdi]
44
45 bcm2835gpio tdo_num 8
46 expected_value "adapter gpio tdo (input): num 8, chip 0, active-high, pull-none, init-state input" [eval adapter gpio tdo]
47
48 bcm2835gpio swd_nums 9 10
49 expected_value "adapter gpio swclk (output): num 9, chip 0, active-high, push-pull, pull-none, init-state inactive" [eval adapter gpio swclk]
50 expected_value "adapter gpio swdio (bidirectional): num 10, chip 0, active-high, push-pull, pull-none, init-state inactive" [eval adapter gpio swdio]
51
52 bcm2835gpio swclk_num 11
53 expected_value "adapter gpio swclk (output): num 11, chip 0, active-high, push-pull, pull-none, init-state inactive" [eval adapter gpio swclk]
54
55 bcm2835gpio swdio_num 12
56 expected_value "adapter gpio swdio (bidirectional): num 12, chip 0, active-high, push-pull, pull-none, init-state inactive" [eval adapter gpio swdio]
57
58 bcm2835gpio swdio_dir_num 13
59 expected_value "adapter gpio swdio_dir (output): num 13, chip 0, active-high, push-pull, pull-none" [eval adapter gpio swdio_dir]
60
61 bcm2835gpio srst_num 14
62 expected_value "adapter gpio srst (output): num 14, chip 0, active-low, pull-none, init-state inactive" [eval adapter gpio srst]
63
64 bcm2835gpio trst_num 15
65 expected_value "adapter gpio trst (output): num 15, chip 0, active-low, pull-none, init-state inactive" [eval adapter gpio trst]
66
67
68 #####################################
69 # Test the old bcm2835gpio_* commands
70
71 # Reset the GPIO chip for all signals. Don't check directly here, do so when
72 # each signal command is tested.
73 foreach sig_name $supported_signals {
74         eval adapter gpio $sig_name -chip -1
75 }
76
77 bcm2835gpio_jtag_nums 17 18 19 20
78 expected_value "adapter gpio tck (output): num 17, chip 0, active-high, push-pull, pull-none, init-state inactive" [eval adapter gpio tck]
79 expected_value "adapter gpio tms (output): num 18, chip 0, active-high, push-pull, pull-none, init-state active" [eval adapter gpio tms]
80 expected_value "adapter gpio tdi (output): num 19, chip 0, active-high, push-pull, pull-none, init-state inactive" [eval adapter gpio tdi]
81 expected_value "adapter gpio tdo (input): num 20, chip 0, active-high, pull-none, init-state input" [eval adapter gpio tdo]
82
83 bcm2835gpio_tck_num 21
84 expected_value "adapter gpio tck (output): num 21, chip 0, active-high, push-pull, pull-none, init-state inactive" [eval adapter gpio tck]
85
86 bcm2835gpio_tms_num 22
87 expected_value "adapter gpio tms (output): num 22, chip 0, active-high, push-pull, pull-none, init-state active" [eval adapter gpio tms]
88
89 bcm2835gpio_tdi_num 23
90 expected_value "adapter gpio tdi (output): num 23, chip 0, active-high, push-pull, pull-none, init-state inactive" [eval adapter gpio tdi]
91
92 bcm2835gpio_tdo_num 24
93 expected_value "adapter gpio tdo (input): num 24, chip 0, active-high, pull-none, init-state input" [eval adapter gpio tdo]
94
95 bcm2835gpio_swd_nums 25 26
96 expected_value "adapter gpio swclk (output): num 25, chip 0, active-high, push-pull, pull-none, init-state inactive" [eval adapter gpio swclk]
97 expected_value "adapter gpio swdio (bidirectional): num 26, chip 0, active-high, push-pull, pull-none, init-state inactive" [eval adapter gpio swdio]
98
99 bcm2835gpio_swclk_num 27
100 expected_value "adapter gpio swclk (output): num 27, chip 0, active-high, push-pull, pull-none, init-state inactive" [eval adapter gpio swclk]
101
102 bcm2835gpio_swdio_num 28
103 expected_value "adapter gpio swdio (bidirectional): num 28, chip 0, active-high, push-pull, pull-none, init-state inactive" [eval adapter gpio swdio]
104
105 puts "SUCCESS"