summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlec Berg <alecaberg@chromium.org>2015-08-28 17:43:20 -0700
committerchrome-bot <chrome-bot@chromium.org>2015-09-01 16:10:43 -0700
commitf44f02e865a9cc81b6ba53cd527458d40fdaa87d (patch)
tree8a78c7063e541362170b621dfd339cc2dd13b605
parentaf79591ed20a9728b872ca4761fa5675f74f7225 (diff)
downloadchrome-ec-f44f02e865a9cc81b6ba53cd527458d40fdaa87d.tar.gz
pd: send soft reset before an EC reset
Send soft reset to all connected USB PD ports before a user initiated reset (via console or host command). This fixes a problem where EC will send PD hard reset to a charger after an EC reboot, which will cause another reboot if battery is not present. BUG=chrome-os-partner:44085 BRANCH=none TEST=tested on glados without a battery. with zinger attached, issue 'reboot' from console and verify that we only reboot once. Change-Id: Id6c56cda33c289e3425cb433f7fcbe76669d2dff Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/295889 Reviewed-by: Shawn N <shawnn@chromium.org>
-rw-r--r--common/system.c19
-rw-r--r--common/usb_pd_protocol.c7
-rw-r--r--include/usb_pd.h4
3 files changed, 20 insertions, 10 deletions
diff --git a/common/system.c b/common/system.c
index 856f3d981f..42eb91bf71 100644
--- a/common/system.c
+++ b/common/system.c
@@ -440,12 +440,8 @@ static void jump_to_image(uintptr_t init_addr)
gpio_set_level(GPIO_ENTERING_RW, 0);
#ifdef CONFIG_USB_POWER_DELIVERY
- /*
- * Notify USB PD module that we are about to sysjump and give it time
- * to do what it needs.
- */
- pd_prepare_sysjump();
- usleep(5*MSEC);
+ /* Notify USB PD module that we are about to reset */
+ pd_prepare_reset();
#endif
#ifdef CONFIG_I2C
@@ -725,10 +721,15 @@ static int handle_pending_reboot(enum ec_reboot_cmd cmd)
case EC_REBOOT_JUMP_RW:
return system_run_image_copy(SYSTEM_IMAGE_RW);
case EC_REBOOT_COLD:
+#ifdef CONFIG_USB_POWER_DELIVERY
+ /* Notify USB PD module that we are about to reset */
+ pd_prepare_reset();
+#endif
#ifdef HAS_TASK_PDCMD
/* Reboot the PD chip as well */
board_reset_pd_mcu();
#endif
+
system_reset(SYSTEM_RESET_HARD);
/* That shouldn't return... */
return EC_ERROR_UNKNOWN;
@@ -918,6 +919,12 @@ static int command_reboot(int argc, char **argv)
ccputs("Hard-");
ccputs("Rebooting!\n\n\n");
cflush();
+
+#ifdef CONFIG_USB_POWER_DELIVERY
+ /* Notify USB PD module that we are about to reset */
+ pd_prepare_reset();
+#endif
+
system_reset(flags);
return EC_SUCCESS;
}
diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c
index b6507baa5c..07ce8189dc 100644
--- a/common/usb_pd_protocol.c
+++ b/common/usb_pd_protocol.c
@@ -558,12 +558,12 @@ void pd_soft_reset(void)
}
}
-void pd_prepare_sysjump(void)
+void pd_prepare_reset(void)
{
int i;
/*
- * On sysjump, we are most definitely going to drop pings (if any)
+ * On reset, we are most definitely going to drop pings (if any)
* and lose all of our PD state. Instead of trying to remember all
* the states and deal with on-going transmission, let's send soft
* reset here and then disable PD communication until after sysjump
@@ -575,6 +575,9 @@ void pd_prepare_sysjump(void)
pd[i].flags |= PD_FLAGS_SFT_RST_DIS_COMM;
pd_soft_reset();
+
+ /* Give time for soft reset to be sent */
+ usleep(5*MSEC);
}
#ifdef CONFIG_USB_PD_DUAL_ROLE
diff --git a/include/usb_pd.h b/include/usb_pd.h
index 6ca88bb55a..5a67965853 100644
--- a/include/usb_pd.h
+++ b/include/usb_pd.h
@@ -1502,8 +1502,8 @@ void pd_ping_enable(int port, int enable);
/* Issue PD soft reset */
void pd_soft_reset(void);
-/* Prepare PD communication for sysjump */
-void pd_prepare_sysjump(void);
+/* Prepare PD communication for reset */
+void pd_prepare_reset(void);
/**
* Signal power request to indicate a charger update that affects the port.