1 /***************************************************************************
2 * Copyright (C) 2016 by Matthias Welwarsky *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
18 ***************************************************************************/
26 #include "target/arm_adi_v5.h"
27 #include "target/arm_cti.h"
28 #include "target/target.h"
29 #include "helper/time_support.h"
36 struct arm_cti
*arm_cti_create(struct adiv5_ap
*ap
, uint32_t base
)
38 struct arm_cti
*self
= calloc(1, sizeof(struct arm_cti
));
47 static int arm_cti_mod_reg_bits(struct arm_cti
*self
, unsigned int reg
, uint32_t mask
, uint32_t value
)
52 int retval
= mem_ap_read_atomic_u32(self
->ap
, self
->base
+ reg
, &tmp
);
53 if (ERROR_OK
!= retval
)
62 return mem_ap_write_atomic_u32(self
->ap
, self
->base
+ reg
, tmp
);
65 int arm_cti_enable(struct arm_cti
*self
, bool enable
)
67 uint32_t val
= enable
? 1 : 0;
69 return mem_ap_write_atomic_u32(self
->ap
, self
->base
+ CTI_CTR
, val
);
72 int arm_cti_ack_events(struct arm_cti
*self
, uint32_t event
)
77 retval
= mem_ap_write_atomic_u32(self
->ap
, self
->base
+ CTI_INACK
, event
);
78 if (retval
== ERROR_OK
) {
79 int64_t then
= timeval_ms();
81 retval
= mem_ap_read_atomic_u32(self
->ap
, self
->base
+ CTI_TROUT_STATUS
, &tmp
);
82 if (retval
!= ERROR_OK
)
84 if ((tmp
& event
) == 0)
86 if (timeval_ms() > then
+ 1000) {
87 LOG_ERROR("timeout waiting for target");
88 retval
= ERROR_TARGET_TIMEOUT
;
97 int arm_cti_gate_channel(struct arm_cti
*self
, uint32_t channel
)
100 return ERROR_COMMAND_ARGUMENT_INVALID
;
102 return arm_cti_mod_reg_bits(self
, CTI_GATE
, CTI_CHNL(channel
), 0);
105 int arm_cti_ungate_channel(struct arm_cti
*self
, uint32_t channel
)
108 return ERROR_COMMAND_ARGUMENT_INVALID
;
110 return arm_cti_mod_reg_bits(self
, CTI_GATE
, CTI_CHNL(channel
), 0xFFFFFFFF);
113 int arm_cti_write_reg(struct arm_cti
*self
, unsigned int reg
, uint32_t value
)
115 return mem_ap_write_atomic_u32(self
->ap
, self
->base
+ reg
, value
);
118 int arm_cti_read_reg(struct arm_cti
*self
, unsigned int reg
, uint32_t *p_value
)
121 return ERROR_COMMAND_ARGUMENT_INVALID
;
123 return mem_ap_read_atomic_u32(self
->ap
, self
->base
+ reg
, p_value
);
126 int arm_cti_pulse_channel(struct arm_cti
*self
, uint32_t channel
)
129 return ERROR_COMMAND_ARGUMENT_INVALID
;
131 return arm_cti_write_reg(self
, CTI_APPPULSE
, CTI_CHNL(channel
));
134 int arm_cti_set_channel(struct arm_cti
*self
, uint32_t channel
)
137 return ERROR_COMMAND_ARGUMENT_INVALID
;
139 return arm_cti_write_reg(self
, CTI_APPSET
, CTI_CHNL(channel
));
142 int arm_cti_clear_channel(struct arm_cti
*self
, uint32_t channel
)
145 return ERROR_COMMAND_ARGUMENT_INVALID
;
147 return arm_cti_write_reg(self
, CTI_APPCLEAR
, CTI_CHNL(channel
));
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)