drivers/am335xgpio: Add AM335x driver for bitbang support on BeagleBones

Change-Id: Iac1c9f3d380e2474c8b77407c89c2aad96fbf2ea
Signed-off-by: Steve Marple <stevemarple@googlemail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6941
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
This commit is contained in:
Steve Marple
2022-04-18 23:27:22 +01:00
committed by Antonio Borneo
parent 0b241ca042
commit bd4bd54b60
7 changed files with 906 additions and 0 deletions

View File

@@ -298,10 +298,14 @@ AS_CASE(["${host_cpu}"],
AC_ARG_ENABLE([imx_gpio],
AS_HELP_STRING([--enable-imx_gpio], [Enable building support for bitbanging on NXP IMX processors]),
[build_imx_gpio=$enableval], [build_imx_gpio=no])
AC_ARG_ENABLE([am335xgpio],
AS_HELP_STRING([--enable-am335xgpio], [Enable building support for bitbanging on AM335x (as found in Beaglebones)]),
[build_am335xgpio=$enableval], [build_am335xgpio=no])
],
[
build_bcm2835gpio=no
build_imx_gpio=no
build_am335xgpio=no
])
AS_CASE(["${host_cpu}"],
@@ -507,6 +511,13 @@ AS_IF([test "x$build_imx_gpio" = "xyes"], [
AC_DEFINE([BUILD_IMX_GPIO], [0], [0 if you don't want imx_gpio.])
])
AS_IF([test "x$build_am335xgpio" = "xyes"], [
build_bitbang=yes
AC_DEFINE([BUILD_AM335XGPIO], [1], [1 if you want am335xgpio.])
], [
AC_DEFINE([BUILD_AM335XGPIO], [0], [0 if you don't want am335xgpio.])
])
AS_IF([test "x$parport_use_ppdev" = "xyes"], [
AC_DEFINE([PARPORT_USE_PPDEV], [1], [1 if you want parport to use ppdev.])
], [
@@ -711,6 +722,7 @@ AM_CONDITIONAL([EP93XX], [test "x$build_ep93xx" = "xyes"])
AM_CONDITIONAL([AT91RM9200], [test "x$build_at91rm9200" = "xyes"])
AM_CONDITIONAL([BCM2835GPIO], [test "x$build_bcm2835gpio" = "xyes"])
AM_CONDITIONAL([IMX_GPIO], [test "x$build_imx_gpio" = "xyes"])
AM_CONDITIONAL([AM335XGPIO], [test "x$build_am335xgpio" = "xyes"])
AM_CONDITIONAL([BITBANG], [test "x$build_bitbang" = "xyes"])
AM_CONDITIONAL([JTAG_VPI], [test "x$build_jtag_vpi" = "xyes"])
AM_CONDITIONAL([VDEBUG], [test "x$build_vdebug" = "xyes"])

View File

@@ -584,6 +584,9 @@ produced, PDF schematics are easily found and it is easy to make.
@item @b{imx_gpio}
@* A NXP i.MX-based board (e.g. Wandboard) using the GPIO pins (should work on any i.MX processor).
@item @b{am335xgpio}
@* A Texas Instruments AM335x-based board (e.g. BeagleBone Black) using the GPIO pins of the expansion headers.
@item @b{jtag_vpi}
@* A JTAG driver acting as a client for the JTAG VPI server interface.
@* Link: @url{http://github.com/fjullien/jtag_vpi}
@@ -3322,6 +3325,98 @@ pinout.
@end deffn
@deffn {Interface Driver} {am335xgpio} The AM335x SoC is present in BeagleBone
Black and BeagleBone Green single-board computers which expose some of the GPIOs
on the two expansion headers.
For maximum performance the driver accesses memory-mapped GPIO peripheral
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
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
0, GPIO numbers 32 to 63 are mapped to GPIO port 1 and so on.
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}
Set SPEED_COEFF and SPEED_OFFSET for delay calculations. If unspecified
speed_coeff defaults to 600000 and speed_offset defaults to 575.
@end deffn
@end deffn
@deffn {Interface Driver} {linuxgpiod}
Linux provides userspace access to GPIO through libgpiod since Linux kernel version v4.6.
The driver emulates either JTAG and SWD transport through bitbanging.

View File

@@ -185,6 +185,9 @@ endif
if XDS110
DRIVERFILES += %D%/xds110.c
endif
if AM335XGPIO
DRIVERFILES += %D%/am335xgpio.c
endif
DRIVERHEADERS = \
%D%/bitbang.h \

File diff suppressed because it is too large Load Diff

View File

@@ -150,6 +150,9 @@ extern struct adapter_driver stlink_dap_adapter_driver;
#if BUILD_RSHIM == 1
extern struct adapter_driver rshim_dap_adapter_driver;
#endif
#if BUILD_AM335XGPIO == 1
extern struct adapter_driver am335xgpio_adapter_driver;
#endif
/**
* The list of built-in JTAG interfaces, containing entries for those
@@ -263,6 +266,9 @@ struct adapter_driver *adapter_drivers[] = {
#endif
#if BUILD_RSHIM == 1
&rshim_dap_adapter_driver,
#endif
#if BUILD_AM335XGPIO == 1
&am335xgpio_adapter_driver,
#endif
NULL,
};

View File

@@ -0,0 +1,28 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# BeagleBone native GPIO interface for JTAG
#
# This is best used with a fast buffer but it is also suitable for a direct
# connection if the target voltage matches the host's IO voltage (typically
# 3.3V) and the cable is short.
#
# DO NOT APPLY VOLTAGE TO THE GPIO PINS UNTIL SYS_RESETN IS HIGH.
#
# Do not forget the GND connection.
adapter driver am335xgpio
# Transition delay calculation: SPEED_COEFF/khz - SPEED_OFFSET
# These depend on the system clock, calibrated for stock 1 GHz BeagleBoneBlack
# am335xgpio speed SPEED_COEFF SPEED_OFFSET
am335xgpio speed_coeffs 600000 575
am335xgpio tdo_num 20
am335xgpio tdi_num 60
am335xgpio tms_num 4
am335xgpio tck_num 2
am335xgpio led_num 51
am335xgpio led_on_state on
am335xgpio srst_num 65
reset_config srst_only srst_push_pull

View File

@@ -0,0 +1,29 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# BeagleBone native GPIO interface for SWD
#
# This is best used with a fast buffer but it is also suitable for a direct
# connection if the target voltage matches the host's IO voltage (typically
# 3.3V) and the cable is short.
#
# DO NOT APPLY VOLTAGE TO THE GPIO PINS UNTIL SYS_RESETN IS HIGH.
#
# Do not forget the GND connection.
adapter driver am335xgpio
# Transition delay calculation: SPEED_COEFF/khz - SPEED_OFFSET
# These depend on the system clock, calibrated for stock 1 GHz BeagleBoneBlack
# am335xgpio speed SPEED_COEFF SPEED_OFFSET
am335xgpio speed_coeffs 600000 575
am335xgpio swclk_num 2
am335xgpio swdio_num 4
am335xgpio swdio_dir_num 60
am335xgpio swdio_dir_output_state on
# USR0 LED
am335xgpio led_num 53
am335xgpio led_on_state on
am335xgpio srst_num 65
reset_config srst_only srst_push_pull