OpenOCD
bcm2835gpio.c
Go to the documentation of this file.
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 
3 /***************************************************************************
4  * Copyright (C) 2013 by Paul Fertser, fercerpav@gmail.com *
5  * *
6  * Copyright (C) 2012 by Creative Product Design, marc @ cpdesign.com.au *
7  * Based on at91rm9200.c (c) Anders Larsen *
8  * and RPi GPIO examples by Gert van Loo & Dom *
9  ***************************************************************************/
10 
11 #ifdef HAVE_CONFIG_H
12 #include "config.h"
13 #endif
14 
15 #include <jtag/adapter.h>
16 #include <jtag/interface.h>
17 #include <transport/transport.h>
18 #include "bitbang.h"
19 
20 #include <sys/mman.h>
21 
22 static char *bcm2835_peri_mem_dev;
23 static off_t bcm2835_peri_base = 0x20000000;
24 #define BCM2835_GPIO_BASE (bcm2835_peri_base + 0x200000) /* GPIO controller */
25 
26 #define BCM2835_PADS_GPIO_0_27 (bcm2835_peri_base + 0x100000)
27 #define BCM2835_PADS_GPIO_0_27_OFFSET (0x2c / 4)
28 
29 /* See "GPIO Function Select Registers (GPFSELn)" in "Broadcom BCM2835 ARM Peripherals" datasheet. */
30 #define BCM2835_GPIO_MODE_INPUT 0
31 #define BCM2835_GPIO_MODE_OUTPUT 1
32 
33 /* GPIO setup macros */
34 #define MODE_GPIO(_g) ({ \
35  typeof(_g) g = (_g); \
36  *(pio_base + (g / 10)) >> ((g % 10) * 3) & 7; \
37 })
38 
39 #define INP_GPIO(_g) do { \
40  typeof(_g) g1 = (_g); \
41  *(pio_base + (g1 / 10)) &= ~(7 << ((g1 % 10) * 3)); \
42 } while (0)
43 
44 #define SET_MODE_GPIO(_g, m) do { \
45  typeof(_g) g = (_g); \
46  /* clear the mode bits first, then set as necessary */ \
47  INP_GPIO(g); \
48  *(pio_base + (g / 10)) |= ((m) << ((g % 10) * 3)); \
49 } while (0)
50 
51 #define OUT_GPIO(g) SET_MODE_GPIO(g, BCM2835_GPIO_MODE_OUTPUT)
52 
53 #define GPIO_SET (*(pio_base + 7)) /* sets bits which are 1, ignores bits which are 0 */
54 #define GPIO_CLR (*(pio_base + 10)) /* clears bits which are 1, ignores bits which are 0 */
55 #define GPIO_LEV (*(pio_base + 13)) /* current level of the pin */
56 
57 static int dev_mem_fd;
58 static volatile uint32_t *pio_base = MAP_FAILED;
59 static volatile uint32_t *pads_base = MAP_FAILED;
60 
61 /* Transition delay coefficients */
62 static int speed_coeff = 113714;
63 static int speed_offset = 28;
64 static unsigned int jtag_delay;
65 
67 static struct initial_gpio_state {
68  unsigned int mode;
69  unsigned int output_level;
72 
73 static inline const char *bcm2835_get_mem_dev(void)
74 {
76  return bcm2835_peri_mem_dev;
77 
78  return "/dev/gpiomem";
79 }
80 
81 static inline void bcm2835_gpio_synchronize(void)
82 {
83  /* Ensure that previous writes to GPIO registers are flushed out of
84  * the inner shareable domain to prevent pipelined writes to the
85  * same address being merged.
86  */
87  __sync_synchronize();
88 }
89 
90 static inline void bcm2835_delay(void)
91 {
92  for (unsigned int i = 0; i < jtag_delay; i++)
93  asm volatile ("");
94 }
95 
97 {
98  /* Only chip 0 is supported, accept unset value (-1) too */
99  return adapter_gpio_config[idx].gpio_num <= 31;
100 }
101 
102 static void set_gpio_value(const struct adapter_gpio_config *gpio_config, int value)
103 {
104  value = value ^ (gpio_config->active_low ? 1 : 0);
105  switch (gpio_config->drive) {
107  if (value)
108  GPIO_SET = 1 << gpio_config->gpio_num;
109  else
110  GPIO_CLR = 1 << gpio_config->gpio_num;
111  /* For performance reasons assume the GPIO is already set as an output
112  * and therefore the call can be omitted here.
113  */
114  break;
116  if (value) {
117  INP_GPIO(gpio_config->gpio_num);
118  } else {
119  GPIO_CLR = 1 << gpio_config->gpio_num;
120  OUT_GPIO(gpio_config->gpio_num);
121  }
122  break;
124  if (value) {
125  GPIO_SET = 1 << gpio_config->gpio_num;
126  OUT_GPIO(gpio_config->gpio_num);
127  } else {
128  INP_GPIO(gpio_config->gpio_num);
129  }
130  break;
131  }
133 }
134 
136 {
137  if (is_gpio_config_valid(idx)) {
140  if (initial_gpio_state[idx].output_level)
142  else
144  }
145  }
147 }
148 
150 {
151  if (!is_gpio_config_valid(idx))
152  return;
153 
155  unsigned int shift = adapter_gpio_config[idx].gpio_num;
156  initial_gpio_state[idx].output_level = (GPIO_LEV >> shift) & 1;
157  LOG_DEBUG("saved GPIO mode for %s (GPIO %d %d): %d",
158  adapter_gpio_get_name(idx), adapter_gpio_config[idx].chip_num, adapter_gpio_config[idx].gpio_num,
159  initial_gpio_state[idx].mode);
160 
161  if (adapter_gpio_config[idx].pull != ADAPTER_GPIO_PULL_NONE) {
162  LOG_WARNING("BCM2835 GPIO does not support pull-up or pull-down settings (signal %s)",
163  adapter_gpio_get_name(idx));
164  }
165 
166  switch (adapter_gpio_config[idx].init_state) {
169  break;
172  break;
174  INP_GPIO(adapter_gpio_config[idx].gpio_num);
175  break;
176  }
177 
178  /* Direction for non push-pull is already set by set_gpio_value() */
181  OUT_GPIO(adapter_gpio_config[idx].gpio_num);
183 }
184 
186 {
187  unsigned int shift = adapter_gpio_config[ADAPTER_GPIO_IDX_TDO].gpio_num;
188  uint32_t value = (GPIO_LEV >> shift) & 1;
190 }
191 
192 static int bcm2835gpio_write(int tck, int tms, int tdi)
193 {
194  uint32_t set = tck << adapter_gpio_config[ADAPTER_GPIO_IDX_TCK].gpio_num |
197  uint32_t clear = !tck << adapter_gpio_config[ADAPTER_GPIO_IDX_TCK].gpio_num |
200 
201  GPIO_SET = set;
202  GPIO_CLR = clear;
204 
205  bcm2835_delay();
206 
207  return ERROR_OK;
208 }
209 
210 /* Requires push-pull drive mode for swclk and swdio */
211 static int bcm2835gpio_swd_write_fast(int swclk, int swdio)
212 {
213  swclk = swclk ^ (adapter_gpio_config[ADAPTER_GPIO_IDX_SWCLK].active_low ? 1 : 0);
214  swdio = swdio ^ (adapter_gpio_config[ADAPTER_GPIO_IDX_SWDIO].active_low ? 1 : 0);
215 
216  uint32_t set = swclk << adapter_gpio_config[ADAPTER_GPIO_IDX_SWCLK].gpio_num |
218  uint32_t clear = !swclk << adapter_gpio_config[ADAPTER_GPIO_IDX_SWCLK].gpio_num |
220 
221  GPIO_SET = set;
222  GPIO_CLR = clear;
224 
225  bcm2835_delay();
226 
227  return ERROR_OK;
228 }
229 
230 /* Generic mode that works for open-drain/open-source drive modes, but slower */
231 static int bcm2835gpio_swd_write_generic(int swclk, int swdio)
232 {
234  set_gpio_value(&adapter_gpio_config[ADAPTER_GPIO_IDX_SWCLK], swclk); /* Write clock last */
235 
236  bcm2835_delay();
237 
238  return ERROR_OK;
239 }
240 
241 /* (1) assert or (0) deassert reset lines */
242 static int bcm2835gpio_reset(int trst, int srst)
243 {
244  /* As the "adapter reset_config" command keeps the srst and trst gpio drive
245  * mode settings in sync we can use our standard set_gpio_value() function
246  * that honours drive mode and active low.
247  */
250 
253 
254  LOG_DEBUG("trst %d gpio: %d %d, srst %d gpio: %d %d",
255  trst,
258  srst,
261  return ERROR_OK;
262 }
263 
264 static void bcm2835_swdio_drive(bool is_output)
265 {
266  if (is_output) {
270  } else {
274  }
276 }
277 
278 static int bcm2835_swdio_read(void)
279 {
281  uint32_t value = (GPIO_LEV >> shift) & 1;
282  return value ^ (adapter_gpio_config[ADAPTER_GPIO_IDX_SWDIO].active_low ? 1 : 0);
283 }
284 
285 static int bcm2835gpio_khz(int khz, int *jtag_speed)
286 {
287  if (!khz) {
288  LOG_DEBUG("BCM2835 GPIO: RCLK not supported");
289  return ERROR_FAIL;
290  }
291  *jtag_speed = DIV_ROUND_UP(speed_coeff, khz) - speed_offset;
292  LOG_DEBUG("jtag_delay %d", *jtag_speed);
293  if (*jtag_speed < 0)
294  *jtag_speed = 0;
295  return ERROR_OK;
296 }
297 
298 static int bcm2835gpio_speed_div(int speed, int *khz)
299 {
300  int divisor = speed + speed_offset;
301  /* divide with roundig to the closest */
302  *khz = (speed_coeff + divisor / 2) / divisor;
303  return ERROR_OK;
304 }
305 
306 static int bcm2835gpio_speed(int speed)
307 {
308  jtag_delay = speed;
309  return ERROR_OK;
310 }
311 
312 COMMAND_HANDLER(bcm2835gpio_handle_speed_coeffs)
313 {
314  if (CMD_ARGC == 2) {
317  }
318 
319  command_print(CMD, "BCM2835 GPIO: speed_coeffs = %d, speed_offset = %d",
321  return ERROR_OK;
322 }
323 
324 COMMAND_HANDLER(bcm2835gpio_handle_peripheral_mem_dev)
325 {
326  if (CMD_ARGC == 1) {
327  free(bcm2835_peri_mem_dev);
328  bcm2835_peri_mem_dev = strdup(CMD_ARGV[0]);
329  }
330 
331  command_print(CMD, "BCM2835 GPIO: peripheral_mem_dev = %s",
333  return ERROR_OK;
334 }
335 
336 COMMAND_HANDLER(bcm2835gpio_handle_peripheral_base)
337 {
338  uint64_t tmp_base;
339  if (CMD_ARGC == 1) {
340  COMMAND_PARSE_NUMBER(u64, CMD_ARGV[0], tmp_base);
341  bcm2835_peri_base = (off_t)tmp_base;
342  }
343 
344  tmp_base = bcm2835_peri_base;
345  command_print(CMD, "BCM2835 GPIO: peripheral_base = 0x%08" PRIx64,
346  tmp_base);
347  return ERROR_OK;
348 }
349 
351  {
352  .name = "speed_coeffs",
353  .handler = &bcm2835gpio_handle_speed_coeffs,
354  .mode = COMMAND_CONFIG,
355  .help = "SPEED_COEFF and SPEED_OFFSET for delay calculations.",
356  .usage = "[SPEED_COEFF SPEED_OFFSET]",
357  },
358  {
359  .name = "peripheral_mem_dev",
360  .handler = &bcm2835gpio_handle_peripheral_mem_dev,
361  .mode = COMMAND_CONFIG,
362  .help = "device to map memory mapped GPIOs from.",
363  .usage = "[device]",
364  },
365  {
366  .name = "peripheral_base",
367  .handler = &bcm2835gpio_handle_peripheral_base,
368  .mode = COMMAND_CONFIG,
369  .help = "peripheral base to access GPIOs, not needed with /dev/gpiomem.",
370  .usage = "[base]",
371  },
372 
374 };
375 
376 static const struct command_registration bcm2835gpio_command_handlers[] = {
377  {
378  .name = "bcm2835gpio",
379  .mode = COMMAND_ANY,
380  .help = "perform bcm2835gpio management",
382  .usage = "",
383  },
385 };
386 
388 {
390  return false;
392  return false;
394  return false;
396  return false;
397  return true;
398 }
399 
401 {
403  return false;
405  return false;
406  return true;
407 }
408 
409 static void bcm2835gpio_munmap(void)
410 {
411  if (pio_base != MAP_FAILED) {
412  munmap((void *)pio_base, sysconf(_SC_PAGE_SIZE));
413  pio_base = MAP_FAILED;
414  }
415 
416  if (pads_base != MAP_FAILED) {
417  munmap((void *)pads_base, sysconf(_SC_PAGE_SIZE));
418  pads_base = MAP_FAILED;
419  }
420 }
421 
422 static int bcm2835gpio_blink(bool on)
423 {
426 
427  return ERROR_OK;
428 }
429 
430 static struct bitbang_interface bcm2835gpio_bitbang = {
432  .write = bcm2835gpio_write,
433  .swdio_read = bcm2835_swdio_read,
434  .swdio_drive = bcm2835_swdio_drive,
435  .swd_write = bcm2835gpio_swd_write_generic,
436  .blink = bcm2835gpio_blink,
437 };
438 
439 static int bcm2835gpio_init(void)
440 {
441  LOG_INFO("BCM2835 GPIO JTAG/SWD bitbang driver");
442 
445 
447  LOG_ERROR("Require tck, tms, tdi and tdo gpios for JTAG mode");
448  return ERROR_JTAG_INIT_FAILED;
449  }
450 
452  LOG_ERROR("Require swclk and swdio gpio for SWD mode");
453  return ERROR_JTAG_INIT_FAILED;
454  }
455 
456  bool is_gpiomem = strcmp(bcm2835_get_mem_dev(), "/dev/gpiomem") == 0;
457  bool pad_mapping_possible = !is_gpiomem;
458 
459  dev_mem_fd = open(bcm2835_get_mem_dev(), O_RDWR | O_SYNC);
460  if (dev_mem_fd < 0) {
461  LOG_ERROR("open %s: %s", bcm2835_get_mem_dev(), strerror(errno));
462  /* TODO: add /dev/mem specific doc and refer to it
463  * if (!is_gpiomem && (errno == EACCES || errno == EPERM))
464  * LOG_INFO("Consult the user's guide chapter 4.? how to set permissions and capabilities");
465  */
466  return ERROR_JTAG_INIT_FAILED;
467  }
468 
469  pio_base = mmap(NULL, sysconf(_SC_PAGE_SIZE), PROT_READ | PROT_WRITE,
470  MAP_SHARED, dev_mem_fd, BCM2835_GPIO_BASE);
471 
472  if (pio_base == MAP_FAILED) {
473  LOG_ERROR("mmap: %s", strerror(errno));
474  close(dev_mem_fd);
475  return ERROR_JTAG_INIT_FAILED;
476  }
477 
478  /* TODO: move pads config to a separate utility */
479  if (pad_mapping_possible) {
480  pads_base = mmap(NULL, sysconf(_SC_PAGE_SIZE), PROT_READ | PROT_WRITE,
481  MAP_SHARED, dev_mem_fd, BCM2835_PADS_GPIO_0_27);
482 
483  if (pads_base == MAP_FAILED) {
484  LOG_ERROR("mmap pads: %s", strerror(errno));
485  LOG_WARNING("Continuing with unchanged GPIO pad settings (drive strength and slew rate)");
486  }
487  } else {
488  pads_base = MAP_FAILED;
489  }
490 
491  close(dev_mem_fd);
492 
493  if (pads_base != MAP_FAILED) {
494  /* set 4mA drive strength, slew rate limited, hysteresis on */
496 LOG_INFO("initial pads conf %08x", pads_base[BCM2835_PADS_GPIO_0_27_OFFSET]);
497  pads_base[BCM2835_PADS_GPIO_0_27_OFFSET] = 0x5a000008 + 1;
498 LOG_INFO("pads conf set to %08x", pads_base[BCM2835_PADS_GPIO_0_27_OFFSET]);
499  }
500 
501  /* Configure JTAG/SWD signals. Default directions and initial states are handled
502  * by adapter.c and "adapter gpio" command.
503  */
504  if (transport_is_jtag()) {
510  }
511 
512  if (transport_is_swd()) {
513  /* swdio and its buffer should be initialized in the order that prevents
514  * two outputs from being connected together. This will occur if the
515  * swdio GPIO of the AM335x is configured as an output while its
516  * external buffer is configured to send the swdio signal from the
517  * target to the AM335x.
518  */
522  } else {
525  }
526 
528 
531  LOG_DEBUG("BCM2835 GPIO using fast mode for SWD write");
533  } else {
534  LOG_DEBUG("BCM2835 GPIO using generic mode for SWD write");
536  }
537  }
538 
541 
542  return ERROR_OK;
543 }
544 
545 static int bcm2835gpio_quit(void)
546 {
547  if (transport_is_jtag()) {
553  }
554 
555  if (transport_is_swd()) {
556  /* Restore swdio/swdio_dir to their initial modes, even if that means
557  * connecting two outputs. Begin by making swdio an input so that the
558  * current and final states of swdio and swdio_dir do not have to be
559  * considered to calculate the safe restoration order.
560  */
565  }
566 
569 
570  if (pads_base != MAP_FAILED) {
571  /* Restore drive strength. MSB is password ("5A") */
573  }
575  free(bcm2835_peri_mem_dev);
576 
577  return ERROR_OK;
578 }
579 
580 
581 static const char * const bcm2835_transports[] = { "jtag", "swd", NULL };
582 
583 static struct jtag_interface bcm2835gpio_interface = {
585  .execute_queue = bitbang_execute_queue,
586 };
588  .name = "bcm2835gpio",
589  .transports = bcm2835_transports,
590  .commands = bcm2835gpio_command_handlers,
591 
592  .init = bcm2835gpio_init,
593  .quit = bcm2835gpio_quit,
594  .reset = bcm2835gpio_reset,
595  .speed = bcm2835gpio_speed,
596  .khz = bcm2835gpio_khz,
597  .speed_div = bcm2835gpio_speed_div,
598 
599  .jtag_ops = &bcm2835gpio_interface,
600  .swd_ops = &bitbang_swd,
601 };
const struct adapter_gpio_config * adapter_gpio_get_config(void)
Retrieves gpio configuration set with command "adapter gpio <signal_name>".
Definition: adapter.c:1221
const char * adapter_gpio_get_name(enum adapter_gpio_config_index idx)
Retrieves gpio name.
Definition: adapter.c:1215
@ ADAPTER_GPIO_INIT_STATE_ACTIVE
Definition: adapter.h:32
@ ADAPTER_GPIO_INIT_STATE_INPUT
Definition: adapter.h:33
@ ADAPTER_GPIO_INIT_STATE_INACTIVE
Definition: adapter.h:31
adapter_gpio_config_index
Adapter GPIO.
Definition: adapter.h:44
@ ADAPTER_GPIO_IDX_LED
Definition: adapter.h:54
@ ADAPTER_GPIO_IDX_NUM
Definition: adapter.h:55
@ ADAPTER_GPIO_IDX_SWCLK
Definition: adapter.h:52
@ ADAPTER_GPIO_IDX_SWDIO_DIR
Definition: adapter.h:51
@ ADAPTER_GPIO_IDX_SRST
Definition: adapter.h:53
@ ADAPTER_GPIO_IDX_TRST
Definition: adapter.h:49
@ ADAPTER_GPIO_IDX_TDI
Definition: adapter.h:46
@ ADAPTER_GPIO_IDX_TMS
Definition: adapter.h:47
@ ADAPTER_GPIO_IDX_TCK
Definition: adapter.h:48
@ ADAPTER_GPIO_IDX_TDO
Definition: adapter.h:45
@ ADAPTER_GPIO_IDX_SWDIO
Definition: adapter.h:50
@ ADAPTER_GPIO_PULL_NONE
Definition: adapter.h:38
@ ADAPTER_GPIO_DRIVE_MODE_OPEN_SOURCE
Definition: adapter.h:19
@ ADAPTER_GPIO_DRIVE_MODE_OPEN_DRAIN
Definition: adapter.h:18
@ ADAPTER_GPIO_DRIVE_MODE_PUSH_PULL
Definition: adapter.h:17
bool transport_is_swd(void)
Returns true if the current debug session is using SWD as its transport.
Definition: adi_v5_swd.c:776
enum arm_mode mode
Definition: armv4_5.c:277
static char * bcm2835_peri_mem_dev
Definition: bcm2835gpio.c:22
static bool bcm2835gpio_jtag_mode_possible(void)
Definition: bcm2835gpio.c:387
static void bcm2835gpio_munmap(void)
Definition: bcm2835gpio.c:409
#define BCM2835_GPIO_BASE
Definition: bcm2835gpio.c:24
static const struct command_registration bcm2835gpio_command_handlers[]
Definition: bcm2835gpio.c:376
static volatile uint32_t * pads_base
Definition: bcm2835gpio.c:59
static bool bcm2835gpio_swd_mode_possible(void)
Definition: bcm2835gpio.c:400
static void restore_gpio(enum adapter_gpio_config_index idx)
Definition: bcm2835gpio.c:135
static bool is_gpio_config_valid(enum adapter_gpio_config_index idx)
Definition: bcm2835gpio.c:96
static int bcm2835gpio_swd_write_generic(int swclk, int swdio)
Definition: bcm2835gpio.c:231
#define GPIO_CLR
Definition: bcm2835gpio.c:54
static void bcm2835_gpio_synchronize(void)
Definition: bcm2835gpio.c:81
static void bcm2835_delay(void)
Definition: bcm2835gpio.c:90
static void bcm2835_swdio_drive(bool is_output)
Definition: bcm2835gpio.c:264
#define BCM2835_PADS_GPIO_0_27
Definition: bcm2835gpio.c:26
static struct bitbang_interface bcm2835gpio_bitbang
Definition: bcm2835gpio.c:430
static int bcm2835gpio_init(void)
Definition: bcm2835gpio.c:439
static bb_value_t bcm2835gpio_read(void)
Definition: bcm2835gpio.c:185
static int bcm2835gpio_write(int tck, int tms, int tdi)
Definition: bcm2835gpio.c:192
#define GPIO_LEV
Definition: bcm2835gpio.c:55
static const char *const bcm2835_transports[]
Definition: bcm2835gpio.c:581
struct adapter_driver bcm2835gpio_adapter_driver
Definition: bcm2835gpio.c:587
static off_t bcm2835_peri_base
Definition: bcm2835gpio.c:23
static int bcm2835gpio_khz(int khz, int *jtag_speed)
Definition: bcm2835gpio.c:285
static unsigned int jtag_delay
Definition: bcm2835gpio.c:64
static const struct command_registration bcm2835gpio_subcommand_handlers[]
Definition: bcm2835gpio.c:350
static int dev_mem_fd
Definition: bcm2835gpio.c:57
static int bcm2835_swdio_read(void)
Definition: bcm2835gpio.c:278
COMMAND_HANDLER(bcm2835gpio_handle_speed_coeffs)
Definition: bcm2835gpio.c:312
static int speed_coeff
Definition: bcm2835gpio.c:62
static const struct adapter_gpio_config * adapter_gpio_config
Definition: bcm2835gpio.c:66
static void set_gpio_value(const struct adapter_gpio_config *gpio_config, int value)
Definition: bcm2835gpio.c:102
static int bcm2835gpio_reset(int trst, int srst)
Definition: bcm2835gpio.c:242
#define BCM2835_GPIO_MODE_OUTPUT
Definition: bcm2835gpio.c:31
static uint32_t initial_drive_strength_etc
Definition: bcm2835gpio.c:71
static int speed_offset
Definition: bcm2835gpio.c:63
#define SET_MODE_GPIO(_g, m)
Definition: bcm2835gpio.c:44
static volatile uint32_t * pio_base
Definition: bcm2835gpio.c:58
static struct jtag_interface bcm2835gpio_interface
Definition: bcm2835gpio.c:583
#define MODE_GPIO(_g)
Definition: bcm2835gpio.c:34
static const char * bcm2835_get_mem_dev(void)
Definition: bcm2835gpio.c:73
static void initialize_gpio(enum adapter_gpio_config_index idx)
Definition: bcm2835gpio.c:149
static int bcm2835gpio_quit(void)
Definition: bcm2835gpio.c:545
static int bcm2835gpio_blink(bool on)
Definition: bcm2835gpio.c:422
#define GPIO_SET
Definition: bcm2835gpio.c:53
static int bcm2835gpio_speed_div(int speed, int *khz)
Definition: bcm2835gpio.c:298
#define INP_GPIO(_g)
Definition: bcm2835gpio.c:39
#define OUT_GPIO(g)
Definition: bcm2835gpio.c:51
static int bcm2835gpio_speed(int speed)
Definition: bcm2835gpio.c:306
static int bcm2835gpio_swd_write_fast(int swclk, int swdio)
Definition: bcm2835gpio.c:211
#define BCM2835_PADS_GPIO_0_27_OFFSET
Definition: bcm2835gpio.c:27
int bitbang_execute_queue(struct jtag_command *cmd_queue)
Definition: bitbang.c:293
const struct swd_driver bitbang_swd
Definition: bitbang.c:614
bb_value_t
Definition: bitbang.h:17
@ BB_LOW
Definition: bitbang.h:18
@ BB_HIGH
Definition: bitbang.h:19
void command_print(struct command_invocation *cmd, const char *format,...)
Definition: command.c:443
#define CMD
Use this macro to access the command being handled, rather than accessing the variable directly.
Definition: command.h:141
#define CMD_ARGV
Use this macro to access the arguments for the command being handled, rather than accessing the varia...
Definition: command.h:156
#define CMD_ARGC
Use this macro to access the number of arguments for the command being handled, rather than accessing...
Definition: command.h:151
#define COMMAND_PARSE_NUMBER(type, in, out)
parses the string in into out as a type, or prints a command error and passes the error code to the c...
Definition: command.h:442
#define COMMAND_REGISTRATION_DONE
Use this as the last entry in an array of command_registration records.
Definition: command.h:253
@ COMMAND_CONFIG
Definition: command.h:41
@ COMMAND_ANY
Definition: command.h:42
#define DEBUG_CAP_TMS_SEQ
Definition: interface.h:187
bool transport_is_jtag(void)
Returns true if the current debug session is using JTAG as its transport.
Definition: jtag/core.c:1827
#define ERROR_JTAG_INIT_FAILED
Definition: jtag.h:553
#define LOG_WARNING(expr ...)
Definition: log.h:129
#define ERROR_FAIL
Definition: log.h:170
#define LOG_ERROR(expr ...)
Definition: log.h:132
#define LOG_INFO(expr ...)
Definition: log.h:126
#define LOG_DEBUG(expr ...)
Definition: log.h:109
#define ERROR_OK
Definition: log.h:164
Represents a driver for a debugging interface.
Definition: interface.h:207
const char *const name
The name of the interface driver.
Definition: interface.h:209
Configuration options for a single GPIO.
Definition: adapter.h:59
unsigned int gpio_num
Definition: adapter.h:60
enum adapter_gpio_drive_mode drive
Definition: adapter.h:62
Low level callbacks (for bitbang).
Definition: bitbang.h:30
int(* swd_write)(int swclk, int swdio)
Set SWCLK and SWDIO to the given value.
Definition: bitbang.h:57
bb_value_t(* read)(void)
Sample TDO and return the value.
Definition: bitbang.h:32
const char * name
Definition: command.h:235
const char * usage
a string listing the options and arguments, required or optional
Definition: command.h:241
unsigned int output_level
Definition: bcm2835gpio.c:69
unsigned int mode
Definition: bcm2835gpio.c:68
Represents a driver for a debugging interface.
Definition: interface.h:182
unsigned int supported
Bit vector listing capabilities exposed by this driver.
Definition: interface.h:186
#define DIV_ROUND_UP(m, n)
Rounds m up to the nearest multiple of n using division.
Definition: types.h:79
#define NULL
Definition: usb.h:16