aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/usb/gadget/pxa2xx_udc.c68
-rw-r--r--drivers/usb/gadget/pxa2xx_udc.h1
2 files changed, 43 insertions, 26 deletions
diff --git a/drivers/usb/gadget/pxa2xx_udc.c b/drivers/usb/gadget/pxa2xx_udc.c
index 1407ad1c8128..90d0d086b9b8 100644
--- a/drivers/usb/gadget/pxa2xx_udc.c
+++ b/drivers/usb/gadget/pxa2xx_udc.c
@@ -43,6 +43,8 @@
43#include <linux/platform_device.h> 43#include <linux/platform_device.h>
44#include <linux/dma-mapping.h> 44#include <linux/dma-mapping.h>
45#include <linux/irq.h> 45#include <linux/irq.h>
46#include <linux/clk.h>
47#include <linux/err.h>
46 48
47#include <asm/byteorder.h> 49#include <asm/byteorder.h>
48#include <asm/dma.h> 50#include <asm/dma.h>
@@ -1157,7 +1159,7 @@ static void udc_disable(struct pxa2xx_udc *dev)
1157 1159
1158#ifdef CONFIG_ARCH_PXA 1160#ifdef CONFIG_ARCH_PXA
1159 /* Disable clock for USB device */ 1161 /* Disable clock for USB device */
1160 pxa_set_cken(CKEN_USB, 0); 1162 clk_disable(dev->clk);
1161#endif 1163#endif
1162 1164
1163 ep0_idle (dev); 1165 ep0_idle (dev);
@@ -1202,8 +1204,7 @@ static void udc_enable (struct pxa2xx_udc *dev)
1202 1204
1203#ifdef CONFIG_ARCH_PXA 1205#ifdef CONFIG_ARCH_PXA
1204 /* Enable clock for USB device */ 1206 /* Enable clock for USB device */
1205 pxa_set_cken(CKEN_USB, 1); 1207 clk_enable(dev->clk);
1206 udelay(5);
1207#endif 1208#endif
1208 1209
1209 /* try to clear these bits before we enable the udc */ 1210 /* try to clear these bits before we enable the udc */
@@ -2137,6 +2138,14 @@ static int __init pxa2xx_udc_probe(struct platform_device *pdev)
2137 if (irq < 0) 2138 if (irq < 0)
2138 return -ENODEV; 2139 return -ENODEV;
2139 2140
2141#ifdef CONFIG_ARCH_PXA
2142 dev->clk = clk_get(&pdev->dev, "UDCCLK");
2143 if (IS_ERR(dev->clk)) {
2144 retval = PTR_ERR(dev->clk);
2145 goto err_clk;
2146 }
2147#endif
2148
2140 pr_debug("%s: IRQ %d%s%s\n", driver_name, irq, 2149 pr_debug("%s: IRQ %d%s%s\n", driver_name, irq,
2141 dev->has_cfr ? "" : " (!cfr)", 2150 dev->has_cfr ? "" : " (!cfr)",
2142 SIZE_STR "(pio)" 2151 SIZE_STR "(pio)"
@@ -2152,11 +2161,10 @@ static int __init pxa2xx_udc_probe(struct platform_device *pdev)
2152 dev_dbg(&pdev->dev, 2161 dev_dbg(&pdev->dev,
2153 "can't get vbus gpio %d, err: %d\n", 2162 "can't get vbus gpio %d, err: %d\n",
2154 dev->mach->gpio_vbus, retval); 2163 dev->mach->gpio_vbus, retval);
2155 return -EBUSY; 2164 goto err_gpio_vbus;
2156 } 2165 }
2157 gpio_direction_input(dev->mach->gpio_vbus); 2166 gpio_direction_input(dev->mach->gpio_vbus);
2158 vbus_irq = gpio_to_irq(dev->mach->gpio_vbus); 2167 vbus_irq = gpio_to_irq(dev->mach->gpio_vbus);
2159 set_irq_type(vbus_irq, IRQT_BOTHEDGE);
2160 } else 2168 } else
2161 vbus_irq = 0; 2169 vbus_irq = 0;
2162 2170
@@ -2166,9 +2174,7 @@ static int __init pxa2xx_udc_probe(struct platform_device *pdev)
2166 dev_dbg(&pdev->dev, 2174 dev_dbg(&pdev->dev,
2167 "can't get pullup gpio %d, err: %d\n", 2175 "can't get pullup gpio %d, err: %d\n",
2168 dev->mach->gpio_pullup, retval); 2176 dev->mach->gpio_pullup, retval);
2169 if (dev->mach->gpio_vbus) 2177 goto err_gpio_pullup;
2170 gpio_free(dev->mach->gpio_vbus);
2171 return -EBUSY;
2172 } 2178 }
2173 gpio_direction_output(dev->mach->gpio_pullup, 0); 2179 gpio_direction_output(dev->mach->gpio_pullup, 0);
2174 } 2180 }
@@ -2195,11 +2201,7 @@ static int __init pxa2xx_udc_probe(struct platform_device *pdev)
2195 if (retval != 0) { 2201 if (retval != 0) {
2196 printk(KERN_ERR "%s: can't get irq %d, err %d\n", 2202 printk(KERN_ERR "%s: can't get irq %d, err %d\n",
2197 driver_name, irq, retval); 2203 driver_name, irq, retval);
2198 if (dev->mach->gpio_pullup) 2204 goto err_irq1;
2199 gpio_free(dev->mach->gpio_pullup);
2200 if (dev->mach->gpio_vbus)
2201 gpio_free(dev->mach->gpio_vbus);
2202 return -EBUSY;
2203 } 2205 }
2204 dev->got_irq = 1; 2206 dev->got_irq = 1;
2205 2207
@@ -2213,12 +2215,7 @@ static int __init pxa2xx_udc_probe(struct platform_device *pdev)
2213 printk(KERN_ERR "%s: can't get irq %i, err %d\n", 2215 printk(KERN_ERR "%s: can't get irq %i, err %d\n",
2214 driver_name, LUBBOCK_USB_DISC_IRQ, retval); 2216 driver_name, LUBBOCK_USB_DISC_IRQ, retval);
2215lubbock_fail0: 2217lubbock_fail0:
2216 free_irq(irq, dev); 2218 goto err_irq_lub;
2217 if (dev->mach->gpio_pullup)
2218 gpio_free(dev->mach->gpio_pullup);
2219 if (dev->mach->gpio_vbus)
2220 gpio_free(dev->mach->gpio_vbus);
2221 return -EBUSY;
2222 } 2219 }
2223 retval = request_irq(LUBBOCK_USB_IRQ, 2220 retval = request_irq(LUBBOCK_USB_IRQ,
2224 lubbock_vbus_irq, 2221 lubbock_vbus_irq,
@@ -2234,22 +2231,37 @@ lubbock_fail0:
2234#endif 2231#endif
2235 if (vbus_irq) { 2232 if (vbus_irq) {
2236 retval = request_irq(vbus_irq, udc_vbus_irq, 2233 retval = request_irq(vbus_irq, udc_vbus_irq,
2237 IRQF_DISABLED | IRQF_SAMPLE_RANDOM, 2234 IRQF_DISABLED | IRQF_SAMPLE_RANDOM |
2235 IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
2238 driver_name, dev); 2236 driver_name, dev);
2239 if (retval != 0) { 2237 if (retval != 0) {
2240 printk(KERN_ERR "%s: can't get irq %i, err %d\n", 2238 printk(KERN_ERR "%s: can't get irq %i, err %d\n",
2241 driver_name, vbus_irq, retval); 2239 driver_name, vbus_irq, retval);
2242 free_irq(irq, dev); 2240 goto err_vbus_irq;
2243 if (dev->mach->gpio_pullup)
2244 gpio_free(dev->mach->gpio_pullup);
2245 if (dev->mach->gpio_vbus)
2246 gpio_free(dev->mach->gpio_vbus);
2247 return -EBUSY;
2248 } 2241 }
2249 } 2242 }
2250 create_proc_files(); 2243 create_proc_files();
2251 2244
2252 return 0; 2245 return 0;
2246
2247 err_vbus_irq:
2248#ifdef CONFIG_ARCH_LUBBOCK
2249 free_irq(LUBBOCK_USB_DISC_IRQ, dev);
2250 err_irq_lub:
2251#endif
2252 free_irq(irq, dev);
2253 err_irq1:
2254 if (dev->mach->gpio_pullup)
2255 gpio_free(dev->mach->gpio_pullup);
2256 err_gpio_pullup:
2257 if (dev->mach->gpio_vbus)
2258 gpio_free(dev->mach->gpio_vbus);
2259 err_gpio_vbus:
2260#ifdef CONFIG_ARCH_PXA
2261 clk_put(dev->clk);
2262 err_clk:
2263#endif
2264 return retval;
2253} 2265}
2254 2266
2255static void pxa2xx_udc_shutdown(struct platform_device *_dev) 2267static void pxa2xx_udc_shutdown(struct platform_device *_dev)
@@ -2284,6 +2296,10 @@ static int __exit pxa2xx_udc_remove(struct platform_device *pdev)
2284 if (dev->mach->gpio_pullup) 2296 if (dev->mach->gpio_pullup)
2285 gpio_free(dev->mach->gpio_pullup); 2297 gpio_free(dev->mach->gpio_pullup);
2286 2298
2299#ifdef CONFIG_ARCH_PXA
2300 clk_put(dev->clk);
2301#endif
2302
2287 platform_set_drvdata(pdev, NULL); 2303 platform_set_drvdata(pdev, NULL);
2288 the_controller = NULL; 2304 the_controller = NULL;
2289 return 0; 2305 return 0;
diff --git a/drivers/usb/gadget/pxa2xx_udc.h b/drivers/usb/gadget/pxa2xx_udc.h
index 0e5d0e6fb0e2..1db46d705777 100644
--- a/drivers/usb/gadget/pxa2xx_udc.h
+++ b/drivers/usb/gadget/pxa2xx_udc.h
@@ -125,6 +125,7 @@ struct pxa2xx_udc {
125 struct timer_list timer; 125 struct timer_list timer;
126 126
127 struct device *dev; 127 struct device *dev;
128 struct clk *clk;
128 struct pxa2xx_udc_mach_info *mach; 129 struct pxa2xx_udc_mach_info *mach;
129 u64 dma_mask; 130 u64 dma_mask;
130 struct pxa2xx_ep ep [PXA_UDC_NUM_ENDPOINTS]; 131 struct pxa2xx_ep ep [PXA_UDC_NUM_ENDPOINTS];