1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 /***************************************************************************
4 * Copyright (C) 2005 by Dominic Rath *
5 * Dominic.Rath@gmx.de *
6 ***************************************************************************/
12 #include <jtag/interface.h>
25 static uint8_t output_value
;
26 static int dev_mem_fd
;
27 static void *gpio_controller
;
28 static volatile uint8_t *gpio_data_register
;
29 static volatile uint8_t *gpio_data_direction_register
;
31 /* low level command set
33 static bb_value_t
ep93xx_read(void);
34 static int ep93xx_write(int tck
, int tms
, int tdi
);
35 static int ep93xx_reset(int trst
, int srst
);
37 static int ep93xx_init(void);
38 static int ep93xx_quit(void);
40 struct timespec ep93xx_zzzz
;
42 static struct jtag_interface ep93xx_interface
= {
43 .supported
= DEBUG_CAP_TMS_SEQ
,
44 .execute_queue
= bitbang_execute_queue
,
47 struct adapter_driver ep93xx_adapter_driver
= {
49 .transports
= jtag_only
,
53 .reset
= ep93xx_reset
,
55 .jtag_ops
= &ep93xx_interface
,
58 static struct bitbang_interface ep93xx_bitbang
= {
60 .write
= ep93xx_write
,
64 static bb_value_t
ep93xx_read(void)
66 return (*gpio_data_register
& TDO_BIT
) ? BB_HIGH
: BB_LOW
;
69 static int ep93xx_write(int tck
, int tms
, int tdi
)
72 output_value
|= TCK_BIT
;
74 output_value
&= ~TCK_BIT
;
77 output_value
|= TMS_BIT
;
79 output_value
&= ~TMS_BIT
;
82 output_value
|= TDI_BIT
;
84 output_value
&= ~TDI_BIT
;
86 *gpio_data_register
= output_value
;
87 nanosleep(&ep93xx_zzzz
, NULL
);
92 /* (1) assert or (0) deassert reset lines */
93 static int ep93xx_reset(int trst
, int srst
)
96 output_value
|= TRST_BIT
;
98 output_value
&= ~TRST_BIT
;
101 output_value
|= SRST_BIT
;
103 output_value
&= ~SRST_BIT
;
105 *gpio_data_register
= output_value
;
106 nanosleep(&ep93xx_zzzz
, NULL
);
111 static int set_gonk_mode(void)
116 syscon
= mmap(NULL
, 4096, PROT_READ
| PROT_WRITE
,
117 MAP_SHARED
, dev_mem_fd
, 0x80930000);
118 if (syscon
== MAP_FAILED
) {
119 LOG_ERROR("mmap: %s", strerror(errno
));
120 return ERROR_JTAG_INIT_FAILED
;
123 devicecfg
= *((volatile int *)(syscon
+ 0x80));
124 *((volatile int *)(syscon
+ 0xc0)) = 0xaa;
125 *((volatile int *)(syscon
+ 0x80)) = devicecfg
| 0x08000000;
127 munmap(syscon
, 4096);
132 static int ep93xx_init(void)
136 bitbang_interface
= &ep93xx_bitbang
;
138 ep93xx_zzzz
.tv_sec
= 0;
139 ep93xx_zzzz
.tv_nsec
= 10000000;
141 dev_mem_fd
= open("/dev/mem", O_RDWR
| O_SYNC
);
142 if (dev_mem_fd
< 0) {
143 LOG_ERROR("open: %s", strerror(errno
));
144 return ERROR_JTAG_INIT_FAILED
;
147 gpio_controller
= mmap(NULL
, 4096, PROT_READ
| PROT_WRITE
,
148 MAP_SHARED
, dev_mem_fd
, 0x80840000);
149 if (gpio_controller
== MAP_FAILED
) {
150 LOG_ERROR("mmap: %s", strerror(errno
));
152 return ERROR_JTAG_INIT_FAILED
;
155 ret
= set_gonk_mode();
156 if (ret
!= ERROR_OK
) {
157 munmap(gpio_controller
, 4096);
163 /* Use GPIO port A. */
164 gpio_data_register
= gpio_controller
+ 0x00;
165 gpio_data_direction_register
= gpio_controller
+ 0x10;
168 /* Use GPIO port B. */
169 gpio_data_register
= gpio_controller
+ 0x04;
170 gpio_data_direction_register
= gpio_controller
+ 0x14;
172 /* Use GPIO port C. */
173 gpio_data_register
= gpio_controller
+ 0x08;
174 gpio_data_direction_register
= gpio_controller
+ 0x18;
176 /* Use GPIO port D. */
177 gpio_data_register
= gpio_controller
+ 0x0c;
178 gpio_data_direction_register
= gpio_controller
+ 0x1c;
181 /* Use GPIO port C. */
182 gpio_data_register
= gpio_controller
+ 0x08;
183 gpio_data_direction_register
= gpio_controller
+ 0x18;
185 LOG_INFO("gpio_data_register = %p", gpio_data_register
);
186 LOG_INFO("gpio_data_direction_reg = %p", gpio_data_direction_register
);
188 * Configure bit 0 (TDO) as an input, and bits 1-5 (TDI, TCK
189 * TMS, TRST, SRST) as outputs. Drive TDI and TCK low, and
190 * TMS/TRST/SRST high.
192 output_value
= TMS_BIT
| TRST_BIT
| SRST_BIT
| VCC_BIT
;
193 *gpio_data_register
= output_value
;
194 nanosleep(&ep93xx_zzzz
, NULL
);
197 * Configure the direction register. 1 = output, 0 = input.
199 *gpio_data_direction_register
=
200 TDI_BIT
| TCK_BIT
| TMS_BIT
| TRST_BIT
| SRST_BIT
| VCC_BIT
;
202 nanosleep(&ep93xx_zzzz
, NULL
);
206 static int ep93xx_quit(void)
Linking to existing account procedure
If you already have an account and want to add another login method
you
MUST first sign in with your existing account and
then change URL to read
https://review.openocd.org/login/?link
to get to this page again but this time it'll work for linking. Thank you.
SSH host keys fingerprints
1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=.. |
|+o.. . |
|*.o . . |
|+B . . . |
|Bo. = o S |
|Oo.+ + = |
|oB=.* = . o |
| =+=.+ + E |
|. .=o . o |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)