aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/host
diff options
context:
space:
mode:
authorBoris BREZILLON <b.brezillon@overkiz.com>2013-08-01 13:09:13 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-08-01 23:31:29 -0400
commit6b0a1cf732f917f2eaccb4a0dd6ae7bfc3ccda15 (patch)
treec9c0d48b91fbb64b045d2beaad0b093cdfbb58ea /drivers/usb/host
parent6753f4cf29046f4a2ae68c3a93bf6e6e6dce9fb7 (diff)
USB: ohci-at91: add usb_clk for transition to common clk framework
The AT91 PMC (Power Management Controller) provides an USB clock used by USB Full Speed host (ohci) and USB Full Speed device (udc). The usb drivers (ohci and udc) must configure this clock to 48Mhz. This configuration was formely done in mach-at91/clock.c, but this implementation will be removed when moving to common clk framework. This patch adds support for usb clock retrieval and configuration, and is backward compatible with the current at91 clk implementation (if usb clk is not found, it does not configure/enable it). Changes since v1: - use IS_ENABLED(CONFIG_COMMON_CLK) to isolate new at91 clk support Signed-off-by: Boris BREZILLON <b.brezillon@overkiz.com> Acked-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/host')
-rw-r--r--drivers/usb/host/ohci-at91.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
index a87564559e03..b3cdd1467521 100644
--- a/drivers/usb/host/ohci-at91.c
+++ b/drivers/usb/host/ohci-at91.c
@@ -31,8 +31,8 @@
31#define at91_for_each_port(index) \ 31#define at91_for_each_port(index) \
32 for ((index) = 0; (index) < AT91_MAX_USBH_PORTS; (index)++) 32 for ((index) = 0; (index) < AT91_MAX_USBH_PORTS; (index)++)
33 33
34/* interface and function clocks; sometimes also an AHB clock */ 34/* interface, function and usb clocks; sometimes also an AHB clock */
35static struct clk *iclk, *fclk, *hclk; 35static struct clk *iclk, *fclk, *uclk, *hclk;
36static int clocked; 36static int clocked;
37 37
38extern int usb_disabled(void); 38extern int usb_disabled(void);
@@ -41,6 +41,10 @@ extern int usb_disabled(void);
41 41
42static void at91_start_clock(void) 42static void at91_start_clock(void)
43{ 43{
44 if (IS_ENABLED(CONFIG_COMMON_CLK)) {
45 clk_set_rate(uclk, 48000000);
46 clk_prepare_enable(uclk);
47 }
44 clk_prepare_enable(hclk); 48 clk_prepare_enable(hclk);
45 clk_prepare_enable(iclk); 49 clk_prepare_enable(iclk);
46 clk_prepare_enable(fclk); 50 clk_prepare_enable(fclk);
@@ -52,6 +56,8 @@ static void at91_stop_clock(void)
52 clk_disable_unprepare(fclk); 56 clk_disable_unprepare(fclk);
53 clk_disable_unprepare(iclk); 57 clk_disable_unprepare(iclk);
54 clk_disable_unprepare(hclk); 58 clk_disable_unprepare(hclk);
59 if (IS_ENABLED(CONFIG_COMMON_CLK))
60 clk_disable_unprepare(uclk);
55 clocked = 0; 61 clocked = 0;
56} 62}
57 63
@@ -162,6 +168,14 @@ static int usb_hcd_at91_probe(const struct hc_driver *driver,
162 retval = PTR_ERR(hclk); 168 retval = PTR_ERR(hclk);
163 goto err5; 169 goto err5;
164 } 170 }
171 if (IS_ENABLED(CONFIG_COMMON_CLK)) {
172 uclk = clk_get(&pdev->dev, "usb_clk");
173 if (IS_ERR(uclk)) {
174 dev_err(&pdev->dev, "failed to get uclk\n");
175 retval = PTR_ERR(uclk);
176 goto err6;
177 }
178 }
165 179
166 at91_start_hc(pdev); 180 at91_start_hc(pdev);
167 ohci_hcd_init(hcd_to_ohci(hcd)); 181 ohci_hcd_init(hcd_to_ohci(hcd));
@@ -173,6 +187,9 @@ static int usb_hcd_at91_probe(const struct hc_driver *driver,
173 /* Error handling */ 187 /* Error handling */
174 at91_stop_hc(pdev); 188 at91_stop_hc(pdev);
175 189
190 if (IS_ENABLED(CONFIG_COMMON_CLK))
191 clk_put(uclk);
192 err6:
176 clk_put(hclk); 193 clk_put(hclk);
177 err5: 194 err5:
178 clk_put(fclk); 195 clk_put(fclk);
@@ -212,6 +229,8 @@ static void usb_hcd_at91_remove(struct usb_hcd *hcd,
212 release_mem_region(hcd->rsrc_start, hcd->rsrc_len); 229 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
213 usb_put_hcd(hcd); 230 usb_put_hcd(hcd);
214 231
232 if (IS_ENABLED(CONFIG_COMMON_CLK))
233 clk_put(uclk);
215 clk_put(hclk); 234 clk_put(hclk);
216 clk_put(fclk); 235 clk_put(fclk);
217 clk_put(iclk); 236 clk_put(iclk);