You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2023/04/21 17:42:09 UTC
[nuttx] 02/02: arch/nrf52: reimplement I-Cache control operations in nrf52_start.c
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit d416ead27cc9c2ece456b69880b7929a9e48d6d2
Author: raiden00pl <ra...@railab.me>
AuthorDate: Wed Mar 15 11:42:33 2023 +0100
arch/nrf52: reimplement I-Cache control operations in nrf52_start.c
---
arch/arm/src/nrf52/nrf52_nvmc.c | 72 ----------------------------------------
arch/arm/src/nrf52/nrf52_nvmc.h | 32 ------------------
arch/arm/src/nrf52/nrf52_start.c | 64 ++++++++++++++++++++++++++++++++---
3 files changed, 59 insertions(+), 109 deletions(-)
diff --git a/arch/arm/src/nrf52/nrf52_nvmc.c b/arch/arm/src/nrf52/nrf52_nvmc.c
index ae3b15ebcb..0fd8948894 100644
--- a/arch/arm/src/nrf52/nrf52_nvmc.c
+++ b/arch/arm/src/nrf52/nrf52_nvmc.c
@@ -110,78 +110,6 @@ static inline void nrf_mem_barrier(void)
* Public Functions
****************************************************************************/
-/****************************************************************************
- * Name: nrf_nvmc_enable_icache
- *
- * Description:
- * Enable I-Cache for Flash
- *
- * Input Parameter:
- * flag - Flag to enable or disable.
- *
- * Returned Values:
- * None
- *
- ****************************************************************************/
-
-void nrf_nvmc_enable_icache(bool flag)
-{
- uint32_t value;
-
- /* Read the current icache configuration */
-
- value = getreg32(NRF52_NVMC_ICACHECNF);
-
- if (flag)
- {
- value |= NVMC_ICACHECNF_CACHEEN;
- }
- else
- {
- value &= ~NVMC_ICACHECNF_CACHEEN;
- }
-
- /* Setup the new icache configuration */
-
- putreg32(value, NRF52_NVMC_ICACHECNF);
-}
-
-/****************************************************************************
- * Name: nrf_nvmc_enable_profile
- *
- * Description:
- * Enable profiling I-Cache for flash
- *
- * Input Parameter:
- * flag - Flag to enable or disable.
- *
- * Returned Values:
- * None
- *
- ****************************************************************************/
-
-void nrf_nvmc_enable_profile(bool flag)
-{
- uint32_t value;
-
- /* Read the current icache configuration */
-
- value = getreg32(NRF52_NVMC_ICACHECNF);
-
- if (flag)
- {
- value |= NVMC_ICACHECNF_CACHEPROFEN;
- }
- else
- {
- value &= ~NVMC_ICACHECNF_CACHEPROFEN;
- }
-
- /* Setup the new icache configuration */
-
- putreg32(value, NRF52_NVMC_ICACHECNF);
-}
-
/****************************************************************************
* Name: nrf_nvmc_get_profiling_ihit
*
diff --git a/arch/arm/src/nrf52/nrf52_nvmc.h b/arch/arm/src/nrf52/nrf52_nvmc.h
index effea59243..5b44d02902 100644
--- a/arch/arm/src/nrf52/nrf52_nvmc.h
+++ b/arch/arm/src/nrf52/nrf52_nvmc.h
@@ -146,38 +146,6 @@ void nrf_nvmc_write_bytes(uint32_t address, const uint8_t *src,
void nrf_nvmc_write_words(uint32_t address, const uint32_t *src,
uint32_t num_words);
-/****************************************************************************
- * Name: nrf_nvmc_enable_icache
- *
- * Description:
- * Enable I-Cache for Flash
- *
- * Input Parameter:
- * flag - Flag to enable or disable.
- *
- * Returned Values:
- * None
- *
- ****************************************************************************/
-
-void nrf_nvmc_enable_icache(bool flag);
-
-/****************************************************************************
- * Name: nrf_nvmc_enable_profile
- *
- * Description:
- * Enable profiling I-Cache for flash
- *
- * Input Parameter:
- * flag - Flag to enable or disable.
- *
- * Returned Values:
- * None
- *
- ****************************************************************************/
-
-void nrf_nvmc_enable_profile(bool flag);
-
/****************************************************************************
* Name: nrf_nvmc_get_profiling_ihit
*
diff --git a/arch/arm/src/nrf52/nrf52_start.c b/arch/arm/src/nrf52/nrf52_start.c
index 1f29458d44..e775fbcc66 100644
--- a/arch/arm/src/nrf52/nrf52_start.c
+++ b/arch/arm/src/nrf52/nrf52_start.c
@@ -33,10 +33,9 @@
#include <arch/irq.h>
#include "arm_internal.h"
-#include "nvic.h"
-
-#include "nrf52_clockconfig.h"
+#include "hardware/nrf52_nvmc.h"
#include "hardware/nrf52_utils.h"
+#include "nrf52_clockconfig.h"
#include "nrf52_lowputc.h"
#include "nrf52_start.h"
#include "nrf52_gpio.h"
@@ -71,6 +70,61 @@
void __start(void) noinstrument_function;
#endif
+#ifdef CONFIG_NRF52_FLASH_PREFETCH
+
+/****************************************************************************
+ * Name: nrf52_enable_icache
+ *
+ * Description:
+ * Enable I-Cache for Flash
+ *
+ * Input Parameter:
+ * enable - enable or disable I-Cache
+ *
+ * Returned Values:
+ * None
+ *
+ ****************************************************************************/
+
+void nrf52_enable_icache(bool enable)
+{
+ if (enable)
+ {
+ modifyreg32(NRF52_NVMC_ICACHECNF, 0, NVMC_ICACHECNF_CACHEEN);
+ }
+ else
+ {
+ modifyreg32(NRF52_NVMC_ICACHECNF, NVMC_ICACHECNF_CACHEEN, 0);
+ }
+}
+
+/****************************************************************************
+ * Name: nrf52_enable_profile
+ *
+ * Description:
+ * Enable profiling I-Cache for flash
+ *
+ * Input Parameter:
+ * enable - enable or disable profiling for I-Cache
+ *
+ * Returned Values:
+ * None
+ *
+ ****************************************************************************/
+
+void nrf52_enable_profile(bool enable)
+{
+ if (enable)
+ {
+ modifyreg32(NRF52_NVMC_ICACHECNF, 0, NVMC_ICACHECNF_CACHEPROFEN);
+ }
+ else
+ {
+ modifyreg32(NRF52_NVMC_ICACHECNF, NVMC_ICACHECNF_CACHEPROFEN, 0);
+ }
+}
+#endif
+
/****************************************************************************
* Public Functions
****************************************************************************/
@@ -145,8 +199,8 @@ void __start(void)
arm_fpuconfig();
#ifdef CONFIG_NRF52_FLASH_PREFETCH
- nrf_nvmc_enable_icache(true);
- nrf_nvmc_enable_profile(true);
+ nrf52_enable_icache(true);
+ nrf52_enable_profile(true);
#endif
showprogress('D');