TimJTi commented on code in PR #16303:
URL: https://github.com/apache/nuttx/pull/16303#discussion_r2072388141


##########
arch/arm/src/sama5/sam_systemreset.c:
##########
@@ -35,13 +35,63 @@
 
 #include "arm_internal.h"
 #include "hardware/sam_rstc.h"
+#include "sam_systemreset.h"
 
 #ifdef CONFIG_SAMA5_SYSTEMRESET
 
 /****************************************************************************
  * Public Functions
  ****************************************************************************/
 
+/****************************************************************************
+ * Name: sam_get_reset_cause
+ *
+ * Description:
+ *   Get cause of the last CPU reset. This is done by reading reset status
+ *   registger.
+ *
+ * Returned Value:
+ *   CPU reset cause in form of macros defined in sam_systemreset.h. This is
+ *   to avoid passing boardctl dependent structure to architecture layer.
+ *   Board level specific code should include sam_systemreset.h and set
+ *   boardctl result according to that. -1 is returned in case of invalid
+ *   value in status register.
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_BOARDCTL_RESET_CAUSE
+int sam_get_reset_cause(void)
+{
+  int ret;
+  uint32_t rstsr;
+
+  rstsr = getreg32(SAM_RSTC_SR);
+  switch (rstsr & RSTC_SR_RSTTYP_MASK)
+    {
+      case RSTC_SR_RSTTYP_PWRUP:
+        ret = SAMA5_RESET_PWRUP;

Review Comment:
   > @xiaoxiang781216 ...
   > I will change it, retest, and push again. I'll mark it back as draft for 
now.
   
   I did this away from my test set up and pushed it...but now see that I have 
board-specific code that mapped the SAMA5 reset cause names to the boardctl 
names, which is probably what the samv7 did.
   
   I will investigate properly next week and rework to the simplest/best/most 
consistent solution rather than just hack it like I did earlier!
   
   



-- 
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: commits-unsubscr...@nuttx.apache.org

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

Reply via email to