aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Brown <broonie@linaro.org>2013-08-11 10:26:04 -0400
committerFelipe Balbi <balbi@ti.com>2013-10-01 10:31:10 -0400
commit4d175f340c9c055482688d2205038413dc7b6f1e (patch)
tree5da0d924d671ffcd059aac014aab990ee499a7f0
parent15c03dd4859ab16f9212238f29dd315654aa94f6 (diff)
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: Mark Brown <broonie@linaro.org> Signed-off-by: Felipe Balbi <balbi@ti.com>
-rw-r--r--drivers/usb/phy/phy-am335x.c5
-rw-r--r--drivers/usb/phy/phy-generic.c24
-rw-r--r--drivers/usb/phy/phy-generic.h1
3 files changed, 5 insertions, 25 deletions
diff --git a/drivers/usb/phy/phy-am335x.c b/drivers/usb/phy/phy-am335x.c
index c4d614d1f173..f836dc68104c 100644
--- a/drivers/usb/phy/phy-am335x.c
+++ b/drivers/usb/phy/phy-am335x.c
@@ -59,15 +59,14 @@ static int am335x_phy_probe(struct platform_device *pdev)
59 59
60 ret = usb_add_phy_dev(&am_phy->usb_phy_gen.phy); 60 ret = usb_add_phy_dev(&am_phy->usb_phy_gen.phy);
61 if (ret) 61 if (ret)
62 goto err_add; 62 return ret;
63 am_phy->usb_phy_gen.phy.init = am335x_init; 63 am_phy->usb_phy_gen.phy.init = am335x_init;
64 am_phy->usb_phy_gen.phy.shutdown = am335x_shutdown; 64 am_phy->usb_phy_gen.phy.shutdown = am335x_shutdown;
65 65
66 platform_set_drvdata(pdev, am_phy); 66 platform_set_drvdata(pdev, am_phy);
67
67 return 0; 68 return 0;
68 69
69err_add:
70 usb_phy_gen_cleanup_phy(&am_phy->usb_phy_gen);
71 return ret; 70 return ret;
72} 71}
73 72
diff --git a/drivers/usb/phy/phy-generic.c b/drivers/usb/phy/phy-generic.c
index efe59f3f7fda..fcc31045fda7 100644
--- a/drivers/usb/phy/phy-generic.c
+++ b/drivers/usb/phy/phy-generic.c
@@ -74,7 +74,7 @@ int usb_gen_phy_init(struct usb_phy *phy)
74 } 74 }
75 75
76 if (!IS_ERR(nop->clk)) 76 if (!IS_ERR(nop->clk))
77 clk_enable(nop->clk); 77 clk_prepare_enable(nop->clk);
78 78
79 if (!IS_ERR(nop->reset)) { 79 if (!IS_ERR(nop->reset)) {
80 /* De-assert RESET */ 80 /* De-assert RESET */
@@ -97,7 +97,7 @@ void usb_gen_phy_shutdown(struct usb_phy *phy)
97 } 97 }
98 98
99 if (!IS_ERR(nop->clk)) 99 if (!IS_ERR(nop->clk))
100 clk_disable(nop->clk); 100 clk_disable_unprepare(nop->clk);
101 101
102 if (!IS_ERR(nop->vcc)) { 102 if (!IS_ERR(nop->vcc)) {
103 if (regulator_disable(nop->vcc)) 103 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 } 160 }
161 } 161 }
162 162
163 if (!IS_ERR(nop->clk)) {
164 err = clk_prepare(nop->clk);
165 if (err) {
166 dev_err(dev, "Error preparing clock\n");
167 return err;
168 }
169 }
170
171 nop->vcc = devm_regulator_get(dev, "vcc"); 163 nop->vcc = devm_regulator_get(dev, "vcc");
172 if (IS_ERR(nop->vcc)) { 164 if (IS_ERR(nop->vcc)) {
173 dev_dbg(dev, "Error getting vcc regulator: %ld\n", 165 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} 192}
201EXPORT_SYMBOL_GPL(usb_phy_gen_create_phy); 193EXPORT_SYMBOL_GPL(usb_phy_gen_create_phy);
202 194
203void usb_phy_gen_cleanup_phy(struct usb_phy_gen_xceiv *nop)
204{
205 if (!IS_ERR(nop->clk))
206 clk_unprepare(nop->clk);
207}
208EXPORT_SYMBOL_GPL(usb_phy_gen_cleanup_phy);
209
210static int usb_phy_gen_xceiv_probe(struct platform_device *pdev) 195static int usb_phy_gen_xceiv_probe(struct platform_device *pdev)
211{ 196{
212 struct device *dev = &pdev->dev; 197 struct device *dev = &pdev->dev;
@@ -252,15 +237,13 @@ static int usb_phy_gen_xceiv_probe(struct platform_device *pdev)
252 if (err) { 237 if (err) {
253 dev_err(&pdev->dev, "can't register transceiver, err: %d\n", 238 dev_err(&pdev->dev, "can't register transceiver, err: %d\n",
254 err); 239 err);
255 goto err_add; 240 return err;
256 } 241 }
257 242
258 platform_set_drvdata(pdev, nop); 243 platform_set_drvdata(pdev, nop);
259 244
260 return 0; 245 return 0;
261 246
262err_add:
263 usb_phy_gen_cleanup_phy(nop);
264 return err; 247 return err;
265} 248}
266 249
@@ -268,7 +251,6 @@ static int usb_phy_gen_xceiv_remove(struct platform_device *pdev)
268{ 251{
269 struct usb_phy_gen_xceiv *nop = platform_get_drvdata(pdev); 252 struct usb_phy_gen_xceiv *nop = platform_get_drvdata(pdev);
270 253
271 usb_phy_gen_cleanup_phy(nop);
272 usb_remove_phy(&nop->phy); 254 usb_remove_phy(&nop->phy);
273 255
274 return 0; 256 return 0;
diff --git a/drivers/usb/phy/phy-generic.h b/drivers/usb/phy/phy-generic.h
index 61687d5a965b..386d11b375aa 100644
--- a/drivers/usb/phy/phy-generic.h
+++ b/drivers/usb/phy/phy-generic.h
@@ -15,6 +15,5 @@ void usb_gen_phy_shutdown(struct usb_phy *phy);
15int usb_phy_gen_create_phy(struct device *dev, struct usb_phy_gen_xceiv *nop, 15int usb_phy_gen_create_phy(struct device *dev, struct usb_phy_gen_xceiv *nop,
16 enum usb_phy_type type, u32 clk_rate, bool needs_vcc, 16 enum usb_phy_type type, u32 clk_rate, bool needs_vcc,
17 bool needs_reset); 17 bool needs_reset);
18void usb_phy_gen_cleanup_phy(struct usb_phy_gen_xceiv *nop);
19 18
20#endif 19#endif