OSDN Git Service

usb: dwc2: gadget: use soft-disconnect udc feature in pullup() method
authorMarek Szyprowski <m.szyprowski@samsung.com>
Mon, 20 Oct 2014 10:45:38 +0000 (12:45 +0200)
committerFelipe Balbi <balbi@ti.com>
Mon, 3 Nov 2014 16:01:23 +0000 (10:01 -0600)
This patch moves udc initialization from pullup() method to
s3c_hsotg_udc_start(), so that method ends with hardware fully
initialized and left in soft-disconnected state. After this change, the
pullup() method simply clears soft-disconnect start() when called with
is_on=1. For completeness, a call to s3c_hsotg_core_disconnect() has
been added when pullup() method is called with is_on=0, what puts the
udc hardware back to soft-disconnected state.

Acked-by: Paul Zimmerman <paulz@synopsys.com>
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
drivers/usb/dwc2/gadget.c

index 68865e5..5872db9 100644 (file)
@@ -2880,6 +2880,7 @@ static int s3c_hsotg_udc_start(struct usb_gadget *gadget,
                           struct usb_gadget_driver *driver)
 {
        struct s3c_hsotg *hsotg = to_hsotg(gadget);
+       unsigned long flags;
        int ret;
 
        if (!hsotg) {
@@ -2918,7 +2919,13 @@ static int s3c_hsotg_udc_start(struct usb_gadget *gadget,
 
        s3c_hsotg_phy_enable(hsotg);
 
+       spin_lock_irqsave(&hsotg->lock, flags);
+       s3c_hsotg_init(hsotg);
+       s3c_hsotg_core_init_disconnected(hsotg);
+       spin_unlock_irqrestore(&hsotg->lock, flags);
+
        dev_info(hsotg->dev, "bound driver %s\n", driver->driver.name);
+
        return 0;
 
 err:
@@ -2990,9 +2997,9 @@ static int s3c_hsotg_pullup(struct usb_gadget *gadget, int is_on)
        spin_lock_irqsave(&hsotg->lock, flags);
        if (is_on) {
                clk_enable(hsotg->clk);
-               s3c_hsotg_core_init_disconnected(hsotg);
                s3c_hsotg_core_connect(hsotg);
        } else {
+               s3c_hsotg_core_disconnect(hsotg);
                clk_disable(hsotg->clk);
        }