Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

USB: pxa2xx_udc: use generic gpio layer

This patch lets the pxa2xx_udc use the generic gpio layer,
on the relevant PXA and IXP systems.

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>

authored by

Milan Svoboda and committed by
Greg Kroah-Hartman
9068a4c6 e4f74737

+49 -69
+49 -14
drivers/usb/gadget/pxa2xx_udc.c
··· 27 27 #undef DEBUG 28 28 // #define VERBOSE DBG_VERBOSE 29 29 30 + #include <linux/device.h> 30 31 #include <linux/module.h> 31 32 #include <linux/kernel.h> 32 33 #include <linux/ioport.h> ··· 47 46 48 47 #include <asm/byteorder.h> 49 48 #include <asm/dma.h> 49 + #include <asm/gpio.h> 50 50 #include <asm/io.h> 51 51 #include <asm/system.h> 52 52 #include <asm/mach-types.h> 53 53 #include <asm/unaligned.h> 54 54 #include <asm/hardware.h> 55 - #ifdef CONFIG_ARCH_PXA 56 - #include <asm/arch/pxa-regs.h> 57 - #endif 58 55 59 56 #include <linux/usb/ch9.h> 60 57 #include <linux/usb_gadget.h> 61 58 62 - #include <asm/arch/udc.h> 59 + #include <asm/mach/udc_pxa2xx.h> 63 60 64 61 65 62 /* ··· 154 155 struct pxa2xx_udc_mach_info *mach = the_controller->mach; 155 156 156 157 if (mach->gpio_vbus) 157 - return udc_gpio_get(mach->gpio_vbus); 158 + return gpio_get_value(mach->gpio_vbus); 158 159 if (mach->udc_is_connected) 159 160 return mach->udc_is_connected(); 160 161 return 1; ··· 166 167 struct pxa2xx_udc_mach_info *mach = the_controller->mach; 167 168 168 169 if (mach->gpio_pullup) 169 - udc_gpio_set(mach->gpio_pullup, 0); 170 + gpio_set_value(mach->gpio_pullup, 0); 170 171 else if (mach->udc_command) 171 172 mach->udc_command(PXA2XX_UDC_CMD_DISCONNECT); 172 173 } ··· 176 177 struct pxa2xx_udc_mach_info *mach = the_controller->mach; 177 178 178 179 if (mach->gpio_pullup) 179 - udc_gpio_set(mach->gpio_pullup, 1); 180 + gpio_set_value(mach->gpio_pullup, 1); 180 181 else if (mach->udc_command) 181 182 mach->udc_command(PXA2XX_UDC_CMD_CONNECT); 182 183 } ··· 1741 1742 static irqreturn_t udc_vbus_irq(int irq, void *_dev) 1742 1743 { 1743 1744 struct pxa2xx_udc *dev = _dev; 1744 - int vbus = udc_gpio_get(dev->mach->gpio_vbus); 1745 + int vbus = gpio_get_value(dev->mach->gpio_vbus); 1745 1746 1746 1747 pxa2xx_udc_vbus_session(&dev->gadget, vbus); 1747 1748 return IRQ_HANDLED; ··· 2534 2535 /* other non-static parts of init */ 2535 2536 dev->dev = &pdev->dev; 2536 2537 dev->mach = pdev->dev.platform_data; 2538 + 2537 2539 if (dev->mach->gpio_vbus) { 2538 - udc_gpio_init_vbus(dev->mach->gpio_vbus); 2539 - vbus_irq = udc_gpio_to_irq(dev->mach->gpio_vbus); 2540 + if ((retval = gpio_request(dev->mach->gpio_vbus, 2541 + "pxa2xx_udc GPIO VBUS"))) { 2542 + dev_dbg(&pdev->dev, 2543 + "can't get vbus gpio %d, err: %d\n", 2544 + dev->mach->gpio_vbus, retval); 2545 + return -EBUSY; 2546 + } 2547 + gpio_direction_input(dev->mach->gpio_vbus); 2548 + vbus_irq = gpio_to_irq(dev->mach->gpio_vbus); 2540 2549 set_irq_type(vbus_irq, IRQT_BOTHEDGE); 2541 2550 } else 2542 2551 vbus_irq = 0; 2543 - if (dev->mach->gpio_pullup) 2544 - udc_gpio_init_pullup(dev->mach->gpio_pullup); 2552 + 2553 + if (dev->mach->gpio_pullup) { 2554 + if ((retval = gpio_request(dev->mach->gpio_pullup, 2555 + "pca2xx_udc GPIO PULLUP"))) { 2556 + dev_dbg(&pdev->dev, 2557 + "can't get pullup gpio %d, err: %d\n", 2558 + dev->mach->gpio_pullup, retval); 2559 + if (dev->mach->gpio_vbus) 2560 + gpio_free(dev->mach->gpio_vbus); 2561 + return -EBUSY; 2562 + } 2563 + gpio_direction_output(dev->mach->gpio_pullup, 0); 2564 + } 2545 2565 2546 2566 init_timer(&dev->timer); 2547 2567 dev->timer.function = udc_watchdog; ··· 2584 2566 if (retval != 0) { 2585 2567 printk(KERN_ERR "%s: can't get irq %d, err %d\n", 2586 2568 driver_name, irq, retval); 2569 + if (dev->mach->gpio_pullup) 2570 + gpio_free(dev->mach->gpio_pullup); 2571 + if (dev->mach->gpio_vbus) 2572 + gpio_free(dev->mach->gpio_vbus); 2587 2573 return -EBUSY; 2588 2574 } 2589 2575 dev->got_irq = 1; ··· 2603 2581 driver_name, LUBBOCK_USB_DISC_IRQ, retval); 2604 2582 lubbock_fail0: 2605 2583 free_irq(irq, dev); 2584 + if (dev->mach->gpio_pullup) 2585 + gpio_free(dev->mach->gpio_pullup); 2586 + if (dev->mach->gpio_vbus) 2587 + gpio_free(dev->mach->gpio_vbus); 2606 2588 return -EBUSY; 2607 2589 } 2608 2590 retval = request_irq(LUBBOCK_USB_IRQ, ··· 2634 2608 printk(KERN_ERR "%s: can't get irq %i, err %d\n", 2635 2609 driver_name, vbus_irq, retval); 2636 2610 free_irq(irq, dev); 2611 + if (dev->mach->gpio_pullup) 2612 + gpio_free(dev->mach->gpio_pullup); 2613 + if (dev->mach->gpio_vbus) 2614 + gpio_free(dev->mach->gpio_vbus); 2637 2615 return -EBUSY; 2638 2616 } 2639 2617 } ··· 2671 2641 free_irq(LUBBOCK_USB_IRQ, dev); 2672 2642 } 2673 2643 #endif 2674 - if (dev->mach->gpio_vbus) 2675 - free_irq(IRQ_GPIO(dev->mach->gpio_vbus), dev); 2644 + if (dev->mach->gpio_vbus) { 2645 + free_irq(gpio_to_irq(dev->mach->gpio_vbus), dev); 2646 + gpio_free(dev->mach->gpio_vbus); 2647 + } 2648 + if (dev->mach->gpio_pullup) 2649 + gpio_free(dev->mach->gpio_pullup); 2650 + 2676 2651 platform_set_drvdata(pdev, NULL); 2677 2652 the_controller = NULL; 2678 2653 return 0;
-22
include/asm-arm/arch-ixp4xx/udc.h
··· 6 6 7 7 extern void ixp4xx_set_udc_info(struct pxa2xx_udc_mach_info *info); 8 8 9 - static inline int udc_gpio_to_irq(unsigned gpio) 10 - { 11 - return 0; 12 - } 13 - 14 - static inline void udc_gpio_init_vbus(unsigned gpio) 15 - { 16 - } 17 - 18 - static inline void udc_gpio_init_pullup(unsigned gpio) 19 - { 20 - } 21 - 22 - static inline int udc_gpio_get(unsigned gpio) 23 - { 24 - return 0; 25 - } 26 - 27 - static inline void udc_gpio_set(unsigned gpio, int is_on) 28 - { 29 - } 30 -
-33
include/asm-arm/arch-pxa/udc.h
··· 1 1 /* 2 2 * linux/include/asm-arm/arch-pxa/udc.h 3 3 * 4 - * This supports machine-specific differences in how the PXA2xx 5 - * USB Device Controller (UDC) is wired. 6 - * 7 4 */ 8 5 #include <asm/mach/udc_pxa2xx.h> 9 6 10 7 extern void pxa_set_udc_info(struct pxa2xx_udc_mach_info *info); 11 - 12 - static inline int udc_gpio_to_irq(unsigned gpio) 13 - { 14 - return IRQ_GPIO(gpio & GPIO_MD_MASK_NR); 15 - } 16 - 17 - static inline void udc_gpio_init_vbus(unsigned gpio) 18 - { 19 - pxa_gpio_mode((gpio & GPIO_MD_MASK_NR) | GPIO_IN); 20 - } 21 - 22 - static inline void udc_gpio_init_pullup(unsigned gpio) 23 - { 24 - pxa_gpio_mode((gpio & GPIO_MD_MASK_NR) | GPIO_OUT | GPIO_DFLT_LOW); 25 - } 26 - 27 - static inline int udc_gpio_get(unsigned gpio) 28 - { 29 - return (GPLR(gpio) & GPIO_bit(gpio)) != 0; 30 - } 31 - 32 - static inline void udc_gpio_set(unsigned gpio, int is_on) 33 - { 34 - int mask = GPIO_bit(gpio); 35 - 36 - if (is_on) 37 - GPSR(gpio) = mask; 38 - else 39 - GPCR(gpio) = mask; 40 - } 41 8