From e3f8db54e67b503011f624db490964dba9399597 Mon Sep 17 00:00:00 2001 From: Christoph Pittracher Date: Thu, 4 Jun 2015 09:25:10 +0200 Subject: [PATCH] bcm2835gpio: Add SWD support, Raspberry Pi 2 support. Added support for SWD transport similar to sysfsgpio driver. Added configurable peripheral base address to support Raspberry Pi 2. Change-Id: If76d45fbe74ce49f1f22af72e5f246e973237e04 Signed-off-by: Christoph Pittracher Reviewed-on: http://openocd.zylin.com/2802 Tested-by: jenkins Reviewed-by: Spencer Oliver --- src/jtag/drivers/bcm2835gpio.c | 167 ++++++++++++++++++++++++-- tcl/interface/raspberrypi-native.cfg | 2 + tcl/interface/raspberrypi2-native.cfg | 42 +++++++ 3 files changed, 202 insertions(+), 9 deletions(-) create mode 100644 tcl/interface/raspberrypi2-native.cfg diff --git a/src/jtag/drivers/bcm2835gpio.c b/src/jtag/drivers/bcm2835gpio.c index a2ba8e642c..1d84cbe405 100644 --- a/src/jtag/drivers/bcm2835gpio.c +++ b/src/jtag/drivers/bcm2835gpio.c @@ -30,10 +30,10 @@ #include -#define BCM2835_PERI_BASE 0x20000000 -#define BCM2835_GPIO_BASE (BCM2835_PERI_BASE + 0x200000) /* GPIO controller */ +uint32_t bcm2835_peri_base = 0x20000000; +#define BCM2835_GPIO_BASE (bcm2835_peri_base + 0x200000) /* GPIO controller */ -#define BCM2835_PADS_GPIO_0_27 (BCM2835_PERI_BASE + 0x100000) +#define BCM2835_PADS_GPIO_0_27 (bcm2835_peri_base + 0x100000) #define BCM2835_PADS_GPIO_0_27_OFFSET (0x2c / 4) /* GPIO setup macros */ @@ -55,6 +55,9 @@ static int bcm2835gpio_read(void); static void bcm2835gpio_write(int tck, int tms, int tdi); static void bcm2835gpio_reset(int trst, int srst); +static int bcm2835_swdio_read(void); +static void bcm2835_swdio_drive(bool is_output); + static int bcm2835gpio_init(void); static int bcm2835gpio_quit(void); @@ -62,6 +65,8 @@ static struct bitbang_interface bcm2835gpio_bitbang = { .read = bcm2835gpio_read, .write = bcm2835gpio_write, .reset = bcm2835gpio_reset, + .swdio_read = bcm2835_swdio_read, + .swdio_drive = bcm2835_swdio_drive, .blink = NULL }; @@ -78,6 +83,10 @@ static int trst_gpio = -1; static int trst_gpio_mode; static int srst_gpio = -1; static int srst_gpio_mode; +static int swclk_gpio = -1; +static int swclk_gpio_mode; +static int swdio_gpio = -1; +static int swdio_gpio_mode; /* Transition delay coefficients */ static int speed_coeff = 113714; @@ -101,6 +110,18 @@ static void bcm2835gpio_write(int tck, int tms, int tdi) asm volatile (""); } +static void bcm2835gpio_swd_write(int tck, int tms, int tdi) +{ + uint32_t set = tck<