[PATCH 4/4] usb: dwc2: gadget: Separate non-periodic and periodic FIFO inits

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Separate dwc2_hsotg_init_fifo function into 2 different functions,
for periodic and non-periodic FIFOs. Initialization of non-periodic
FIFOs must be done after soft or USB resets, while initialization
of periodic FIFOs must be done only after soft reset.

Signed-off-by: Sevak Arakelyan <sevaka@xxxxxxxxxxxx>
---
 drivers/usb/dwc2/gadget.c | 46 ++++++++++++++++++++++++----------------------
 1 file changed, 24 insertions(+), 22 deletions(-)

diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index 574562a0286d..0bf42a0a3213 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -285,10 +285,9 @@ int dwc2_hsotg_tx_fifo_average_depth(struct dwc2_hsotg *hsotg)
 }
 
 /**
- * dwc2_hsotg_init_fifo - initialise non-periodic FIFOs
- * @hsotg: The device instance.
+ * dwc2_hsotg_init_periodic_fifos - initialize periodic FIFOs
  */
-static void dwc2_hsotg_init_fifo(struct dwc2_hsotg *hsotg)
+static void dwc2_hsotg_init_periodic_fifos(struct dwc2_hsotg *hsotg)
 {
 	unsigned int ep;
 	unsigned int addr;
@@ -303,27 +302,12 @@ static void dwc2_hsotg_init_fifo(struct dwc2_hsotg *hsotg)
 	WARN_ON(hsotg->fifo_map);
 	hsotg->fifo_map = 0;
 
-	/* set RX/NPTX FIFO sizes */
-	dwc2_writel(hsotg->params.g_rx_fifo_size, hsotg->regs + GRXFSIZ);
-	dwc2_writel((hsotg->params.g_rx_fifo_size << FIFOSIZE_STARTADDR_SHIFT) |
-		    (hsotg->params.g_np_tx_fifo_size << FIFOSIZE_DEPTH_SHIFT),
-		    hsotg->regs + GNPTXFSIZ);
-
 	/*
-	 * arange all the rest of the TX FIFOs, as some versions of this
-	 * block have overlapping default addresses. This also ensures
-	 * that if the settings have been changed, then they are set to
-	 * known values.
+	 * Arange periodic TX FIFOs to correctly calculated values.
+	 * Start at the end of the GNPTXFSIZ.
 	 */
-
-	/* start at the end of the GNPTXFSIZ, rounded up */
 	addr = hsotg->params.g_rx_fifo_size + hsotg->params.g_np_tx_fifo_size;
 
-	/*
-	 * Configure fifos sizes from provided configuration and assign
-	 * them to endpoints dynamically according to maxpacket size value of
-	 * given endpoint.
-	 */
 	fifo_count = dwc2_hsotg_tx_fifo_count(hsotg);
 
 	for (ep = 1; ep <= fifo_count; ep++) {
@@ -340,6 +324,21 @@ static void dwc2_hsotg_init_fifo(struct dwc2_hsotg *hsotg)
 	dwc2_writel(hsotg->hw_params.total_fifo_size |
 		    addr << GDFIFOCFG_EPINFOBASE_SHIFT,
 		    hsotg->regs + GDFIFOCFG);
+}
+
+/**
+ * dwc2_hsotg_init_non_periodic_fifos - initialize non-periodic FIFOs
+ */
+static void dwc2_hsotg_init_non_periodic_fifos(struct dwc2_hsotg *hsotg)
+{
+	if (!hsotg->params.enable_dynamic_fifo)
+		return;
+
+	/* set RX/NPTX FIFO sizes */
+	dwc2_writel(hsotg->params.g_rx_fifo_size, hsotg->regs + GRXFSIZ);
+	dwc2_writel((hsotg->params.g_rx_fifo_size << FIFOSIZE_STARTADDR_SHIFT) |
+		    (hsotg->params.g_np_tx_fifo_size << FIFOSIZE_DEPTH_SHIFT),
+		    hsotg->regs + GNPTXFSIZ);
 
 	/*
 	 * Chapter 2.1.1 of the Programming Guide - The TxFIFOs and the RxFIFO
@@ -3269,10 +3268,13 @@ void dwc2_hsotg_core_init_disconnected(struct dwc2_hsotg *hsotg,
 	}
 	dwc2_writel(usbcfg, hsotg->regs + GUSBCFG);
 
-	dwc2_hsotg_init_fifo(hsotg);
+	dwc2_hsotg_init_non_periodic_fifos(hsotg);
+
+	if (!is_usb_reset) {
+		dwc2_hsotg_init_periodic_fifos(hsotg);
 
-	if (!is_usb_reset)
 		__orr32(hsotg->regs + DCTL, DCTL_SFTDISCON);
+	}
 
 	dcfg |= DCFG_EPMISCNT(1);
 
-- 
2.11.0

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux