diff options
Diffstat (limited to 'drivers/usb/gadget/pxa2xx_udc.c')
-rw-r--r-- | drivers/usb/gadget/pxa2xx_udc.c | 70 |
1 files changed, 68 insertions, 2 deletions
diff --git a/drivers/usb/gadget/pxa2xx_udc.c b/drivers/usb/gadget/pxa2xx_udc.c index fff027d30a09..f1adcf8b2023 100644 --- a/drivers/usb/gadget/pxa2xx_udc.c +++ b/drivers/usb/gadget/pxa2xx_udc.c | |||
@@ -150,6 +150,39 @@ MODULE_PARM_DESC (fifo_mode, "pxa2xx udc fifo mode"); | |||
150 | static void pxa2xx_ep_fifo_flush (struct usb_ep *ep); | 150 | static void pxa2xx_ep_fifo_flush (struct usb_ep *ep); |
151 | static void nuke (struct pxa2xx_ep *, int status); | 151 | static void nuke (struct pxa2xx_ep *, int status); |
152 | 152 | ||
153 | /* one GPIO should be used to detect VBUS from the host */ | ||
154 | static int is_vbus_present(void) | ||
155 | { | ||
156 | struct pxa2xx_udc_mach_info *mach = the_controller->mach; | ||
157 | |||
158 | if (mach->gpio_vbus) | ||
159 | return pxa_gpio_get(mach->gpio_vbus); | ||
160 | if (mach->udc_is_connected) | ||
161 | return mach->udc_is_connected(); | ||
162 | return 1; | ||
163 | } | ||
164 | |||
165 | /* one GPIO should control a D+ pullup, so host sees this device (or not) */ | ||
166 | static void pullup_off(void) | ||
167 | { | ||
168 | struct pxa2xx_udc_mach_info *mach = the_controller->mach; | ||
169 | |||
170 | if (mach->gpio_pullup) | ||
171 | pxa_gpio_set(mach->gpio_pullup, 0); | ||
172 | else if (mach->udc_command) | ||
173 | mach->udc_command(PXA2XX_UDC_CMD_DISCONNECT); | ||
174 | } | ||
175 | |||
176 | static void pullup_on(void) | ||
177 | { | ||
178 | struct pxa2xx_udc_mach_info *mach = the_controller->mach; | ||
179 | |||
180 | if (mach->gpio_pullup) | ||
181 | pxa_gpio_set(mach->gpio_pullup, 1); | ||
182 | else if (mach->udc_command) | ||
183 | mach->udc_command(PXA2XX_UDC_CMD_CONNECT); | ||
184 | } | ||
185 | |||
153 | static void pio_irq_enable(int bEndpointAddress) | 186 | static void pio_irq_enable(int bEndpointAddress) |
154 | { | 187 | { |
155 | bEndpointAddress &= 0xf; | 188 | bEndpointAddress &= 0xf; |
@@ -1721,6 +1754,16 @@ lubbock_vbus_irq(int irq, void *_dev, struct pt_regs *r) | |||
1721 | 1754 | ||
1722 | #endif | 1755 | #endif |
1723 | 1756 | ||
1757 | static irqreturn_t | ||
1758 | udc_vbus_irq(int irq, void *_dev, struct pt_regs *r) | ||
1759 | { | ||
1760 | struct pxa2xx_udc *dev = _dev; | ||
1761 | int vbus = pxa_gpio_get(dev->mach->gpio_vbus); | ||
1762 | |||
1763 | pxa2xx_udc_vbus_session(&dev->gadget, vbus); | ||
1764 | return IRQ_HANDLED; | ||
1765 | } | ||
1766 | |||
1724 | 1767 | ||
1725 | /*-------------------------------------------------------------------------*/ | 1768 | /*-------------------------------------------------------------------------*/ |
1726 | 1769 | ||
@@ -2438,7 +2481,7 @@ static struct pxa2xx_udc memory = { | |||
2438 | static int __init pxa2xx_udc_probe(struct platform_device *pdev) | 2481 | static int __init pxa2xx_udc_probe(struct platform_device *pdev) |
2439 | { | 2482 | { |
2440 | struct pxa2xx_udc *dev = &memory; | 2483 | struct pxa2xx_udc *dev = &memory; |
2441 | int retval, out_dma = 1; | 2484 | int retval, out_dma = 1, vbus_irq; |
2442 | u32 chiprev; | 2485 | u32 chiprev; |
2443 | 2486 | ||
2444 | /* insist on Intel/ARM/XScale */ | 2487 | /* insist on Intel/ARM/XScale */ |
@@ -2502,6 +2545,16 @@ static int __init pxa2xx_udc_probe(struct platform_device *pdev) | |||
2502 | /* other non-static parts of init */ | 2545 | /* other non-static parts of init */ |
2503 | dev->dev = &pdev->dev; | 2546 | dev->dev = &pdev->dev; |
2504 | dev->mach = pdev->dev.platform_data; | 2547 | dev->mach = pdev->dev.platform_data; |
2548 | if (dev->mach->gpio_vbus) { | ||
2549 | vbus_irq = IRQ_GPIO(dev->mach->gpio_vbus & GPIO_MD_MASK_NR); | ||
2550 | pxa_gpio_mode((dev->mach->gpio_vbus & GPIO_MD_MASK_NR) | ||
2551 | | GPIO_IN); | ||
2552 | set_irq_type(vbus_irq, IRQT_BOTHEDGE); | ||
2553 | } else | ||
2554 | vbus_irq = 0; | ||
2555 | if (dev->mach->gpio_pullup) | ||
2556 | pxa_gpio_mode((dev->mach->gpio_pullup & GPIO_MD_MASK_NR) | ||
2557 | | GPIO_OUT | GPIO_DFLT_LOW); | ||
2505 | 2558 | ||
2506 | init_timer(&dev->timer); | 2559 | init_timer(&dev->timer); |
2507 | dev->timer.function = udc_watchdog; | 2560 | dev->timer.function = udc_watchdog; |
@@ -2557,8 +2610,19 @@ lubbock_fail0: | |||
2557 | HEX_DISPLAY(dev->stats.irqs); | 2610 | HEX_DISPLAY(dev->stats.irqs); |
2558 | LUB_DISC_BLNK_LED &= 0xff; | 2611 | LUB_DISC_BLNK_LED &= 0xff; |
2559 | #endif | 2612 | #endif |
2560 | } | 2613 | } else |
2561 | #endif | 2614 | #endif |
2615 | if (vbus_irq) { | ||
2616 | retval = request_irq(vbus_irq, udc_vbus_irq, | ||
2617 | SA_INTERRUPT | SA_SAMPLE_RANDOM, | ||
2618 | driver_name, dev); | ||
2619 | if (retval != 0) { | ||
2620 | printk(KERN_ERR "%s: can't get irq %i, err %d\n", | ||
2621 | driver_name, vbus_irq, retval); | ||
2622 | free_irq(IRQ_USB, dev); | ||
2623 | return -EBUSY; | ||
2624 | } | ||
2625 | } | ||
2562 | create_proc_files(); | 2626 | create_proc_files(); |
2563 | 2627 | ||
2564 | return 0; | 2628 | return 0; |
@@ -2587,6 +2651,8 @@ static int __exit pxa2xx_udc_remove(struct platform_device *pdev) | |||
2587 | free_irq(LUBBOCK_USB_IRQ, dev); | 2651 | free_irq(LUBBOCK_USB_IRQ, dev); |
2588 | } | 2652 | } |
2589 | #endif | 2653 | #endif |
2654 | if (dev->mach->gpio_vbus) | ||
2655 | free_irq(IRQ_GPIO(dev->mach->gpio_vbus), dev); | ||
2590 | platform_set_drvdata(pdev, NULL); | 2656 | platform_set_drvdata(pdev, NULL); |
2591 | the_controller = NULL; | 2657 | the_controller = NULL; |
2592 | return 0; | 2658 | return 0; |