Skip to contentSkip to conversation

usb: dwc2: correctly handle binding for g-tx-fifo-size

PATCH New Patrick Delaunay 3 participants 9 messages Jun 18, 2019 – Jun 19, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/3 usb: dwc2: correctly handle binding for g-tx-fifo-size

Manage g-tx-fifo-size as a array as specify in the binding.

---

Changes in v2:
- move dt update in a separate patch
- remove unecessary temporary variable

 drivers/usb/gadget/dwc2_udc_otg.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
drivers/usb/gadget/dwc2_udc_otg.c +13 -1
index 494ab53..023439c 100644
@@ -1039,6 +1039,7 @@ static int dwc2_udc_otg_ofdata_to_platdata(struct udevice *dev)
 	int node = dev_of_offset(dev);
 	ulong drvdata;
 	void (*set_params)(struct dwc2_plat_otg_data *data);
+	int ret;
 
 	if (usb_get_dr_mode(node) != USB_DR_MODE_PERIPHERAL) {
 		dev_dbg(dev, "Invalid mode\n");
@@ -1050,7 +1051,18 @@ static int dwc2_udc_otg_ofdata_to_platdata(struct udevice *dev)
 	platdata->rx_fifo_sz = dev_read_u32_default(dev, "g-rx-fifo-size", 0);
 	platdata->np_tx_fifo_sz = dev_read_u32_default(dev,
 						       "g-np-tx-fifo-size", 0);
-	platdata->tx_fifo_sz = dev_read_u32_default(dev, "g-tx-fifo-size", 0);
+
+	platdata->tx_fifo_sz_nb =
+		dev_read_size(dev, "g-tx-fifo-size") / sizeof(u32);
+	if (platdata->tx_fifo_sz_nb > DWC2_MAX_HW_ENDPOINTS)
+		platdata->tx_fifo_sz_nb = DWC2_MAX_HW_ENDPOINTS;
+	if (platdata->tx_fifo_sz_nb) {
+		ret = dev_read_u32_array(dev, "g-tx-fifo-size",
+					 platdata->tx_fifo_sz_array,
+					 platdata->tx_fifo_sz_nb);
+		if (ret)
+			return ret;
+	}
 
 	platdata->force_b_session_valid =
 		dev_read_bool(dev, "u-boot,force-b-session-valid");
Signature · 1 line
2.7.4
#1 lore raw

PATCH v2 2/3 ARM: dts: stm32mp1: remove override for g-tx-fifo-size

Remove the override for usbotg_hs on g-tx-fifo-size as the correct binding, used in the kernel device tree, is now supported in dwc2 device driver.

---

Changes in v2:
- move dt update in a separate patch

 arch/arm/dts/stm32mp157c-ev1-u-boot.dtsi | 4 ----
 1 file changed, 4 deletions(-)
arch/arm/dts/stm32mp157c-ev1-u-boot.dtsi +0 -4
index 5b19e44..994092a 100644
@@ -56,10 +56,6 @@
 	};
 };
 
-&usbotg_hs {
-	g-tx-fifo-size = <576>;
-};
-
 &v3v3 {
 	regulator-always-on;
 };
Signature · 1 line
2.7.4
#2 lore raw

PATCH v2 2/3 ARM: dts: stm32mp1: remove override for g-tx-fifo-size

Hi Patrick

Quoted 18 lines · Patrick Delaunay

Remove the override for usbotg_hs on g-tx-fifo-size as the correct binding, used in the kernel device tree, is now supported in dwc2 device driver.

---

Changes in v2:
- move dt update in a separate patch

 arch/arm/dts/stm32mp157c-ev1-u-boot.dtsi | 4 ----
 1 file changed, 4 deletions(-)
arch/arm/dts/stm32mp157c-ev1-u-boot.dtsi +0 -0
index 5b19e44..994092a 100644

arch/arm/dts/stm32mp157c-ev1-u-boot.dtsi line 61

Quoted 10 lines
arch/arm/dts/stm32mp157c-ev1-u-boot.dtsi +0 -4
@@ -56,10 +56,6 @@
 	};
 };
 
-&usbotg_hs {
-	g-tx-fifo-size = <576>;
-};
-
 &v3v3 {
 	regulator-always-on;
 };

Applied to uboot-stm

Thanks

#3 lore raw

PATCH v2 3/3 usb: dwc2: allow peripheral mode for OTG configuration

In reply to Patrick Delaunay

Allow device mode in DWC2 driver when device tree select the dr_mode "peripheral" or "otg".

The device mode is not allowed when dr_mode = "host" in device tree.

---

Changes in v2: None

 drivers/usb/gadget/dwc2_udc_otg.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/usb/gadget/dwc2_udc_otg.c +2 -1
index 023439c..35f4147 100644
@@ -1041,7 +1041,8 @@ static int dwc2_udc_otg_ofdata_to_platdata(struct udevice *dev)
 	void (*set_params)(struct dwc2_plat_otg_data *data);
 	int ret;
 
-	if (usb_get_dr_mode(node) != USB_DR_MODE_PERIPHERAL) {
+	if (usb_get_dr_mode(node) != USB_DR_MODE_PERIPHERAL &&
+	    usb_get_dr_mode(node) != USB_DR_MODE_OTG) {
 		dev_dbg(dev, "Invalid mode\n");
 		return -ENODEV;
 	}
Signature · 1 line
2.7.4
#4 lore raw

PATCH v2 3/3 usb: dwc2: allow peripheral mode for OTG configuration

Quoted 6 lines · Patrick Delaunay

Allow device mode in DWC2 driver when device tree select the dr_mode "peripheral" or "otg".

The device mode is not allowed when dr_mode = "host" in device tree.

Quoted 22 lines

---

Changes in v2: None

 drivers/usb/gadget/dwc2_udc_otg.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/usb/gadget/dwc2_udc_otg.c +2 -1
index 023439c..35f4147 100644
@@ -1041,7 +1041,8 @@ static int dwc2_udc_otg_ofdata_to_platdata(struct udevice *dev)
 	void (*set_params)(struct dwc2_plat_otg_data *data);
 	int ret;
 
-	if (usb_get_dr_mode(node) != USB_DR_MODE_PERIPHERAL) {
+	if (usb_get_dr_mode(node) != USB_DR_MODE_PERIPHERAL &&
+	    usb_get_dr_mode(node) != USB_DR_MODE_OTG) {
 		dev_dbg(dev, "Invalid mode\n");
 		return -ENODEV;
 	}
Signature · 2 lines
Best regards,
Marek Vasut
#5 lore raw

PATCH v2 3/3 usb: dwc2: allow peripheral mode for OTG configuration

Hi Patrick

Quoted 24 lines · Marek Vasut
Quoted 6 lines · Patrick Delaunay

Allow device mode in DWC2 driver when device tree select the dr_mode "peripheral" or "otg".

The device mode is not allowed when dr_mode = "host" in device tree.

Quoted 15 lines

---

Changes in v2: None

 drivers/usb/gadget/dwc2_udc_otg.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/usb/gadget/dwc2_udc_otg.c +0 -0
index 023439c..35f4147 100644
@@ -1041,7 +1041,8 @@ static int dwc2_udc_otg_ofdata_to_platdata(struct udevice *dev)
 	void (*set_params)(struct dwc2_plat_otg_data *data);
 	int ret;
 
Quoted 8 lines

drivers/usb/gadget/dwc2_udc_otg.c static int dwc2_udc_otg_ofdata_to_platdata(struct udevice *dev) · line 1048

Quoted 7 lines
drivers/usb/gadget/dwc2_udc_otg.c +2 -1
-	if (usb_get_dr_mode(node) != USB_DR_MODE_PERIPHERAL) {
+	if (usb_get_dr_mode(node) != USB_DR_MODE_PERIPHERAL &&
+	    usb_get_dr_mode(node) != USB_DR_MODE_OTG) {
 		dev_dbg(dev, "Invalid mode\n");
 		return -ENODEV;
 	}

Applied to uboot-stm

Thanks

#6 lore raw

PATCH v2 1/3 usb: dwc2: correctly handle binding for g-tx-fifo-size

In reply to Patrick Delaunay
Quoted 3 lines · Patrick Delaunay

Manage g-tx-fifo-size as a array as specify in the binding.

I'm missing 2/3 , although I think it might be better if you take this whole series through u-boot-stm .

Quoted 42 lines

---

Changes in v2:
- move dt update in a separate patch
- remove unecessary temporary variable

 drivers/usb/gadget/dwc2_udc_otg.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
drivers/usb/gadget/dwc2_udc_otg.c +13 -1
index 494ab53..023439c 100644
@@ -1039,6 +1039,7 @@ static int dwc2_udc_otg_ofdata_to_platdata(struct udevice *dev)
 	int node = dev_of_offset(dev);
 	ulong drvdata;
 	void (*set_params)(struct dwc2_plat_otg_data *data);
+	int ret;
 
 	if (usb_get_dr_mode(node) != USB_DR_MODE_PERIPHERAL) {
 		dev_dbg(dev, "Invalid mode\n");
@@ -1050,7 +1051,18 @@ static int dwc2_udc_otg_ofdata_to_platdata(struct udevice *dev)
 	platdata->rx_fifo_sz = dev_read_u32_default(dev, "g-rx-fifo-size", 0);
 	platdata->np_tx_fifo_sz = dev_read_u32_default(dev,
 						       "g-np-tx-fifo-size", 0);
-	platdata->tx_fifo_sz = dev_read_u32_default(dev, "g-tx-fifo-size", 0);
+
+	platdata->tx_fifo_sz_nb =
+		dev_read_size(dev, "g-tx-fifo-size") / sizeof(u32);
+	if (platdata->tx_fifo_sz_nb > DWC2_MAX_HW_ENDPOINTS)
+		platdata->tx_fifo_sz_nb = DWC2_MAX_HW_ENDPOINTS;
+	if (platdata->tx_fifo_sz_nb) {
+		ret = dev_read_u32_array(dev, "g-tx-fifo-size",
+					 platdata->tx_fifo_sz_array,
+					 platdata->tx_fifo_sz_nb);
+		if (ret)
+			return ret;
+	}
 
 	platdata->force_b_session_valid =
 		dev_read_bool(dev, "u-boot,force-b-session-valid");
Signature · 2 lines
Best regards,
Marek Vasut
#7 lore raw

PATCH v2 1/3 usb: dwc2: correctly handle binding for g-tx-fifo-size

Hi Marek,

Quoted 4 lines

From: Marek Vasut <[email protected]>
Sent: mardi 18 juin 2019 18:46

On 6/18/19 4:57 PM, Patrick Delaunay wrote:

Quoted 8 lines
Quoted 3 lines

Manage g-tx-fifo-size as a array as specify in the binding.

I'm missing 2/3 , although I think it might be better if you take this whole series through u-boot-stm .

Ok thanks,

We (Patrice or me) we will take the serie on u-boot-stm.

Quoted 50 lines

drivers/usb/gadget/dwc2_udc_otg.c static int dwc2_udc_otg_ofdata_to_platdata(struct

Quoted 15 lines

---

Changes in v2:
- move dt update in a separate patch
- remove unecessary temporary variable

 drivers/usb/gadget/dwc2_udc_otg.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
drivers/usb/gadget/dwc2_udc_otg.c +0 -0
index 494ab53..023439c 100644
@@ -1039,6 +1039,7 @@ static int dwc2_udc_otg_ofdata_to_platdata(struct

udevice *dev)

drivers/usb/gadget/dwc2_udc_otg.c static int dwc2_udc_otg_ofdata_to_platdata(struct

Quoted 8 lines
drivers/usb/gadget/dwc2_udc_otg.c +1 -0
 	int node = dev_of_offset(dev);
 	ulong drvdata;
 	void (*set_params)(struct dwc2_plat_otg_data *data);
+	int ret;
 
 	if (usb_get_dr_mode(node) != USB_DR_MODE_PERIPHERAL) {
 		dev_dbg(dev, "Invalid mode\n");
@@ -1050,7 +1051,18 @@ static int dwc2_udc_otg_ofdata_to_platdata(struct

udevice *dev)

Quoted 10 lines
drivers/usb/gadget/dwc2_udc_otg.c +5 -1
 	platdata->rx_fifo_sz = dev_read_u32_default(dev, "g-rx-fifo-size", 0);
 	platdata->np_tx_fifo_sz = dev_read_u32_default(dev,
 						       "g-np-tx-fifo-size", 0);
-	platdata->tx_fifo_sz = dev_read_u32_default(dev, "g-tx-fifo-size", 0);
+
+	platdata->tx_fifo_sz_nb =
+		dev_read_size(dev, "g-tx-fifo-size") / sizeof(u32);
+	if (platdata->tx_fifo_sz_nb > DWC2_MAX_HW_ENDPOINTS)
+		platdata->tx_fifo_sz_nb = DWC2_MAX_HW_ENDPOINTS;

drivers/usb/gadget/dwc2_udc_otg.c static int dwc2_udc_otg_ofdata_to_platdata(struct udevice *dev) · line 1068

Quoted 10 lines
drivers/usb/gadget/dwc2_udc_otg.c +7 -0
+	if (platdata->tx_fifo_sz_nb) {
+		ret = dev_read_u32_array(dev, "g-tx-fifo-size",
+					 platdata->tx_fifo_sz_array,
+					 platdata->tx_fifo_sz_nb);
+		if (ret)
+			return ret;
+	}
 
 	platdata->force_b_session_valid =
 		dev_read_bool(dev, "u-boot,force-b-session-valid");

--
Best regards,
Marek Vasut

#8 lore raw

PATCH v2 1/3 usb: dwc2: correctly handle binding for g-tx-fifo-size

In reply to Marek Vasut

Hi Patrick

Quoted 8 lines · Marek Vasut
Quoted 3 lines · Patrick Delaunay

Manage g-tx-fifo-size as a array as specify in the binding.

I'm missing 2/3 , although I think it might be better if you take this whole series through u-boot-stm .

Applied to uboot-stm

Thanks

Quoted 43 lines
Quoted 42 lines

---

Changes in v2:
- move dt update in a separate patch
- remove unecessary temporary variable

 drivers/usb/gadget/dwc2_udc_otg.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
drivers/usb/gadget/dwc2_udc_otg.c +13 -1
index 494ab53..023439c 100644
@@ -1039,6 +1039,7 @@ static int dwc2_udc_otg_ofdata_to_platdata(struct udevice *dev)
 	int node = dev_of_offset(dev);
 	ulong drvdata;
 	void (*set_params)(struct dwc2_plat_otg_data *data);
+	int ret;
 
 	if (usb_get_dr_mode(node) != USB_DR_MODE_PERIPHERAL) {
 		dev_dbg(dev, "Invalid mode\n");
@@ -1050,7 +1051,18 @@ static int dwc2_udc_otg_ofdata_to_platdata(struct udevice *dev)
 	platdata->rx_fifo_sz = dev_read_u32_default(dev, "g-rx-fifo-size", 0);
 	platdata->np_tx_fifo_sz = dev_read_u32_default(dev,
 						       "g-np-tx-fifo-size", 0);
-	platdata->tx_fifo_sz = dev_read_u32_default(dev, "g-tx-fifo-size", 0);
+
+	platdata->tx_fifo_sz_nb =
+		dev_read_size(dev, "g-tx-fifo-size") / sizeof(u32);
+	if (platdata->tx_fifo_sz_nb > DWC2_MAX_HW_ENDPOINTS)
+		platdata->tx_fifo_sz_nb = DWC2_MAX_HW_ENDPOINTS;
+	if (platdata->tx_fifo_sz_nb) {
+		ret = dev_read_u32_array(dev, "g-tx-fifo-size",
+					 platdata->tx_fifo_sz_array,
+					 platdata->tx_fifo_sz_nb);
+		if (ret)
+			return ret;
+	}
 
 	platdata->force_b_session_valid =
 		dev_read_bool(dev, "u-boot,force-b-session-valid");