Skip to content

Commit

Permalink
target/arm_adi_v5,arm_dap: introduce pre_connect_init() dap operation
Browse files Browse the repository at this point in the history
SWD multidrop requires some initialization once before connecting
all daps. Provide an optional pre-connect dap operation.

Change-Id: I778215c512c56423a425dda80ab19a739f22f285
Signed-off-by: Tomas Vanek <[email protected]>
Reviewed-on: https://review.openocd.org/c/openocd/+/7542
Tested-by: jenkins
Reviewed-by: Antonio Borneo <[email protected]>
  • Loading branch information
tom-van committed Dec 29, 2023
1 parent ee3fb5a commit bfc1252
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/target/arm_adi_v5.h
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,9 @@ struct adiv5_dap {
* available until run().
*/
struct dap_ops {
/** Optional; called once on the first enabled dap before connecting */
int (*pre_connect_init)(struct adiv5_dap *dap);

/** connect operation for SWD */
int (*connect)(struct adiv5_dap *dap);

Expand Down
9 changes: 9 additions & 0 deletions src/target/arm_dap.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ static int dap_init_all(void)
{
struct arm_dap_object *obj;
int retval;
bool pre_connect = true;

LOG_DEBUG("Initializing all DAPs ...");

Expand Down Expand Up @@ -123,6 +124,14 @@ static int dap_init_all(void)
is_adiv6(dap) ? "ADIv6" : "ADIv5");
}

if (pre_connect && dap->ops->pre_connect_init) {
retval = dap->ops->pre_connect_init(dap);
if (retval != ERROR_OK)
return retval;

pre_connect = false;
}

retval = dap->ops->connect(dap);
if (retval != ERROR_OK)
return retval;
Expand Down

0 comments on commit bfc1252

Please sign in to comment.