Merge pull request #9879 from c1728p9/usb_sleep_lock

Lock sleep when USB is initialized
pull/9899/head
Cruz Monrreal 2019-02-28 19:56:41 -06:00 committed by GitHub
commit 3d1b55da36
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 34 additions and 2 deletions

View File

@ -106,7 +106,7 @@ USBPhy *get_usb_phy()
return &usbphy; return &usbphy;
} }
USBPhyHw::USBPhyHw() USBPhyHw::USBPhyHw(): events(NULL)
{ {
} }
@ -117,6 +117,9 @@ USBPhyHw::~USBPhyHw()
void USBPhyHw::init(USBPhyEvents *events) void USBPhyHw::init(USBPhyEvents *events)
{ {
if (this->events == NULL) {
sleep_manager_lock_deep_sleep();
}
this->events = events; this->events = events;
// Disable IRQ // Disable IRQ
@ -183,6 +186,11 @@ void USBPhyHw::deinit()
disconnect(); disconnect();
NVIC_DisableIRQ(USB0_IRQn); NVIC_DisableIRQ(USB0_IRQn);
USB0->INTEN = 0; USB0->INTEN = 0;
if (events != NULL) {
sleep_manager_unlock_deep_sleep();
}
events = NULL;
} }
bool USBPhyHw::powered() bool USBPhyHw::powered()

View File

@ -369,7 +369,7 @@ USBPhy *get_usb_phy()
return &usbphy; return &usbphy;
} }
USBPhyHw::USBPhyHw(void) USBPhyHw::USBPhyHw(void): events(NULL)
{ {
} }
@ -381,6 +381,9 @@ USBPhyHw::~USBPhyHw(void)
void USBPhyHw::init(USBPhyEvents *events) void USBPhyHw::init(USBPhyEvents *events)
{ {
if (this->events == NULL) {
sleep_manager_lock_deep_sleep();
}
this->events = events; this->events = events;
// Disable IRQ // Disable IRQ
@ -440,6 +443,11 @@ void USBPhyHw::deinit()
NVIC_DisableIRQ(USB_IRQn); NVIC_DisableIRQ(USB_IRQn);
events = NULL; events = NULL;
opStarted = 0; opStarted = 0;
if (events != NULL) {
sleep_manager_unlock_deep_sleep();
}
events = NULL;
} }
bool USBPhyHw::powered() bool USBPhyHw::powered()

View File

@ -128,6 +128,9 @@ void USBPhyHw::init(USBPhyEvents *events)
{ {
volatile uint8_t dummy_read; volatile uint8_t dummy_read;
if (this->events == NULL) {
sleep_manager_lock_deep_sleep();
}
this->events = events; this->events = events;
/* registers me */ /* registers me */
@ -174,6 +177,11 @@ void USBPhyHw::deinit()
#endif #endif
dummy_read = CPG.STBCR7; dummy_read = CPG.STBCR7;
(void)dummy_read; (void)dummy_read;
if (events != NULL) {
sleep_manager_unlock_deep_sleep();
}
events = NULL;
} }
bool USBPhyHw::powered() bool USBPhyHw::powered()

View File

@ -168,6 +168,9 @@ void USBPhyHw::init(USBPhyEvents *events)
{ {
NVIC_DisableIRQ(USBHAL_IRQn); NVIC_DisableIRQ(USBHAL_IRQn);
if (this->events == NULL) {
sleep_manager_lock_deep_sleep();
}
this->events = events; this->events = events;
sof_enabled = false; sof_enabled = false;
memset(epComplete, 0, sizeof(epComplete)); memset(epComplete, 0, sizeof(epComplete));
@ -333,6 +336,11 @@ void USBPhyHw::deinit()
{ {
HAL_PCD_DeInit(&hpcd); HAL_PCD_DeInit(&hpcd);
NVIC_DisableIRQ(USBHAL_IRQn); NVIC_DisableIRQ(USBHAL_IRQn);
if (events != NULL) {
sleep_manager_unlock_deep_sleep();
}
events = NULL;
} }
bool USBPhyHw::powered() bool USBPhyHw::powered()