drivers/am335xgpio: Migrate to adapter gpio commands

Use the new "adapter gpio" commands to configure the GPIOs used by the
am335xgpio driver. The AM335x has 4 GPIO 'chips' (chip number 0-3
inclusive), with each one providing 32 GPIOs (gpio_num 0-31 inclusive).

Change-Id: I7c63c0e4763657ea51790c43fc40d32b7c3580bb
Signed-off-by: Steve Marple <stevemarple@googlemail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6984
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
This commit is contained in:
Steve Marple
2022-05-17 21:51:17 +01:00
committed by Antonio Borneo
parent 82fd400542
commit ace028262b
6 changed files with 405 additions and 517 deletions

View File

@@ -3387,86 +3387,16 @@ registers directly. The memory mapping requires read and write permission to
kernel memory; if /dev/gpiomem exists it will be used, otherwise /dev/mem will kernel memory; if /dev/gpiomem exists it will be used, otherwise /dev/mem will
be used. The driver restores the GPIO state on exit. be used. The driver restores the GPIO state on exit.
All four GPIO ports are available. GPIOs numbered 0 to 31 are mapped to GPIO port All four GPIO ports are available. GPIO configuration is handled by the generic
0, GPIO numbers 32 to 63 are mapped to GPIO port 1 and so on. command @ref{adapter gpio, @command{adapter gpio}}.
See @file{interface/beaglebone-swd-native.cfg} for a sample configuration file.
@deffn {Config Command} {am335xgpio jtag_nums} @var{tck} @var{tms} @var{tdi} @var{tdo}
Set JTAG transport GPIO numbers for TCK, TMS, TDI, and TDO (in that order).
Must be specified to enable JTAG transport. These pins can also be specified
individually.
@end deffn
@deffn {Config Command} {am335xgpio tck_num} @var{tck}
Set TCK GPIO number. Must be specified to enable JTAG transport. Can also be
specified using the configuration command @command{am335xgpio jtag_nums}.
@end deffn
@deffn {Config Command} {am335xgpio tms_num} @var{tms}
Set TMS GPIO number. Must be specified to enable JTAG transport. Can also be
specified using the configuration command @command{am335xgpio jtag_nums}.
@end deffn
@deffn {Config Command} {am335xgpio tdo_num} @var{tdo}
Set TDO GPIO number. Must be specified to enable JTAG transport. Can also be
specified using the configuration command @command{am335xgpio jtag_nums}.
@end deffn
@deffn {Config Command} {am335xgpio tdi_num} @var{tdi}
Set TDI GPIO number. Must be specified to enable JTAG transport. Can also be
specified using the configuration command @command{am335xgpio jtag_nums}.
@end deffn
@deffn {Config Command} {am335xgpio swd_nums} @var{swclk} @var{swdio}
Set SWD transport GPIO numbers for SWCLK and SWDIO (in that order). Must be
specified to enable SWD transport. These pins can also be specified individually.
@end deffn
@deffn {Config Command} {am335xgpio swclk_num} @var{swclk}
Set SWCLK GPIO number. Must be specified to enable SWD transport. Can also be
specified using the configuration command @command{am335xgpio swd_nums}.
@end deffn
@deffn {Config Command} {am335xgpio swdio_num} @var{swdio}
Set SWDIO GPIO number. Must be specified to enable SWD transport. Can also be
specified using the configuration command @command{am335xgpio swd_nums}.
@end deffn
@deffn {Config Command} {am335xgpio swdio_dir_num} @var{swdio_dir}
Set SWDIO direction control pin GPIO number. If specified, this pin can be used
to control the direction of an external buffer on the SWDIO pin. The direction
control state can be set with the command @command{am335xgpio
swdio_dir_output_state}. If not specified this feature is disabled.
@end deffn
@deffn {Config Command} {am335xgpio swdio_dir_output_state} @var{output_state}
Set the state required for an external SWDIO buffer to be an output. Valid
values are @option{on} (default) and @option{off}.
@end deffn
@deffn {Config Command} {am335xgpio srst_num} @var{srst}
Set SRST GPIO number. Must be specified to enable SRST.
@end deffn
@deffn {Config Command} {am335xgpio trst_num} @var{trst}
Set TRST GPIO number. Must be specified to enable TRST.
@end deffn
@deffn {Config Command} {am335xgpio led_num} @var{led}
Set activity LED GPIO number. If not specified an activity LED is not enabled.
@end deffn
@deffn {Config Command} {am335xgpio led_on_state} @var{on_state}
Set required logic level for the LED to be on. Valid values are @option{on}
(default) and @option{off}.
@end deffn
@deffn {Config Command} {am335xgpio speed_coeffs} @var{speed_coeff} @var{speed_offset} @deffn {Config Command} {am335xgpio speed_coeffs} @var{speed_coeff} @var{speed_offset}
Set SPEED_COEFF and SPEED_OFFSET for delay calculations. If unspecified Set SPEED_COEFF and SPEED_OFFSET for delay calculations. If unspecified
speed_coeff defaults to 600000 and speed_offset defaults to 575. speed_coeff defaults to 600000 and speed_offset defaults to 575.
@end deffn @end deffn
See @file{interface/beaglebone-swd-native.cfg} for a sample configuration file.
@end deffn @end deffn

File diff suppressed because it is too large Load Diff

View File

@@ -863,4 +863,106 @@ proc "xds110 serial" {args} {
eval adapter serial $args eval adapter serial $args
} }
lappend _telnet_autocomplete_skip "am335xgpio jtag_nums"
proc "am335xgpio jtag_nums" {tck_num tms_num tdi_num tdo_num} {
echo "DEPRECATED! use 'adapter gpio tck; adapter gpio tms; adapter gpio tdi; adapter gpio tdo' not 'am335xgpio jtag_nums'"
eval adapter gpio tck [expr {$tck_num % 32}] -chip [expr {$tck_num / 32}]
eval adapter gpio tms [expr {$tms_num % 32}] -chip [expr {$tms_num / 32}]
eval adapter gpio tdi [expr {$tdi_num % 32}] -chip [expr {$tdi_num / 32}]
eval adapter gpio tdo [expr {$tdo_num % 32}] -chip [expr {$tdo_num / 32}]
}
lappend _telnet_autocomplete_skip "am335xgpio tck_num"
proc "am335xgpio tck_num" {num} {
echo "DEPRECATED! use 'adapter gpio tck' not 'am335xgpio tck_num'"
eval adapter gpio tck [expr {$num % 32}] -chip [expr {$num / 32}]
}
lappend _telnet_autocomplete_skip "am335xgpio tms_num"
proc "am335xgpio tms_num" {num} {
echo "DEPRECATED! use 'adapter gpio tms' not 'am335xgpio tms_num'"
eval adapter gpio tms [expr {$num % 32}] -chip [expr {$num / 32}]
}
lappend _telnet_autocomplete_skip "am335xgpio tdi_num"
proc "am335xgpio tdi_num" {num} {
echo "DEPRECATED! use 'adapter gpio tdi' not 'am335xgpio tdi_num'"
eval adapter gpio tdi [expr {$num % 32}] -chip [expr {$num / 32}]
}
lappend _telnet_autocomplete_skip "am335xgpio tdo_num"
proc "am335xgpio tdo_num" {num} {
echo "DEPRECATED! use 'adapter gpio tdo' not 'am335xgpio tdo_num'"
eval adapter gpio tdo [expr {$num % 32}] -chip [expr {$num / 32}]
}
lappend _telnet_autocomplete_skip "am335xgpio swd_nums"
proc "am335xgpio swd_nums" {swclk swdio} {
echo "DEPRECATED! use 'adapter gpio swclk; adapter gpio swdio' not 'am335xgpio jtag_nums'"
eval adapter gpio swclk [expr {$swclk % 32}] -chip [expr {$swclk / 32}]
eval adapter gpio swdio [expr {$swdio % 32}] -chip [expr {$swdio / 32}]
}
lappend _telnet_autocomplete_skip "am335xgpio swclk_num"
proc "am335xgpio swclk_num" {num} {
echo "DEPRECATED! use 'adapter gpio swclk' not 'am335xgpio swclk_num'"
eval adapter gpio swclk [expr {$num % 32}] -chip [expr {$num / 32}]
}
lappend _telnet_autocomplete_skip "am335xgpio swdio_num"
proc "am335xgpio swdio_num" {num} {
echo "DEPRECATED! use 'adapter gpio swdio' not 'am335xgpio swdio_num'"
eval adapter gpio swdio [expr {$num % 32}] -chip [expr {$num / 32}]
}
lappend _telnet_autocomplete_skip "am335xgpio swdio_dir_num"
proc "am335xgpio swdio_dir_num" {num} {
echo "DEPRECATED! use 'adapter gpio swdio_dir' not 'am335xgpio swdio_dir_num'"
eval adapter gpio swdio_dir [expr {$num % 32}] -chip [expr {$num / 32}]
}
lappend _telnet_autocomplete_skip "am335xgpio swdio_dir_output_state"
proc "am335xgpio swdio_dir_output_state" {state} {
echo "DEPRECATED! use 'adapter gpio swdio_dir -active-high' or 'adapter gpio swdio_dir -active-low', not 'am335xgpio swdio_dir_output_state'"
switch $state {
"high"
{eval adapter gpio swdio_dir -active-high}
"low"
{eval adapter gpio swdio_dir -active-low}
default
{return -code 1 -level 1 "am335xgpio swdio_dir_output_state: syntax error"}
}
}
lappend _telnet_autocomplete_skip "am335xgpio srst_num"
proc "am335xgpio srst_num" {num} {
echo "DEPRECATED! use 'adapter gpio srst' not 'am335xgpio srst_num'"
eval adapter gpio srst [expr {$num % 32}] -chip [expr {$num / 32}]
}
lappend _telnet_autocomplete_skip "am335xgpio trst_num"
proc "am335xgpio trst_num" {num} {
echo "DEPRECATED! use 'adapter gpio trst' not 'am335xgpio trst_num'"
eval adapter gpio trst [expr {$num % 32}] -chip [expr {$num / 32}]
}
lappend _telnet_autocomplete_skip "am335xgpio led_num"
proc "am335xgpio led_num" {num} {
echo "DEPRECATED! use 'adapter gpio led' not 'am335xgpio led_num'"
eval adapter gpio led [expr {$num % 32}] -chip [expr {$num / 32}]
}
lappend _telnet_autocomplete_skip "am335xgpio led_on_state"
proc "am335xgpio led_on_state" {state} {
echo "DEPRECATED! use 'adapter gpio led -active-high' or 'adapter gpio led -active-low', not 'am335xgpio led_on_state'"
switch $state {
"high"
{eval adapter gpio led -active-high}
"low"
{eval adapter gpio led -active-low}
default
{return -code 1 -level 1 "am335xgpio led_on_state: syntax error"}
}
}
# END MIGRATION AIDS # END MIGRATION AIDS

View File

@@ -16,13 +16,21 @@ adapter driver am335xgpio
# am335xgpio speed SPEED_COEFF SPEED_OFFSET # am335xgpio speed SPEED_COEFF SPEED_OFFSET
am335xgpio speed_coeffs 600000 575 am335xgpio speed_coeffs 600000 575
am335xgpio tdo_num 20 # BeagleBone pin P9_41
am335xgpio tdi_num 60 adapter gpio tdo 20 -chip 0
am335xgpio tms_num 4
am335xgpio tck_num 2
am335xgpio led_num 51 # BeagleBone pin P9_12
am335xgpio led_on_state on adapter gpio tdi 28 -chip 1
am335xgpio srst_num 65 # BeagleBone pin P9_18
adapter gpio tms 4 -chip 0
# BeagleBone pin P9_22
adapter gpio tck 2 -chip 0
# BeagleBone pin P9_16
adapter gpio led 19 -chip 1
# BeagleBone pin P8_18
adapter gpio srst 1 -chip 2
reset_config srst_only srst_push_pull reset_config srst_only srst_push_pull

View File

@@ -16,14 +16,18 @@ adapter driver am335xgpio
# am335xgpio speed SPEED_COEFF SPEED_OFFSET # am335xgpio speed SPEED_COEFF SPEED_OFFSET
am335xgpio speed_coeffs 600000 575 am335xgpio speed_coeffs 600000 575
am335xgpio swclk_num 2 # BeagleBone pin P9_22
am335xgpio swdio_num 4 adapter gpio swclk 2 -chip 0
am335xgpio swdio_dir_num 60
am335xgpio swdio_dir_output_state on # BeagleBone pin P9_18
adapter gpio swdio 4 -chip 0
# BeagleBone pin P9_12
adapter gpio swdio_dir 28 -chip 1
# USR0 LED # USR0 LED
am335xgpio led_num 53 adapter gpio led 21 -chip 1
am335xgpio led_on_state on
am335xgpio srst_num 65 # BeagleBone pin P8_18
adapter gpio srst 1 -chip 2
reset_config srst_only srst_push_pull reset_config srst_only srst_push_pull

View File

@@ -0,0 +1,70 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# OpenOCD script to test that the deprecated "am335xgpio *" commands produce the
# expected results. Run this command as:
#
# openocd -f <path>/test-linuxgpiod-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}'"]
}
}
adapter driver am335xgpio
am335xgpio 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]
am335xgpio 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]
am335xgpio 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]
am335xgpio 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]
am335xgpio tdo_num 8
expected_value "adapter gpio tdo (input): num 8, chip 0, active-high, pull-none, init-state input" [eval adapter gpio tdo]
am335xgpio 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]
am335xgpio 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]
am335xgpio 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]
am335xgpio 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]
am335xgpio swdio_dir_output_state low
expected_value "adapter gpio swdio_dir (output): num 13, chip 0, active-low, push-pull, pull-none" [eval adapter gpio swdio_dir]
am335xgpio swdio_dir_output_state high
expected_value "adapter gpio swdio_dir (output): num 13, chip 0, active-high, push-pull, pull-none" [eval adapter gpio swdio_dir]
am335xgpio srst_num 14
expected_value "adapter gpio srst (output): num 14, chip 0, active-low, pull-none, init-state inactive" [eval adapter gpio srst]
am335xgpio trst_num 15
expected_value "adapter gpio trst (output): num 15, chip 0, active-low, pull-none, init-state inactive" [eval adapter gpio trst]
am335xgpio led_num 16
expected_value "adapter gpio led (output): num 16, chip 0, active-high, push-pull, pull-none, init-state inactive" [eval adapter gpio led]
am335xgpio led_on_state low
expected_value "adapter gpio led (output): num 16, chip 0, active-low, push-pull, pull-none, init-state inactive" [eval adapter gpio led]
am335xgpio led_on_state high
expected_value "adapter gpio led (output): num 16, chip 0, active-high, push-pull, pull-none, init-state inactive" [eval adapter gpio led]
puts "SUCCESS"