btashton commented on a change in pull request #2991:
URL: https://github.com/apache/incubator-nuttx/pull/2991#discussion_r591045660



##########
File path: arch/risc-v/src/bl602/bl602_systemreset.c
##########
@@ -68,25 +96,34 @@ static void bl602_chip_reset(uint32_t mask)
   putreg32(1, 0x40000ffc);
   putreg32(0, 0x40000ffc);
 
+  /* Avoid glitches  */
+
+  asm volatile("nop;nop;nop;nop");
+  asm volatile("nop;nop;nop;nop");
+
   /* Trigger reset
    * NOTE: The reset seems to be rising _edge_ triggered so the reset
    *       bit should be cleared first otherwise the reset will not
    *       trigger if it has previously fired.
    */
 
-  modifyreg32(
-      BL602_SWRST_CFG2,
-      (SWRST_CFG2_CTRL_SYS_RESET | SWRST_CFG2_CTRL_CPU_RESET | \
-       SWRST_CFG2_CTRL_PWRON_RST),
-      0
-  );
-
-  modifyreg32(
-      BL602_SWRST_CFG2,
-      (SWRST_CFG2_CTRL_SYS_RESET | SWRST_CFG2_CTRL_CPU_RESET | \
-       SWRST_CFG2_CTRL_PWRON_RST),
-      mask
-  );
+  regval = getreg32(BL602_SWRST_CFG2);
+  regval &= ~(SWRST_CFG2_CTRL_SYS_RESET | SWRST_CFG2_CTRL_CPU_RESET |
+        SWRST_CFG2_CTRL_PWRON_RST);
+  putreg32(regval, BL602_SWRST_CFG2);
+
+  regval = getreg32(BL602_SWRST_CFG2);
+  regval &= ~(SWRST_CFG2_CTRL_SYS_RESET | SWRST_CFG2_CTRL_CPU_RESET |
+        SWRST_CFG2_CTRL_PWRON_RST);
+  regval |= mask;
+  putreg32(regval, BL602_SWRST_CFG2);
+#else
+  /* When perform reset before, MUST disable interrupt */
+
+  asm volatile("csrci mstatus, 8");
+
+  ((bl602_romdrv_reset_por)(*((uint32_t *)(0x210108c4))))();

Review comment:
       Can we call the reset api with the mask argument to select which reset 
we want to call (sys, cpu, pwron) and then drop the code I added here that has 
been disabled?




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to