Skip to content

Commit 1464209

Browse files
kasjernashif
authored andcommitted
drivers: usb_device: smartbond: Fix EP OUT after resume
When device was resumed from sleep OUT endpoints were most likely not enabled due to condition that checked pending transfer. Configured OUT endpoints should be enabled (ready for RX) if they were enabled by interfaces. Now separate bit field enabled is added and check to see if OUT endpoint should be ready for reception after sleep is done. Signed-off-by: Jerzy Kasenberg <[email protected]>
1 parent a953bdf commit 1464209

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

drivers/usb/device/usb_dc_smartbond.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ struct smartbond_ep_state {
124124
uint8_t data1 : 1; /** DATA0/1 toggle bit 1 DATA1 is expected or transmitted */
125125
uint8_t stall : 1; /** Endpoint is stalled */
126126
uint8_t iso : 1; /** ISO endpoint */
127+
uint8_t enabled : 1; /** Endpoint is enabled */
127128
uint8_t ep_addr; /** EP address */
128129
struct smartbond_ep_reg_set *regs;
129130
};
@@ -768,7 +769,7 @@ static void handle_alt_ev(void)
768769
/* Re-enable reception of endpoint with pending transfer */
769770
for (int ep_num = 1; ep_num < EP_MAX; ++ep_num) {
770771
ep_state = usb_dc_get_ep_out_state(ep_num);
771-
if (ep_state->total_len > ep_state->transferred) {
772+
if (ep_state->enabled) {
772773
start_rx_packet(ep_state);
773774
}
774775
}
@@ -1037,6 +1038,7 @@ int usb_dc_ep_disable(const uint8_t ep)
10371038
return -EINVAL;
10381039
}
10391040

1041+
ep_state->enabled = 0;
10401042
if (ep_state->ep_addr == EP0_IN) {
10411043
REG_SET_BIT(USB_TXC0_REG, USB_IGN_IN);
10421044
} else if (ep_state->ep_addr == EP0_OUT) {
@@ -1288,6 +1290,7 @@ int usb_dc_ep_enable(const uint8_t ep)
12881290
REG_SET_BIT(USB_MAMSK_REG, USB_M_TX_EV);
12891291
ep_state->regs->epc_in |= USB_USB_EPC2_REG_USB_EP_EN_Msk;
12901292
}
1293+
ep_state->enabled = 1;
12911294

12921295
return 0;
12931296
}

0 commit comments

Comments
 (0)