mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-27 18:25:05 +00:00
gaia: Add a warm reboot function
Added a warm reboot function that reboots the AP while preserving RAM contents. This will be helpful in debugging AP/OS hard hangs since in conjunction with PSTORE_CONSOLE in the kernel, the kernel log messages from the previous boot will be preserved. BUG=chrome-os-partner:13249 TEST=1. From EC console issue the "warm_reboot" command. Upon rebooting "cat /dev/pstore/console-ramoops" and ensure that the contents are dmesg of previous boot. 2. Reboot the system using alt-volume_up-r key combination. Upon rebooting, check pstore contents in the same manner as case#1 above. BRANCH=snow Change-Id: Ic8f0415da6182f4c1bc2d35b91302ceda5c19569 Signed-off-by: Sameer Nanda <snanda@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/31523 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
This commit is contained in:
@@ -64,6 +64,16 @@ static const uint8_t actual_key_masks[4][KB_OUTPUTS] = {
|
||||
#define MASK_INDEX_REFRESH 2
|
||||
#define MASK_VALUE_REFRESH 0x04
|
||||
|
||||
/* Key masks and values for warm reboot combination */
|
||||
#define MASK_INDEX_KEYR 3
|
||||
#define MASK_VALUE_KEYR 0x80
|
||||
#define MASK_INDEX_VOL_UP 4
|
||||
#define MASK_VALUE_VOL_UP 0x01
|
||||
#define MASK_INDEX_RIGHT_ALT 10
|
||||
#define MASK_VALUE_RIGHT_ALT 0x01
|
||||
#define MASK_INDEX_LEFT_ALT 10
|
||||
#define MASK_VALUE_LEFT_ALT 0x40
|
||||
|
||||
struct kbc_gpio {
|
||||
int num; /* logical row or column number */
|
||||
uint32_t port;
|
||||
@@ -217,6 +227,16 @@ void enter_polling_mode(void)
|
||||
select_column(COL_TRI_STATE_ALL);
|
||||
}
|
||||
|
||||
static int check_warm_reboot_keys(void)
|
||||
{
|
||||
if (raw_state[MASK_INDEX_KEYR] == MASK_VALUE_KEYR &&
|
||||
raw_state[MASK_INDEX_VOL_UP] == MASK_VALUE_VOL_UP &&
|
||||
(raw_state[MASK_INDEX_RIGHT_ALT] == MASK_VALUE_RIGHT_ALT ||
|
||||
raw_state[MASK_INDEX_LEFT_ALT] == MASK_VALUE_LEFT_ALT))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Returns 1 if any key is still pressed. 0 if no key is pressed. */
|
||||
static int check_keys_changed(void)
|
||||
@@ -295,6 +315,11 @@ static int check_keys_changed(void)
|
||||
}
|
||||
CPUTS("]\n");
|
||||
|
||||
if (num_press == 3) {
|
||||
if (check_warm_reboot_keys())
|
||||
system_warm_reboot();
|
||||
}
|
||||
|
||||
if (kb_fifo_add(raw_state) == EC_SUCCESS)
|
||||
board_interrupt_host(1);
|
||||
else
|
||||
|
||||
@@ -588,3 +588,30 @@ DECLARE_CONSOLE_COMMAND(power, command_power,
|
||||
"on/off",
|
||||
"Turn AP power on/off",
|
||||
NULL);
|
||||
|
||||
void system_warm_reboot(void)
|
||||
{
|
||||
CPRINTF("[%T EC triggered warm reboot ]\n");
|
||||
|
||||
/* This is a hack to do an AP warm reboot while still preserving
|
||||
* RAM contents. This is useful for looking at kernel log message
|
||||
* contents from previous boot in cases where the AP/OS is hard
|
||||
* hung. */
|
||||
gpio_set_level(GPIO_EN_PP5000, 0);
|
||||
gpio_set_level(GPIO_EN_PP3300, 0);
|
||||
|
||||
power_request = POWER_REQ_ON;
|
||||
task_wake(TASK_ID_GAIAPOWER);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static int command_warm_reboot(int argc, char **argv)
|
||||
{
|
||||
system_warm_reboot();
|
||||
return EC_SUCCESS;
|
||||
}
|
||||
DECLARE_CONSOLE_COMMAND(warm_reboot, command_warm_reboot,
|
||||
NULL,
|
||||
"EC triggered warm reboot",
|
||||
NULL);
|
||||
|
||||
@@ -156,6 +156,9 @@ const char *system_get_build_info(void);
|
||||
|
||||
void system_reset(int flags);
|
||||
|
||||
/* System warm reboot while keeping the RAM alive. */
|
||||
void system_warm_reboot(void);
|
||||
|
||||
/* Set a scratchpad register to the specified value. The scratchpad
|
||||
* register must maintain its contents across a software-requested
|
||||
* warm reset. */
|
||||
|
||||
Reference in New Issue
Block a user