usbc: ensure we are suspending USB-C ports on shutdown
After CL:2208221, the check for the PD_CMD task no longer trigger, so we end up not calling suspend on our TCPC ports. We want to continue to suspend, which will apply CC open in TCPMv2 for a cooperative shutdown Also, correct override keyword usage for board_get_usb_pd_port_count since I had to touch those definitions to make IS_ENABLE work BRANCH=none BUG=b:160243292 TEST=See that software sync reboot, applies CC open (and browns out system) Change-Id: I00bf08c7d347441d77834e2c5122a09ca2316280 Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2276318 Reviewed-by: Diana Z <dzigterman@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org>
This commit is contained in:
parent
5330a08fb0
commit
bd4116995d
|
@ -164,7 +164,7 @@ void board_overcurrent_event(int port, int is_overcurrented)
|
|||
gpio_set_level(GPIO_USB_C_OC, !is_overcurrented);
|
||||
}
|
||||
|
||||
uint8_t board_get_usb_pd_port_count(void)
|
||||
__override uint8_t board_get_usb_pd_port_count(void)
|
||||
{
|
||||
if (sku_id == 2)
|
||||
return CONFIG_USB_PD_PORT_MAX_COUNT - 1;
|
||||
|
|
|
@ -296,7 +296,7 @@ void board_overcurrent_event(int port, int is_overcurrented)
|
|||
gpio_set_level(GPIO_USB_C_OC, !is_overcurrented);
|
||||
}
|
||||
|
||||
uint8_t board_get_usb_pd_port_count(void)
|
||||
__override uint8_t board_get_usb_pd_port_count(void)
|
||||
{
|
||||
/* HDMI SKU has one USB PD port */
|
||||
if (sku_id == 9 || sku_id == 19 || sku_id == 50)
|
||||
|
|
|
@ -49,6 +49,19 @@ void board_config_pre_init(void)
|
|||
|
||||
#include "gpio_list.h"
|
||||
|
||||
__override uint8_t board_get_usb_pd_port_count(void)
|
||||
{
|
||||
return CONFIG_USB_PD_PORT_MAX_COUNT;
|
||||
}
|
||||
|
||||
void pd_set_suspend(int port, int suspend)
|
||||
{
|
||||
/*
|
||||
* Do nothing. This is only here to make the linker happy for this
|
||||
* old board on ToT.
|
||||
*/
|
||||
}
|
||||
|
||||
/* Initialize board. */
|
||||
static void board_init(void)
|
||||
{
|
||||
|
|
|
@ -78,3 +78,8 @@ inline uint8_t board_get_usb_pd_port_count(void)
|
|||
{
|
||||
return CONFIG_USB_PD_PORT_MAX_COUNT;
|
||||
}
|
||||
|
||||
void pd_set_suspend(int port, int suspend)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -872,23 +872,31 @@ static int handle_pending_reboot(enum ec_reboot_cmd cmd)
|
|||
case EC_REBOOT_JUMP_RW:
|
||||
return system_run_image_copy(system_get_active_copy());
|
||||
case EC_REBOOT_COLD:
|
||||
#ifdef HAS_TASK_PDCMD
|
||||
/*
|
||||
* Reboot the PD chip(s) as well, but first suspend the ports
|
||||
* if this board has PD tasks running so they don't query the
|
||||
* TCPCs while they reset.
|
||||
*/
|
||||
#ifdef HAS_TASK_PD_C0
|
||||
{
|
||||
if (IS_ENABLED(HAS_TASK_PD_C0)) {
|
||||
int port;
|
||||
|
||||
for (port = 0; port < board_get_usb_pd_port_count();
|
||||
port++)
|
||||
pd_set_suspend(port, 1);
|
||||
|
||||
/*
|
||||
* Give enough time to apply CC Open and brown out if
|
||||
* we are running with out a battery.
|
||||
*/
|
||||
msleep(20 * MSEC);
|
||||
}
|
||||
#endif
|
||||
board_reset_pd_mcu();
|
||||
#endif
|
||||
|
||||
/* Reset external PD chips. */
|
||||
if (IS_ENABLED(HAS_TASK_PDCMD) ||
|
||||
IS_ENABLED(HAS_TASK_PD_INT_C0) ||
|
||||
IS_ENABLED(HAS_TASK_PD_INT_C1) ||
|
||||
IS_ENABLED(HAS_TASK_PD_INT_C2))
|
||||
board_reset_pd_mcu();
|
||||
|
||||
cflush();
|
||||
system_reset(SYSTEM_RESET_HARD);
|
||||
|
|
|
@ -297,7 +297,7 @@ int pd_check_requested_voltage(uint32_t rdo, const int port)
|
|||
return EC_SUCCESS;
|
||||
}
|
||||
|
||||
__attribute__((weak)) uint8_t board_get_usb_pd_port_count(void)
|
||||
__overridable uint8_t board_get_usb_pd_port_count(void)
|
||||
{
|
||||
return CONFIG_USB_PD_PORT_MAX_COUNT;
|
||||
}
|
||||
|
|
|
@ -286,6 +286,16 @@ static void tc_disabled_exit(const int port)
|
|||
CPRINTS("C%d: resumed!", port);
|
||||
}
|
||||
|
||||
void pd_set_suspend(int port, int suspend)
|
||||
{
|
||||
/*
|
||||
* This shouldn't happen. If it does, we need to send an event to the
|
||||
* PD task to put the SM into the disabled state. It is not safe to
|
||||
* directly set_state here since this may be in another task.
|
||||
*/
|
||||
assert(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* ErrorRecovery
|
||||
*
|
||||
|
|
|
@ -187,6 +187,16 @@ static void tc_disabled_run(const int port)
|
|||
task_wait_event(-1);
|
||||
}
|
||||
|
||||
void pd_set_suspend(int port, int suspend)
|
||||
{
|
||||
/*
|
||||
* This shouldn't happen. If it does, we need to send an event to the
|
||||
* PD task to put the SM into the disabled state. It is not safe to
|
||||
* directly set_state here since this may be in another task.
|
||||
*/
|
||||
assert(false);
|
||||
}
|
||||
|
||||
static void tc_disabled_exit(const int port)
|
||||
{
|
||||
if (!IS_ENABLED(CONFIG_USB_PD_TCPC)) {
|
||||
|
|
|
@ -5117,6 +5117,10 @@
|
|||
#undef CONFIG_HOSTCMD_PD
|
||||
#endif
|
||||
|
||||
#if defined(HAS_TASK_PDCMD) && defined(HAS_TASK_PD_C0_INT)
|
||||
#error Should not use PDCMD task with PD INT tasks
|
||||
#endif
|
||||
|
||||
/* Certain console cmds are irrelevant without parent modules. */
|
||||
#ifndef CONFIG_BATTERY
|
||||
#undef CONFIG_CMD_PWR_AVG
|
||||
|
|
|
@ -2667,22 +2667,22 @@ int pd_set_frs_enable(int port, int enable);
|
|||
*/
|
||||
__override_proto uint8_t get_dp_pin_mode(int port);
|
||||
|
||||
#ifdef CONFIG_USB_PD_PORT_MAX_COUNT
|
||||
#ifdef CONFIG_USB_POWER_DELIVERY
|
||||
/**
|
||||
* Get board specific usb pd port count
|
||||
*
|
||||
* @return <= CONFIG_USB_PD_PORT_MAX_COUNT if configured in board file,
|
||||
* else return CONFIG_USB_PD_PORT_MAX_COUNT
|
||||
*/
|
||||
uint8_t board_get_usb_pd_port_count(void);
|
||||
#else
|
||||
static inline uint8_t board_get_usb_pd_port_count(void)
|
||||
{
|
||||
return CONFIG_USB_PD_PORT_MAX_COUNT;
|
||||
}
|
||||
#endif /* CONFIG_USB_POWER_DELIVERY */
|
||||
#endif /* CONFIG_USB_PD_PORT_MAX_COUNT */
|
||||
__override_proto uint8_t board_get_usb_pd_port_count(void);
|
||||
|
||||
|
||||
/**
|
||||
* Resets external PD chips including TCPCs and MCUs.
|
||||
*
|
||||
* Boards must provide this when PDCMD (PD MCUs case) or PD INT (TCPC case)
|
||||
* tasks are present.
|
||||
*/
|
||||
void board_reset_pd_mcu(void);
|
||||
|
||||
/**
|
||||
* Return true if specified PD port is debug accessory.
|
||||
|
|
|
@ -45,6 +45,11 @@ void board_set_charge_limit(int port, int supplier, int charge_ma,
|
|||
active_charge_limit = charge_ma;
|
||||
}
|
||||
|
||||
__override uint8_t board_get_usb_pd_port_count(void)
|
||||
{
|
||||
return CONFIG_USB_PD_PORT_MAX_COUNT;
|
||||
}
|
||||
|
||||
/* Sets a charge port that will be rejected as the active port. */
|
||||
static void set_charge_port_to_reject(int port)
|
||||
{
|
||||
|
|
|
@ -37,6 +37,11 @@ static int charge_limit_ma;
|
|||
|
||||
/* Mock functions */
|
||||
|
||||
__override uint8_t board_get_usb_pd_port_count(void)
|
||||
{
|
||||
return CONFIG_USB_PD_PORT_MAX_COUNT;
|
||||
}
|
||||
|
||||
/* Override test_mockable implementations in charge_ramp module */
|
||||
int chg_ramp_allowed(int port, int supplier)
|
||||
{
|
||||
|
|
|
@ -25,6 +25,10 @@ const struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
|
|||
}
|
||||
};
|
||||
|
||||
void board_reset_pd_mcu(void)
|
||||
{
|
||||
}
|
||||
|
||||
static int deferred_resume_called;
|
||||
void pd_deferred_resume(int port)
|
||||
{
|
||||
|
|
|
@ -92,6 +92,10 @@ static uint32_t test_data[] = {
|
|||
0x11223344
|
||||
};
|
||||
|
||||
void pd_set_suspend(int port, int suspend)
|
||||
{
|
||||
}
|
||||
|
||||
static struct pd_prl {
|
||||
int rev;
|
||||
int pd_enable;
|
||||
|
|
Loading…
Reference in New Issue