aboutsummaryrefslogtreecommitdiff
path: root/src/flash/nor/sim3x.c
diff options
context:
space:
mode:
authorAndreas Fritiofson <andreas.fritiofson@gmail.com>2015-12-06 17:16:31 +0100
committerAndreas Fritiofson <andreas.fritiofson@gmail.com>2015-12-29 20:32:10 +0000
commite7d165f3dbff0fbe11f458becdccbb3d4fa8ccc4 (patch)
tree1277356692c41400ff7d5c237c413170c556e430 /src/flash/nor/sim3x.c
parentd84c7d91960bbba0079268d165f0bb29a0da4d86 (diff)
arm_adi_v5: Remove all cases of "restoring" previous dap_ap_select()
All AP operations should select the AP to use before calling it so there's no point in restoring the previous value afterwards. The explicit call to dap_ap_select() before all AP operations should be moved into dap_queue_ap_read/write() which then would have to take the AP as an argument instead of the DAP. Change-Id: Icacb0c76ef2a5ac36b4d2f26b52ec01a8850286e Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com> Reviewed-on: http://openocd.zylin.com/3156 Tested-by: jenkins Reviewed-by: Matthias Welwarsky <matthias@welwarsky.de>
Diffstat (limited to 'src/flash/nor/sim3x.c')
-rw-r--r--src/flash/nor/sim3x.c19
1 files changed, 6 insertions, 13 deletions
diff --git a/src/flash/nor/sim3x.c b/src/flash/nor/sim3x.c
index 0a5906c1..e30ca454 100644
--- a/src/flash/nor/sim3x.c
+++ b/src/flash/nor/sim3x.c
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2014 by Ladislav Bábel *
+ * Copyright (C) 2014 by Ladislav Bábel *
* ladababel@seznam.cz *
* *
* Copyright (C) 2015 by Andreas Bomholtz *
@@ -893,6 +893,8 @@ static int ap_write_register(struct adiv5_dap *dap, unsigned reg, uint32_t value
int retval;
LOG_DEBUG("DAP_REG[0x%02x] <- %08" PRIX32, reg, value);
+ dap_ap_select(dap, SIM3X_AP);
+
retval = dap_queue_ap_write(dap, reg, value);
if (retval != ERROR_OK) {
LOG_DEBUG("DAP: failed to queue a write request");
@@ -911,6 +913,9 @@ static int ap_write_register(struct adiv5_dap *dap, unsigned reg, uint32_t value
static int ap_read_register(struct adiv5_dap *dap, unsigned reg, uint32_t *result)
{
int retval;
+
+ dap_ap_select(dap, SIM3X_AP);
+
retval = dap_queue_ap_read(dap, reg, result);
if (retval != ERROR_OK) {
LOG_DEBUG("DAP: failed to queue a read request");
@@ -959,9 +964,6 @@ COMMAND_HANDLER(sim3x_mass_erase)
return ERROR_FAIL;
}
- const uint8_t origninal_ap = dap_ap_get_select(dap);
- dap_ap_select(dap, SIM3X_AP);
-
ret = ap_read_register(dap, SIM3X_AP_ID, &val);
if (ret != ERROR_OK)
return ret;
@@ -988,8 +990,6 @@ COMMAND_HANDLER(sim3x_mass_erase)
if (ret != ERROR_OK)
return ret;
- dap_ap_select(dap, origninal_ap);
-
LOG_INFO("Mass erase success");
return ERROR_OK;
}
@@ -1017,9 +1017,6 @@ COMMAND_HANDLER(sim3x_lock)
return ERROR_FAIL;
}
} else {
- const uint8_t origninal_ap = dap_ap_get_select(dap);
- dap_ap_select(dap, SIM3X_AP);
-
/* check SIM3X_AP_ID */
ret = ap_read_register(dap, SIM3X_AP_ID, &val);
if (ret != ERROR_OK)
@@ -1039,8 +1036,6 @@ COMMAND_HANDLER(sim3x_lock)
if (ret != ERROR_OK)
return ret;
- dap_ap_select(dap, origninal_ap);
-
if (val & SIM3X_AP_INIT_STAT_LOCK) {
LOG_INFO("Target is already locked");
return ERROR_OK;
@@ -1049,8 +1044,6 @@ COMMAND_HANDLER(sim3x_lock)
return ERROR_FAIL;
}
}
-
- dap_ap_select(dap, origninal_ap);
}
ret = target_read_u32(target, LOCK_WORD_ADDRESS, &val);