aboutsummaryrefslogtreecommitdiff
path: root/src/target/arm_adi_v5.c
diff options
context:
space:
mode:
authorAndrey Smirnov <andrew.smirnov@gmail.com>2014-04-03 14:27:27 -0700
committerAndreas Fritiofson <andreas.fritiofson@gmail.com>2014-06-01 17:01:37 +0000
commitd80123f20b747feb7ef70ac8e5de8938be0002f4 (patch)
tree2495b4fb423f532c099468370ed92dbc1b2dccaa /src/target/arm_adi_v5.c
parentd007764fe88958aa556f060054d55841e1d9306d (diff)
downloadriscv-openocd-d80123f20b747feb7ef70ac8e5de8938be0002f4.zip
riscv-openocd-d80123f20b747feb7ef70ac8e5de8938be0002f4.tar.gz
riscv-openocd-d80123f20b747feb7ef70ac8e5de8938be0002f4.tar.bz2
arm_adi_v5: Do not ignore register polling timeout
Previous to this commit 'ahbap_debugport_init' would ignore if timeout happened or not when waiting for CDBGPWRUPACK and CSYSPWRUPACK and would continue initialization regardless. It also would not reset the timeout counter after finishing polling for CDBGPWRUPACK and starting for CSYSPWRUPACK which could potentially cause some problems. Also refactor code of both snippets into a more generic function to avoid duplication. Change-Id: I16e4f50e6819e08c4126e71ef8cec7db559d608e Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Reviewed-on: http://openocd.zylin.com/2086 Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com> Tested-by: jenkins
Diffstat (limited to 'src/target/arm_adi_v5.c')
-rw-r--r--src/target/arm_adi_v5.c39
1 files changed, 12 insertions, 27 deletions
diff --git a/src/target/arm_adi_v5.c b/src/target/arm_adi_v5.c
index 1c80fcc..1e324ef 100644
--- a/src/target/arm_adi_v5.c
+++ b/src/target/arm_adi_v5.c
@@ -619,6 +619,8 @@ int mem_ap_sel_write_buf_noincr(struct adiv5_dap *swjdp, uint8_t ap,
/*--------------------------------------------------------------------------*/
+#define DAP_POWER_DOMAIN_TIMEOUT (10)
+
/* FIXME don't import ... just initialize as
* part of DAP transport setup
*/
@@ -640,8 +642,6 @@ extern const struct dap_ops jtag_dp_ops;
*/
int ahbap_debugport_init(struct adiv5_dap *dap)
{
- uint32_t ctrlstat;
- int cnt = 0;
int retval;
LOG_DEBUG(" ");
@@ -681,36 +681,21 @@ int ahbap_debugport_init(struct adiv5_dap *dap)
if (retval != ERROR_OK)
return retval;
- retval = dap_queue_dp_read(dap, DP_CTRL_STAT, &ctrlstat);
+ /* Check that we have debug power domains activated */
+ LOG_DEBUG("DAP: wait CDBGPWRUPACK");
+ retval = dap_dp_poll_register(dap, DP_CTRL_STAT,
+ CDBGPWRUPACK, CDBGPWRUPACK,
+ DAP_POWER_DOMAIN_TIMEOUT);
if (retval != ERROR_OK)
return retval;
- retval = dap_run(dap);
+
+ LOG_DEBUG("DAP: wait CSYSPWRUPACK");
+ retval = dap_dp_poll_register(dap, DP_CTRL_STAT,
+ CSYSPWRUPACK, CSYSPWRUPACK,
+ DAP_POWER_DOMAIN_TIMEOUT);
if (retval != ERROR_OK)
return retval;
- /* Check that we have debug power domains activated */
- while (!(ctrlstat & CDBGPWRUPACK) && (cnt++ < 10)) {
- LOG_DEBUG("DAP: wait CDBGPWRUPACK");
- retval = dap_queue_dp_read(dap, DP_CTRL_STAT, &ctrlstat);
- if (retval != ERROR_OK)
- return retval;
- retval = dap_run(dap);
- if (retval != ERROR_OK)
- return retval;
- alive_sleep(10);
- }
-
- while (!(ctrlstat & CSYSPWRUPACK) && (cnt++ < 10)) {
- LOG_DEBUG("DAP: wait CSYSPWRUPACK");
- retval = dap_queue_dp_read(dap, DP_CTRL_STAT, &ctrlstat);
- if (retval != ERROR_OK)
- return retval;
- retval = dap_run(dap);
- if (retval != ERROR_OK)
- return retval;
- alive_sleep(10);
- }
-
retval = dap_queue_dp_read(dap, DP_CTRL_STAT, NULL);
if (retval != ERROR_OK)
return retval;