jerpelea commented on code in PR #21185:
URL: https://github.com/apache/nuttx/pull/21185#discussion_r4431014966


##########
arch/arm/src/rp23xx/rp23xx_flash_mtd.c:
##########
@@ -368,90 +438,290 @@ static void leave_smp_isolation(struct smp_isolation_s 
*const data)
 #endif /* CONFIG_SMP */
 
 /****************************************************************************
- * Name: rp23xx_flash_restore_xip
+ * Name: rp23xx_flash_begin
  *
  * Description:
- *   Put the QSPI interface back into execute-in-place mode.  Must run from
- *   RAM: until it returns, nothing can be fetched from flash.
+ *   Save the QSPI state and put the flash in serial command mode, as the
+ *   Pico SDK does.  Must run from RAM: XIP is not available until
+ *   rp23xx_flash_end() returns.
  *
  ****************************************************************************/
 
-static void RAM_CODE(rp23xx_flash_restore_xip)(void)
+static void RAM_CODE(rp23xx_flash_begin)(struct rp23xx_qspi_state_s *state)
 {
-  g_rom.flash_flush_cache();
+  int i;
 
-  /* Ask the bootrom to put the flash back into a fast quad read mode.  It
-   * reports whether it managed to, so a part that cannot do quad falls
-   * back rather than leaving the interface unusable.
-   */
+  /* Write back dirty PSRAM lines.  flash_flush_cache() discards them. */
 
-  if (g_rom.select_xip_read_mode == NULL ||
-      !g_rom.select_xip_read_mode(RP23XX_XIP_MODE_EBH_QUAD,
-                                  RP23XX_XIP_CLKDIV))
+  for (i = 0; i < XIP_CACHE_SIZE; i += XIP_CACHE_LINE_SIZE)
+    {
+      putreg8(0, XIP_CACHE_CLEAN_BASE + i);
+    }
+
+  UP_DSB();
+  UP_ISB();

Review Comment:
   https://github.com/apache/nuttx/pull/21249



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to