diff options
-rw-r--r-- | arch/arm/mach-davinci/usb-da8xx.c | 34 |
1 files changed, 15 insertions, 19 deletions
diff --git a/arch/arm/mach-davinci/usb-da8xx.c b/arch/arm/mach-davinci/usb-da8xx.c index c6feecf7ae24..9a6af0bd5dc3 100644 --- a/arch/arm/mach-davinci/usb-da8xx.c +++ b/arch/arm/mach-davinci/usb-da8xx.c | |||
@@ -22,6 +22,8 @@ | |||
22 | #define DA8XX_USB0_BASE 0x01e00000 | 22 | #define DA8XX_USB0_BASE 0x01e00000 |
23 | #define DA8XX_USB1_BASE 0x01e25000 | 23 | #define DA8XX_USB1_BASE 0x01e25000 |
24 | 24 | ||
25 | static struct clk *usb20_clk; | ||
26 | |||
25 | static struct platform_device da8xx_usb_phy = { | 27 | static struct platform_device da8xx_usb_phy = { |
26 | .name = "da8xx-usb-phy", | 28 | .name = "da8xx-usb-phy", |
27 | .id = -1, | 29 | .id = -1, |
@@ -158,26 +160,13 @@ int __init da8xx_register_usb_refclkin(int rate) | |||
158 | 160 | ||
159 | static void usb20_phy_clk_enable(struct clk *clk) | 161 | static void usb20_phy_clk_enable(struct clk *clk) |
160 | { | 162 | { |
161 | struct clk *usb20_clk; | ||
162 | int err; | ||
163 | u32 val; | 163 | u32 val; |
164 | u32 timeout = 500000; /* 500 msec */ | 164 | u32 timeout = 500000; /* 500 msec */ |
165 | 165 | ||
166 | val = readl(DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP2_REG)); | 166 | val = readl(DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP2_REG)); |
167 | 167 | ||
168 | usb20_clk = clk_get(&da8xx_usb20_dev.dev, "usb20"); | ||
169 | if (IS_ERR(usb20_clk)) { | ||
170 | pr_err("could not get usb20 clk: %ld\n", PTR_ERR(usb20_clk)); | ||
171 | return; | ||
172 | } | ||
173 | |||
174 | /* The USB 2.O PLL requires that the USB 2.O PSC is enabled as well. */ | 168 | /* The USB 2.O PLL requires that the USB 2.O PSC is enabled as well. */ |
175 | err = clk_prepare_enable(usb20_clk); | 169 | davinci_clk_enable(usb20_clk); |
176 | if (err) { | ||
177 | pr_err("failed to enable usb20 clk: %d\n", err); | ||
178 | clk_put(usb20_clk); | ||
179 | return; | ||
180 | } | ||
181 | 170 | ||
182 | /* | 171 | /* |
183 | * Turn on the USB 2.0 PHY, but just the PLL, and not OTG. The USB 1.1 | 172 | * Turn on the USB 2.0 PHY, but just the PLL, and not OTG. The USB 1.1 |
@@ -197,8 +186,7 @@ static void usb20_phy_clk_enable(struct clk *clk) | |||
197 | 186 | ||
198 | pr_err("Timeout waiting for USB 2.0 PHY clock good\n"); | 187 | pr_err("Timeout waiting for USB 2.0 PHY clock good\n"); |
199 | done: | 188 | done: |
200 | clk_disable_unprepare(usb20_clk); | 189 | davinci_clk_disable(usb20_clk); |
201 | clk_put(usb20_clk); | ||
202 | } | 190 | } |
203 | 191 | ||
204 | static void usb20_phy_clk_disable(struct clk *clk) | 192 | static void usb20_phy_clk_disable(struct clk *clk) |
@@ -285,11 +273,19 @@ static struct clk_lookup usb20_phy_clk_lookup = | |||
285 | int __init da8xx_register_usb20_phy_clk(bool use_usb_refclkin) | 273 | int __init da8xx_register_usb20_phy_clk(bool use_usb_refclkin) |
286 | { | 274 | { |
287 | struct clk *parent; | 275 | struct clk *parent; |
288 | int ret = 0; | 276 | int ret; |
277 | |||
278 | usb20_clk = clk_get(&da8xx_usb20_dev.dev, "usb20"); | ||
279 | ret = PTR_ERR_OR_ZERO(usb20_clk); | ||
280 | if (ret) | ||
281 | return ret; | ||
289 | 282 | ||
290 | parent = clk_get(NULL, use_usb_refclkin ? "usb_refclkin" : "pll0_aux"); | 283 | parent = clk_get(NULL, use_usb_refclkin ? "usb_refclkin" : "pll0_aux"); |
291 | if (IS_ERR(parent)) | 284 | ret = PTR_ERR_OR_ZERO(parent); |
292 | return PTR_ERR(parent); | 285 | if (ret) { |
286 | clk_put(usb20_clk); | ||
287 | return ret; | ||
288 | } | ||
293 | 289 | ||
294 | usb20_phy_clk.parent = parent; | 290 | usb20_phy_clk.parent = parent; |
295 | ret = clk_register(&usb20_phy_clk); | 291 | ret = clk_register(&usb20_phy_clk); |