summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/mock/usb_pd_mock.c5
-rw-r--r--common/system.c20
-rw-r--r--common/usb_common.c2
-rw-r--r--common/usbc/usb_tc_ctvpd_sm.c10
-rw-r--r--common/usbc/usb_tc_vpd_sm.c10
5 files changed, 40 insertions, 7 deletions
diff --git a/common/mock/usb_pd_mock.c b/common/mock/usb_pd_mock.c
index 2223e9153d..afcf19b483 100644
--- a/common/mock/usb_pd_mock.c
+++ b/common/mock/usb_pd_mock.c
@@ -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)
+{
+}
+
diff --git a/common/system.c b/common/system.c
index 6a26161f67..333ca2d26e 100644
--- a/common/system.c
+++ b/common/system.c
@@ -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);
diff --git a/common/usb_common.c b/common/usb_common.c
index b1920e3351..c592deaafa 100644
--- a/common/usb_common.c
+++ b/common/usb_common.c
@@ -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;
}
diff --git a/common/usbc/usb_tc_ctvpd_sm.c b/common/usbc/usb_tc_ctvpd_sm.c
index 4cb2599431..f6aab7dec3 100644
--- a/common/usbc/usb_tc_ctvpd_sm.c
+++ b/common/usbc/usb_tc_ctvpd_sm.c
@@ -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
*
diff --git a/common/usbc/usb_tc_vpd_sm.c b/common/usbc/usb_tc_vpd_sm.c
index 1b5f308098..7d25001813 100644
--- a/common/usbc/usb_tc_vpd_sm.c
+++ b/common/usbc/usb_tc_vpd_sm.c
@@ -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)) {