Created
November 15, 2018 17:35
-
-
Save jimparis/5b3afa31d3a0793f8cb0ff4e6516b742 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
commit 9bc389963dc95edc679b31d32c285f2dd6aab619 (HEAD -> jim-rtt) | |
Author: Jim Paris <[email protected]> | |
Date: Thu Nov 15 12:30:30 2018 -0500 | |
target/arm_adi_v5: power off chip debug hardware on shutdown | |
Change-Id: I759442371439ec54597f75964115776bfaa67949 | |
diff --git a/src/target/arm_adi_v5.c b/src/target/arm_adi_v5.c | |
index 4dc2594cf521..52fe7c9c6311 100644 | |
--- a/src/target/arm_adi_v5.c | |
+++ b/src/target/arm_adi_v5.c | |
@@ -710,6 +710,26 @@ int dap_dp_init(struct adiv5_dap *dap) | |
return retval; | |
} | |
+/** | |
+ * Deinitialize a DAP. This turns off power to the debug domain. | |
+ * | |
+ * @param dap The DAP being initialized. | |
+ */ | |
+int dap_dp_uninit(struct adiv5_dap *dap) | |
+{ | |
+ int retval; | |
+ | |
+ LOG_DEBUG("%s", adiv5_dap_name(dap)); | |
+ | |
+ /* Deassert CDBGPWRUPREQ and CSYSPWRUPREQ */ | |
+ dap->dp_ctrl_stat = 0; | |
+ retval = dap_queue_dp_write(dap, DP_CTRL_STAT, dap->dp_ctrl_stat); | |
+ if (retval != ERROR_OK) | |
+ return retval; | |
+ | |
+ return dap_run(dap); | |
+} | |
+ | |
/** | |
* Initialize a DAP. This sets up the power domains, prepares the DP | |
* for further use, and arranges to use AP #0 for all AP operations | |
diff --git a/src/target/arm_adi_v5.h b/src/target/arm_adi_v5.h | |
index 22c316630691..7ae75a2c803f 100644 | |
--- a/src/target/arm_adi_v5.h | |
+++ b/src/target/arm_adi_v5.h | |
@@ -486,6 +486,9 @@ int mem_ap_write_buf_noincr(struct adiv5_ap *ap, | |
int dap_dp_init(struct adiv5_dap *dap); | |
int mem_ap_init(struct adiv5_ap *ap); | |
+/* Deinitialisation of the debug system and power domains */ | |
+int dap_dp_uninit(struct adiv5_dap *dap); | |
+ | |
/* Invalidate cached DP select and cached TAR and CSW of all APs */ | |
void dap_invalidate_cache(struct adiv5_dap *dap); | |
diff --git a/src/target/cortex_m.c b/src/target/cortex_m.c | |
index dcb3ddd8264f..5f49af6c4ccb 100644 | |
--- a/src/target/cortex_m.c | |
+++ b/src/target/cortex_m.c | |
@@ -1676,6 +1676,8 @@ void cortex_m_deinit_target(struct target *target) | |
{ | |
struct cortex_m_common *cortex_m = target_to_cm(target); | |
+ dap_dp_uninit(cortex_m->armv7m.debug_ap->dap); | |
+ | |
free(cortex_m->fp_comparator_list); | |
cortex_m_dwt_free(target); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment