usb: dwc2: Fix EP TxFIFO number setting
authorMinas Harutyunyan <minas.harutyunyan@synopsys.com>
Thu, 31 Jan 2019 14:28:07 +0000 (18:28 +0400)
committerFelipe Balbi <felipe.balbi@linux.intel.com>
Thu, 7 Feb 2019 11:14:51 +0000 (13:14 +0200)
In case when some EP IN is frequently reused, i.e. enabled/disabled by
function driver. It is required to clear TxFIFO number field in DIEPCTL
register before setting new number. Otherwise there is probability to
have same TxFIFO number for different EP's because of OR operator.

Signed-off-by: Minas Harutyunyan <hminas@synopsys.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
drivers/usb/dwc2/gadget.c

index 55ef3cc2701b999aa93d9bca90cc979bfb1cc08a..e15d8a462085d9e0b28b4b1fef20a3c8bc55a231 100644 (file)
@@ -4005,6 +4005,7 @@ static int dwc2_hsotg_ep_enable(struct usb_ep *ep,
                        ret = -ENOMEM;
                        goto error1;
                }
+               epctrl &= ~(DXEPCTL_TXFNUM_LIMIT << DXEPCTL_TXFNUM_SHIFT);
                hsotg->fifo_map |= 1 << fifo_index;
                epctrl |= DXEPCTL_TXFNUM(fifo_index);
                hs_ep->fifo_index = fifo_index;