diff options
author | Milan Svoboda <msvoboda@ra.rockwell.com> | 2007-06-30 09:25:35 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2007-07-12 19:34:42 -0400 |
commit | 9068a4c6467986e8fda5bdb29bd5f10c6788e2ff (patch) | |
tree | dcb2889be80b750da2454c60a1d567e391ee560b /drivers/usb/gadget/pxa2xx_udc.c | |
parent | e4f747373cd96c86db3c64c21710748c6889c03c (diff) |
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>
Diffstat (limited to 'drivers/usb/gadget/pxa2xx_udc.c')
-rw-r--r-- | drivers/usb/gadget/pxa2xx_udc.c | 63 |
1 files changed, 49 insertions, 14 deletions
diff --git a/drivers/usb/gadget/pxa2xx_udc.c b/drivers/usb/gadget/pxa2xx_udc.c index 84392e835d5f..c9ec0b3e582a 100644 --- a/drivers/usb/gadget/pxa2xx_udc.c +++ b/drivers/usb/gadget/pxa2xx_udc.c | |||
@@ -27,6 +27,7 @@ | |||
27 | #undef DEBUG | 27 | #undef DEBUG |
28 | // #define VERBOSE DBG_VERBOSE | 28 | // #define VERBOSE DBG_VERBOSE |
29 | 29 | ||
30 | #include <linux/device.h> | ||
30 | #include <linux/module.h> | 31 | #include <linux/module.h> |
31 | #include <linux/kernel.h> | 32 | #include <linux/kernel.h> |
32 | #include <linux/ioport.h> | 33 | #include <linux/ioport.h> |
@@ -46,19 +47,17 @@ | |||
46 | 47 | ||
47 | #include <asm/byteorder.h> | 48 | #include <asm/byteorder.h> |
48 | #include <asm/dma.h> | 49 | #include <asm/dma.h> |
50 | #include <asm/gpio.h> | ||
49 | #include <asm/io.h> | 51 | #include <asm/io.h> |
50 | #include <asm/system.h> | 52 | #include <asm/system.h> |
51 | #include <asm/mach-types.h> | 53 | #include <asm/mach-types.h> |
52 | #include <asm/unaligned.h> | 54 | #include <asm/unaligned.h> |
53 | #include <asm/hardware.h> | 55 | #include <asm/hardware.h> |
54 | #ifdef CONFIG_ARCH_PXA | ||
55 | #include <asm/arch/pxa-regs.h> | ||
56 | #endif | ||
57 | 56 | ||
58 | #include <linux/usb/ch9.h> | 57 | #include <linux/usb/ch9.h> |
59 | #include <linux/usb_gadget.h> | 58 | #include <linux/usb_gadget.h> |
60 | 59 | ||
61 | #include <asm/arch/udc.h> | 60 | #include <asm/mach/udc_pxa2xx.h> |
62 | 61 | ||
63 | 62 | ||
64 | /* | 63 | /* |
@@ -155,7 +154,7 @@ static int is_vbus_present(void) | |||
155 | struct pxa2xx_udc_mach_info *mach = the_controller->mach; | 154 | struct pxa2xx_udc_mach_info *mach = the_controller->mach; |
156 | 155 | ||
157 | if (mach->gpio_vbus) | 156 | if (mach->gpio_vbus) |
158 | return udc_gpio_get(mach->gpio_vbus); | 157 | return gpio_get_value(mach->gpio_vbus); |
159 | if (mach->udc_is_connected) | 158 | if (mach->udc_is_connected) |
160 | return mach->udc_is_connected(); | 159 | return mach->udc_is_connected(); |
161 | return 1; | 160 | return 1; |
@@ -167,7 +166,7 @@ static void pullup_off(void) | |||
167 | struct pxa2xx_udc_mach_info *mach = the_controller->mach; | 166 | struct pxa2xx_udc_mach_info *mach = the_controller->mach; |
168 | 167 | ||
169 | if (mach->gpio_pullup) | 168 | if (mach->gpio_pullup) |
170 | udc_gpio_set(mach->gpio_pullup, 0); | 169 | gpio_set_value(mach->gpio_pullup, 0); |
171 | else if (mach->udc_command) | 170 | else if (mach->udc_command) |
172 | mach->udc_command(PXA2XX_UDC_CMD_DISCONNECT); | 171 | mach->udc_command(PXA2XX_UDC_CMD_DISCONNECT); |
173 | } | 172 | } |
@@ -177,7 +176,7 @@ static void pullup_on(void) | |||
177 | struct pxa2xx_udc_mach_info *mach = the_controller->mach; | 176 | struct pxa2xx_udc_mach_info *mach = the_controller->mach; |
178 | 177 | ||
179 | if (mach->gpio_pullup) | 178 | if (mach->gpio_pullup) |
180 | udc_gpio_set(mach->gpio_pullup, 1); | 179 | gpio_set_value(mach->gpio_pullup, 1); |
181 | else if (mach->udc_command) | 180 | else if (mach->udc_command) |
182 | mach->udc_command(PXA2XX_UDC_CMD_CONNECT); | 181 | mach->udc_command(PXA2XX_UDC_CMD_CONNECT); |
183 | } | 182 | } |
@@ -1742,7 +1741,7 @@ lubbock_vbus_irq(int irq, void *_dev) | |||
1742 | static irqreturn_t udc_vbus_irq(int irq, void *_dev) | 1741 | static irqreturn_t udc_vbus_irq(int irq, void *_dev) |
1743 | { | 1742 | { |
1744 | struct pxa2xx_udc *dev = _dev; | 1743 | struct pxa2xx_udc *dev = _dev; |
1745 | int vbus = udc_gpio_get(dev->mach->gpio_vbus); | 1744 | int vbus = gpio_get_value(dev->mach->gpio_vbus); |
1746 | 1745 | ||
1747 | pxa2xx_udc_vbus_session(&dev->gadget, vbus); | 1746 | pxa2xx_udc_vbus_session(&dev->gadget, vbus); |
1748 | return IRQ_HANDLED; | 1747 | return IRQ_HANDLED; |
@@ -2535,14 +2534,33 @@ static int __init pxa2xx_udc_probe(struct platform_device *pdev) | |||
2535 | /* other non-static parts of init */ | 2534 | /* other non-static parts of init */ |
2536 | dev->dev = &pdev->dev; | 2535 | dev->dev = &pdev->dev; |
2537 | dev->mach = pdev->dev.platform_data; | 2536 | dev->mach = pdev->dev.platform_data; |
2537 | |||
2538 | if (dev->mach->gpio_vbus) { | 2538 | if (dev->mach->gpio_vbus) { |
2539 | udc_gpio_init_vbus(dev->mach->gpio_vbus); | 2539 | if ((retval = gpio_request(dev->mach->gpio_vbus, |
2540 | vbus_irq = udc_gpio_to_irq(dev->mach->gpio_vbus); | 2540 | "pxa2xx_udc GPIO VBUS"))) { |
2541 | dev_dbg(&pdev->dev, | ||
2542 | "can't get vbus gpio %d, err: %d\n", | ||
2543 | dev->mach->gpio_vbus, retval); | ||
2544 | return -EBUSY; | ||
2545 | } | ||
2546 | gpio_direction_input(dev->mach->gpio_vbus); | ||
2547 | vbus_irq = gpio_to_irq(dev->mach->gpio_vbus); | ||
2541 | set_irq_type(vbus_irq, IRQT_BOTHEDGE); | 2548 | set_irq_type(vbus_irq, IRQT_BOTHEDGE); |
2542 | } else | 2549 | } else |
2543 | vbus_irq = 0; | 2550 | vbus_irq = 0; |
2544 | if (dev->mach->gpio_pullup) | 2551 | |
2545 | udc_gpio_init_pullup(dev->mach->gpio_pullup); | 2552 | if (dev->mach->gpio_pullup) { |
2553 | if ((retval = gpio_request(dev->mach->gpio_pullup, | ||
2554 | "pca2xx_udc GPIO PULLUP"))) { | ||
2555 | dev_dbg(&pdev->dev, | ||
2556 | "can't get pullup gpio %d, err: %d\n", | ||
2557 | dev->mach->gpio_pullup, retval); | ||
2558 | if (dev->mach->gpio_vbus) | ||
2559 | gpio_free(dev->mach->gpio_vbus); | ||
2560 | return -EBUSY; | ||
2561 | } | ||
2562 | gpio_direction_output(dev->mach->gpio_pullup, 0); | ||
2563 | } | ||
2546 | 2564 | ||
2547 | init_timer(&dev->timer); | 2565 | init_timer(&dev->timer); |
2548 | dev->timer.function = udc_watchdog; | 2566 | dev->timer.function = udc_watchdog; |
@@ -2566,6 +2584,10 @@ static int __init pxa2xx_udc_probe(struct platform_device *pdev) | |||
2566 | if (retval != 0) { | 2584 | if (retval != 0) { |
2567 | printk(KERN_ERR "%s: can't get irq %d, err %d\n", | 2585 | printk(KERN_ERR "%s: can't get irq %d, err %d\n", |
2568 | driver_name, irq, retval); | 2586 | driver_name, irq, retval); |
2587 | if (dev->mach->gpio_pullup) | ||
2588 | gpio_free(dev->mach->gpio_pullup); | ||
2589 | if (dev->mach->gpio_vbus) | ||
2590 | gpio_free(dev->mach->gpio_vbus); | ||
2569 | return -EBUSY; | 2591 | return -EBUSY; |
2570 | } | 2592 | } |
2571 | dev->got_irq = 1; | 2593 | dev->got_irq = 1; |
@@ -2581,6 +2603,10 @@ static int __init pxa2xx_udc_probe(struct platform_device *pdev) | |||
2581 | driver_name, LUBBOCK_USB_DISC_IRQ, retval); | 2603 | driver_name, LUBBOCK_USB_DISC_IRQ, retval); |
2582 | lubbock_fail0: | 2604 | lubbock_fail0: |
2583 | free_irq(irq, dev); | 2605 | free_irq(irq, dev); |
2606 | if (dev->mach->gpio_pullup) | ||
2607 | gpio_free(dev->mach->gpio_pullup); | ||
2608 | if (dev->mach->gpio_vbus) | ||
2609 | gpio_free(dev->mach->gpio_vbus); | ||
2584 | return -EBUSY; | 2610 | return -EBUSY; |
2585 | } | 2611 | } |
2586 | retval = request_irq(LUBBOCK_USB_IRQ, | 2612 | retval = request_irq(LUBBOCK_USB_IRQ, |
@@ -2608,6 +2634,10 @@ lubbock_fail0: | |||
2608 | printk(KERN_ERR "%s: can't get irq %i, err %d\n", | 2634 | printk(KERN_ERR "%s: can't get irq %i, err %d\n", |
2609 | driver_name, vbus_irq, retval); | 2635 | driver_name, vbus_irq, retval); |
2610 | free_irq(irq, dev); | 2636 | free_irq(irq, dev); |
2637 | if (dev->mach->gpio_pullup) | ||
2638 | gpio_free(dev->mach->gpio_pullup); | ||
2639 | if (dev->mach->gpio_vbus) | ||
2640 | gpio_free(dev->mach->gpio_vbus); | ||
2611 | return -EBUSY; | 2641 | return -EBUSY; |
2612 | } | 2642 | } |
2613 | } | 2643 | } |
@@ -2641,8 +2671,13 @@ static int __exit pxa2xx_udc_remove(struct platform_device *pdev) | |||
2641 | free_irq(LUBBOCK_USB_IRQ, dev); | 2671 | free_irq(LUBBOCK_USB_IRQ, dev); |
2642 | } | 2672 | } |
2643 | #endif | 2673 | #endif |
2644 | if (dev->mach->gpio_vbus) | 2674 | if (dev->mach->gpio_vbus) { |
2645 | free_irq(IRQ_GPIO(dev->mach->gpio_vbus), dev); | 2675 | free_irq(gpio_to_irq(dev->mach->gpio_vbus), dev); |
2676 | gpio_free(dev->mach->gpio_vbus); | ||
2677 | } | ||
2678 | if (dev->mach->gpio_pullup) | ||
2679 | gpio_free(dev->mach->gpio_pullup); | ||
2680 | |||
2646 | platform_set_drvdata(pdev, NULL); | 2681 | platform_set_drvdata(pdev, NULL); |
2647 | the_controller = NULL; | 2682 | the_controller = NULL; |
2648 | return 0; | 2683 | return 0; |