target/arm_adi_v5,arm_dap: introduce pre_connect_init() dap operation

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 <vanekt@fbl.cz>
Reviewed-on: https://review.openocd.org/c/openocd/+/7542
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
This commit is contained in:
Tomas Vanek 2023-03-15 13:58:52 +01:00
parent ee3fb5a0ea
commit bfc1252239
2 changed files with 12 additions and 0 deletions

View File

@ -420,6 +420,9 @@ struct adiv5_dap {
* available until run(). * available until run().
*/ */
struct dap_ops { 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 */ /** connect operation for SWD */
int (*connect)(struct adiv5_dap *dap); int (*connect)(struct adiv5_dap *dap);

View File

@ -91,6 +91,7 @@ static int dap_init_all(void)
{ {
struct arm_dap_object *obj; struct arm_dap_object *obj;
int retval; int retval;
bool pre_connect = true;
LOG_DEBUG("Initializing all DAPs ..."); LOG_DEBUG("Initializing all DAPs ...");
@ -123,6 +124,14 @@ static int dap_init_all(void)
is_adiv6(dap) ? "ADIv6" : "ADIv5"); 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); retval = dap->ops->connect(dap);
if (retval != ERROR_OK) if (retval != ERROR_OK)
return retval; return retval;