Commit c943740c authored by Sascha Hauer's avatar Sascha Hauer

USB ehci mxc: sanitize clock handling

Every i.MX ehci controller has a ahb and a ipg clock, so request
it on every SoC. Do not make a special case for the usb phy clock
of the i.MX51. Just request it but make it optional.
Signed-off-by: default avatarSascha Hauer <s.hauer@pengutronix.de>
parent 198ad2ce
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
#define ULPI_VIEWPORT_OFFSET 0x170 #define ULPI_VIEWPORT_OFFSET 0x170
struct ehci_mxc_priv { struct ehci_mxc_priv {
struct clk *usbclk, *ahbclk, *phy1clk; struct clk *usbclk, *ahbclk, *phyclk;
struct usb_hcd *hcd; struct usb_hcd *hcd;
}; };
...@@ -166,31 +166,26 @@ static int ehci_mxc_drv_probe(struct platform_device *pdev) ...@@ -166,31 +166,26 @@ static int ehci_mxc_drv_probe(struct platform_device *pdev)
} }
/* enable clocks */ /* enable clocks */
priv->usbclk = clk_get(dev, "usb"); priv->usbclk = clk_get(dev, "ipg");
if (IS_ERR(priv->usbclk)) { if (IS_ERR(priv->usbclk)) {
ret = PTR_ERR(priv->usbclk); ret = PTR_ERR(priv->usbclk);
goto err_clk; goto err_clk;
} }
clk_prepare_enable(priv->usbclk); clk_prepare_enable(priv->usbclk);
if (!cpu_is_mx35() && !cpu_is_mx25()) { priv->ahbclk = clk_get(dev, "ahb");
priv->ahbclk = clk_get(dev, "usb_ahb");
if (IS_ERR(priv->ahbclk)) { if (IS_ERR(priv->ahbclk)) {
ret = PTR_ERR(priv->ahbclk); ret = PTR_ERR(priv->ahbclk);
goto err_clk_ahb; goto err_clk_ahb;
} }
clk_prepare_enable(priv->ahbclk); clk_prepare_enable(priv->ahbclk);
}
/* "dr" device has its own clock on i.MX51 */ /* "dr" device has its own clock on i.MX51 */
if (cpu_is_mx51() && (pdev->id == 0)) { priv->phyclk = clk_get(dev, "phy");
priv->phy1clk = clk_get(dev, "usb_phy1"); if (IS_ERR(priv->phyclk))
if (IS_ERR(priv->phy1clk)) { priv->phyclk = NULL;
ret = PTR_ERR(priv->phy1clk); if (priv->phyclk)
goto err_clk_phy; clk_prepare_enable(priv->phyclk);
}
clk_prepare_enable(priv->phy1clk);
}
/* call platform specific init function */ /* call platform specific init function */
...@@ -265,15 +260,13 @@ static int ehci_mxc_drv_probe(struct platform_device *pdev) ...@@ -265,15 +260,13 @@ static int ehci_mxc_drv_probe(struct platform_device *pdev)
if (pdata && pdata->exit) if (pdata && pdata->exit)
pdata->exit(pdev); pdata->exit(pdev);
err_init: err_init:
if (priv->phy1clk) { if (priv->phyclk) {
clk_disable_unprepare(priv->phy1clk); clk_disable_unprepare(priv->phyclk);
clk_put(priv->phy1clk); clk_put(priv->phyclk);
} }
err_clk_phy:
if (priv->ahbclk) {
clk_disable_unprepare(priv->ahbclk); clk_disable_unprepare(priv->ahbclk);
clk_put(priv->ahbclk); clk_put(priv->ahbclk);
}
err_clk_ahb: err_clk_ahb:
clk_disable_unprepare(priv->usbclk); clk_disable_unprepare(priv->usbclk);
clk_put(priv->usbclk); clk_put(priv->usbclk);
...@@ -309,13 +302,12 @@ static int __exit ehci_mxc_drv_remove(struct platform_device *pdev) ...@@ -309,13 +302,12 @@ static int __exit ehci_mxc_drv_remove(struct platform_device *pdev)
clk_disable_unprepare(priv->usbclk); clk_disable_unprepare(priv->usbclk);
clk_put(priv->usbclk); clk_put(priv->usbclk);
if (priv->ahbclk) {
clk_disable_unprepare(priv->ahbclk); clk_disable_unprepare(priv->ahbclk);
clk_put(priv->ahbclk); clk_put(priv->ahbclk);
}
if (priv->phy1clk) { if (priv->phyclk) {
clk_disable_unprepare(priv->phy1clk); clk_disable_unprepare(priv->phyclk);
clk_put(priv->phy1clk); clk_put(priv->phyclk);
} }
kfree(priv); kfree(priv);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment