Commit 4615f3bd authored by Maxime Ripard's avatar Maxime Ripard Committed by Greg Kroah-Hartman

usb: ohci-platform: Enable optional use of reset controller

The OHCI controllers used in the Allwinner A31 are asserted in reset using a
global reset controller.

Add optional support for such a controller in the OHCI platform driver.
Signed-off-by: default avatarMaxime Ripard <maxime.ripard@free-electrons.com>
Reviewed-by: default avatarHans de Goede <hdegoede@redhat.com>
Acked-by: default avatarAlan Stern <stern@rowland.harvard.edu>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 38e0c109
...@@ -12,6 +12,7 @@ Optional properties: ...@@ -12,6 +12,7 @@ Optional properties:
- clocks : a list of phandle + clock specifier pairs - clocks : a list of phandle + clock specifier pairs
- phys : phandle + phy specifier pair - phys : phandle + phy specifier pair
- phy-names : "usb" - phy-names : "usb"
- resets : phandle + reset specifier pair
Example: Example:
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include <linux/err.h> #include <linux/err.h>
#include <linux/phy/phy.h> #include <linux/phy/phy.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/reset.h>
#include <linux/usb/ohci_pdriver.h> #include <linux/usb/ohci_pdriver.h>
#include <linux/usb.h> #include <linux/usb.h>
#include <linux/usb/hcd.h> #include <linux/usb/hcd.h>
...@@ -36,6 +37,7 @@ ...@@ -36,6 +37,7 @@
struct ohci_platform_priv { struct ohci_platform_priv {
struct clk *clks[OHCI_MAX_CLKS]; struct clk *clks[OHCI_MAX_CLKS];
struct reset_control *rst;
struct phy *phy; struct phy *phy;
}; };
...@@ -191,6 +193,19 @@ static int ohci_platform_probe(struct platform_device *dev) ...@@ -191,6 +193,19 @@ static int ohci_platform_probe(struct platform_device *dev)
break; break;
} }
} }
}
priv->rst = devm_reset_control_get_optional(&dev->dev, NULL);
if (IS_ERR(priv->rst)) {
err = PTR_ERR(priv->rst);
if (err == -EPROBE_DEFER)
goto err_put_clks;
priv->rst = NULL;
} else {
err = reset_control_deassert(priv->rst);
if (err)
goto err_put_clks;
} }
if (pdata->big_endian_desc) if (pdata->big_endian_desc)
...@@ -203,7 +218,7 @@ static int ohci_platform_probe(struct platform_device *dev) ...@@ -203,7 +218,7 @@ static int ohci_platform_probe(struct platform_device *dev)
dev_err(&dev->dev, dev_err(&dev->dev,
"Error: CONFIG_USB_OHCI_BIG_ENDIAN_MMIO not set\n"); "Error: CONFIG_USB_OHCI_BIG_ENDIAN_MMIO not set\n");
err = -EINVAL; err = -EINVAL;
goto err_put_clks; goto err_reset;
} }
#endif #endif
#ifndef CONFIG_USB_OHCI_BIG_ENDIAN_DESC #ifndef CONFIG_USB_OHCI_BIG_ENDIAN_DESC
...@@ -211,14 +226,14 @@ static int ohci_platform_probe(struct platform_device *dev) ...@@ -211,14 +226,14 @@ static int ohci_platform_probe(struct platform_device *dev)
dev_err(&dev->dev, dev_err(&dev->dev,
"Error: CONFIG_USB_OHCI_BIG_ENDIAN_DESC not set\n"); "Error: CONFIG_USB_OHCI_BIG_ENDIAN_DESC not set\n");
err = -EINVAL; err = -EINVAL;
goto err_put_clks; goto err_reset;
} }
#endif #endif
if (pdata->power_on) { if (pdata->power_on) {
err = pdata->power_on(dev); err = pdata->power_on(dev);
if (err < 0) if (err < 0)
goto err_put_clks; goto err_reset;
} }
hcd->rsrc_start = res_mem->start; hcd->rsrc_start = res_mem->start;
...@@ -242,6 +257,9 @@ static int ohci_platform_probe(struct platform_device *dev) ...@@ -242,6 +257,9 @@ static int ohci_platform_probe(struct platform_device *dev)
err_power: err_power:
if (pdata->power_off) if (pdata->power_off)
pdata->power_off(dev); pdata->power_off(dev);
err_reset:
if (priv->rst)
reset_control_assert(priv->rst);
err_put_clks: err_put_clks:
while (--clk >= 0) while (--clk >= 0)
clk_put(priv->clks[clk]); clk_put(priv->clks[clk]);
...@@ -266,6 +284,9 @@ static int ohci_platform_remove(struct platform_device *dev) ...@@ -266,6 +284,9 @@ static int ohci_platform_remove(struct platform_device *dev)
if (pdata->power_off) if (pdata->power_off)
pdata->power_off(dev); pdata->power_off(dev);
if (priv->rst)
reset_control_assert(priv->rst);
for (clk = 0; clk < OHCI_MAX_CLKS && priv->clks[clk]; clk++) for (clk = 0; clk < OHCI_MAX_CLKS && priv->clks[clk]; clk++)
clk_put(priv->clks[clk]); clk_put(priv->clks[clk]);
......
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