aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Brownell <david-b@pacbell.net>2007-02-24 15:23:52 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2007-04-27 16:28:33 -0400
commit34ebcd28235dc58633eeb8f7ca603838af23df0d (patch)
tree3e968a667c4fb1d2158a223ed5b8485890269f6c
parentc51e9749ab49c5fa6c9cc1cb96bb5f36a571f553 (diff)
pxa2xx_udc: cleanups, use platform_get_irq
Make the pxa2xx_udc driver fetch its IRQ from platform resources rather than using compile-time constants, so that it works properly on IXP4xx systems not just PXA21x/25x/26x. Other updates: - Do that using platform_get_irq() - Switch to platform_driver_probe() - Handle device_add() errors - Remove "function" sysfs attribute and its potential errors - Whitespace cleanups Signed-off-by: Milan Svoboda <msvoboda@ra.rockwell.com> Signed-off-by: David Brownell <dbrownell@users.sourceforge.net> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r--drivers/usb/gadget/pxa2xx_udc.c96
1 files changed, 43 insertions, 53 deletions
diff --git a/drivers/usb/gadget/pxa2xx_udc.c b/drivers/usb/gadget/pxa2xx_udc.c
index f01890dc8751..1096a30d18c1 100644
--- a/drivers/usb/gadget/pxa2xx_udc.c
+++ b/drivers/usb/gadget/pxa2xx_udc.c
@@ -71,7 +71,7 @@
71 * by the host to interact with this device, and allocates endpoints to 71 * by the host to interact with this device, and allocates endpoints to
72 * the different protocol interfaces. The controller driver virtualizes 72 * the different protocol interfaces. The controller driver virtualizes
73 * usb hardware so that the gadget drivers will be more portable. 73 * usb hardware so that the gadget drivers will be more portable.
74 * 74 *
75 * This UDC hardware wants to implement a bit too much USB protocol, so 75 * This UDC hardware wants to implement a bit too much USB protocol, so
76 * it constrains the sorts of USB configuration change events that work. 76 * it constrains the sorts of USB configuration change events that work.
77 * The errata for these chips are misleading; some "fixed" bugs from 77 * The errata for these chips are misleading; some "fixed" bugs from
@@ -141,7 +141,7 @@ MODULE_PARM_DESC (fifo_mode, "pxa2xx udc fifo mode");
141#endif 141#endif
142 142
143/* --------------------------------------------------------------------------- 143/* ---------------------------------------------------------------------------
144 * endpoint related parts of the api to the usb controller hardware, 144 * endpoint related parts of the api to the usb controller hardware,
145 * used by gadget driver; and the inner talker-to-hardware core. 145 * used by gadget driver; and the inner talker-to-hardware core.
146 * --------------------------------------------------------------------------- 146 * ---------------------------------------------------------------------------
147 */ 147 */
@@ -293,7 +293,7 @@ static int pxa2xx_ep_enable (struct usb_ep *_ep,
293 293
294#ifdef USE_DMA 294#ifdef USE_DMA
295 /* for (some) bulk and ISO endpoints, try to get a DMA channel and 295 /* for (some) bulk and ISO endpoints, try to get a DMA channel and
296 * bind it to the endpoint. otherwise use PIO. 296 * bind it to the endpoint. otherwise use PIO.
297 */ 297 */
298 switch (ep->bmAttributes) { 298 switch (ep->bmAttributes) {
299 case USB_ENDPOINT_XFER_ISOC: 299 case USB_ENDPOINT_XFER_ISOC:
@@ -304,7 +304,7 @@ static int pxa2xx_ep_enable (struct usb_ep *_ep,
304 if (!use_dma || !ep->reg_drcmr) 304 if (!use_dma || !ep->reg_drcmr)
305 break; 305 break;
306 ep->dma = pxa_request_dma ((char *)_ep->name, 306 ep->dma = pxa_request_dma ((char *)_ep->name,
307 (le16_to_cpu (desc->wMaxPacketSize) > 64) 307 (le16_to_cpu (desc->wMaxPacketSize) > 64)
308 ? DMA_PRIO_MEDIUM /* some iso */ 308 ? DMA_PRIO_MEDIUM /* some iso */
309 : DMA_PRIO_LOW, 309 : DMA_PRIO_LOW,
310 dma_nodesc_handler, ep); 310 dma_nodesc_handler, ep);
@@ -361,7 +361,7 @@ static int pxa2xx_ep_disable (struct usb_ep *_ep)
361 */ 361 */
362 362
363/* 363/*
364 * pxa2xx_ep_alloc_request - allocate a request data structure 364 * pxa2xx_ep_alloc_request - allocate a request data structure
365 */ 365 */
366static struct usb_request * 366static struct usb_request *
367pxa2xx_ep_alloc_request (struct usb_ep *_ep, gfp_t gfp_flags) 367pxa2xx_ep_alloc_request (struct usb_ep *_ep, gfp_t gfp_flags)
@@ -378,7 +378,7 @@ pxa2xx_ep_alloc_request (struct usb_ep *_ep, gfp_t gfp_flags)
378 378
379 379
380/* 380/*
381 * pxa2xx_ep_free_request - deallocate a request data structure 381 * pxa2xx_ep_free_request - deallocate a request data structure
382 */ 382 */
383static void 383static void
384pxa2xx_ep_free_request (struct usb_ep *_ep, struct usb_request *_req) 384pxa2xx_ep_free_request (struct usb_ep *_ep, struct usb_request *_req)
@@ -1031,7 +1031,7 @@ pxa2xx_ep_queue(struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags)
1031 1031
1032 1032
1033/* 1033/*
1034 * nuke - dequeue ALL requests 1034 * nuke - dequeue ALL requests
1035 */ 1035 */
1036static void nuke(struct pxa2xx_ep *ep, int status) 1036static void nuke(struct pxa2xx_ep *ep, int status)
1037{ 1037{
@@ -1136,16 +1136,16 @@ static int pxa2xx_ep_set_halt(struct usb_ep *_ep, int value)
1136 ep->dev->req_pending = 0; 1136 ep->dev->req_pending = 0;
1137 ep->dev->ep0state = EP0_STALL; 1137 ep->dev->ep0state = EP0_STALL;
1138 1138
1139 /* and bulk/intr endpoints like dropping stalls too */ 1139 /* and bulk/intr endpoints like dropping stalls too */
1140 } else { 1140 } else {
1141 unsigned i; 1141 unsigned i;
1142 for (i = 0; i < 1000; i += 20) { 1142 for (i = 0; i < 1000; i += 20) {
1143 if (*ep->reg_udccs & UDCCS_BI_SST) 1143 if (*ep->reg_udccs & UDCCS_BI_SST)
1144 break; 1144 break;
1145 udelay(20); 1145 udelay(20);
1146 } 1146 }
1147 } 1147 }
1148 local_irq_restore(flags); 1148 local_irq_restore(flags);
1149 1149
1150 DBG(DBG_VERBOSE, "%s halt\n", _ep->name); 1150 DBG(DBG_VERBOSE, "%s halt\n", _ep->name);
1151 return 0; 1151 return 0;
@@ -1216,7 +1216,7 @@ static struct usb_ep_ops pxa2xx_ep_ops = {
1216 1216
1217 1217
1218/* --------------------------------------------------------------------------- 1218/* ---------------------------------------------------------------------------
1219 * device-scoped parts of the api to the usb controller hardware 1219 * device-scoped parts of the api to the usb controller hardware
1220 * --------------------------------------------------------------------------- 1220 * ---------------------------------------------------------------------------
1221 */ 1221 */
1222 1222
@@ -1239,7 +1239,7 @@ static void udc_enable (struct pxa2xx_udc *);
1239static void udc_disable(struct pxa2xx_udc *); 1239static void udc_disable(struct pxa2xx_udc *);
1240 1240
1241/* We disable the UDC -- and its 48 MHz clock -- whenever it's not 1241/* We disable the UDC -- and its 48 MHz clock -- whenever it's not
1242 * in active use. 1242 * in active use.
1243 */ 1243 */
1244static int pullup(struct pxa2xx_udc *udc, int is_active) 1244static int pullup(struct pxa2xx_udc *udc, int is_active)
1245{ 1245{
@@ -1464,24 +1464,10 @@ done:
1464 1464
1465#endif /* CONFIG_USB_GADGET_DEBUG_FILES */ 1465#endif /* CONFIG_USB_GADGET_DEBUG_FILES */
1466 1466
1467/* "function" sysfs attribute */
1468static ssize_t
1469show_function (struct device *_dev, struct device_attribute *attr, char *buf)
1470{
1471 struct pxa2xx_udc *dev = dev_get_drvdata (_dev);
1472
1473 if (!dev->driver
1474 || !dev->driver->function
1475 || strlen (dev->driver->function) > PAGE_SIZE)
1476 return 0;
1477 return scnprintf (buf, PAGE_SIZE, "%s\n", dev->driver->function);
1478}
1479static DEVICE_ATTR (function, S_IRUGO, show_function, NULL);
1480
1481/*-------------------------------------------------------------------------*/ 1467/*-------------------------------------------------------------------------*/
1482 1468
1483/* 1469/*
1484 * udc_disable - disable USB device controller 1470 * udc_disable - disable USB device controller
1485 */ 1471 */
1486static void udc_disable(struct pxa2xx_udc *dev) 1472static void udc_disable(struct pxa2xx_udc *dev)
1487{ 1473{
@@ -1507,7 +1493,7 @@ static void udc_disable(struct pxa2xx_udc *dev)
1507 1493
1508 1494
1509/* 1495/*
1510 * udc_reinit - initialize software state 1496 * udc_reinit - initialize software state
1511 */ 1497 */
1512static void udc_reinit(struct pxa2xx_udc *dev) 1498static void udc_reinit(struct pxa2xx_udc *dev)
1513{ 1499{
@@ -1635,18 +1621,20 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
1635 dev->gadget.dev.driver = &driver->driver; 1621 dev->gadget.dev.driver = &driver->driver;
1636 dev->pullup = 1; 1622 dev->pullup = 1;
1637 1623
1638 device_add (&dev->gadget.dev); 1624 retval = device_add (&dev->gadget.dev);
1625 if (retval) {
1626fail:
1627 dev->driver = NULL;
1628 dev->gadget.dev.driver = NULL;
1629 return retval;
1630 }
1639 retval = driver->bind(&dev->gadget); 1631 retval = driver->bind(&dev->gadget);
1640 if (retval) { 1632 if (retval) {
1641 DMSG("bind to driver %s --> error %d\n", 1633 DMSG("bind to driver %s --> error %d\n",
1642 driver->driver.name, retval); 1634 driver->driver.name, retval);
1643 device_del (&dev->gadget.dev); 1635 device_del (&dev->gadget.dev);
1644 1636 goto fail;
1645 dev->driver = NULL;
1646 dev->gadget.dev.driver = NULL;
1647 return retval;
1648 } 1637 }
1649 device_create_file(dev->dev, &dev_attr_function);
1650 1638
1651 /* ... then enable host detection and ep0; and we're ready 1639 /* ... then enable host detection and ep0; and we're ready
1652 * for set_configuration as well as eventual disconnect. 1640 * for set_configuration as well as eventual disconnect.
@@ -1704,7 +1692,6 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
1704 dev->driver = NULL; 1692 dev->driver = NULL;
1705 1693
1706 device_del (&dev->gadget.dev); 1694 device_del (&dev->gadget.dev);
1707 device_remove_file(dev->dev, &dev_attr_function);
1708 1695
1709 DMSG("unregistered gadget driver '%s'\n", driver->driver.name); 1696 DMSG("unregistered gadget driver '%s'\n", driver->driver.name);
1710 dump_state(dev); 1697 dump_state(dev);
@@ -2474,12 +2461,12 @@ static struct pxa2xx_udc memory = {
2474#define IXP465_AD 0x00000200 2461#define IXP465_AD 0x00000200
2475 2462
2476/* 2463/*
2477 * probe - binds to the platform device 2464 * probe - binds to the platform device
2478 */ 2465 */
2479static int __init pxa2xx_udc_probe(struct platform_device *pdev) 2466static int __init pxa2xx_udc_probe(struct platform_device *pdev)
2480{ 2467{
2481 struct pxa2xx_udc *dev = &memory; 2468 struct pxa2xx_udc *dev = &memory;
2482 int retval, out_dma = 1, vbus_irq; 2469 int retval, out_dma = 1, vbus_irq, irq;
2483 u32 chiprev; 2470 u32 chiprev;
2484 2471
2485 /* insist on Intel/ARM/XScale */ 2472 /* insist on Intel/ARM/XScale */
@@ -2522,7 +2509,11 @@ static int __init pxa2xx_udc_probe(struct platform_device *pdev)
2522 return -ENODEV; 2509 return -ENODEV;
2523 } 2510 }
2524 2511
2525 pr_debug("%s: IRQ %d%s%s%s\n", driver_name, IRQ_USB, 2512 irq = platform_get_irq(pdev, 0);
2513 if (irq < 0)
2514 return -ENODEV;
2515
2516 pr_debug("%s: IRQ %d%s%s%s\n", driver_name, irq,
2526 dev->has_cfr ? "" : " (!cfr)", 2517 dev->has_cfr ? "" : " (!cfr)",
2527 out_dma ? "" : " (broken dma-out)", 2518 out_dma ? "" : " (broken dma-out)",
2528 SIZE_STR DMASTR 2519 SIZE_STR DMASTR
@@ -2570,11 +2561,11 @@ static int __init pxa2xx_udc_probe(struct platform_device *pdev)
2570 dev->vbus = is_vbus_present(); 2561 dev->vbus = is_vbus_present();
2571 2562
2572 /* irq setup after old hardware state is cleaned up */ 2563 /* irq setup after old hardware state is cleaned up */
2573 retval = request_irq(IRQ_USB, pxa2xx_udc_irq, 2564 retval = request_irq(irq, pxa2xx_udc_irq,
2574 IRQF_DISABLED, driver_name, dev); 2565 IRQF_DISABLED, driver_name, dev);
2575 if (retval != 0) { 2566 if (retval != 0) {
2576 printk(KERN_ERR "%s: can't get irq %i, err %d\n", 2567 printk(KERN_ERR "%s: can't get irq %d, err %d\n",
2577 driver_name, IRQ_USB, retval); 2568 driver_name, irq, retval);
2578 return -EBUSY; 2569 return -EBUSY;
2579 } 2570 }
2580 dev->got_irq = 1; 2571 dev->got_irq = 1;
@@ -2589,7 +2580,7 @@ static int __init pxa2xx_udc_probe(struct platform_device *pdev)
2589 printk(KERN_ERR "%s: can't get irq %i, err %d\n", 2580 printk(KERN_ERR "%s: can't get irq %i, err %d\n",
2590 driver_name, LUBBOCK_USB_DISC_IRQ, retval); 2581 driver_name, LUBBOCK_USB_DISC_IRQ, retval);
2591lubbock_fail0: 2582lubbock_fail0:
2592 free_irq(IRQ_USB, dev); 2583 free_irq(irq, dev);
2593 return -EBUSY; 2584 return -EBUSY;
2594 } 2585 }
2595 retval = request_irq(LUBBOCK_USB_IRQ, 2586 retval = request_irq(LUBBOCK_USB_IRQ,
@@ -2641,7 +2632,7 @@ static int __exit pxa2xx_udc_remove(struct platform_device *pdev)
2641 remove_proc_files(); 2632 remove_proc_files();
2642 2633
2643 if (dev->got_irq) { 2634 if (dev->got_irq) {
2644 free_irq(IRQ_USB, dev); 2635 free_irq(platform_get_irq(pdev, 0), dev);
2645 dev->got_irq = 0; 2636 dev->got_irq = 0;
2646 } 2637 }
2647#ifdef CONFIG_ARCH_LUBBOCK 2638#ifdef CONFIG_ARCH_LUBBOCK
@@ -2668,7 +2659,7 @@ static int __exit pxa2xx_udc_remove(struct platform_device *pdev)
2668 * 2659 *
2669 * For now, we punt and forcibly disconnect from the USB host when PXA 2660 * For now, we punt and forcibly disconnect from the USB host when PXA
2670 * enters any suspend state. While we're disconnected, we always disable 2661 * enters any suspend state. While we're disconnected, we always disable
2671 * the 48MHz USB clock ... allowing PXA sleep and/or 33 MHz idle states. 2662 * the 48MHz USB clock ... allowing PXA sleep and/or 33 MHz idle states.
2672 * Boards without software pullup control shouldn't use those states. 2663 * Boards without software pullup control shouldn't use those states.
2673 * VBUS IRQs should probably be ignored so that the PXA device just acts 2664 * VBUS IRQs should probably be ignored so that the PXA device just acts
2674 * "dead" to USB hosts until system resume. 2665 * "dead" to USB hosts until system resume.
@@ -2701,7 +2692,6 @@ static int pxa2xx_udc_resume(struct platform_device *dev)
2701/*-------------------------------------------------------------------------*/ 2692/*-------------------------------------------------------------------------*/
2702 2693
2703static struct platform_driver udc_driver = { 2694static struct platform_driver udc_driver = {
2704 .probe = pxa2xx_udc_probe,
2705 .shutdown = pxa2xx_udc_shutdown, 2695 .shutdown = pxa2xx_udc_shutdown,
2706 .remove = __exit_p(pxa2xx_udc_remove), 2696 .remove = __exit_p(pxa2xx_udc_remove),
2707 .suspend = pxa2xx_udc_suspend, 2697 .suspend = pxa2xx_udc_suspend,
@@ -2715,7 +2705,7 @@ static struct platform_driver udc_driver = {
2715static int __init udc_init(void) 2705static int __init udc_init(void)
2716{ 2706{
2717 printk(KERN_INFO "%s: version %s\n", driver_name, DRIVER_VERSION); 2707 printk(KERN_INFO "%s: version %s\n", driver_name, DRIVER_VERSION);
2718 return platform_driver_register(&udc_driver); 2708 return platform_driver_probe(&udc_driver, pxa2xx_udc_probe);
2719} 2709}
2720module_init(udc_init); 2710module_init(udc_init);
2721 2711