aboutsummaryrefslogtreecommitdiff
path: root/src/target/cortex_a.c
diff options
context:
space:
mode:
authorAndreas Fritiofson <andreas.fritiofson@gmail.com>2015-12-06 14:04:24 +0100
committerAndreas Fritiofson <andreas.fritiofson@gmail.com>2015-12-29 20:29:46 +0000
commit00dbc185ee56e68fac04935f388259d13ecef315 (patch)
treed44852d6285ad765d0f370b32e135d846b767853 /src/target/cortex_a.c
parentc6ce183055acebcc1c5ef004f2f6f4a4042700dd (diff)
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 <andreas.fritiofson@gmail.com> Reviewed-on: http://openocd.zylin.com/3151 Tested-by: jenkins Reviewed-by: Matthias Welwarsky <matthias@welwarsky.de>
Diffstat (limited to 'src/target/cortex_a.c')
-rw-r--r--src/target/cortex_a.c32
1 files changed, 21 insertions, 11 deletions
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 */