From: Oleksij Rempel <o.rempel@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Oleksij Rempel <o.rempel@pengutronix.de>
Subject: [PATCH v1 2/4] usb: dwc2: Port FIFO configuration sync from Linux v6.3
Date: Wed, 3 May 2023 12:19:17 +0200 [thread overview]
Message-ID: <20230503101919.1826193-3-o.rempel@pengutronix.de> (raw)
In-Reply-To: <20230503101919.1826193-1-o.rempel@pengutronix.de>
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>
---
drivers/usb/dwc2/gadget.c | 29 +++++++++++++----------------
1 file 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 |
--
2.39.2
next prev parent reply other threads:[~2023-05-03 10:20 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-03 10:19 [PATCH v1 0/4] Improve USB FIFO handling and enable UMS mode on PRTT1L boards Oleksij Rempel
2023-05-03 10:19 ` [PATCH v1 1/4] usb: dwc2: Port support for USB FIFO devicetree properties from Linux v6.3 Oleksij Rempel
2023-05-03 10:19 ` Oleksij Rempel [this message]
2023-05-03 10:19 ` [PATCH v1 3/4] usb: dwc2: fix multiplier handling in endpoint setup Oleksij Rempel
2023-05-03 10:19 ` [PATCH v1 4/4] arm: dts: stm32mp151-prtt1l: Configure USB gadget FIFOs for multiple gadgets support Oleksij Rempel
2023-05-03 10:25 ` Ahmad Fatoum
2023-05-03 11:01 ` Oleksij Rempel
2023-05-05 6:39 ` [PATCH v1 0/4] Improve USB FIFO handling and enable UMS mode on PRTT1L boards Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230503101919.1826193-3-o.rempel@pengutronix.de \
--to=o.rempel@pengutronix.de \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox