aboutsummaryrefslogtreecommitdiff
path: root/testing
diff options
context:
space:
mode:
authorSteve Marple <stevemarple@googlemail.com>2022-06-25 23:45:18 +0100
committerAntonio Borneo <borneo.antonio@gmail.com>2022-09-13 22:17:14 +0000
commit0dd969d83badb6793519ee99dd8ab8579d5f59df (patch)
tree2ff179188f8fa72735ea80ce2a6d32418e64d156 /testing
parente643a494d46c571711ccba361ad20faaf6f6503c (diff)
downloadriscv-openocd-0dd969d83badb6793519ee99dd8ab8579d5f59df.zip
riscv-openocd-0dd969d83badb6793519ee99dd8ab8579d5f59df.tar.gz
riscv-openocd-0dd969d83badb6793519ee99dd8ab8579d5f59df.tar.bz2
drivers/bcm2835gpio: Migrate to adapter gpio commands
Use the new "adapter gpio" commands to configure the GPIOs used by the bcm2835gpio driver. The driver supports only 1 chip (gpiochip0). The reset function now honours the srst_open_drain and trst_open_drain options. Signed-off-by: Steve Marple <stevemarple@googlemail.com> Change-Id: I5b6c68b16362000cf5141a83394549d2bf3af108 Reviewed-on: https://review.openocd.org/c/openocd/+/7123 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Diffstat (limited to 'testing')
-rw-r--r--testing/test-bcm2835gpio-deprecated-commands.cfg105
1 files changed, 105 insertions, 0 deletions
diff --git a/testing/test-bcm2835gpio-deprecated-commands.cfg b/testing/test-bcm2835gpio-deprecated-commands.cfg
new file mode 100644
index 0000000..b34eb36
--- /dev/null
+++ b/testing/test-bcm2835gpio-deprecated-commands.cfg
@@ -0,0 +1,105 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+# OpenOCD script to test that the deprecated "bcm2835gpio *" and "bcm2835gpio_*"
+# commands produce the expected results. Run this command as:
+# openocd -f <path>/test-bcm2835gpio-deprecated-commands.cfg
+
+# Raise an error if the "actual" value does not match the "expected" value. Trim
+# whitespace (including newlines) from strings before comparing.
+proc expected_value {expected actual} {
+ if {[string trim $expected] ne [string trim $actual]} {
+ error [puts "ERROR: '${actual}' != '${expected}'"]
+ }
+}
+
+set supported_signals {tdo tdi tms tck trst swdio swdio_dir swclk srst}
+
+adapter speed 100
+adapter driver bcm2835gpio
+puts "Driver is '[adapter name]'"
+expected_value "bcm2835gpio" [adapter name]
+echo [adapter gpio]
+
+#####################################
+# Test the "bcm2835gpio *" commands
+
+# Change the GPIO chip for all signals. Don't check directly here, do so when
+# each signal command is tested.
+# bcm2835gpio gpiochip 0
+
+bcm2835gpio jtag_nums 1 2 3 4
+expected_value "adapter gpio tck (output): num 1, chip 0, active-high, push-pull, pull-none, init-state inactive" [eval adapter gpio tck]
+expected_value "adapter gpio tms (output): num 2, chip 0, active-high, push-pull, pull-none, init-state active" [eval adapter gpio tms]
+expected_value "adapter gpio tdi (output): num 3, chip 0, active-high, push-pull, pull-none, init-state inactive" [eval adapter gpio tdi]
+expected_value "adapter gpio tdo (input): num 4, chip 0, active-high, pull-none, init-state input" [eval adapter gpio tdo]
+
+bcm2835gpio tck_num 5
+expected_value "adapter gpio tck (output): num 5, chip 0, active-high, push-pull, pull-none, init-state inactive" [eval adapter gpio tck]
+
+bcm2835gpio tms_num 6
+expected_value "adapter gpio tms (output): num 6, chip 0, active-high, push-pull, pull-none, init-state active" [eval adapter gpio tms]
+
+bcm2835gpio tdi_num 7
+expected_value "adapter gpio tdi (output): num 7, chip 0, active-high, push-pull, pull-none, init-state inactive" [eval adapter gpio tdi]
+
+bcm2835gpio tdo_num 8
+expected_value "adapter gpio tdo (input): num 8, chip 0, active-high, pull-none, init-state input" [eval adapter gpio tdo]
+
+bcm2835gpio swd_nums 9 10
+expected_value "adapter gpio swclk (output): num 9, chip 0, active-high, push-pull, pull-none, init-state inactive" [eval adapter gpio swclk]
+expected_value "adapter gpio swdio (bidirectional): num 10, chip 0, active-high, push-pull, pull-none, init-state inactive" [eval adapter gpio swdio]
+
+bcm2835gpio swclk_num 11
+expected_value "adapter gpio swclk (output): num 11, chip 0, active-high, push-pull, pull-none, init-state inactive" [eval adapter gpio swclk]
+
+bcm2835gpio swdio_num 12
+expected_value "adapter gpio swdio (bidirectional): num 12, chip 0, active-high, push-pull, pull-none, init-state inactive" [eval adapter gpio swdio]
+
+bcm2835gpio swdio_dir_num 13
+expected_value "adapter gpio swdio_dir (output): num 13, chip 0, active-high, push-pull, pull-none" [eval adapter gpio swdio_dir]
+
+bcm2835gpio srst_num 14
+expected_value "adapter gpio srst (output): num 14, chip 0, active-low, pull-none, init-state inactive" [eval adapter gpio srst]
+
+bcm2835gpio trst_num 15
+expected_value "adapter gpio trst (output): num 15, chip 0, active-low, pull-none, init-state inactive" [eval adapter gpio trst]
+
+
+#####################################
+# Test the old bcm2835gpio_* commands
+
+# Reset the GPIO chip for all signals. Don't check directly here, do so when
+# each signal command is tested.
+foreach sig_name $supported_signals {
+ eval adapter gpio $sig_name -chip -1
+}
+
+bcm2835gpio_jtag_nums 17 18 19 20
+expected_value "adapter gpio tck (output): num 17, chip 0, active-high, push-pull, pull-none, init-state inactive" [eval adapter gpio tck]
+expected_value "adapter gpio tms (output): num 18, chip 0, active-high, push-pull, pull-none, init-state active" [eval adapter gpio tms]
+expected_value "adapter gpio tdi (output): num 19, chip 0, active-high, push-pull, pull-none, init-state inactive" [eval adapter gpio tdi]
+expected_value "adapter gpio tdo (input): num 20, chip 0, active-high, pull-none, init-state input" [eval adapter gpio tdo]
+
+bcm2835gpio_tck_num 21
+expected_value "adapter gpio tck (output): num 21, chip 0, active-high, push-pull, pull-none, init-state inactive" [eval adapter gpio tck]
+
+bcm2835gpio_tms_num 22
+expected_value "adapter gpio tms (output): num 22, chip 0, active-high, push-pull, pull-none, init-state active" [eval adapter gpio tms]
+
+bcm2835gpio_tdi_num 23
+expected_value "adapter gpio tdi (output): num 23, chip 0, active-high, push-pull, pull-none, init-state inactive" [eval adapter gpio tdi]
+
+bcm2835gpio_tdo_num 24
+expected_value "adapter gpio tdo (input): num 24, chip 0, active-high, pull-none, init-state input" [eval adapter gpio tdo]
+
+bcm2835gpio_swd_nums 25 26
+expected_value "adapter gpio swclk (output): num 25, chip 0, active-high, push-pull, pull-none, init-state inactive" [eval adapter gpio swclk]
+expected_value "adapter gpio swdio (bidirectional): num 26, chip 0, active-high, push-pull, pull-none, init-state inactive" [eval adapter gpio swdio]
+
+bcm2835gpio_swclk_num 27
+expected_value "adapter gpio swclk (output): num 27, chip 0, active-high, push-pull, pull-none, init-state inactive" [eval adapter gpio swclk]
+
+bcm2835gpio_swdio_num 28
+expected_value "adapter gpio swdio (bidirectional): num 28, chip 0, active-high, push-pull, pull-none, init-state inactive" [eval adapter gpio swdio]
+
+puts "SUCCESS"