mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2026-01-10 17:41:54 +00:00
cr50: release the AP usb if the AP is shutdown
When cr50 connects to the AP usb it should only initialize the usb when it knows that the AP is on. If usb is incorrectly initialized it can prevent cr50 from going to sleep. In this change the AP usb will be initialized when suzyq is disconnected or on HOOK_CHIPSET_RESUME and it will be released on HOOK_CHIPSET_SHUTDOWN. BUG=chrome-os-partner:55747 BRANCH=none TEST=manual On reef run apreset and verify the AP can communicate with cr50 over usb after it boots up. Run poweroff and verify cr50 has released the usb. power the AP back on and check that it can communicate with cr50 again Change-Id: Id35010525e2354ee140d3b7220fb5ea434a0993f Signed-off-by: Mary Ruthven <mruthven@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/383979 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
#include "console.h"
|
||||
#include "device_state.h"
|
||||
#include "gpio.h"
|
||||
#include "hooks.h"
|
||||
#include "rdd.h"
|
||||
#include "registers.h"
|
||||
#include "system.h"
|
||||
@@ -16,6 +17,7 @@
|
||||
#define CPRINTS(format, args...) cprints(CC_USB, format, ## args)
|
||||
|
||||
static int ec_uart_enabled, enable_usb_wakeup;
|
||||
static int usb_is_initialized;
|
||||
|
||||
struct uart_config {
|
||||
const char *name;
|
||||
@@ -144,15 +146,46 @@ void ccd_phy_init(int enable_ccd)
|
||||
*/
|
||||
usb_select_phy(which_phy);
|
||||
|
||||
/*
|
||||
* If the usb is going to be initialized on the AP PHY, but the AP is
|
||||
* off, wait until HOOK_CHIPSET_RESUME to initialize usb.
|
||||
*/
|
||||
if (!enable_ccd && device_get_state(DEVICE_AP) != DEVICE_STATE_ON) {
|
||||
usb_is_initialized = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* If the board has the non-ccd phy connected to the AP initialize the
|
||||
* phy no matter what. Otherwise only initialized the phy if ccd is
|
||||
* enabled.
|
||||
*/
|
||||
if ((properties & BOARD_USB_AP) || enable_ccd)
|
||||
if ((properties & BOARD_USB_AP) || enable_ccd) {
|
||||
usb_init();
|
||||
usb_is_initialized = 1;
|
||||
}
|
||||
}
|
||||
|
||||
void disable_ap_usb(void)
|
||||
{
|
||||
if ((system_get_board_properties() & BOARD_USB_AP) &&
|
||||
!ccd_is_enabled() && usb_is_initialized) {
|
||||
usb_release();
|
||||
usb_is_initialized = 0;
|
||||
}
|
||||
}
|
||||
DECLARE_HOOK(HOOK_CHIPSET_SHUTDOWN, disable_ap_usb, HOOK_PRIO_DEFAULT);
|
||||
|
||||
void enable_ap_usb(void)
|
||||
{
|
||||
if ((system_get_board_properties() & BOARD_USB_AP) &&
|
||||
!ccd_is_enabled() && !usb_is_initialized) {
|
||||
usb_is_initialized = 1;
|
||||
usb_init();
|
||||
}
|
||||
}
|
||||
DECLARE_HOOK(HOOK_CHIPSET_RESUME, enable_ap_usb, HOOK_PRIO_DEFAULT);
|
||||
|
||||
static int command_ccd(int argc, char **argv)
|
||||
{
|
||||
int val;
|
||||
|
||||
Reference in New Issue
Block a user