[PATCH 02/13] usb: udc: set the udc is ready to pullup dp when it needs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Except for chipidea driver, all other udc drivers will tell the
gadget driver that they are ready to pullup dp at udc_start, it
is the default behaviour.

The chipidea driver is ready to pullup dp when the vbus is there,
and isn't ready to pullup dp when the vbus is not there. Other
udc drivers which should not pull up when vbus is not there should
change like chipidea does to pass the Back-Voltage Testing at
www.usb.org/developers/docs/USB-IFTestProc1_3.pdf.

Signed-off-by: Peter Chen <peter.chen@xxxxxxxxxxxxx>
---
 drivers/usb/chipidea/udc.c              |    9 ++++-----
 drivers/usb/dwc2/gadget.c               |    2 ++
 drivers/usb/dwc3/gadget.c               |    2 ++
 drivers/usb/gadget/udc/amd5536udc.c     |    1 +
 drivers/usb/gadget/udc/atmel_usba_udc.c |    2 ++
 drivers/usb/gadget/udc/bcm63xx_udc.c    |    2 ++
 drivers/usb/gadget/udc/dummy_hcd.c      |    1 +
 drivers/usb/gadget/udc/fotg210-udc.c    |    1 +
 drivers/usb/gadget/udc/fsl_qe_udc.c     |    1 +
 drivers/usb/gadget/udc/fsl_udc_core.c   |    2 ++
 drivers/usb/gadget/udc/fusb300_udc.c    |    1 +
 drivers/usb/gadget/udc/gr_udc.c         |    2 ++
 drivers/usb/gadget/udc/lpc32xx_udc.c    |    2 ++
 drivers/usb/gadget/udc/m66592-udc.c     |    2 ++
 drivers/usb/gadget/udc/mv_u3d_core.c    |    1 +
 drivers/usb/gadget/udc/mv_udc_core.c    |    2 ++
 drivers/usb/gadget/udc/net2272.c        |    1 +
 drivers/usb/gadget/udc/net2280.c        |    1 +
 drivers/usb/gadget/udc/omap_udc.c       |    1 +
 drivers/usb/gadget/udc/pch_udc.c        |    1 +
 drivers/usb/gadget/udc/pxa25x_udc.c     |    1 +
 drivers/usb/gadget/udc/pxa27x_udc.c     |    1 +
 drivers/usb/gadget/udc/r8a66597-udc.c   |    1 +
 drivers/usb/gadget/udc/s3c-hsudc.c      |    1 +
 drivers/usb/gadget/udc/s3c2410_udc.c    |    1 +
 drivers/usb/musb/musb_gadget.c          |    2 ++
 drivers/usb/renesas_usbhs/mod_gadget.c  |    7 ++++++-
 27 files changed, 45 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
index b8125aa..2830066 100644
--- a/drivers/usb/chipidea/udc.c
+++ b/drivers/usb/chipidea/udc.c
@@ -86,10 +86,8 @@ static int hw_device_state(struct ci_hdrc *ci, u32 dma)
 		/* interrupt, error, port change, reset, sleep/suspend */
 		hw_write(ci, OP_USBINTR, ~0,
 			     USBi_UI|USBi_UEI|USBi_PCI|USBi_URI|USBi_SLI);
-		hw_write(ci, OP_USBCMD, USBCMD_RS, USBCMD_RS);
 	} else {
 		hw_write(ci, OP_USBINTR, ~0, 0);
-		hw_write(ci, OP_USBCMD, USBCMD_RS, 0);
 	}
 	return 0;
 }
@@ -1477,8 +1475,10 @@ static int ci_udc_vbus_session(struct usb_gadget *_gadget, int is_active)
 			pm_runtime_get_sync(&_gadget->dev);
 			hw_device_reset(ci, USBMODE_CM_DC);
 			hw_device_state(ci, ci->ep0out->qh.dma);
+			usb_udc_ready_to_connect(ci->driver, _gadget, true);
 			usb_gadget_set_state(_gadget, USB_STATE_POWERED);
 		} else {
+			usb_udc_ready_to_connect(ci->driver, _gadget, false);
 			if (ci->driver)
 				ci->driver->disconnect(&ci->gadget);
 			hw_device_state(ci, 0);
@@ -1531,9 +1531,6 @@ static int ci_udc_pullup(struct usb_gadget *_gadget, int is_on)
 {
 	struct ci_hdrc *ci = container_of(_gadget, struct ci_hdrc, gadget);
 
-	if (!ci->vbus_active)
-		return -EOPNOTSUPP;
-
 	if (is_on)
 		hw_write(ci, OP_USBCMD, USBCMD_RS, USBCMD_RS);
 	else
@@ -1676,6 +1673,8 @@ static int ci_udc_start(struct usb_gadget *gadget,
 	if (retval)
 		pm_runtime_put_sync(&ci->gadget.dev);
 
+	usb_udc_ready_to_connect(driver, gadget, true);
+
 	return retval;
 }
 
diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index 0ba9c33..2421eaa 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -2865,6 +2865,8 @@ static int s3c_hsotg_udc_start(struct usb_gadget *gadget,
 		goto err;
 	}
 
+	usb_udc_ready_to_connect(driver, gadget, true);
+
 	hsotg->last_rst = jiffies;
 	dev_info(hsotg->dev, "bound driver %s\n", driver->driver.name);
 	return 0;
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 349cacc..d952eaa 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -1680,6 +1680,8 @@ static int dwc3_gadget_start(struct usb_gadget *g,
 
 	dwc3_gadget_enable_irq(dwc);
 
+	usb_udc_ready_to_connect(driver, g, true);
+
 	spin_unlock_irqrestore(&dwc->lock, flags);
 
 	return 0;
diff --git a/drivers/usb/gadget/udc/amd5536udc.c b/drivers/usb/gadget/udc/amd5536udc.c
index 41b062e..f8af622 100644
--- a/drivers/usb/gadget/udc/amd5536udc.c
+++ b/drivers/usb/gadget/udc/amd5536udc.c
@@ -1940,6 +1940,7 @@ static int amd5536_udc_start(struct usb_gadget *g,
 	writel(tmp, &dev->regs->ctl);
 
 	usb_connect(dev);
+	usb_udc_ready_to_connect(driver, g, true);
 
 	return 0;
 }
diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c b/drivers/usb/gadget/udc/atmel_usba_udc.c
index 906e65f..93c959f 100644
--- a/drivers/usb/gadget/udc/atmel_usba_udc.c
+++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
@@ -1806,6 +1806,8 @@ static int atmel_usba_start(struct usb_gadget *gadget,
 	}
 	spin_unlock_irqrestore(&udc->lock, flags);
 
+	usb_udc_ready_to_connect(driver, gadget, true);
+
 	return 0;
 }
 
diff --git a/drivers/usb/gadget/udc/bcm63xx_udc.c b/drivers/usb/gadget/udc/bcm63xx_udc.c
index e969eb8..b9858f4 100644
--- a/drivers/usb/gadget/udc/bcm63xx_udc.c
+++ b/drivers/usb/gadget/udc/bcm63xx_udc.c
@@ -1828,6 +1828,8 @@ static int bcm63xx_udc_start(struct usb_gadget *gadget,
 
 	spin_unlock_irqrestore(&udc->lock, flags);
 
+	usb_udc_ready_to_connect(driver, gadget, true);
+
 	return 0;
 }
 
diff --git a/drivers/usb/gadget/udc/dummy_hcd.c b/drivers/usb/gadget/udc/dummy_hcd.c
index 2b54955..dd01648 100644
--- a/drivers/usb/gadget/udc/dummy_hcd.c
+++ b/drivers/usb/gadget/udc/dummy_hcd.c
@@ -910,6 +910,7 @@ static int dummy_udc_start(struct usb_gadget *g,
 	dum->devstatus = 0;
 
 	dum->driver = driver;
+	usb_udc_ready_to_connect(driver, g, true);
 	dev_dbg(udc_dev(dum), "binding gadget driver '%s'\n",
 			driver->driver.name);
 	return 0;
diff --git a/drivers/usb/gadget/udc/fotg210-udc.c b/drivers/usb/gadget/udc/fotg210-udc.c
index e143d69..762a39e 100644
--- a/drivers/usb/gadget/udc/fotg210-udc.c
+++ b/drivers/usb/gadget/udc/fotg210-udc.c
@@ -1028,6 +1028,7 @@ static int fotg210_udc_start(struct usb_gadget *g,
 	value |= DMCR_GLINT_EN;
 	iowrite32(value, fotg210->reg + FOTG210_DMCR);
 
+	usb_udc_ready_to_connect(driver, g, true);
 	return 0;
 }
 
diff --git a/drivers/usb/gadget/udc/fsl_qe_udc.c b/drivers/usb/gadget/udc/fsl_qe_udc.c
index 7324308..e759224 100644
--- a/drivers/usb/gadget/udc/fsl_qe_udc.c
+++ b/drivers/usb/gadget/udc/fsl_qe_udc.c
@@ -2308,6 +2308,7 @@ static int fsl_qe_start(struct usb_gadget *gadget,
 	udc->ep0_dir = USB_DIR_OUT;
 	spin_unlock_irqrestore(&udc->lock, flags);
 
+	usb_udc_ready_to_connect(driver, gadget, true);
 	dev_info(udc->dev, "%s bind to driver %s\n", udc->gadget.name,
 			driver->driver.name);
 	return 0;
diff --git a/drivers/usb/gadget/udc/fsl_udc_core.c b/drivers/usb/gadget/udc/fsl_udc_core.c
index 75b23ea..63437ad 100644
--- a/drivers/usb/gadget/udc/fsl_udc_core.c
+++ b/drivers/usb/gadget/udc/fsl_udc_core.c
@@ -1973,6 +1973,8 @@ static int fsl_udc_start(struct usb_gadget *g,
 		udc_controller->ep0_dir = 0;
 	}
 
+	usb_udc_ready_to_connect(driver, g, true);
+
 	return retval;
 }
 
diff --git a/drivers/usb/gadget/udc/fusb300_udc.c b/drivers/usb/gadget/udc/fusb300_udc.c
index d40255f..b47ab54 100644
--- a/drivers/usb/gadget/udc/fusb300_udc.c
+++ b/drivers/usb/gadget/udc/fusb300_udc.c
@@ -1316,6 +1316,7 @@ static int fusb300_udc_start(struct usb_gadget *g,
 	/* hook up the driver */
 	driver->driver.bus = NULL;
 	fusb300->driver = driver;
+	usb_udc_ready_to_connect(driver, g, true);
 
 	return 0;
 }
diff --git a/drivers/usb/gadget/udc/gr_udc.c b/drivers/usb/gadget/udc/gr_udc.c
index 08df5c4..dd7c675 100644
--- a/drivers/usb/gadget/udc/gr_udc.c
+++ b/drivers/usb/gadget/udc/gr_udc.c
@@ -1917,6 +1917,8 @@ static int gr_udc_start(struct usb_gadget *gadget,
 
 	spin_unlock(&dev->lock);
 
+	usb_udc_ready_to_connect(driver, gadget, true);
+
 	dev_info(dev->dev, "Started with gadget driver '%s'\n",
 		 driver->driver.name);
 
diff --git a/drivers/usb/gadget/udc/lpc32xx_udc.c b/drivers/usb/gadget/udc/lpc32xx_udc.c
index 1629ad7..932428b 100644
--- a/drivers/usb/gadget/udc/lpc32xx_udc.c
+++ b/drivers/usb/gadget/udc/lpc32xx_udc.c
@@ -2958,6 +2958,8 @@ static int lpc32xx_start(struct usb_gadget *gadget,
 	for (i = IRQ_USB_LP; i < IRQ_USB_ATX; i++)
 		enable_irq(udc->udp_irq[i]);
 
+	usb_udc_ready_to_connect(driver, gadget, true);
+
 	return 0;
 }
 
diff --git a/drivers/usb/gadget/udc/m66592-udc.c b/drivers/usb/gadget/udc/m66592-udc.c
index de88d33..8eaaa76 100644
--- a/drivers/usb/gadget/udc/m66592-udc.c
+++ b/drivers/usb/gadget/udc/m66592-udc.c
@@ -1482,6 +1482,8 @@ static int m66592_udc_start(struct usb_gadget *g,
 		mod_timer(&m66592->timer, jiffies + msecs_to_jiffies(50));
 	}
 
+	usb_udc_ready_to_connect(driver, g, true);
+
 	return 0;
 }
 
diff --git a/drivers/usb/gadget/udc/mv_u3d_core.c b/drivers/usb/gadget/udc/mv_u3d_core.c
index 1624871..f50231b 100644
--- a/drivers/usb/gadget/udc/mv_u3d_core.c
+++ b/drivers/usb/gadget/udc/mv_u3d_core.c
@@ -1266,6 +1266,7 @@ static int mv_u3d_start(struct usb_gadget *g,
 	spin_unlock_irqrestore(&u3d->lock, flags);
 
 	u3d->vbus_valid_detect = 1;
+	usb_udc_ready_to_connect(driver, g, true);
 
 	return 0;
 }
diff --git a/drivers/usb/gadget/udc/mv_udc_core.c b/drivers/usb/gadget/udc/mv_udc_core.c
index 040fb16..5db678d 100644
--- a/drivers/usb/gadget/udc/mv_udc_core.c
+++ b/drivers/usb/gadget/udc/mv_udc_core.c
@@ -1372,6 +1372,8 @@ static int mv_udc_start(struct usb_gadget *gadget,
 	if (udc->qwork)
 		queue_work(udc->qwork, &udc->vbus_work);
 
+	usb_udc_ready_to_connect(driver, gadget, true);
+
 	return 0;
 }
 
diff --git a/drivers/usb/gadget/udc/net2272.c b/drivers/usb/gadget/udc/net2272.c
index 059cfe5..d3e2a42 100644
--- a/drivers/usb/gadget/udc/net2272.c
+++ b/drivers/usb/gadget/udc/net2272.c
@@ -1470,6 +1470,7 @@ static int net2272_start(struct usb_gadget *_gadget,
 	 * for set_configuration as well as eventual disconnect.
 	 */
 	net2272_ep0_start(dev);
+	usb_udc_ready_to_connect(driver, _gadget, true);
 
 	dev_dbg(dev->dev, "%s ready\n", driver->driver.name);
 
diff --git a/drivers/usb/gadget/udc/net2280.c b/drivers/usb/gadget/udc/net2280.c
index f4eac11..2352847 100644
--- a/drivers/usb/gadget/udc/net2280.c
+++ b/drivers/usb/gadget/udc/net2280.c
@@ -2402,6 +2402,7 @@ static int net2280_start(struct usb_gadget *_gadget,
 			readl(&dev->usb->usbctl),
 			readl(&dev->usb->stdrsp));
 
+	usb_udc_ready_to_connect(driver, _gadget, true);
 	/* pci writes may still be posted */
 	return 0;
 
diff --git a/drivers/usb/gadget/udc/omap_udc.c b/drivers/usb/gadget/udc/omap_udc.c
index e731373..c2b1a35 100644
--- a/drivers/usb/gadget/udc/omap_udc.c
+++ b/drivers/usb/gadget/udc/omap_udc.c
@@ -2095,6 +2095,7 @@ static int omap_udc_start(struct usb_gadget *g,
 	if (machine_without_vbus_sense())
 		omap_vbus_session(&udc->gadget, 1);
 
+	usb_udc_ready_to_connect(driver, g, true);
 done:
 	if (udc->dc_clk != NULL)
 		omap_udc_enable_clock(0);
diff --git a/drivers/usb/gadget/udc/pch_udc.c b/drivers/usb/gadget/udc/pch_udc.c
index eb8c3be..f7bafdc 100644
--- a/drivers/usb/gadget/udc/pch_udc.c
+++ b/drivers/usb/gadget/udc/pch_udc.c
@@ -3001,6 +3001,7 @@ static int pch_udc_start(struct usb_gadget *g,
 		pch_udc_clear_disconnect(dev);
 
 	dev->connected = 1;
+	usb_udc_ready_to_connect(driver, g, true);
 	return 0;
 }
 
diff --git a/drivers/usb/gadget/udc/pxa25x_udc.c b/drivers/usb/gadget/udc/pxa25x_udc.c
index 251e4d5..64733ba 100644
--- a/drivers/usb/gadget/udc/pxa25x_udc.c
+++ b/drivers/usb/gadget/udc/pxa25x_udc.c
@@ -1278,6 +1278,7 @@ static int pxa25x_udc_start(struct usb_gadget *g,
 	}
 
 	pullup(dev);
+	usb_udc_ready_to_connect(driver, g, true);
 	dump_state(dev);
 	return 0;
 bind_fail:
diff --git a/drivers/usb/gadget/udc/pxa27x_udc.c b/drivers/usb/gadget/udc/pxa27x_udc.c
index 597d39f..4cf3387 100644
--- a/drivers/usb/gadget/udc/pxa27x_udc.c
+++ b/drivers/usb/gadget/udc/pxa27x_udc.c
@@ -1825,6 +1825,7 @@ static int pxa27x_udc_start(struct usb_gadget *g,
 
 	if (should_enable_udc(udc))
 		udc_enable(udc);
+	usb_udc_ready_to_connect(driver, g, true);
 	return 0;
 
 fail:
diff --git a/drivers/usb/gadget/udc/r8a66597-udc.c b/drivers/usb/gadget/udc/r8a66597-udc.c
index 4600842..c963fe3 100644
--- a/drivers/usb/gadget/udc/r8a66597-udc.c
+++ b/drivers/usb/gadget/udc/r8a66597-udc.c
@@ -1759,6 +1759,7 @@ static int r8a66597_start(struct usb_gadget *gadget,
 		r8a66597->scount = R8A66597_MAX_SAMPLING;
 		mod_timer(&r8a66597->timer, jiffies + msecs_to_jiffies(50));
 	}
+	usb_udc_ready_to_connect(driver, gadget, true);
 
 	return 0;
 }
diff --git a/drivers/usb/gadget/udc/s3c-hsudc.c b/drivers/usb/gadget/udc/s3c-hsudc.c
index 10c6a12..48cbed4 100644
--- a/drivers/usb/gadget/udc/s3c-hsudc.c
+++ b/drivers/usb/gadget/udc/s3c-hsudc.c
@@ -1182,6 +1182,7 @@ static int s3c_hsudc_start(struct usb_gadget *gadget,
 	s3c_hsudc_init_phy();
 	if (hsudc->pd->gpio_init)
 		hsudc->pd->gpio_init();
+	usb_udc_ready_to_connect(driver, gadget, true);
 
 	return 0;
 err_otg:
diff --git a/drivers/usb/gadget/udc/s3c2410_udc.c b/drivers/usb/gadget/udc/s3c2410_udc.c
index 357b58e..b7f4bff 100644
--- a/drivers/usb/gadget/udc/s3c2410_udc.c
+++ b/drivers/usb/gadget/udc/s3c2410_udc.c
@@ -1679,6 +1679,7 @@ static int s3c2410_udc_start(struct usb_gadget *g,
 
 	/* Enable udc */
 	s3c2410_udc_enable(udc);
+	usb_udc_ready_to_connect(driver, g, true);
 
 	return 0;
 }
diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c
index d4aa779..b3db6cd 100644
--- a/drivers/usb/musb/musb_gadget.c
+++ b/drivers/usb/musb/musb_gadget.c
@@ -1865,6 +1865,8 @@ static int musb_gadget_start(struct usb_gadget *g,
 
 	musb_start(musb);
 
+	usb_udc_ready_to_connect(driver, g, true);
+
 	/* REVISIT:  funcall to other code, which also
 	 * handles power budgeting ... this way also
 	 * ensures HdrcStart is indirectly called.
diff --git a/drivers/usb/renesas_usbhs/mod_gadget.c b/drivers/usb/renesas_usbhs/mod_gadget.c
index 04e6505..33f4860 100644
--- a/drivers/usb/renesas_usbhs/mod_gadget.c
+++ b/drivers/usb/renesas_usbhs/mod_gadget.c
@@ -839,6 +839,7 @@ static int usbhsg_gadget_start(struct usb_gadget *gadget,
 {
 	struct usbhsg_gpriv *gpriv = usbhsg_gadget_to_gpriv(gadget);
 	struct usbhs_priv *priv = usbhsg_gpriv_to_priv(gpriv);
+	int ret;
 
 	if (!driver		||
 	    !driver->setup	||
@@ -848,7 +849,11 @@ static int usbhsg_gadget_start(struct usb_gadget *gadget,
 	/* first hook up the driver ... */
 	gpriv->driver = driver;
 
-	return usbhsg_try_start(priv, USBHSG_STATUS_REGISTERD);
+	ret = usbhsg_try_start(priv, USBHSG_STATUS_REGISTERD);
+	if (!ret)
+		usb_udc_ready_to_connect(driver, gadget, true);
+
+	return ret;
 }
 
 static int usbhsg_gadget_stop(struct usb_gadget *gadget,
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux