ohci-platform: Add support for controllers with multiple reset lines

At least the EHCI/OHCI found on the Allwinnner H3 SoC needs multiple
reset lines, the controller will not initialize while the reset for
its companion is still asserted, which means we need to de-assert
2 resets for the controller to work.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Hans de Goede 2016-06-02 17:14:06 +02:00 committed by Greg Kroah-Hartman
parent cab4328268
commit 62d9694a00
2 changed files with 24 additions and 21 deletions

View File

@ -14,7 +14,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 - resets : a list of phandle + reset specifier pairs
Example: Example:

View File

@ -33,11 +33,12 @@
#define DRIVER_DESC "OHCI generic platform driver" #define DRIVER_DESC "OHCI generic platform driver"
#define OHCI_MAX_CLKS 3 #define OHCI_MAX_CLKS 3
#define OHCI_MAX_RESETS 2
#define hcd_to_ohci_priv(h) ((struct ohci_platform_priv *)hcd_to_ohci(h)->priv) #define hcd_to_ohci_priv(h) ((struct ohci_platform_priv *)hcd_to_ohci(h)->priv)
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 reset_control *resets[OHCI_MAX_RESETS];
struct phy **phys; struct phy **phys;
int num_phys; int num_phys;
}; };
@ -117,7 +118,7 @@ static int ohci_platform_probe(struct platform_device *dev)
struct usb_ohci_pdata *pdata = dev_get_platdata(&dev->dev); struct usb_ohci_pdata *pdata = dev_get_platdata(&dev->dev);
struct ohci_platform_priv *priv; struct ohci_platform_priv *priv;
struct ohci_hcd *ohci; struct ohci_hcd *ohci;
int err, irq, phy_num, clk = 0; int err, irq, phy_num, clk = 0, rst = 0;
if (usb_disabled()) if (usb_disabled())
return -ENODEV; return -ENODEV;
@ -195,19 +196,21 @@ static int ohci_platform_probe(struct platform_device *dev)
break; break;
} }
} }
for (rst = 0; rst < OHCI_MAX_RESETS; rst++) {
} priv->resets[rst] =
devm_reset_control_get_shared_by_index(
priv->rst = devm_reset_control_get_optional(&dev->dev, NULL); &dev->dev, rst);
if (IS_ERR(priv->rst)) { if (IS_ERR(priv->resets[rst])) {
err = PTR_ERR(priv->rst); err = PTR_ERR(priv->resets[rst]);
if (err == -EPROBE_DEFER) if (err == -EPROBE_DEFER)
goto err_put_clks; goto err_reset;
priv->rst = NULL; priv->resets[rst] = NULL;
} else { break;
err = reset_control_deassert(priv->rst); }
if (err) err = reset_control_deassert(priv->resets[rst]);
goto err_put_clks; if (err)
goto err_reset;
}
} }
if (pdata->big_endian_desc) if (pdata->big_endian_desc)
@ -265,8 +268,8 @@ err_power:
if (pdata->power_off) if (pdata->power_off)
pdata->power_off(dev); pdata->power_off(dev);
err_reset: err_reset:
if (priv->rst) while (--rst >= 0)
reset_control_assert(priv->rst); reset_control_assert(priv->resets[rst]);
err_put_clks: err_put_clks:
while (--clk >= 0) while (--clk >= 0)
clk_put(priv->clks[clk]); clk_put(priv->clks[clk]);
@ -284,15 +287,15 @@ static int ohci_platform_remove(struct platform_device *dev)
struct usb_hcd *hcd = platform_get_drvdata(dev); struct usb_hcd *hcd = platform_get_drvdata(dev);
struct usb_ohci_pdata *pdata = dev_get_platdata(&dev->dev); struct usb_ohci_pdata *pdata = dev_get_platdata(&dev->dev);
struct ohci_platform_priv *priv = hcd_to_ohci_priv(hcd); struct ohci_platform_priv *priv = hcd_to_ohci_priv(hcd);
int clk; int clk, rst;
usb_remove_hcd(hcd); usb_remove_hcd(hcd);
if (pdata->power_off) if (pdata->power_off)
pdata->power_off(dev); pdata->power_off(dev);
if (priv->rst) for (rst = 0; rst < OHCI_MAX_RESETS && priv->resets[rst]; rst++)
reset_control_assert(priv->rst); reset_control_assert(priv->resets[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]);