summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzhang sanshan <b51434@freescale.com>2016-09-09 11:00:27 +0800
committerzhang sanshan <b51434@freescale.com>2016-09-09 14:17:12 +0800
commit5249e804483a8c3b7807d8bbb7371308be9f2dea (patch)
tree7179c9e140c9068275ac6789fc06880367f10fd0
parent50bebf0bca2cb8627e82a721d130590b106aa950 (diff)
downloadu-boot-imx-5249e804483a8c3b7807d8bbb7371308be9f2dea.zip
u-boot-imx-5249e804483a8c3b7807d8bbb7371308be9f2dea.tar.gz
u-boot-imx-5249e804483a8c3b7807d8bbb7371308be9f2dea.tar.bz2
MA-8658-2 [Android_Imx]bootstat:record the reason of system boot
Bootstat in android need info about boot reason. Read the reset reason and pass it to kernel through bootargs. Signed-off-by: zhang sanshan <b51434@freescale.com> Changes in v2: Delete the kernel_panic bootreason for we do not have a formal way to record panic reason in kernel.
-rw-r--r--arch/arm/cpu/armv7/mx6/soc.c18
-rw-r--r--arch/arm/cpu/armv7/mx7/soc.c20
-rw-r--r--common/image-android.c28
-rw-r--r--include/configs/mx6sabreandroid_common.h1
-rw-r--r--include/configs/mx6slevkandroid.h1
-rw-r--r--include/configs/mx6sxsabreautoandroid.h1
-rw-r--r--include/configs/mx6sxsabresdandroid.h1
-rw-r--r--include/configs/mx7dsabresdandroid.h1
-rw-r--r--include/recovery.h2
9 files changed, 72 insertions, 1 deletions
diff --git a/arch/arm/cpu/armv7/mx6/soc.c b/arch/arm/cpu/armv7/mx6/soc.c
index 29e1043..ba768e3 100644
--- a/arch/arm/cpu/armv7/mx6/soc.c
+++ b/arch/arm/cpu/armv7/mx6/soc.c
@@ -1055,7 +1055,25 @@ void v7_outer_cache_disable(void)
#endif /* !CONFIG_SYS_L2CACHE_OFF */
#ifdef CONFIG_FSL_FASTBOOT
+#ifdef CONFIG_RESET_CAUSE
+#define ANDROID_NORMAL_BOOT 6
+#define ANDROID_BOOT_REASON_OFFSET 6
+int read_boot_reason()
+{
+ u32 reg;
+ reg = readl(SNVS_BASE_ADDR + SNVS_LPGPR);
+ if (reg & (1 << ANDROID_NORMAL_BOOT))
+ return ANDROID_NORMAL_BOOT;
+ return 0;
+}
+void clear_boot_reason()
+{
+ u32 reg;
+ reg &= ~(1 << ANDROID_BOOT_REASON_OFFSET);
+ writel(reg, SNVS_BASE_ADDR + SNVS_LPGPR);
+}
+#endif
#ifdef CONFIG_ANDROID_RECOVERY
#define ANDROID_RECOVERY_BOOT (1 << 7)
/* check if the recovery bit is set by kernel, it can be set by kernel
diff --git a/arch/arm/cpu/armv7/mx7/soc.c b/arch/arm/cpu/armv7/mx7/soc.c
index d718e67..f807a55 100644
--- a/arch/arm/cpu/armv7/mx7/soc.c
+++ b/arch/arm/cpu/armv7/mx7/soc.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2014-2015 Freescale Semiconductor, Inc.
+ * Copyright (C) 2014-2016 Freescale Semiconductor, Inc.
*
* SPDX-License-Identifier: GPL-2.0+
*/
@@ -466,7 +466,25 @@ void reset_misc(void)
}
#ifdef CONFIG_FSL_FASTBOOT
+#ifdef CONFIG_RESET_CAUSE
+#define ANDROID_NORMAL_BOOT 6
+#define ANDROID_BOOT_REASON_OFFSET 6
+int read_boot_reason()
+{
+ u32 reg;
+ reg = readl(SNVS_BASE_ADDR + SNVS_LPGPR);
+ if (reg & (1 << ANDROID_NORMAL_BOOT))
+ return ANDROID_NORMAL_BOOT;
+ return 0;
+}
+void clear_boot_reason()
+{
+ u32 reg;
+ reg &= ~(1 << ANDROID_BOOT_REASON_OFFSET);
+ writel(reg, SNVS_BASE_ADDR + SNVS_LPGPR);
+}
+#endif
#ifdef CONFIG_ANDROID_RECOVERY
#define ANDROID_RECOVERY_BOOT (1 << 7)
/*
diff --git a/common/image-android.c b/common/image-android.c
index 6e38519..88289cb 100644
--- a/common/image-android.c
+++ b/common/image-android.c
@@ -20,6 +20,13 @@ static char andr_tmp_str[ANDR_BOOT_ARGS_SIZE + 1];
#include <linux/usb/gadget.h>
#include "../drivers/usb/gadget/bootctrl.h"
#endif
+#ifdef CONFIG_RESET_CAUSE
+#include <asm/arch-imx/cpu.h>
+#include <recovery.h>
+#define POR_NUM1 0x1
+#define POR_NUM2 0x11
+#define ANDROID_NORMAL_BOOT 6
+#endif
/**
* android_image_get_kernel() - processes kernel part of Android boot images
* @hdr: Pointer to image header, which is at the start
@@ -43,6 +50,9 @@ int android_image_get_kernel(const struct andr_img_hdr *hdr, int verify,
* sha1 (or anything) so we don't check it. It is not obvious that the
* string is null terminated so we take care of this.
*/
+#ifdef CONFIG_RESET_CAUSE
+ u32 reset_cause_sw,reset_cause_hw;
+#endif
strncpy(andr_tmp_str, hdr->name, ANDR_BOOT_NAME_SIZE);
andr_tmp_str[ANDR_BOOT_NAME_SIZE] = '\0';
if (strlen(andr_tmp_str))
@@ -84,6 +94,24 @@ int android_image_get_kernel(const struct andr_img_hdr *hdr, int verify,
newbootargs,
serialnr.high,
serialnr.low);
+ newbootargs = commandline;
+#endif
+#ifdef CONFIG_RESET_CAUSE
+ reset_cause_sw = read_boot_reason();
+ clear_boot_reason();
+ reset_cause_hw = get_imx_reset_cause();
+ if (ANDROID_NORMAL_BOOT == reset_cause_sw)
+ sprintf(commandline,
+ "%s androidboot.bootreason=Reboot",
+ newbootargs);
+ else if (POR_NUM1==reset_cause_hw || POR_NUM2 == reset_cause_hw)
+ sprintf(commandline,
+ "%s androidboot.bootreason=normal",
+ newbootargs);
+ else
+ sprintf(commandline,
+ "%s androidboot.bootreason=unknown",
+ newbootargs);
#endif
#ifdef CONFIG_BRILLO_SUPPORT
diff --git a/include/configs/mx6sabreandroid_common.h b/include/configs/mx6sabreandroid_common.h
index a531a02..2429b20 100644
--- a/include/configs/mx6sabreandroid_common.h
+++ b/include/configs/mx6sabreandroid_common.h
@@ -68,6 +68,7 @@
#define CONFIG_CMD_BOOTA
#define CONFIG_SUPPORT_RAW_INITRD
#define CONFIG_SERIAL_TAG
+#define CONFIG_RESET_CAUSE
#undef CONFIG_EXTRA_ENV_SETTINGS
#undef CONFIG_BOOTCOMMAND
diff --git a/include/configs/mx6slevkandroid.h b/include/configs/mx6slevkandroid.h
index 1f2f0e5..558dcb2 100644
--- a/include/configs/mx6slevkandroid.h
+++ b/include/configs/mx6slevkandroid.h
@@ -46,6 +46,7 @@
#define CONFIG_CMD_BOOTA
#define CONFIG_SUPPORT_RAW_INITRD
#define CONFIG_SERIAL_TAG
+#define CONFIG_RESET_CAUSE
/*keyboard mapping*/
#define CONFIG_VOL_DOWN_KEY KEY_BACK
diff --git a/include/configs/mx6sxsabreautoandroid.h b/include/configs/mx6sxsabreautoandroid.h
index f825bdb..049d240 100644
--- a/include/configs/mx6sxsabreautoandroid.h
+++ b/include/configs/mx6sxsabreautoandroid.h
@@ -67,6 +67,7 @@
#define CONFIG_CMD_BOOTA
#define CONFIG_SUPPORT_RAW_INITRD
#define CONFIG_SERIAL_TAG
+#define CONFIG_RESET_CAUSE
#undef CONFIG_EXTRA_ENV_SETTINGS
#undef CONFIG_BOOTCOMMAND
diff --git a/include/configs/mx6sxsabresdandroid.h b/include/configs/mx6sxsabresdandroid.h
index b1318bd..8be5675 100644
--- a/include/configs/mx6sxsabresdandroid.h
+++ b/include/configs/mx6sxsabresdandroid.h
@@ -59,6 +59,7 @@
#define CONFIG_CMD_BOOTA
#define CONFIG_SUPPORT_RAW_INITRD
#define CONFIG_SERIAL_TAG
+#define CONFIG_RESET_CAUSE
#undef CONFIG_EXTRA_ENV_SETTINGS
#undef CONFIG_BOOTCOMMAND
diff --git a/include/configs/mx7dsabresdandroid.h b/include/configs/mx7dsabresdandroid.h
index 74112d8..cb8d64f 100644
--- a/include/configs/mx7dsabresdandroid.h
+++ b/include/configs/mx7dsabresdandroid.h
@@ -43,6 +43,7 @@
#define CONFIG_CMD_BOOTA
#define CONFIG_SUPPORT_RAW_INITRD
#define CONFIG_SERIAL_TAG
+#define CONFIG_RESET_CAUSE
#undef CONFIG_EXTRA_ENV_SETTINGS
#undef CONFIG_BOOTCOMMAND
diff --git a/include/recovery.h b/include/recovery.h
index bd3d010..3adaeb1 100644
--- a/include/recovery.h
+++ b/include/recovery.h
@@ -17,5 +17,7 @@ int recovery_check_and_clean_flag(void);
int recovery_check_and_clean_command(void);
int check_recovery_cmd_file(void);
void board_recovery_setup(void);
+int read_boot_reason(void);
+void clear_boot_reason(void);
#endif