From 00dbc185ee56e68fac04935f388259d13ecef315 Mon Sep 17 00:00:00 2001 From: Andreas Fritiofson Date: Sun, 6 Dec 2015 14:04:24 +0100 Subject: arm_adi_v5: Split ahbap_debugport_init This function does two separate things, powering up the DP and setting up a MEM-AP. But the DP needs to be powered before even searching for a MEM-AP to initialize and targets may have multiple MEM-APs that need initializing. Split the function into dap_dp_init() and mem_ap_init() and change all call sites to use the appropriate one. Change-Id: I92f55e09754a93f3f01dd8e5aa1ffdf60c856126 Signed-off-by: Andreas Fritiofson Reviewed-on: http://openocd.zylin.com/3151 Tested-by: jenkins Reviewed-by: Matthias Welwarsky --- src/target/cortex_a.c | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) (limited to 'src/target/cortex_a.c') diff --git a/src/target/cortex_a.c b/src/target/cortex_a.c index f95985a7..0923f880 100644 --- a/src/target/cortex_a.c +++ b/src/target/cortex_a.c @@ -2910,6 +2910,12 @@ static int cortex_a_examine_first(struct target *target) int retval = ERROR_OK; uint32_t didr, ctypr, ttypr, cpuid, dbg_osreg; + retval = dap_dp_init(swjdp); + if (retval != ERROR_OK) { + LOG_ERROR("Could not initialize the debug port"); + return retval; + } + /* Search for the APB-AB - it is needed for access to debug registers */ retval = dap_find_ap(swjdp, AP_TYPE_APB_AP, &armv7a->debug_ap); if (retval != ERROR_OK) { @@ -2917,24 +2923,28 @@ static int cortex_a_examine_first(struct target *target) return retval; } - /* We do one extra read to ensure DAP is configured, - * we call ahbap_debugport_init(swjdp) instead - */ - retval = ahbap_debugport_init(armv7a->debug_ap); - if (retval != ERROR_OK) + retval = mem_ap_init(armv7a->debug_ap); + if (retval != ERROR_OK) { + LOG_ERROR("Could not initialize the APB-AP"); return retval; + } - /* Search for the AHB-AB */ + /* Search for the AHB-AB. + * REVISIT: We should search for AXI-AP as well and make sure the AP's MEMTYPE says it + * can access system memory. */ + armv7a->memory_ap_available = false; retval = dap_find_ap(swjdp, AP_TYPE_AHB_AP, &armv7a->memory_ap); - if (retval != ERROR_OK) { + if (retval == ERROR_OK) { + retval = mem_ap_init(armv7a->memory_ap); + if (retval == ERROR_OK) + armv7a->memory_ap_available = true; + else + LOG_WARNING("Could not initialize AHB-AP for memory access - using APB-AP"); + } else { /* AHB-AP not found - use APB-AP */ LOG_DEBUG("Could not find AHB-AP - using APB-AP for memory access"); - armv7a->memory_ap_available = false; - } else { - armv7a->memory_ap_available = true; } - if (!target->dbgbase_set) { uint32_t dbgbase; /* Get ROM Table base */ -- cgit v1.2.3-18-g5258