soc:exynos-reboot:Store the last powerup reason to INFORM9
authora17671 <a17671@motorola.com>
Mon, 8 Oct 2018 09:49:12 +0000 (17:49 +0800)
committerxiest1 <xiest1@lenovo.com>
Tue, 5 Nov 2019 09:30:17 +0000 (17:30 +0800)
Set the last power up reason register to INFORM9 register
According to the reboot parameter from kpreadwrite

Change-Id: I7719aa93ddcc50b97b6d973ea2e06c16317fa785
Signed-off-by: a17671 <a17671@motorola.com>
Reviewed-on: https://gerrit.mot.com/1251924
SLTApproved: Slta Waiver
SME-Granted: SME Approvals Granted
Tested-by: Jira Key
Reviewed-by: Xiangpo Zhao <zhaoxp3@motorola.com>
Submit-Approved: Jira Key

drivers/soc/samsung/exynos-reboot.c

index a8560e329d7c3542e1443c968d553233481473a4..61c4add4d8b9416f500917e97a328f368dbb2681 100644 (file)
@@ -70,7 +70,7 @@ int soc_has_big(void)
 #define RESET_SEQUENCER_CONFIGURATION  (0x0500)
 #define PS_HOLD_CONTROL                        (0x330C)
 #define EXYNOS_PMU_SYSIP_DAT0                  (0x0810)
-
+#define LAST_POWERUP_REASON_REG                        (0x0854)  /*EXYNOS9610_POWER_INFORM9*/
 /* defines for BIG reset */
 #define PEND_BIG                               (1 << 0)
 #define PEND_LITTLE                            (1 << 1)
@@ -211,6 +211,15 @@ void big_reset_control(int en)
 /* Reboot into recovery */
 #define REBOOT_MODE_FACTORY            0xFD
 
+#define RESET_EXTRA_RESET_KUNPOW_REASON        BIT(9)
+#define RESET_EXTRA_POST_PANIC_REASON  (BIT(4) | BIT(5))
+#define RESET_EXTRA_POST_PMICWDT_REASON        BIT(5)
+#define RESET_EXTRA_POST_WDT_REASON    BIT(4)
+#define RESET_EXTRA_POST_REBOOT_MASK   (BIT(4) | BIT(5) | BIT(6))
+#define RESET_EXTRA_PANIC_REASON        BIT(3)
+#define RESET_EXTRA_REBOOT_BL_REASON    BIT(2)
+#define RESET_EXTRA_HW_RESET_REASON    BIT(1)
+
 #if !defined(CONFIG_SEC_REBOOT)
 #ifdef CONFIG_OF
 static void exynos_power_off(void)
@@ -275,7 +284,7 @@ static void exynos_reboot(enum reboot_mode mode, const char *cmd)
 {
        u32 soc_id, revision;
        void __iomem *addr;
-
+       void __iomem *addr_extra;
        if (!exynos_pmu_base)
                return;
 #ifdef CONFIG_EXYNOS_ACPM
@@ -284,6 +293,9 @@ static void exynos_reboot(enum reboot_mode mode, const char *cmd)
        printk("[%s] reboot cmd: %s\n", __func__, cmd);
 
        addr = exynos_pmu_base + EXYNOS_PMU_SYSIP_DAT0;
+       addr_extra = exynos_pmu_base + LAST_POWERUP_REASON_REG;
+       /*Clear the last power up reason first*/
+       __raw_writel(0, addr_extra);
        if (cmd) {
                if (!strcmp((char *)cmd, "charge")) {
                        __raw_writel(REBOOT_MODE_CHARGE, addr);
@@ -294,6 +306,12 @@ static void exynos_reboot(enum reboot_mode mode, const char *cmd)
                        __raw_writel(REBOOT_MODE_RECOVERY, addr);
                } else if (!strcmp(cmd, "sfactory")) {
                        __raw_writel(REBOOT_MODE_FACTORY, addr);
+               } else if (!strncmp(cmd, "post-wdt",8)) {
+                       __raw_writel(RESET_EXTRA_POST_WDT_REASON, addr_extra);
+               } else if (!strncmp(cmd, "post-pmicwdt",12)) {
+                       __raw_writel(RESET_EXTRA_POST_PMICWDT_REASON, addr_extra);
+               } else if (!strncmp(cmd, "post-panic",10)) {
+                       __raw_writel(RESET_EXTRA_POST_PANIC_REASON, addr_extra);
                }
        }