summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorOleksij Rempel <o.rempel@pengutronix.de>2023-05-03 12:19:17 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2023-05-22 13:29:46 +0200
commitb176ffd3fc0e935f2fdbfff1ef14bf33bcefdb1f (patch)
treeb8975c70c6dd33d86aad398ce88486aff933e0f2 /drivers
parentf4d3e936bceb8310cf4d64f55f70fe77fd8aae77 (diff)
downloadbarebox-b176ffd3fc0e935f2fdbfff1ef14bf33bcefdb1f.tar.gz
barebox-b176ffd3fc0e935f2fdbfff1ef14bf33bcefdb1f.tar.xz
usb: dwc2: Port FIFO configuration sync from Linux v6.3
This patch ports the FIFO configuration from Linux kernel v6.3. The change mainly syncs the code with the kernel and removes an unused register read and value assignment in the first step of the loop (txfsz = dwc2_readl(dwc2, DPTXFSIZN(ep));). Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Link: https://lore.barebox.org/20230503101919.1826193-3-o.rempel@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/usb/dwc2/gadget.c29
1 files changed, 13 insertions, 16 deletions
diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index 028f3c877a..bb55888abf 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -1549,9 +1549,8 @@ static void dwc2_gadget_setup_fifo(struct dwc2 *dwc2)
u32 np_tx_fifo_size = dwc2->params.g_np_tx_fifo_size;
u32 rx_fifo_size = dwc2->params.g_rx_fifo_size;
u32 fifo_size = dwc2->hw_params.total_fifo_size;
- u32 *tx_fifo_size = dwc2->params.g_tx_fifo_size;
- u32 size, depth;
- u32 txfsz;
+ u32 *txfsz = dwc2->params.g_tx_fifo_size;
+ u32 size, val;
/* Reset fifo map if not correctly cleared during previous session */
WARN_ON(dwc2->fifo_map);
@@ -1578,19 +1577,17 @@ static void dwc2_gadget_setup_fifo(struct dwc2 *dwc2)
* them to endpoints dynamically according to maxpacket size value of
* given endpoint.
*/
-
- for (ep = 1; ep < dwc2->num_eps; ep++) {
- txfsz = dwc2_readl(dwc2, DPTXFSIZN(ep));
- depth = tx_fifo_size[ep];
-
- if (addr + depth > fifo_size)
- dwc2_err(dwc2, "insufficient fifo memory\n");
-
- txfsz = depth << FIFOSIZE_DEPTH_SHIFT;
- txfsz |= addr & 0xffff;
- dwc2_writel(dwc2, txfsz, DPTXFSIZN(ep));
-
- addr += depth;
+ for (ep = 1; ep < DWC2_MAX_EPS_CHANNELS; ep++) {
+ if (!txfsz[ep])
+ continue;
+ val = addr;
+ val |= txfsz[ep] << FIFOSIZE_DEPTH_SHIFT;
+ WARN_ONCE(addr + txfsz[ep] > fifo_size,
+ "insufficient fifo memory");
+ addr += txfsz[ep];
+
+ dwc2_writel(dwc2, val, DPTXFSIZN(ep));
+ val = dwc2_readl(dwc2, DPTXFSIZN(ep));
}
dwc2_writel(dwc2, dwc2->hw_params.total_fifo_size |