From: Sevak Arakelyan <SEVAK.ARAKELYAN@synopsys.com>
To: John Youn <John.Youn@synopsys.com>,
Felipe Balbi <balbi@kernel.org>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
<linux-usb@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Cc: Sevak Arakelyan <SEVAK.ARAKELYAN@synopsys.com>
Subject: [PATCH 4/4] usb: dwc2: gadget: Separate non-periodic and periodic FIFO inits
Date: Wed, 26 Apr 2017 23:23:13 +0400 [thread overview]
Message-ID: <90a20e29194bda542a6d9c4fa2f5b0abeb3aa22e.1493234662.git.sevaka@synopsys.com> (raw)
In-Reply-To: <cover.1493234662.git.sevaka@synopsys.com>
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@synopsys.com>
---
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
prev parent reply other threads:[~2017-04-26 19:24 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-26 19:22 [PATCH 0/4] usb: dwc2: gadget: Fix dynamic FIFO initialization flow Sevak Arakelyan
2017-04-26 19:22 ` [PATCH 1/4] usb: dwc2: gadget: Fix in TX " Sevak Arakelyan
2017-04-26 19:22 ` [PATCH 2/4] usb: dwc2: gadget: Remove duplicated FIFO initialization Sevak Arakelyan
2017-04-26 19:23 ` [PATCH 3/4] usb: dwc2: gadget: Replace code with function calls Sevak Arakelyan
2017-04-26 19:23 ` Sevak Arakelyan [this message]
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=90a20e29194bda542a6d9c4fa2f5b0abeb3aa22e.1493234662.git.sevaka@synopsys.com \
--to=sevak.arakelyan@synopsys.com \
--cc=John.Youn@synopsys.com \
--cc=balbi@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.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
all inboxes | Powered by JetHome®