Avoid delay when inializing USB peripheral by dwc2.c
A message that is not in the archive (sent off-list or not yet received): CAJMWnChnVRL1N24RHhs-eUF1niyEKGVAsuReovvnYvy8Xjw4sw@mail.gmail.com
PATCH 1/1 Avoid delay when inializing USB peripheral by dwc2.c
Quoted 11 lines · Jo?o Loureiro
When
usb startis called, the dwc2 driver will try to start every USB device as host first, even if it is explicitly configured as peripheral in the device tree, as the documentation explains (dr_mode = "peripheral").So to avoid an unwanted 15 seconds delay when initializing the usb (one second per channel = 1s x 15), this patch adds a check to the initialization, and will skip a host initialization of the device, when it is explicitly set as peripheral. The checking is already done similarly in the
drivers/usb/gadget/dwc2_udc_otg.cdriver.
Quoted 6 lines
An example device tree entry:
&usb0 { compatible = "snps,dwc2"; status = "okay"; dr_mode = "peripheral"; };
+CC Lukasz.
The patch looks OK, except you need SoB line, see e.g.
https://www.kernel.org/doc/html/v5.10/process/submitting-patches.html
When in doubt, git format-patch -1 -o /tmp the patch and then run ./scripts/checkpatch.pl /tmp/00*patch on it, this will tell you what to do.
Quoted 33 lines
Proposed patch below:
drivers/usb/host/dwc2.c +8
-1@@ -21,6 +21,7 @@#include <asm/io.h> #include <dm/device_compat.h> #include <linux/delay.h> +#include <linux/usb/otg.h> #include <power/regulator.h> #include <reset.h> @@ -1204,7 +1205,13 @@ static int dwc2_init_common(struct udevice *dev, struct dwc2_priv *priv)#endif dwc_otg_core_init (dev); -dwc_otg_core_host_init (dev, regs); + +if (usb_get_dr_mode (dev_ofnode (dev)) ==USB_DR_MODE_PERIPHERAL ) { +dev_dbg (dev,"USB device %s dr_mode set to %d. Skipping host_init.\n" ,\ + dev->name,usb_get_dr_mode (dev_ofnode (dev))); + } +else +dwc_otg_core_host_init (dev, regs); clrsetbits_le32(®s->hprt0, DWC2_HPRT0_PRTENA |
DWC2_HPRT0_PRTCONNDET|DWC2_HPRT0_PRTENCHNG|---
Excuse me if I missed any detail; That's my first patch to u-boot.
Signature · 2 lines
Best regards, Marek Vasut
PATCH 1/1 Avoid delay when initializing USB peripherals by dwc2
In reply to a message not in the archiveWhen usb start is called, the dwc2 driver will try to start every USB device as host first, even if it is explicitly configured as peripheral in the device tree, as the documentation explains (dr_mode = "peripheral").
So to avoid an unwanted 15 seconds delay when initializing the usb (one second per channel = 1s x 15), this patch adds a check to the initialization, and will skip a host initialization of the device, when it is explicitly set as peripheral. The checking is already done similarly in the drivers/usb/gadget/dwc2_udc_otg.c driver.
An example device tree entry:
&usb0 {
compatible = "snps,dwc2";
status = "okay";
dr_mode = "peripheral";
};
---drivers/usb/host/dwc2.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
drivers/usb/host/dwc2.c +0 -0
@@ -21,6 +21,7 @@
#include <asm/io.h>
#include <dm/device_compat.h>
#include <linux/delay.h>
+#include <linux/usb/otg.h>
#include <power/regulator.h>
#include <reset.h>
@@ -1204,7 +1205,13 @@ static int dwc2_init_common(struct udevice *dev, struct dwc2_priv *priv)
#endifdwc_otg_core_init(dev);
- dwc_otg_core_host_init(dev, regs);
+
+ if (usb_get_dr_mode(dev_ofnode(dev)) == USB_DR_MODE_PERIPHERAL) {
+ dev_dbg(dev, "USB device %s dr_mode set to %d. Skipping host_init.\n",\
+ dev->name, usb_get_dr_mode(dev_ofnode(dev)));
+ } else {
+ dwc_otg_core_host_init(dev, regs);
+ }
clrsetbits_le32(®s->hprt0, DWC2_HPRT0_PRTENA | DWC2_HPRT0_PRTCONNDET | DWC2_HPRT0_PRTENCHNG |
Signature · 1 line
2.25.1
PATCH 1/1 Avoid delay when initializing USB peripherals by dwc2
Quoted 36 lines · Jo?o Loureiro
When
usb startis called, the dwc2 driver will try to start every USB device as host first, even if it is explicitly configured as peripheral in the device tree, as the documentation explains (dr_mode = "peripheral").So to avoid an unwanted 15 seconds delay when initializing the usb (one second per channel = 1s x 15), this patch adds a check to the initialization, and will skip a host initialization of the device, when it is explicitly set as peripheral. The checking is already done similarly in the
drivers/usb/gadget/dwc2_udc_otg.cdriver.An example device tree entry:
&usb0 { compatible = "snps,dwc2"; status = "okay"; dr_mode = "peripheral"; };Signed-off-by Jo?o Loureiro <[email protected]>---
drivers/usb/host/dwc2.c| 9 ++++++++-1 file changed, 8 insertions(+), 1 deletion(-)drivers/usb/host/dwc2.c +1
-0@@ -21,6 +21,7 @@#include <asm/io.h> #include <dm/device_compat.h> #include <linux/delay.h> +#include <linux/usb/otg.h> #include <power/regulator.h> #include <reset.h> @@ -1204,7 +1205,13 @@ static int dwc2_init_common(struct udevice *dev, struct dwc2_priv *priv)
drivers/usb/host/dwc2.c static int dwc2_init_common(struct udevice · line 1214
Quoted 10 lines
drivers/usb/host/dwc2.c +7
-1#endif dwc_otg_core_init (dev); -dwc_otg_core_host_init (dev, regs); + +if (usb_get_dr_mode (dev_ofnode (dev)) ==USB_DR_MODE_PERIPHERAL ) { +dev_dbg (dev,"USB device %s dr_mode set to %d. Skipping host_init.\n" ,\ + dev->name,usb_get_dr_mode (dev_ofnode (dev))); + }else { +dwc_otg_core_host_init (dev, regs); + }
The patch is corrupted, please use git send-email if possible.