diff options
-rw-r--r-- | board/glados/board.h | 1 | ||||
-rw-r--r-- | board/glados_pd/board.c | 14 | ||||
-rw-r--r-- | board/oak/board.h | 1 | ||||
-rw-r--r-- | board/oak_pd/board.c | 29 | ||||
-rw-r--r-- | board/samus_pd/board.c | 10 |
5 files changed, 34 insertions, 21 deletions
diff --git a/board/glados/board.h b/board/glados/board.h index b4feaca8b5..afb5772043 100644 --- a/board/glados/board.h +++ b/board/glados/board.h @@ -38,6 +38,7 @@ #define CONFIG_CLOCK_CRYSTAL #define CONFIG_EXTPOWER_GPIO #define CONFIG_HOSTCMD_PD +#define CONFIG_HOSTCMD_PD_PANIC #define CONFIG_I2C #define CONFIG_KEYBOARD_PROTOCOL_8042 #define CONFIG_LED_COMMON diff --git a/board/glados_pd/board.c b/board/glados_pd/board.c index d1f4568842..791d29a097 100644 --- a/board/glados_pd/board.c +++ b/board/glados_pd/board.c @@ -21,13 +21,15 @@ #define CPRINTS(format, args...) cprints(CC_USBCHARGE, format, ## args) +/* 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 of 3 sources are active, then drive the line low */ + /* If any sources are active, then drive the line low */ gpio_set_level(GPIO_EC_INT, !ec_int_status); - } void vbus0_evt(enum gpio_signal signal) @@ -61,6 +63,12 @@ static void board_init(void) /* Enable interrupts on VBUS transitions. */ 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; } DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT); @@ -136,7 +144,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. */ diff --git a/board/oak/board.h b/board/oak/board.h index e578b8a5ee..a09dbf43bf 100644 --- a/board/oak/board.h +++ b/board/oak/board.h @@ -49,6 +49,7 @@ #define CONFIG_HIBERNATE_WAKEUP_PINS (STM32_PWR_CSR_EWUP1|STM32_PWR_CSR_EWUP6) #define CONFIG_HOST_COMMAND_STATUS #define CONFIG_HOSTCMD_PD +#define CONFIG_HOSTCMD_PD_PANIC #define CONFIG_I2C #define CONFIG_KEYBOARD_COL2_INVERTED #define CONFIG_KEYBOARD_PROTOCOL_MKBP 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. */ diff --git a/board/samus_pd/board.c b/board/samus_pd/board.c index 8b86994b72..ff85debd22 100644 --- a/board/samus_pd/board.c +++ b/board/samus_pd/board.c @@ -51,13 +51,9 @@ static int batt_soc; /* Default to 5V charging allowed for dead battery case */ static enum pd_charge_state charge_state = PD_CHARGE_5V; -/* - * PD MCU status and host event status for host command - * Note: these vars must be aligned on 4-byte boundary because we pass the - * address to atomic_ functions which use assembly to access them. - */ -static int32_t host_event_status_flags __aligned(4); -static int32_t pd_status_flags __aligned(4); +/* PD MCU status and host event status for host command */ +static int32_t host_event_status_flags; +static int32_t pd_status_flags; static struct ec_response_pd_status pd_status; |