mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Oleksij Rempel <o.rempel@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Oleksij Rempel <o.rempel@pengutronix.de>
Subject: [PATCH v1 1/4] usb: dwc2: Port support for USB FIFO devicetree properties from Linux v6.3
Date: Wed,  3 May 2023 12:19:16 +0200	[thread overview]
Message-ID: <20230503101919.1826193-2-o.rempel@pengutronix.de> (raw)
In-Reply-To: <20230503101919.1826193-1-o.rempel@pengutronix.de>

This patch ports the support for "g-rx-fifo-size", "g-np-tx-fifo-size",
and "g-tx-fifo-size" devicetree properties from Linux kernel v6.3. These
properties are required for proper FIFO configuration of different USB
endpoints in the gadget mode.

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
 drivers/usb/dwc2/core.c | 27 +++++++++++++++++++++++++++
 drivers/usb/dwc2/dwc2.c |  1 +
 drivers/usb/dwc2/dwc2.h |  1 +
 3 files changed, 29 insertions(+)

diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c
index 9edd56d483..b198ba6bf8 100644
--- a/drivers/usb/dwc2/core.c
+++ b/drivers/usb/dwc2/core.c
@@ -188,6 +188,33 @@ void dwc2_set_default_params(struct dwc2 *dwc2)
 	}
 }
 
+void dwc2_get_device_properties(struct dwc2 *dwc2)
+{
+	struct dwc2_core_params *p = &dwc2->params;
+	struct device_node *np = dwc2->dev->of_node;
+	int num;
+
+	if ((dwc2->dr_mode == USB_DR_MODE_PERIPHERAL) ||
+	    (dwc2->dr_mode == USB_DR_MODE_OTG)) {
+		of_property_read_u32(np, "g-rx-fifo-size",
+					 &p->g_rx_fifo_size);
+
+		of_property_read_u32(np, "g-np-tx-fifo-size",
+					 &p->g_np_tx_fifo_size);
+
+		num = of_property_count_elems_of_size(np, "g-tx-fifo-size", sizeof(u32));
+		if (num > 0) {
+			num = min(num, 15);
+			memset(p->g_tx_fifo_size, 0,
+			       sizeof(p->g_tx_fifo_size));
+			of_property_read_u32_array(np,
+						       "g-tx-fifo-size",
+						       &p->g_tx_fifo_size[1],
+						       num);
+		}
+	}
+}
+
 int dwc2_check_core_version(struct dwc2 *dwc2)
 {
 	struct dwc2_hw_params *hw = &dwc2->hw_params;
diff --git a/drivers/usb/dwc2/dwc2.c b/drivers/usb/dwc2/dwc2.c
index ff4842ce62..3564cdd1d1 100644
--- a/drivers/usb/dwc2/dwc2.c
+++ b/drivers/usb/dwc2/dwc2.c
@@ -148,6 +148,7 @@ static int dwc2_probe(struct device *dev)
 		goto error;
 
 	dwc2_set_default_params(dwc2);
+	dwc2_get_device_properties(dwc2);
 
 	set_params = of_device_get_match_data(dev);
 	if (set_params)
diff --git a/drivers/usb/dwc2/dwc2.h b/drivers/usb/dwc2/dwc2.h
index 15d4b69759..2e740a890e 100644
--- a/drivers/usb/dwc2/dwc2.h
+++ b/drivers/usb/dwc2/dwc2.h
@@ -9,6 +9,7 @@
 
 /* Core functions */
 void dwc2_set_default_params(struct dwc2 *dwc2);
+void dwc2_get_device_properties(struct dwc2 *dwc2);
 int dwc2_check_core_version(struct dwc2 *dwc2);
 void dwc2_get_hwparams(struct dwc2 *dwc2);
 
-- 
2.39.2




  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 ` Oleksij Rempel [this message]
2023-05-03 10:19 ` [PATCH v1 2/4] usb: dwc2: Port FIFO configuration sync from Linux v6.3 Oleksij Rempel
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-2-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