Commit 4d175f34 authored by Mark Brown's avatar Mark Brown Committed by Felipe Balbi

usb: phy: nop: Defer clock prepare until PHY init

Since we only enable the PHY clock on init and the PHY init and shutdown
does not occur in atomitc context there is no need to prepare the clock
before it is enabled.  Move the clk_prepare() operations to go along
with the enables, allowing the clock to be fully idle when not in use.
Signed-off-by: default avatarMark Brown <broonie@linaro.org>
Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
parent 15c03dd4
...@@ -59,15 +59,14 @@ static int am335x_phy_probe(struct platform_device *pdev) ...@@ -59,15 +59,14 @@ static int am335x_phy_probe(struct platform_device *pdev)
ret = usb_add_phy_dev(&am_phy->usb_phy_gen.phy); ret = usb_add_phy_dev(&am_phy->usb_phy_gen.phy);
if (ret) if (ret)
goto err_add; return ret;
am_phy->usb_phy_gen.phy.init = am335x_init; am_phy->usb_phy_gen.phy.init = am335x_init;
am_phy->usb_phy_gen.phy.shutdown = am335x_shutdown; am_phy->usb_phy_gen.phy.shutdown = am335x_shutdown;
platform_set_drvdata(pdev, am_phy); platform_set_drvdata(pdev, am_phy);
return 0; return 0;
err_add:
usb_phy_gen_cleanup_phy(&am_phy->usb_phy_gen);
return ret; return ret;
} }
......
...@@ -74,7 +74,7 @@ int usb_gen_phy_init(struct usb_phy *phy) ...@@ -74,7 +74,7 @@ int usb_gen_phy_init(struct usb_phy *phy)
} }
if (!IS_ERR(nop->clk)) if (!IS_ERR(nop->clk))
clk_enable(nop->clk); clk_prepare_enable(nop->clk);
if (!IS_ERR(nop->reset)) { if (!IS_ERR(nop->reset)) {
/* De-assert RESET */ /* De-assert RESET */
...@@ -97,7 +97,7 @@ void usb_gen_phy_shutdown(struct usb_phy *phy) ...@@ -97,7 +97,7 @@ void usb_gen_phy_shutdown(struct usb_phy *phy)
} }
if (!IS_ERR(nop->clk)) if (!IS_ERR(nop->clk))
clk_disable(nop->clk); clk_disable_unprepare(nop->clk);
if (!IS_ERR(nop->vcc)) { if (!IS_ERR(nop->vcc)) {
if (regulator_disable(nop->vcc)) if (regulator_disable(nop->vcc))
...@@ -160,14 +160,6 @@ int usb_phy_gen_create_phy(struct device *dev, struct usb_phy_gen_xceiv *nop, ...@@ -160,14 +160,6 @@ int usb_phy_gen_create_phy(struct device *dev, struct usb_phy_gen_xceiv *nop,
} }
} }
if (!IS_ERR(nop->clk)) {
err = clk_prepare(nop->clk);
if (err) {
dev_err(dev, "Error preparing clock\n");
return err;
}
}
nop->vcc = devm_regulator_get(dev, "vcc"); nop->vcc = devm_regulator_get(dev, "vcc");
if (IS_ERR(nop->vcc)) { if (IS_ERR(nop->vcc)) {
dev_dbg(dev, "Error getting vcc regulator: %ld\n", dev_dbg(dev, "Error getting vcc regulator: %ld\n",
...@@ -200,13 +192,6 @@ int usb_phy_gen_create_phy(struct device *dev, struct usb_phy_gen_xceiv *nop, ...@@ -200,13 +192,6 @@ int usb_phy_gen_create_phy(struct device *dev, struct usb_phy_gen_xceiv *nop,
} }
EXPORT_SYMBOL_GPL(usb_phy_gen_create_phy); EXPORT_SYMBOL_GPL(usb_phy_gen_create_phy);
void usb_phy_gen_cleanup_phy(struct usb_phy_gen_xceiv *nop)
{
if (!IS_ERR(nop->clk))
clk_unprepare(nop->clk);
}
EXPORT_SYMBOL_GPL(usb_phy_gen_cleanup_phy);
static int usb_phy_gen_xceiv_probe(struct platform_device *pdev) static int usb_phy_gen_xceiv_probe(struct platform_device *pdev)
{ {
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
...@@ -252,15 +237,13 @@ static int usb_phy_gen_xceiv_probe(struct platform_device *pdev) ...@@ -252,15 +237,13 @@ static int usb_phy_gen_xceiv_probe(struct platform_device *pdev)
if (err) { if (err) {
dev_err(&pdev->dev, "can't register transceiver, err: %d\n", dev_err(&pdev->dev, "can't register transceiver, err: %d\n",
err); err);
goto err_add; return err;
} }
platform_set_drvdata(pdev, nop); platform_set_drvdata(pdev, nop);
return 0; return 0;
err_add:
usb_phy_gen_cleanup_phy(nop);
return err; return err;
} }
...@@ -268,7 +251,6 @@ static int usb_phy_gen_xceiv_remove(struct platform_device *pdev) ...@@ -268,7 +251,6 @@ static int usb_phy_gen_xceiv_remove(struct platform_device *pdev)
{ {
struct usb_phy_gen_xceiv *nop = platform_get_drvdata(pdev); struct usb_phy_gen_xceiv *nop = platform_get_drvdata(pdev);
usb_phy_gen_cleanup_phy(nop);
usb_remove_phy(&nop->phy); usb_remove_phy(&nop->phy);
return 0; return 0;
......
...@@ -15,6 +15,5 @@ void usb_gen_phy_shutdown(struct usb_phy *phy); ...@@ -15,6 +15,5 @@ void usb_gen_phy_shutdown(struct usb_phy *phy);
int usb_phy_gen_create_phy(struct device *dev, struct usb_phy_gen_xceiv *nop, int usb_phy_gen_create_phy(struct device *dev, struct usb_phy_gen_xceiv *nop,
enum usb_phy_type type, u32 clk_rate, bool needs_vcc, enum usb_phy_type type, u32 clk_rate, bool needs_vcc,
bool needs_reset); bool needs_reset);
void usb_phy_gen_cleanup_phy(struct usb_phy_gen_xceiv *nop);
#endif #endif
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