All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
To: Felipe Balbi <balbi@kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Thinh Nguyen <Thinh.Nguyen@synopsys.com>,
	linux-usb@vger.kernel.org
Cc: John Youn <John.Youn@synopsys.com>
Subject: [RFC PATCH 10/14] usb: dwc3: Update HWPARAMS0.MDWIDTH for DWC_usb32
Date: Wed, 11 Dec 2019 18:50:01 -0800	[thread overview]
Message-ID: <26d33a2b42b350e6ac751d6179a8b5f9ce333c5b.1576118671.git.thinhn@synopsys.com> (raw)
In-Reply-To: <cover.1576118671.git.thinhn@synopsys.com>

DWC_usb32 supports MDWIDTH larger than 255 and up to 1023 (10 bit
value). The field HWPARAMS6[9:8] field is used to store the upper 2-bit
values of the MDWIDTH. This patch checks that param and properly get the
MDWIDTH for DWC_usb32.

Signed-off-by: Thinh Nguyen <thinhn@synopsys.com>
---
 drivers/usb/dwc3/core.h    |  1 +
 drivers/usb/dwc3/debugfs.c | 14 ++++++++++++--
 drivers/usb/dwc3/gadget.c  |  7 +++++++
 3 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
index 8e729d4cd5bd..bd446dca0869 100644
--- a/drivers/usb/dwc3/core.h
+++ b/drivers/usb/dwc3/core.h
@@ -363,6 +363,7 @@
 #define DWC3_GHWPARAMS6_HNPSUPPORT		BIT(11)
 #define DWC3_GHWPARAMS6_SRPSUPPORT		BIT(10)
 #define DWC3_GHWPARAMS6_EN_FPGA			BIT(7)
+#define DWC3_GHWPARAMS6_MDWIDTH(n)		((n) & (0x3 << 8)) /* DWC_usb32 only */
 
 /* Global HWPARAMS7 Register */
 #define DWC3_GHWPARAMS7_RAM1_DEPTH(n)	((n) & 0xffff)
diff --git a/drivers/usb/dwc3/debugfs.c b/drivers/usb/dwc3/debugfs.c
index 4fe8b1e1485c..7610f51e1f82 100644
--- a/drivers/usb/dwc3/debugfs.c
+++ b/drivers/usb/dwc3/debugfs.c
@@ -635,13 +635,18 @@ static int dwc3_tx_fifo_size_show(struct seq_file *s, void *unused)
 	struct dwc3_ep		*dep = s->private;
 	struct dwc3		*dwc = dep->dwc;
 	unsigned long		flags;
+	int			mdwidth;
 	u32			val;
 
 	spin_lock_irqsave(&dwc->lock, flags);
 	val = dwc3_core_fifo_space(dep, DWC3_TXFIFO);
 
 	/* Convert to bytes */
-	val *= DWC3_MDWIDTH(dwc->hwparams.hwparams0);
+	mdwidth = DWC3_MDWIDTH(dwc->hwparams.hwparams0);
+	if (dwc3_is_usb32(dwc))
+		mdwidth += DWC3_GHWPARAMS6_MDWIDTH(dwc->hwparams.hwparams6);
+
+	val *= mdwidth;
 	val >>= 3;
 	seq_printf(s, "%u\n", val);
 	spin_unlock_irqrestore(&dwc->lock, flags);
@@ -654,13 +659,18 @@ static int dwc3_rx_fifo_size_show(struct seq_file *s, void *unused)
 	struct dwc3_ep		*dep = s->private;
 	struct dwc3		*dwc = dep->dwc;
 	unsigned long		flags;
+	int			mdwidth;
 	u32			val;
 
 	spin_lock_irqsave(&dwc->lock, flags);
 	val = dwc3_core_fifo_space(dep, DWC3_RXFIFO);
 
 	/* Convert to bytes */
-	val *= DWC3_MDWIDTH(dwc->hwparams.hwparams0);
+	mdwidth = DWC3_MDWIDTH(dwc->hwparams.hwparams0);
+	if (dwc3_is_usb32(dwc))
+		mdwidth += DWC3_GHWPARAMS6_MDWIDTH(dwc->hwparams.hwparams6);
+
+	val *= mdwidth;
 	val >>= 3;
 	seq_printf(s, "%u\n", val);
 	spin_unlock_irqrestore(&dwc->lock, flags);
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index d56feea01066..569be19c84d3 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -1934,6 +1934,8 @@ static void dwc3_gadget_setup_nump(struct dwc3 *dwc)
 
 	ram2_depth = DWC3_GHWPARAMS7_RAM2_DEPTH(dwc->hwparams.hwparams7);
 	mdwidth = DWC3_GHWPARAMS0_MDWIDTH(dwc->hwparams.hwparams0);
+	if (dwc3_is_usb32(dwc))
+		mdwidth += DWC3_GHWPARAMS6_MDWIDTH(dwc->hwparams.hwparams6);
 
 	nump = ((ram2_depth * mdwidth / 8) - 24 - 16) / 1024;
 	nump = min_t(u32, nump, 16);
@@ -2271,6 +2273,9 @@ static int dwc3_gadget_init_in_endpoint(struct dwc3_ep *dep)
 	int size;
 
 	mdwidth = DWC3_MDWIDTH(dwc->hwparams.hwparams0);
+	if (dwc3_is_usb32(dwc))
+		mdwidth += DWC3_GHWPARAMS6_MDWIDTH(dwc->hwparams.hwparams6);
+
 	/* MDWIDTH is represented in bits, we need it in bytes */
 	mdwidth /= 8;
 
@@ -2315,6 +2320,8 @@ static int dwc3_gadget_init_out_endpoint(struct dwc3_ep *dep)
 	int size;
 
 	mdwidth = DWC3_MDWIDTH(dwc->hwparams.hwparams0);
+	if (dwc3_is_usb32(dwc))
+		mdwidth += DWC3_GHWPARAMS6_MDWIDTH(dwc->hwparams.hwparams6);
 
 	/* MDWIDTH is represented in bits, convert to bytes */
 	mdwidth /= 8;
-- 
2.11.0


  parent reply	other threads:[~2019-12-12  2:50 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-12  2:48 [RFC PATCH 00/14] usb: dwc3: Introduce DWC_usb32 Thinh Nguyen
2019-12-12  2:49 ` [RFC PATCH 01/14] usb: gadget: Add lane count and lsm Thinh Nguyen
2019-12-12  2:49 ` [RFC PATCH 02/14] usb: gadget: Add callback to set lane and transfer rate Thinh Nguyen
2019-12-12  7:58   ` Felipe Balbi
2019-12-12 15:49     ` Alan Stern
2019-12-12 22:33       ` Thinh Nguyen
2019-12-12 22:10     ` Thinh Nguyen
2019-12-12  2:49 ` [RFC PATCH 03/14] usb: composite: Properly report lsm Thinh Nguyen
2019-12-12  7:59   ` Felipe Balbi
2019-12-12 22:10     ` Thinh Nguyen
2019-12-12  2:49 ` [RFC PATCH 04/14] usb: dwc3: Implement new id check for DWC_usb32 Thinh Nguyen
2019-12-12  2:49 ` [RFC PATCH 05/14] usb: dwc3: Update IP checks to support DWC_usb32 Thinh Nguyen
2019-12-12  8:05   ` Felipe Balbi
2019-12-12 22:12     ` Thinh Nguyen
2019-12-12  2:49 ` [RFC PATCH 06/14] usb: devicetree: dwc3: Add max lane and lsm Thinh Nguyen
2019-12-12  8:06   ` Felipe Balbi
2019-12-19 22:09   ` Rob Herring
2019-12-19 22:49     ` Thinh Nguyen
2019-12-12  2:49 ` [RFC PATCH 07/14] usb: dwc3: gadget: Set lane count " Thinh Nguyen
2019-12-12  8:14   ` Felipe Balbi
2019-12-12 22:15     ` Thinh Nguyen
2019-12-12  2:49 ` [RFC PATCH 08/14] usb: dwc3: gadget: Track connected lane count and speed Thinh Nguyen
2019-12-12  2:49 ` [RFC PATCH 09/14] usb: dwc3: gadget: Limit the setting of speed Thinh Nguyen
2019-12-12  2:50 ` Thinh Nguyen [this message]
2019-12-12  2:50 ` [RFC PATCH 11/14] usb: devicetree: dwc3: Add TRB prefetch count Thinh Nguyen
2019-12-12  8:18   ` Felipe Balbi
2019-12-12 22:16     ` Thinh Nguyen
2019-12-12  2:50 ` [RFC PATCH 12/14] usb: dwc3: gadget: Set number of TRB prefetch Thinh Nguyen
2019-12-12  2:50 ` [RFC PATCH 13/14] usb: devicetree: dwc3: Add property to disable mult TRB fetch Thinh Nguyen
2019-12-12  8:19   ` Felipe Balbi
2019-12-12 22:28     ` Thinh Nguyen
2019-12-13  7:04       ` Felipe Balbi
2019-12-13 20:10         ` Thinh Nguyen
2019-12-19 22:17         ` Rob Herring
2019-12-19 22:51           ` Thinh Nguyen
2019-12-20 22:11             ` Rob Herring
2019-12-20 23:52               ` Thinh Nguyen
2019-12-12  2:50 ` [RFC PATCH 14/14] usb: dwc3: gadget: Implement disabling of " Thinh Nguyen

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=26d33a2b42b350e6ac751d6179a8b5f9ce333c5b.1576118671.git.thinhn@synopsys.com \
    --to=thinh.nguyen@synopsys.com \
    --cc=John.Youn@synopsys.com \
    --cc=balbi@kernel.org \
    --cc=gregkh@linuxfoundation.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.