Merge branch 'usb-next' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb-2.6
[firefly-linux-kernel-4.4.55.git] / drivers / usb / host / ehci-mxc.c
index 535dcae7949fbd3ed08b2572543acb53611640cb..fa59b26fc5bce0c7812dd933a169fddb52ef2837 100644 (file)
@@ -28,7 +28,7 @@
 #define ULPI_VIEWPORT_OFFSET   0x170
 
 struct ehci_mxc_priv {
-       struct clk *usbclk, *ahbclk;
+       struct clk *usbclk, *ahbclk, *phy1clk;
        struct usb_hcd *hcd;
 };
 
@@ -160,17 +160,6 @@ static int ehci_mxc_drv_probe(struct platform_device *pdev)
                goto err_ioremap;
        }
 
-       /* call platform specific init function */
-       if (pdata->init) {
-               ret = pdata->init(pdev);
-               if (ret) {
-                       dev_err(dev, "platform init failed\n");
-                       goto err_init;
-               }
-               /* platforms need some time to settle changed IO settings */
-               mdelay(10);
-       }
-
        /* enable clocks */
        priv->usbclk = clk_get(dev, "usb");
        if (IS_ERR(priv->usbclk)) {
@@ -188,6 +177,28 @@ static int ehci_mxc_drv_probe(struct platform_device *pdev)
                clk_enable(priv->ahbclk);
        }
 
+       /* "dr" device has its own clock */
+       if (pdev->id == 0) {
+               priv->phy1clk = clk_get(dev, "usb_phy1");
+               if (IS_ERR(priv->phy1clk)) {
+                       ret = PTR_ERR(priv->phy1clk);
+                       goto err_clk_phy;
+               }
+               clk_enable(priv->phy1clk);
+       }
+
+
+       /* call platform specific init function */
+       if (pdata->init) {
+               ret = pdata->init(pdev);
+               if (ret) {
+                       dev_err(dev, "platform init failed\n");
+                       goto err_init;
+               }
+               /* platforms need some time to settle changed IO settings */
+               mdelay(10);
+       }
+
        /* setup specific usb hw */
        ret = mxc_initialize_usb_hw(pdev->id, pdata->flags);
        if (ret < 0)
@@ -235,6 +246,11 @@ err_add:
        if (pdata && pdata->exit)
                pdata->exit(pdev);
 err_init:
+       if (priv->phy1clk) {
+               clk_disable(priv->phy1clk);
+               clk_put(priv->phy1clk);
+       }
+err_clk_phy:
        if (priv->ahbclk) {
                clk_disable(priv->ahbclk);
                clk_put(priv->ahbclk);
@@ -278,6 +294,10 @@ static int __exit ehci_mxc_drv_remove(struct platform_device *pdev)
                clk_disable(priv->ahbclk);
                clk_put(priv->ahbclk);
        }
+       if (priv->phy1clk) {
+               clk_disable(priv->phy1clk);
+               clk_put(priv->phy1clk);
+       }
 
        kfree(priv);