summaryrefslogtreecommitdiff
path: root/board/oak_pd
diff options
context:
space:
mode:
authorAlec Berg <alecaberg@chromium.org>2015-10-23 16:37:45 -0700
committerchrome-bot <chrome-bot@chromium.org>2015-10-23 22:49:29 -0700
commit9acd84460e953dd793c9594b141ca7e38568820d (patch)
tree5e12ae87e6f7c94fb49d74381adccabcdfb8b2e6 /board/oak_pd
parent71e12124e5e5e54e921a6940ed93599a90b3035a (diff)
downloadchrome-ec-9acd84460e953dd793c9594b141ca7e38568820d.tar.gz
glados: oak: reboot EC if PD MCU crashes
If PD MCU crashes, it will go back to RO code and stay there until the next AP boot. So, if EC detects PD has crashed, then EC should panic reboot with debug message that it detected a PD crash. PD MCU crash is detected by EC by seeing the PD MCU transition from RW to RO, without it setting the flag that it got there from a sysjump. This CL also makes minor changes to oak_pd and glados_pd board.c files to make them identical, other than the few minor real differences between them. BUG=none BRANCH=none TEST=tested on glados using pdcmd console command on EC to test sysjumps and reboots: sysjump to RW: pdcmd 0xd2 0 2 0 sysjump to RO: pdcmd 0xd2 0 1 0 cold reboot: pdcmd 0xd2 0 4 0 Verified that PD can jump back and forth between RO and RW without EC panicing. Verified that if PD MCU is in RW and reboots, then the EC will panic and print 'PD crash'. Verify if PD MCU reboots while in RO, without ever going to RW first, then EC does not panic. Change-Id: Id3191f4005e70a6c61a9322bf535b4374e85eb9a Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/308586 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'board/oak_pd')
-rw-r--r--board/oak_pd/board.c29
1 files changed, 18 insertions, 11 deletions
diff --git a/board/oak_pd/board.c b/board/oak_pd/board.c
index 0bac0dcdc7..16c3ba604c 100644
--- a/board/oak_pd/board.c
+++ b/board/oak_pd/board.c
@@ -21,14 +21,15 @@
#define CPRINTS(format, args...) cprints(CC_USBCHARGE, format, ## args)
-/* Variable used to indicate which source is driving the ec_int line */
+/* Indicate which source is driving the ec_int line. */
static uint32_t ec_int_status;
+static uint32_t pd_status_flags;
+
void pd_send_ec_int(void)
{
/* If any sources are active, then drive the line low */
gpio_set_level(GPIO_EC_INT, !ec_int_status);
-
}
void board_config_pre_init(void)
@@ -53,6 +54,12 @@ static void board_init(void)
gpio_enable_interrupt(GPIO_USB_C0_VBUS_WAKE_L);
gpio_enable_interrupt(GPIO_USB_C1_VBUS_WAKE_L);
+ /* Set PD MCU system status bits */
+ if (system_jumped_to_this_image())
+ pd_status_flags |= PD_STATUS_JUMPED_TO_IMAGE;
+ if (system_get_image_copy() == SYSTEM_IMAGE_RW)
+ pd_status_flags |= PD_STATUS_IN_RW;
+
/* OAK_PD: TODO: Power management of ARM based system */
}
DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT);
@@ -97,6 +104,14 @@ void tcpc_alert_clear(int port)
pd_send_ec_int();
}
+static void system_hibernate_deferred(void)
+{
+ ccprintf("EC requested hibernate\n");
+ cflush();
+ system_hibernate(0, 0);
+}
+DECLARE_DEFERRED(system_hibernate_deferred);
+
/****************************************************************************/
/* Console commands */
static int command_ec_int(int argc, char **argv)
@@ -112,14 +127,6 @@ DECLARE_CONSOLE_COMMAND(ecint, command_ec_int,
"Toggle EC interrupt line",
NULL);
-static void system_hibernate_deferred(void)
-{
- ccprintf("EC requested hibernate\n");
- cflush();
- system_hibernate(0, 0);
-}
-DECLARE_DEFERRED(system_hibernate_deferred);
-
static int ec_status_host_cmd(struct host_cmd_handler_args *args)
{
const struct ec_params_pd_status *p = args->params;
@@ -129,7 +136,7 @@ static int ec_status_host_cmd(struct host_cmd_handler_args *args)
* ec_int_status is used to store state for HOST_EVENT,
* TCPC 0 Alert, and TCPC 1 Alert bits.
*/
- r->status = ec_int_status;
+ r->status = ec_int_status | pd_status_flags;
args->response_size = sizeof(*r);
/* Have the PD follow the EC into hibernate. */