Commit 02b8787d0dc66aebbf395c4707c795ed8a42c5ff
1 parent
225fa189fa
Exists in
smarc_8mm-imx_v2018.03_4.14.98_2.0.0_ga
and in
5 other branches
MA-12335 Canonical Boot Reason in Android Pie 9.0
Read boot reason from SRC(system reset controller) and report it to kernel by "androidboot.bootreason=<>" kernel commandline. This is enabled on imx6/7/7ulp/8m, imx8 will report default value "androidboot.bootreason=reboot" since it can't get such info on A core at u-boot stage. Test: Boot reason report ok on imx6qp/imx7ulp/imx8qxp. Change-Id: I03effaa03bc513bec6153e82c1a04e29c07e7db8 Signed-off-by: Ji Luo <ji.luo@nxp.com>
Showing 4 changed files with 53 additions and 0 deletions Side-by-side Diff
arch/arm/mach-imx/cpu.c
... | ... | @@ -43,7 +43,12 @@ |
43 | 43 | struct src *src_regs = (struct src *)SRC_BASE_ADDR; |
44 | 44 | |
45 | 45 | cause = readl(&src_regs->srsr); |
46 | +#ifndef CONFIG_ANDROID_BOOT_IMAGE | |
47 | + /* We will read the ssrs states later for android so we don't | |
48 | + * clear the states here. | |
49 | + */ | |
46 | 50 | writel(cause, &src_regs->srsr); |
51 | +#endif | |
47 | 52 | reset_cause = cause; |
48 | 53 | |
49 | 54 | switch (cause) { |
... | ... | @@ -86,6 +91,17 @@ |
86 | 91 | return "unknown reset"; |
87 | 92 | } |
88 | 93 | } |
94 | + | |
95 | +#ifdef CONFIG_ANDROID_BOOT_IMAGE | |
96 | +void get_reboot_reason(char *ret) | |
97 | +{ | |
98 | + struct src *src_regs = (struct src *)SRC_BASE_ADDR; | |
99 | + | |
100 | + strcpy(ret, (char *)get_reset_cause()); | |
101 | + /* clear the srsr here, its state has been recorded in reset_cause */ | |
102 | + writel(reset_cause, &src_regs->srsr); | |
103 | +} | |
104 | +#endif | |
89 | 105 | |
90 | 106 | u32 get_imx_reset_cause(void) |
91 | 107 | { |
arch/arm/mach-imx/mx7ulp/soc.c
... | ... | @@ -252,7 +252,12 @@ |
252 | 252 | |
253 | 253 | srs = readl(reg_srs); |
254 | 254 | cause1 = readl(reg_ssrs); |
255 | +#ifndef CONFIG_ANDROID_BOOT_IMAGE | |
256 | + /* We will read the ssrs states later for android so we don't | |
257 | + * clear the states here. | |
258 | + */ | |
255 | 259 | writel(cause1, reg_ssrs); |
260 | +#endif | |
256 | 261 | |
257 | 262 | reset_cause = cause1; |
258 | 263 | |
... | ... | @@ -291,6 +296,17 @@ |
291 | 296 | debug("[%X] SRS[%X] %X - ", cause1, srs, srs^cause1); |
292 | 297 | return ret; |
293 | 298 | } |
299 | + | |
300 | +#ifdef CONFIG_ANDROID_BOOT_IMAGE | |
301 | +void get_reboot_reason(char *ret) | |
302 | +{ | |
303 | + u32 *reg_ssrs = (u32 *)(SRC_BASE_ADDR + 0x28); | |
304 | + | |
305 | + get_reset_cause(ret); | |
306 | + /* clear the ssrs here, its state has been recorded in reset_cause */ | |
307 | + writel(reset_cause, reg_ssrs); | |
308 | +} | |
309 | +#endif | |
294 | 310 | |
295 | 311 | void arch_preboot_os(void) |
296 | 312 | { |
common/image-android.c
... | ... | @@ -143,6 +143,23 @@ |
143 | 143 | metrics.odt, metrics.sw); |
144 | 144 | strncat(commandline, newbootargs, sizeof(commandline) - strlen(commandline)); |
145 | 145 | |
146 | +#if defined(CONFIG_ARCH_MX6) || defined(CONFIG_ARCH_MX7) || \ | |
147 | + defined(CONFIG_ARCH_MX7ULP) || defined(CONFIG_ARCH_IMX8M) | |
148 | + char cause[18]; | |
149 | + | |
150 | + memset(cause, '\0', sizeof(cause)); | |
151 | + get_reboot_reason(cause); | |
152 | + if (strstr(cause, "POR")) | |
153 | + sprintf(newbootargs," androidboot.bootreason=cold,powerkey"); | |
154 | + else if (strstr(cause, "WDOG") || strstr(cause, "WDG")) | |
155 | + sprintf(newbootargs," androidboot.bootreason=watchdog"); | |
156 | + else | |
157 | + sprintf(newbootargs," androidboot.bootreason=reboot"); | |
158 | +#else | |
159 | + sprintf(newbootargs," androidboot.bootreason=reboot"); | |
160 | +#endif | |
161 | + strncat(commandline, newbootargs, sizeof(commandline) - strlen(commandline)); | |
162 | + | |
146 | 163 | #ifdef CONFIG_AVB_SUPPORT |
147 | 164 | /* secondary cmdline added by avb */ |
148 | 165 | char *bootargs_sec = env_get("bootargs_sec"); |
include/common.h
... | ... | @@ -164,6 +164,10 @@ |
164 | 164 | int update_flash_size(int flash_size); |
165 | 165 | int arch_early_init_r(void); |
166 | 166 | |
167 | +#ifdef CONFIG_ANDROID_BOOT_IMAGE | |
168 | +void get_reboot_reason(char *ret); | |
169 | +#endif | |
170 | + | |
167 | 171 | /* |
168 | 172 | * setup_board_extra() - Fill in extra details in the bd_t structure |
169 | 173 | * |