mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-28 02:35:28 +00:00
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>
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user