usb: dwc2: gadget: decouple setting soft-disconnect from s3c_hsotg_core_init
authorMarek Szyprowski <m.szyprowski@samsung.com>
Mon, 20 Oct 2014 10:45:36 +0000 (12:45 +0200)
committerFelipe Balbi <balbi@ti.com>
Mon, 3 Nov 2014 16:01:22 +0000 (10:01 -0600)
This patch changes s3c_hsotg_core_init function to leave hardware in
soft disconnect mode, so the moment of coupling the hardware to the usb
bus can be later controlled by the separate functions for enabling and
disabling soft disconnect mode. This patch is a preparation to rework
pullup() method.

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 f1cde255570a3929a13bde5ed54d53cbc110e75f..5109936c4f3398cd2639c9a1908747f5c1882c4f 100644 (file)
@@ -2124,7 +2124,7 @@ static int s3c_hsotg_corereset(struct s3c_hsotg *hsotg)
  *
  * Issue a soft reset to the core, and await the core finishing it.
  */
-static void s3c_hsotg_core_init(struct s3c_hsotg *hsotg)
+static void s3c_hsotg_core_init_disconnected(struct s3c_hsotg *hsotg)
 {
        s3c_hsotg_corereset(hsotg);
 
@@ -2241,14 +2241,23 @@ static void s3c_hsotg_core_init(struct s3c_hsotg *hsotg)
                readl(hsotg->regs + DOEPCTL0));
 
        /* clear global NAKs */
-       writel(DCTL_CGOUTNAK | DCTL_CGNPINNAK,
+       writel(DCTL_CGOUTNAK | DCTL_CGNPINNAK | DCTL_SFTDISCON,
               hsotg->regs + DCTL);
 
        /* must be at-least 3ms to allow bus to see disconnect */
        mdelay(3);
 
        hsotg->last_rst = jiffies;
+}
+
+static void s3c_hsotg_core_disconnect(struct s3c_hsotg *hsotg)
+{
+       /* set the soft-disconnect bit */
+       __orr32(hsotg->regs + DCTL, DCTL_SFTDISCON);
+}
 
+static void s3c_hsotg_core_connect(struct s3c_hsotg *hsotg)
+{
        /* remove the soft-disconnect and let's go */
        __bic32(hsotg->regs + DCTL, DCTL_SFTDISCON);
 }
@@ -2342,7 +2351,8 @@ irq_retry:
                                kill_all_requests(hsotg, &hsotg->eps[0],
                                                          -ECONNRESET, true);
 
-                               s3c_hsotg_core_init(hsotg);
+                               s3c_hsotg_core_init_disconnected(hsotg);
+                               s3c_hsotg_core_connect(hsotg);
                        }
                }
        }
@@ -2977,7 +2987,8 @@ static int s3c_hsotg_pullup(struct usb_gadget *gadget, int is_on)
        if (is_on) {
                s3c_hsotg_phy_enable(hsotg);
                clk_enable(hsotg->clk);
-               s3c_hsotg_core_init(hsotg);
+               s3c_hsotg_core_init_disconnected(hsotg);
+               s3c_hsotg_core_connect(hsotg);
        } else {
                clk_disable(hsotg->clk);
                s3c_hsotg_phy_disable(hsotg);
@@ -3657,7 +3668,8 @@ static int s3c_hsotg_resume(struct platform_device *pdev)
 
        spin_lock_irqsave(&hsotg->lock, flags);
        s3c_hsotg_phy_enable(hsotg);
-       s3c_hsotg_core_init(hsotg);
+       s3c_hsotg_core_init_disconnected(hsotg);
+       s3c_hsotg_core_connect(hsotg);
        spin_unlock_irqrestore(&hsotg->lock, flags);
 
        return ret;