at91: USB gadget subsystem cleanup and driver fix.
[openwrt/svn-archive/archive.git] / target / linux / at91 / patches / 200-ARM-at91-udc-clockfix-backport.patch
1 --- a/drivers/usb/gadget/udc/at91_udc.c
2 +++ b/drivers/usb/gadget/udc/at91_udc.c
3 @@ -870,8 +870,6 @@
4 return;
5 udc->clocked = 1;
6
7 - if (IS_ENABLED(CONFIG_COMMON_CLK))
8 - clk_enable(udc->uclk);
9 clk_enable(udc->iclk);
10 clk_enable(udc->fclk);
11 }
12 @@ -884,8 +882,6 @@
13 udc->gadget.speed = USB_SPEED_UNKNOWN;
14 clk_disable(udc->fclk);
15 clk_disable(udc->iclk);
16 - if (IS_ENABLED(CONFIG_COMMON_CLK))
17 - clk_disable(udc->uclk);
18 }
19
20 /*
21 @@ -1766,27 +1762,18 @@
22 udc_reinit(udc);
23
24 /* get interface and function clocks */
25 - udc->iclk = clk_get(dev, "udc_clk");
26 - udc->fclk = clk_get(dev, "udpck");
27 - if (IS_ENABLED(CONFIG_COMMON_CLK))
28 - udc->uclk = clk_get(dev, "usb_clk");
29 - if (IS_ERR(udc->iclk) || IS_ERR(udc->fclk) ||
30 - (IS_ENABLED(CONFIG_COMMON_CLK) && IS_ERR(udc->uclk))) {
31 + udc->iclk = clk_get(dev, "pclk");
32 + udc->fclk = clk_get(dev, "hclk");
33 + if (IS_ERR(udc->iclk) || IS_ERR(udc->fclk)) {
34 DBG("clocks missing\n");
35 retval = -ENODEV;
36 goto fail1;
37 }
38
39 - /* don't do anything until we have both gadget driver and VBUS */
40 - if (IS_ENABLED(CONFIG_COMMON_CLK)) {
41 - clk_set_rate(udc->uclk, 48000000);
42 - retval = clk_prepare(udc->uclk);
43 - if (retval)
44 - goto fail1;
45 - }
46 + clk_set_rate(udc->fclk, 48000000);
47 retval = clk_prepare(udc->fclk);
48 if (retval)
49 - goto fail1a;
50 + goto fail1;
51
52 retval = clk_prepare_enable(udc->iclk);
53 if (retval)
54 @@ -1860,12 +1847,7 @@
55 clk_unprepare(udc->iclk);
56 fail1b:
57 clk_unprepare(udc->fclk);
58 -fail1a:
59 - if (IS_ENABLED(CONFIG_COMMON_CLK))
60 - clk_unprepare(udc->uclk);
61 fail1:
62 - if (IS_ENABLED(CONFIG_COMMON_CLK) && !IS_ERR(udc->uclk))
63 - clk_put(udc->uclk);
64 if (!IS_ERR(udc->fclk))
65 clk_put(udc->fclk);
66 if (!IS_ERR(udc->iclk))
67 @@ -1911,15 +1893,11 @@
68 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
69 release_mem_region(res->start, resource_size(res));
70
71 - if (IS_ENABLED(CONFIG_COMMON_CLK))
72 - clk_unprepare(udc->uclk);
73 clk_unprepare(udc->fclk);
74 clk_unprepare(udc->iclk);
75
76 clk_put(udc->iclk);
77 clk_put(udc->fclk);
78 - if (IS_ENABLED(CONFIG_COMMON_CLK))
79 - clk_put(udc->uclk);
80
81 return 0;
82 }