diff mbox series

[5/8] Spi: sprd-adi: Checking panic reason from sml

Message ID 20230815023426.15076-5-jiansheng.wu@unisoc.com
State New
Headers show
Series [1/8] Spi: sprd-adi: Getting panic reason before reboot | expand

Commit Message

Jiansheng Wu Aug. 15, 2023, 2:34 a.m. UTC
Checking panic reason from sml and recording reboot mode to pmic's reg.
It used to check reboot reason on next boot.

Signed-off-by: XiaoQing Wu <xiaoqing.wu@unisoc.com>
Signed-off-by: Jiansheng Wu <jiansheng.wu@unisoc.com>
---
 drivers/spi/spi-sprd-adi.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/drivers/spi/spi-sprd-adi.c b/drivers/spi/spi-sprd-adi.c
index eea64d20279e..c31035fffe4c 100644
--- a/drivers/spi/spi-sprd-adi.c
+++ b/drivers/spi/spi-sprd-adi.c
@@ -119,6 +119,7 @@ 
 /* Definition of PMIC reset status register */
 #define HWRST_STATUS_SECURITY		0x02
 #define HWRST_STATUS_SECBOOT		0x03
+#define HWRST_STATUS_SML_PANIC          0x04
 #define HWRST_STATUS_RECOVERY		0x20
 #define HWRST_STATUS_NORMAL		0x40
 #define HWRST_STATUS_ALARM		0x50
@@ -410,7 +411,7 @@  static int sprd_adi_restart_handler(struct notifier_block *this, unsigned long m
 {
 	struct sprd_adi *sadi = container_of(this, struct sprd_adi,
 					     restart_handler);
-	u32 val, reboot_mode = 0;
+	u32 val = 0, reboot_mode = 0, sml_mode;
 
 	if (!cmd) {
 		if (strlen(panic_reason)) {
@@ -453,9 +454,12 @@  static int sprd_adi_restart_handler(struct notifier_block *this, unsigned long m
 
 	/* Record the reboot mode */
 	sprd_adi_read(sadi, sadi->data->rst_sts, &val);
-	val &= ~0xFF;
-	val |= reboot_mode;
-	sprd_adi_write(sadi, sadi->data->rst_sts, val);
+	sml_mode = val & 0xFF;
+	if (sml_mode != HWRST_STATUS_SML_PANIC && sml_mode != HWRST_STATUS_SECURITY) {
+		val &= ~0xFF;
+		val |= reboot_mode;
+		sprd_adi_write(sadi, sadi->data->rst_sts, val);
+	}
 
 	/*enable register reboot mode*/
 	sprd_adi_read(sadi, sadi->data->swrst_base, &val);