Skip to content

Commit 9238144

Browse files
tmon-nordicjukkar
authored andcommitted
[nrf fromtree] nrf_usbd_common: Do not trigger DMA in low power mode
DMA transfers do not execute when the USBD peripheral is in Low Power mode. Make sure that there is no DMA active transfer when entering Low Power mode and that new DMA transfers are not started when in Low Power mode because the transfer won't ever finish. Signed-off-by: Tomasz Moń <[email protected]> (cherry picked from commit cb1e7d6) (cherry picked from commit fecf399)
1 parent dc2aeea commit 9238144

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

drivers/usb/common/nrf_usbd_common/nrf_usbd_common.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -834,9 +834,10 @@ static void usbd_dmareq_process(void)
834834
{
835835
if ((m_ep_dma_waiting & m_ep_ready) &&
836836
(k_sem_take(&dma_available, K_NO_WAIT) == 0)) {
837+
const bool low_power = nrf_usbd_common_suspend_check();
837838
uint32_t req;
838839

839-
while (0 != (req = m_ep_dma_waiting & m_ep_ready)) {
840+
while (!low_power && 0 != (req = m_ep_dma_waiting & m_ep_ready)) {
840841
uint8_t pos;
841842

842843
if (NRFX_USBD_CONFIG_DMASCHEDULER_ISO_BOOST &&
@@ -1310,7 +1311,11 @@ bool nrf_usbd_common_is_started(void)
13101311
bool nrf_usbd_common_suspend(void)
13111312
{
13121313
bool suspended = false;
1313-
unsigned int irq_lock_key = irq_lock();
1314+
unsigned int irq_lock_key;
1315+
1316+
/* DMA doesn't work in Low Power mode, ensure there is no active DMA */
1317+
k_sem_take(&dma_available, K_FOREVER);
1318+
irq_lock_key = irq_lock();
13141319

13151320
if (m_bus_suspend) {
13161321
if (!(NRF_USBD->EVENTCAUSE & USBD_EVENTCAUSE_RESUME_Msk)) {
@@ -1327,6 +1332,7 @@ bool nrf_usbd_common_suspend(void)
13271332
}
13281333

13291334
irq_unlock(irq_lock_key);
1335+
k_sem_give(&dma_available);
13301336

13311337
return suspended;
13321338
}

0 commit comments

Comments
 (0)