aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Kocialkowski2016-03-28 13:32:26 +0200
committerPaul Kocialkowski2016-03-28 13:56:04 +0200
commit5c5a54e6514649b6a30732d3249ebb6bcee4232b (patch)
tree5f0a0502ab758f4e670c284fa67f7514a6ec149f
parent8e12dd979e105e115f04383de9255adc03bd1242 (diff)
kc1: Proper reboot mode and boot reason validation
With the previous implementation, rebooting without registering a recognized reboot mode would end up with U-Boot checking for a valid power-on reason, which might result in the device turning off (e.g. with no USB cable attached and no buttons pressed). Since this approach is not viable (breaks reboot in most cases), the validity of the reboot reason is checked (in turn, by checking that a warm reset happened, as there is no magic) to detect a reboot and the 'o' char is recognized to indicate that power-off is required. Still, that might be overridden by the detection of usual power-on reasons, on purpose. Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
-rw-r--r--board/amazon/kc1/kc1.c23
1 files changed, 10 insertions, 13 deletions
diff --git a/board/amazon/kc1/kc1.c b/board/amazon/kc1/kc1.c
index ca63af8be47..469a83eeef3 100644
--- a/board/amazon/kc1/kc1.c
+++ b/board/amazon/kc1/kc1.c
@@ -88,10 +88,11 @@ int misc_init_r(void)
char reboot_mode[2] = { 0 };
u32 data = 0;
u32 value;
+ int rc;
/* Reboot mode */
- omap_reboot_mode(reboot_mode, sizeof(reboot_mode));
+ rc = omap_reboot_mode(reboot_mode, sizeof(reboot_mode));
/* USB ID pin pull-up indicates factory (fastboot) cable detection. */
gpio_request(KC1_GPIO_USB_ID, "USB_ID");
@@ -101,18 +102,7 @@ int misc_init_r(void)
if (value)
reboot_mode[0] = 'b';
- if (reboot_mode[0] > 0 && isascii(reboot_mode[0])) {
- if (reboot_mode[0] == 'o')
- twl6030_power_off();
-
- if (!getenv("reboot-mode"))
- setenv("reboot-mode", (char *)reboot_mode);
-
- omap_reboot_mode_clear();
- } else {
- /* Reboot mode garbage may still be valid, so clear it. */
- omap_reboot_mode_clear();
-
+ if (rc < 0 || reboot_mode[0] == 'o') {
/*
* When not rebooting, valid power on reasons are either the
* power button, charger plug or USB plug.
@@ -126,6 +116,13 @@ int misc_init_r(void)
twl6030_power_off();
}
+ if (reboot_mode[0] > 0 && isascii(reboot_mode[0])) {
+ if (!getenv("reboot-mode"))
+ setenv("reboot-mode", (char *)reboot_mode);
+ }
+
+ omap_reboot_mode_clear();
+
/* Serial number */
omap_die_id_serial();