aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/Kconfig4
-rw-r--r--drivers/usb/gadget/Kconfig8
-rw-r--r--drivers/usb/gadget/at91_udc.c49
-rw-r--r--drivers/usb/gadget/atmel_usba_udc.c6
-rw-r--r--drivers/usb/gadget/f_phonet.c2
-rw-r--r--drivers/usb/host/ehci-atmel.c24
-rw-r--r--drivers/usb/host/ohci-at91.c106
-rw-r--r--drivers/usb/host/ohci-hcd.c2
-rw-r--r--drivers/usb/host/ohci-sa1111.c297
-rw-r--r--drivers/usb/serial/option.c6
10 files changed, 326 insertions, 178 deletions
diff --git a/drivers/usb/Kconfig b/drivers/usb/Kconfig
index e4405e088589..cbd8f5f80596 100644
--- a/drivers/usb/Kconfig
+++ b/drivers/usb/Kconfig
@@ -16,7 +16,7 @@ config USB_ARCH_HAS_OHCI
16 # ARM: 16 # ARM:
17 default y if SA1111 17 default y if SA1111
18 default y if ARCH_OMAP 18 default y if ARCH_OMAP
19 default y if ARCH_S3C2410 19 default y if ARCH_S3C24XX
20 default y if PXA27x 20 default y if PXA27x
21 default y if PXA3xx 21 default y if PXA3xx
22 default y if ARCH_EP93XX 22 default y if ARCH_EP93XX
@@ -44,7 +44,7 @@ config USB_ARCH_HAS_EHCI
44 default y if PPC_MPC512x 44 default y if PPC_MPC512x
45 default y if ARCH_IXP4XX 45 default y if ARCH_IXP4XX
46 default y if ARCH_W90X900 46 default y if ARCH_W90X900
47 default y if ARCH_AT91SAM9G45 47 default y if ARCH_AT91
48 default y if ARCH_MXC 48 default y if ARCH_MXC
49 default y if ARCH_OMAP3 49 default y if ARCH_OMAP3
50 default y if ARCH_CNS3XXX 50 default y if ARCH_CNS3XXX
diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index c14a3972953a..2633f7595116 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -137,7 +137,7 @@ choice
137 137
138config USB_AT91 138config USB_AT91
139 tristate "Atmel AT91 USB Device Port" 139 tristate "Atmel AT91 USB Device Port"
140 depends on ARCH_AT91 && !ARCH_AT91SAM9RL && !ARCH_AT91CAP9 && !ARCH_AT91SAM9G45 140 depends on ARCH_AT91
141 help 141 help
142 Many Atmel AT91 processors (such as the AT91RM2000) have a 142 Many Atmel AT91 processors (such as the AT91RM2000) have a
143 full speed USB Device Port with support for five configurable 143 full speed USB Device Port with support for five configurable
@@ -150,7 +150,7 @@ config USB_AT91
150config USB_ATMEL_USBA 150config USB_ATMEL_USBA
151 tristate "Atmel USBA" 151 tristate "Atmel USBA"
152 select USB_GADGET_DUALSPEED 152 select USB_GADGET_DUALSPEED
153 depends on AVR32 || ARCH_AT91CAP9 || ARCH_AT91SAM9RL || ARCH_AT91SAM9G45 153 depends on AVR32 || ARCH_AT91SAM9RL || ARCH_AT91SAM9G45
154 help 154 help
155 USBA is the integrated high-speed USB Device controller on 155 USBA is the integrated high-speed USB Device controller on
156 the AT32AP700x, some AT91SAM9 and AT91CAP9 processors from Atmel. 156 the AT32AP700x, some AT91SAM9 and AT91CAP9 processors from Atmel.
@@ -284,7 +284,7 @@ config USB_IMX
284 284
285config USB_S3C2410 285config USB_S3C2410
286 tristate "S3C2410 USB Device Controller" 286 tristate "S3C2410 USB Device Controller"
287 depends on ARCH_S3C2410 287 depends on ARCH_S3C24XX
288 help 288 help
289 Samsung's S3C2410 is an ARM-4 processor with an integrated 289 Samsung's S3C2410 is an ARM-4 processor with an integrated
290 full speed USB 1.1 device controller. It has 4 configurable 290 full speed USB 1.1 device controller. It has 4 configurable
@@ -299,7 +299,7 @@ config USB_S3C2410_DEBUG
299 299
300config USB_S3C_HSUDC 300config USB_S3C_HSUDC
301 tristate "S3C2416, S3C2443 and S3C2450 USB Device Controller" 301 tristate "S3C2416, S3C2443 and S3C2450 USB Device Controller"
302 depends on ARCH_S3C2410 302 depends on ARCH_S3C24XX
303 select USB_GADGET_DUALSPEED 303 select USB_GADGET_DUALSPEED
304 help 304 help
305 Samsung's S3C2416, S3C2443 and S3C2450 is an ARM9 based SoC 305 Samsung's S3C2416, S3C2443 and S3C2450 is an ARM9 based SoC
diff --git a/drivers/usb/gadget/at91_udc.c b/drivers/usb/gadget/at91_udc.c
index 15a8cdb2ded5..36fd2b4b49a2 100644
--- a/drivers/usb/gadget/at91_udc.c
+++ b/drivers/usb/gadget/at91_udc.c
@@ -29,6 +29,8 @@
29#include <linux/clk.h> 29#include <linux/clk.h>
30#include <linux/usb/ch9.h> 30#include <linux/usb/ch9.h>
31#include <linux/usb/gadget.h> 31#include <linux/usb/gadget.h>
32#include <linux/of.h>
33#include <linux/of_gpio.h>
32 34
33#include <asm/byteorder.h> 35#include <asm/byteorder.h>
34#include <mach/hardware.h> 36#include <mach/hardware.h>
@@ -40,6 +42,7 @@
40#include <mach/board.h> 42#include <mach/board.h>
41#include <mach/cpu.h> 43#include <mach/cpu.h>
42#include <mach/at91sam9261_matrix.h> 44#include <mach/at91sam9261_matrix.h>
45#include <mach/at91_matrix.h>
43 46
44#include "at91_udc.h" 47#include "at91_udc.h"
45 48
@@ -910,9 +913,9 @@ static void pullup(struct at91_udc *udc, int is_on)
910 } else if (cpu_is_at91sam9261() || cpu_is_at91sam9g10()) { 913 } else if (cpu_is_at91sam9261() || cpu_is_at91sam9g10()) {
911 u32 usbpucr; 914 u32 usbpucr;
912 915
913 usbpucr = at91_sys_read(AT91_MATRIX_USBPUCR); 916 usbpucr = at91_matrix_read(AT91_MATRIX_USBPUCR);
914 usbpucr |= AT91_MATRIX_USBPUCR_PUON; 917 usbpucr |= AT91_MATRIX_USBPUCR_PUON;
915 at91_sys_write(AT91_MATRIX_USBPUCR, usbpucr); 918 at91_matrix_write(AT91_MATRIX_USBPUCR, usbpucr);
916 } 919 }
917 } else { 920 } else {
918 stop_activity(udc); 921 stop_activity(udc);
@@ -928,9 +931,9 @@ static void pullup(struct at91_udc *udc, int is_on)
928 } else if (cpu_is_at91sam9261() || cpu_is_at91sam9g10()) { 931 } else if (cpu_is_at91sam9261() || cpu_is_at91sam9g10()) {
929 u32 usbpucr; 932 u32 usbpucr;
930 933
931 usbpucr = at91_sys_read(AT91_MATRIX_USBPUCR); 934 usbpucr = at91_matrix_read(AT91_MATRIX_USBPUCR);
932 usbpucr &= ~AT91_MATRIX_USBPUCR_PUON; 935 usbpucr &= ~AT91_MATRIX_USBPUCR_PUON;
933 at91_sys_write(AT91_MATRIX_USBPUCR, usbpucr); 936 at91_matrix_write(AT91_MATRIX_USBPUCR, usbpucr);
934 } 937 }
935 clk_off(udc); 938 clk_off(udc);
936 } 939 }
@@ -1706,7 +1709,27 @@ static void at91udc_shutdown(struct platform_device *dev)
1706 spin_unlock_irqrestore(&udc->lock, flags); 1709 spin_unlock_irqrestore(&udc->lock, flags);
1707} 1710}
1708 1711
1709static int __init at91udc_probe(struct platform_device *pdev) 1712static void __devinit at91udc_of_init(struct at91_udc *udc,
1713 struct device_node *np)
1714{
1715 struct at91_udc_data *board = &udc->board;
1716 u32 val;
1717 enum of_gpio_flags flags;
1718
1719 if (of_property_read_u32(np, "atmel,vbus-polled", &val) == 0)
1720 board->vbus_polled = 1;
1721
1722 board->vbus_pin = of_get_named_gpio_flags(np, "atmel,vbus-gpio", 0,
1723 &flags);
1724 board->vbus_active_low = (flags & OF_GPIO_ACTIVE_LOW) ? 1 : 0;
1725
1726 board->pullup_pin = of_get_named_gpio_flags(np, "atmel,pullup-gpio", 0,
1727 &flags);
1728
1729 board->pullup_active_low = (flags & OF_GPIO_ACTIVE_LOW) ? 1 : 0;
1730}
1731
1732static int __devinit at91udc_probe(struct platform_device *pdev)
1710{ 1733{
1711 struct device *dev = &pdev->dev; 1734 struct device *dev = &pdev->dev;
1712 struct at91_udc *udc; 1735 struct at91_udc *udc;
@@ -1741,7 +1764,11 @@ static int __init at91udc_probe(struct platform_device *pdev)
1741 /* init software state */ 1764 /* init software state */
1742 udc = &controller; 1765 udc = &controller;
1743 udc->gadget.dev.parent = dev; 1766 udc->gadget.dev.parent = dev;
1744 udc->board = *(struct at91_udc_data *) dev->platform_data; 1767 if (pdev->dev.of_node)
1768 at91udc_of_init(udc, pdev->dev.of_node);
1769 else
1770 memcpy(&udc->board, dev->platform_data,
1771 sizeof(struct at91_udc_data));
1745 udc->pdev = pdev; 1772 udc->pdev = pdev;
1746 udc->enabled = 0; 1773 udc->enabled = 0;
1747 spin_lock_init(&udc->lock); 1774 spin_lock_init(&udc->lock);
@@ -1970,6 +1997,15 @@ static int at91udc_resume(struct platform_device *pdev)
1970#define at91udc_resume NULL 1997#define at91udc_resume NULL
1971#endif 1998#endif
1972 1999
2000#if defined(CONFIG_OF)
2001static const struct of_device_id at91_udc_dt_ids[] = {
2002 { .compatible = "atmel,at91rm9200-udc" },
2003 { /* sentinel */ }
2004};
2005
2006MODULE_DEVICE_TABLE(of, at91_udc_dt_ids);
2007#endif
2008
1973static struct platform_driver at91_udc_driver = { 2009static struct platform_driver at91_udc_driver = {
1974 .remove = __exit_p(at91udc_remove), 2010 .remove = __exit_p(at91udc_remove),
1975 .shutdown = at91udc_shutdown, 2011 .shutdown = at91udc_shutdown,
@@ -1978,6 +2014,7 @@ static struct platform_driver at91_udc_driver = {
1978 .driver = { 2014 .driver = {
1979 .name = (char *) driver_name, 2015 .name = (char *) driver_name,
1980 .owner = THIS_MODULE, 2016 .owner = THIS_MODULE,
2017 .of_match_table = of_match_ptr(at91_udc_dt_ids),
1981 }, 2018 },
1982}; 2019};
1983 2020
diff --git a/drivers/usb/gadget/atmel_usba_udc.c b/drivers/usb/gadget/atmel_usba_udc.c
index 5e10f651ad63..9f98508966d1 100644
--- a/drivers/usb/gadget/atmel_usba_udc.c
+++ b/drivers/usb/gadget/atmel_usba_udc.c
@@ -332,12 +332,12 @@ static int vbus_is_present(struct usba_udc *udc)
332 332
333static void toggle_bias(int is_on) 333static void toggle_bias(int is_on)
334{ 334{
335 unsigned int uckr = at91_sys_read(AT91_CKGR_UCKR); 335 unsigned int uckr = at91_pmc_read(AT91_CKGR_UCKR);
336 336
337 if (is_on) 337 if (is_on)
338 at91_sys_write(AT91_CKGR_UCKR, uckr | AT91_PMC_BIASEN); 338 at91_pmc_write(AT91_CKGR_UCKR, uckr | AT91_PMC_BIASEN);
339 else 339 else
340 at91_sys_write(AT91_CKGR_UCKR, uckr & ~(AT91_PMC_BIASEN)); 340 at91_pmc_write(AT91_CKGR_UCKR, uckr & ~(AT91_PMC_BIASEN));
341} 341}
342 342
343#else 343#else
diff --git a/drivers/usb/gadget/f_phonet.c b/drivers/usb/gadget/f_phonet.c
index 7cdcb63b21ff..85a5cebe96b3 100644
--- a/drivers/usb/gadget/f_phonet.c
+++ b/drivers/usb/gadget/f_phonet.c
@@ -345,7 +345,7 @@ static void pn_rx_complete(struct usb_ep *ep, struct usb_request *req)
345 } 345 }
346 346
347 skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags, page, 347 skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags, page,
348 skb->len <= 1, req->actual); 348 skb->len <= 1, req->actual, req->actual);
349 page = NULL; 349 page = NULL;
350 350
351 if (req->actual < req->length) { /* Last fragment */ 351 if (req->actual < req->length) { /* Last fragment */
diff --git a/drivers/usb/host/ehci-atmel.c b/drivers/usb/host/ehci-atmel.c
index a5a3ef1f0096..19f318ababa2 100644
--- a/drivers/usb/host/ehci-atmel.c
+++ b/drivers/usb/host/ehci-atmel.c
@@ -13,6 +13,7 @@
13 13
14#include <linux/clk.h> 14#include <linux/clk.h>
15#include <linux/platform_device.h> 15#include <linux/platform_device.h>
16#include <linux/of_platform.h>
16 17
17/* interface and function clocks */ 18/* interface and function clocks */
18static struct clk *iclk, *fclk; 19static struct clk *iclk, *fclk;
@@ -115,6 +116,8 @@ static const struct hc_driver ehci_atmel_hc_driver = {
115 .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete, 116 .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete,
116}; 117};
117 118
119static u64 at91_ehci_dma_mask = DMA_BIT_MASK(32);
120
118static int __devinit ehci_atmel_drv_probe(struct platform_device *pdev) 121static int __devinit ehci_atmel_drv_probe(struct platform_device *pdev)
119{ 122{
120 struct usb_hcd *hcd; 123 struct usb_hcd *hcd;
@@ -137,6 +140,13 @@ static int __devinit ehci_atmel_drv_probe(struct platform_device *pdev)
137 goto fail_create_hcd; 140 goto fail_create_hcd;
138 } 141 }
139 142
143 /* Right now device-tree probed devices don't get dma_mask set.
144 * Since shared usb code relies on it, set it here for now.
145 * Once we have dma capability bindings this can go away.
146 */
147 if (!pdev->dev.dma_mask)
148 pdev->dev.dma_mask = &at91_ehci_dma_mask;
149
140 hcd = usb_create_hcd(driver, &pdev->dev, dev_name(&pdev->dev)); 150 hcd = usb_create_hcd(driver, &pdev->dev, dev_name(&pdev->dev));
141 if (!hcd) { 151 if (!hcd) {
142 retval = -ENOMEM; 152 retval = -ENOMEM;
@@ -225,9 +235,21 @@ static int __devexit ehci_atmel_drv_remove(struct platform_device *pdev)
225 return 0; 235 return 0;
226} 236}
227 237
238#ifdef CONFIG_OF
239static const struct of_device_id atmel_ehci_dt_ids[] = {
240 { .compatible = "atmel,at91sam9g45-ehci" },
241 { /* sentinel */ }
242};
243
244MODULE_DEVICE_TABLE(of, atmel_ehci_dt_ids);
245#endif
246
228static struct platform_driver ehci_atmel_driver = { 247static struct platform_driver ehci_atmel_driver = {
229 .probe = ehci_atmel_drv_probe, 248 .probe = ehci_atmel_drv_probe,
230 .remove = __devexit_p(ehci_atmel_drv_remove), 249 .remove = __devexit_p(ehci_atmel_drv_remove),
231 .shutdown = usb_hcd_platform_shutdown, 250 .shutdown = usb_hcd_platform_shutdown,
232 .driver.name = "atmel-ehci", 251 .driver = {
252 .name = "atmel-ehci",
253 .of_match_table = of_match_ptr(atmel_ehci_dt_ids),
254 },
233}; 255};
diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
index 77afabc77f9b..db8963f5fbce 100644
--- a/drivers/usb/host/ohci-at91.c
+++ b/drivers/usb/host/ohci-at91.c
@@ -14,6 +14,8 @@
14 14
15#include <linux/clk.h> 15#include <linux/clk.h>
16#include <linux/platform_device.h> 16#include <linux/platform_device.h>
17#include <linux/of_platform.h>
18#include <linux/of_gpio.h>
17 19
18#include <mach/hardware.h> 20#include <mach/hardware.h>
19#include <asm/gpio.h> 21#include <asm/gpio.h>
@@ -448,10 +450,11 @@ static irqreturn_t ohci_hcd_at91_overcurrent_irq(int irq, void *data)
448 450
449 /* From the GPIO notifying the over-current situation, find 451 /* From the GPIO notifying the over-current situation, find
450 * out the corresponding port */ 452 * out the corresponding port */
451 gpio = irq_to_gpio(irq);
452 for (port = 0; port < ARRAY_SIZE(pdata->overcurrent_pin); port++) { 453 for (port = 0; port < ARRAY_SIZE(pdata->overcurrent_pin); port++) {
453 if (pdata->overcurrent_pin[port] == gpio) 454 if (gpio_to_irq(pdata->overcurrent_pin[port]) == irq) {
455 gpio = pdata->overcurrent_pin[port];
454 break; 456 break;
457 }
455 } 458 }
456 459
457 if (port == ARRAY_SIZE(pdata->overcurrent_pin)) { 460 if (port == ARRAY_SIZE(pdata->overcurrent_pin)) {
@@ -476,13 +479,109 @@ static irqreturn_t ohci_hcd_at91_overcurrent_irq(int irq, void *data)
476 return IRQ_HANDLED; 479 return IRQ_HANDLED;
477} 480}
478 481
482#ifdef CONFIG_OF
483static const struct of_device_id at91_ohci_dt_ids[] = {
484 { .compatible = "atmel,at91rm9200-ohci" },
485 { /* sentinel */ }
486};
487
488MODULE_DEVICE_TABLE(of, at91_ohci_dt_ids);
489
490static u64 at91_ohci_dma_mask = DMA_BIT_MASK(32);
491
492static int __devinit ohci_at91_of_init(struct platform_device *pdev)
493{
494 struct device_node *np = pdev->dev.of_node;
495 int i, ret, gpio;
496 enum of_gpio_flags flags;
497 struct at91_usbh_data *pdata;
498 u32 ports;
499
500 if (!np)
501 return 0;
502
503 /* Right now device-tree probed devices don't get dma_mask set.
504 * Since shared usb code relies on it, set it here for now.
505 * Once we have dma capability bindings this can go away.
506 */
507 if (!pdev->dev.dma_mask)
508 pdev->dev.dma_mask = &at91_ohci_dma_mask;
509
510 pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
511 if (!pdata)
512 return -ENOMEM;
513
514 if (!of_property_read_u32(np, "num-ports", &ports))
515 pdata->ports = ports;
516
517 for (i = 0; i < 2; i++) {
518 gpio = of_get_named_gpio_flags(np, "atmel,vbus-gpio", i, &flags);
519 pdata->vbus_pin[i] = gpio;
520 if (!gpio_is_valid(gpio))
521 continue;
522 pdata->vbus_pin_active_low[i] = flags & OF_GPIO_ACTIVE_LOW;
523 ret = gpio_request(gpio, "ohci_vbus");
524 if (ret) {
525 dev_warn(&pdev->dev, "can't request vbus gpio %d", gpio);
526 continue;
527 }
528 ret = gpio_direction_output(gpio, !(flags & OF_GPIO_ACTIVE_LOW) ^ 1);
529 if (ret)
530 dev_warn(&pdev->dev, "can't put vbus gpio %d as output %d",
531 !(flags & OF_GPIO_ACTIVE_LOW) ^ 1, gpio);
532 }
533
534 for (i = 0; i < 2; i++) {
535 gpio = of_get_named_gpio_flags(np, "atmel,oc-gpio", i, &flags);
536 pdata->overcurrent_pin[i] = gpio;
537 if (!gpio_is_valid(gpio))
538 continue;
539 ret = gpio_request(gpio, "ohci_overcurrent");
540 if (ret) {
541 dev_err(&pdev->dev, "can't request overcurrent gpio %d", gpio);
542 continue;
543 }
544
545 ret = gpio_direction_input(gpio);
546 if (ret) {
547 dev_err(&pdev->dev, "can't configure overcurrent gpio %d as input", gpio);
548 continue;
549 }
550
551 ret = request_irq(gpio_to_irq(gpio),
552 ohci_hcd_at91_overcurrent_irq,
553 IRQF_SHARED, "ohci_overcurrent", pdev);
554 if (ret) {
555 gpio_free(gpio);
556 dev_warn(& pdev->dev, "cannot get GPIO IRQ for overcurrent\n");
557 }
558 }
559
560 pdev->dev.platform_data = pdata;
561
562 return 0;
563}
564#else
565static int __devinit ohci_at91_of_init(struct platform_device *pdev)
566{
567 return 0;
568}
569#endif
570
479/*-------------------------------------------------------------------------*/ 571/*-------------------------------------------------------------------------*/
480 572
481static int ohci_hcd_at91_drv_probe(struct platform_device *pdev) 573static int ohci_hcd_at91_drv_probe(struct platform_device *pdev)
482{ 574{
483 struct at91_usbh_data *pdata = pdev->dev.platform_data; 575 struct at91_usbh_data *pdata;
484 int i; 576 int i;
485 577
578 i = ohci_at91_of_init(pdev);
579
580 if (i)
581 return i;
582
583 pdata = pdev->dev.platform_data;
584
486 if (pdata) { 585 if (pdata) {
487 for (i = 0; i < ARRAY_SIZE(pdata->vbus_pin); i++) { 586 for (i = 0; i < ARRAY_SIZE(pdata->vbus_pin); i++) {
488 if (!gpio_is_valid(pdata->vbus_pin[i])) 587 if (!gpio_is_valid(pdata->vbus_pin[i]))
@@ -595,5 +694,6 @@ static struct platform_driver ohci_hcd_at91_driver = {
595 .driver = { 694 .driver = {
596 .name = "at91_ohci", 695 .name = "at91_ohci",
597 .owner = THIS_MODULE, 696 .owner = THIS_MODULE,
697 .of_match_table = of_match_ptr(at91_ohci_dt_ids),
598 }, 698 },
599}; 699};
diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
index cd5e382db89c..543e90e336b8 100644
--- a/drivers/usb/host/ohci-hcd.c
+++ b/drivers/usb/host/ohci-hcd.c
@@ -1000,7 +1000,7 @@ MODULE_LICENSE ("GPL");
1000#define SA1111_DRIVER ohci_hcd_sa1111_driver 1000#define SA1111_DRIVER ohci_hcd_sa1111_driver
1001#endif 1001#endif
1002 1002
1003#if defined(CONFIG_ARCH_S3C2410) || defined(CONFIG_ARCH_S3C64XX) 1003#if defined(CONFIG_ARCH_S3C24XX) || defined(CONFIG_ARCH_S3C64XX)
1004#include "ohci-s3c2410.c" 1004#include "ohci-s3c2410.c"
1005#define PLATFORM_DRIVER ohci_hcd_s3c2410_driver 1005#define PLATFORM_DRIVER ohci_hcd_s3c2410_driver
1006#endif 1006#endif
diff --git a/drivers/usb/host/ohci-sa1111.c b/drivers/usb/host/ohci-sa1111.c
index 4bde4f9821ba..e1004fb37bd9 100644
--- a/drivers/usb/host/ohci-sa1111.c
+++ b/drivers/usb/host/ohci-sa1111.c
@@ -16,29 +16,115 @@
16#include <mach/hardware.h> 16#include <mach/hardware.h>
17#include <asm/mach-types.h> 17#include <asm/mach-types.h>
18#include <mach/assabet.h> 18#include <mach/assabet.h>
19#include <mach/badge4.h>
20#include <asm/hardware/sa1111.h> 19#include <asm/hardware/sa1111.h>
21 20
22#ifndef CONFIG_SA1111 21#ifndef CONFIG_SA1111
23#error "This file is SA-1111 bus glue. CONFIG_SA1111 must be defined." 22#error "This file is SA-1111 bus glue. CONFIG_SA1111 must be defined."
24#endif 23#endif
25 24
26extern int usb_disabled(void); 25#define USB_STATUS 0x0118
26#define USB_RESET 0x011c
27#define USB_IRQTEST 0x0120
28
29#define USB_RESET_FORCEIFRESET (1 << 0)
30#define USB_RESET_FORCEHCRESET (1 << 1)
31#define USB_RESET_CLKGENRESET (1 << 2)
32#define USB_RESET_SIMSCALEDOWN (1 << 3)
33#define USB_RESET_USBINTTEST (1 << 4)
34#define USB_RESET_SLEEPSTBYEN (1 << 5)
35#define USB_RESET_PWRSENSELOW (1 << 6)
36#define USB_RESET_PWRCTRLLOW (1 << 7)
37
38#define USB_STATUS_IRQHCIRMTWKUP (1 << 7)
39#define USB_STATUS_IRQHCIBUFFACC (1 << 8)
40#define USB_STATUS_NIRQHCIM (1 << 9)
41#define USB_STATUS_NHCIMFCLR (1 << 10)
42#define USB_STATUS_USBPWRSENSE (1 << 11)
27 43
28/*-------------------------------------------------------------------------*/ 44#if 0
45static void dump_hci_status(struct usb_hcd *hcd, const char *label)
46{
47 unsigned long status = sa1111_readl(hcd->regs + USB_STATUS);
48
49 dbg("%s USB_STATUS = { %s%s%s%s%s}", label,
50 ((status & USB_STATUS_IRQHCIRMTWKUP) ? "IRQHCIRMTWKUP " : ""),
51 ((status & USB_STATUS_IRQHCIBUFFACC) ? "IRQHCIBUFFACC " : ""),
52 ((status & USB_STATUS_NIRQHCIM) ? "" : "IRQHCIM "),
53 ((status & USB_STATUS_NHCIMFCLR) ? "" : "HCIMFCLR "),
54 ((status & USB_STATUS_USBPWRSENSE) ? "USBPWRSENSE " : ""));
55}
56#endif
29 57
30static void sa1111_start_hc(struct sa1111_dev *dev) 58static int ohci_sa1111_reset(struct usb_hcd *hcd)
31{ 59{
32 unsigned int usb_rst = 0; 60 struct ohci_hcd *ohci = hcd_to_ohci(hcd);
61
62 ohci_hcd_init(ohci);
63 return ohci_init(ohci);
64}
33 65
34 printk(KERN_DEBUG "%s: starting SA-1111 OHCI USB Controller\n", 66static int __devinit ohci_sa1111_start(struct usb_hcd *hcd)
35 __FILE__); 67{
68 struct ohci_hcd *ohci = hcd_to_ohci(hcd);
69 int ret;
36 70
37#ifdef CONFIG_SA1100_BADGE4 71 ret = ohci_run(ohci);
38 if (machine_is_badge4()) { 72 if (ret < 0) {
39 badge4_set_5V(BADGE4_5V_USB, 1); 73 ohci_err(ohci, "can't start\n");
74 ohci_stop(hcd);
40 } 75 }
76 return ret;
77}
78
79static const struct hc_driver ohci_sa1111_hc_driver = {
80 .description = hcd_name,
81 .product_desc = "SA-1111 OHCI",
82 .hcd_priv_size = sizeof(struct ohci_hcd),
83
84 /*
85 * generic hardware linkage
86 */
87 .irq = ohci_irq,
88 .flags = HCD_USB11 | HCD_MEMORY,
89
90 /*
91 * basic lifecycle operations
92 */
93 .reset = ohci_sa1111_reset,
94 .start = ohci_sa1111_start,
95 .stop = ohci_stop,
96 .shutdown = ohci_shutdown,
97
98 /*
99 * managing i/o requests and associated device resources
100 */
101 .urb_enqueue = ohci_urb_enqueue,
102 .urb_dequeue = ohci_urb_dequeue,
103 .endpoint_disable = ohci_endpoint_disable,
104
105 /*
106 * scheduling support
107 */
108 .get_frame_number = ohci_get_frame,
109
110 /*
111 * root hub support
112 */
113 .hub_status_data = ohci_hub_status_data,
114 .hub_control = ohci_hub_control,
115#ifdef CONFIG_PM
116 .bus_suspend = ohci_bus_suspend,
117 .bus_resume = ohci_bus_resume,
41#endif 118#endif
119 .start_port_reset = ohci_start_port_reset,
120};
121
122static int sa1111_start_hc(struct sa1111_dev *dev)
123{
124 unsigned int usb_rst = 0;
125 int ret;
126
127 dev_dbg(&dev->dev, "starting SA-1111 OHCI USB Controller\n");
42 128
43 if (machine_is_xp860() || 129 if (machine_is_xp860() ||
44 machine_has_neponset() || 130 machine_has_neponset() ||
@@ -51,220 +137,121 @@ static void sa1111_start_hc(struct sa1111_dev *dev)
51 * host controller in reset. 137 * host controller in reset.
52 */ 138 */
53 sa1111_writel(usb_rst | USB_RESET_FORCEIFRESET | USB_RESET_FORCEHCRESET, 139 sa1111_writel(usb_rst | USB_RESET_FORCEIFRESET | USB_RESET_FORCEHCRESET,
54 dev->mapbase + SA1111_USB_RESET); 140 dev->mapbase + USB_RESET);
55 141
56 /* 142 /*
57 * Now, carefully enable the USB clock, and take 143 * Now, carefully enable the USB clock, and take
58 * the USB host controller out of reset. 144 * the USB host controller out of reset.
59 */ 145 */
60 sa1111_enable_device(dev); 146 ret = sa1111_enable_device(dev);
61 udelay(11); 147 if (ret == 0) {
62 sa1111_writel(usb_rst, dev->mapbase + SA1111_USB_RESET); 148 udelay(11);
149 sa1111_writel(usb_rst, dev->mapbase + USB_RESET);
150 }
151
152 return ret;
63} 153}
64 154
65static void sa1111_stop_hc(struct sa1111_dev *dev) 155static void sa1111_stop_hc(struct sa1111_dev *dev)
66{ 156{
67 unsigned int usb_rst; 157 unsigned int usb_rst;
68 printk(KERN_DEBUG "%s: stopping SA-1111 OHCI USB Controller\n", 158
69 __FILE__); 159 dev_dbg(&dev->dev, "stopping SA-1111 OHCI USB Controller\n");
70 160
71 /* 161 /*
72 * Put the USB host controller into reset. 162 * Put the USB host controller into reset.
73 */ 163 */
74 usb_rst = sa1111_readl(dev->mapbase + SA1111_USB_RESET); 164 usb_rst = sa1111_readl(dev->mapbase + USB_RESET);
75 sa1111_writel(usb_rst | USB_RESET_FORCEIFRESET | USB_RESET_FORCEHCRESET, 165 sa1111_writel(usb_rst | USB_RESET_FORCEIFRESET | USB_RESET_FORCEHCRESET,
76 dev->mapbase + SA1111_USB_RESET); 166 dev->mapbase + USB_RESET);
77 167
78 /* 168 /*
79 * Stop the USB clock. 169 * Stop the USB clock.
80 */ 170 */
81 sa1111_disable_device(dev); 171 sa1111_disable_device(dev);
82
83#ifdef CONFIG_SA1100_BADGE4
84 if (machine_is_badge4()) {
85 /* Disable power to the USB bus */
86 badge4_set_5V(BADGE4_5V_USB, 0);
87 }
88#endif
89}
90
91
92/*-------------------------------------------------------------------------*/
93
94#if 0
95static void dump_hci_status(struct usb_hcd *hcd, const char *label)
96{
97 unsigned long status = sa1111_readl(hcd->regs + SA1111_USB_STATUS);
98
99 dbg ("%s USB_STATUS = { %s%s%s%s%s}", label,
100 ((status & USB_STATUS_IRQHCIRMTWKUP) ? "IRQHCIRMTWKUP " : ""),
101 ((status & USB_STATUS_IRQHCIBUFFACC) ? "IRQHCIBUFFACC " : ""),
102 ((status & USB_STATUS_NIRQHCIM) ? "" : "IRQHCIM "),
103 ((status & USB_STATUS_NHCIMFCLR) ? "" : "HCIMFCLR "),
104 ((status & USB_STATUS_USBPWRSENSE) ? "USBPWRSENSE " : ""));
105} 172}
106#endif
107
108/*-------------------------------------------------------------------------*/
109
110/* configure so an HC device and id are always provided */
111/* always called with process context; sleeping is OK */
112
113 173
114/** 174/**
115 * usb_hcd_sa1111_probe - initialize SA-1111-based HCDs 175 * ohci_hcd_sa1111_probe - initialize SA-1111-based HCDs
116 * Context: !in_interrupt()
117 * 176 *
118 * Allocates basic resources for this USB host controller, and 177 * Allocates basic resources for this USB host controller, and
119 * then invokes the start() method for the HCD associated with it 178 * then invokes the start() method for the HCD associated with it.
120 * through the hotplug entry's driver_data.
121 *
122 * Store this function in the HCD's struct pci_driver as probe().
123 */ 179 */
124int usb_hcd_sa1111_probe (const struct hc_driver *driver, 180static int ohci_hcd_sa1111_probe(struct sa1111_dev *dev)
125 struct sa1111_dev *dev)
126{ 181{
127 struct usb_hcd *hcd; 182 struct usb_hcd *hcd;
128 int retval; 183 int ret;
129 184
130 hcd = usb_create_hcd (driver, &dev->dev, "sa1111"); 185 if (usb_disabled())
186 return -ENODEV;
187
188 hcd = usb_create_hcd(&ohci_sa1111_hc_driver, &dev->dev, "sa1111");
131 if (!hcd) 189 if (!hcd)
132 return -ENOMEM; 190 return -ENOMEM;
191
133 hcd->rsrc_start = dev->res.start; 192 hcd->rsrc_start = dev->res.start;
134 hcd->rsrc_len = resource_size(&dev->res); 193 hcd->rsrc_len = resource_size(&dev->res);
135 194
136 if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { 195 if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) {
137 dbg("request_mem_region failed"); 196 dbg("request_mem_region failed");
138 retval = -EBUSY; 197 ret = -EBUSY;
139 goto err1; 198 goto err1;
140 } 199 }
200
141 hcd->regs = dev->mapbase; 201 hcd->regs = dev->mapbase;
142 202
143 sa1111_start_hc(dev); 203 ret = sa1111_start_hc(dev);
144 ohci_hcd_init(hcd_to_ohci(hcd)); 204 if (ret)
205 goto err2;
145 206
146 retval = usb_add_hcd(hcd, dev->irq[1], 0); 207 ret = usb_add_hcd(hcd, dev->irq[1], 0);
147 if (retval == 0) 208 if (ret == 0)
148 return retval; 209 return ret;
149 210
150 sa1111_stop_hc(dev); 211 sa1111_stop_hc(dev);
212 err2:
151 release_mem_region(hcd->rsrc_start, hcd->rsrc_len); 213 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
152 err1: 214 err1:
153 usb_put_hcd(hcd); 215 usb_put_hcd(hcd);
154 return retval; 216 return ret;
155} 217}
156 218
157
158/* may be called without controller electrically present */
159/* may be called with controller, bus, and devices active */
160
161/** 219/**
162 * usb_hcd_sa1111_remove - shutdown processing for SA-1111-based HCDs 220 * ohci_hcd_sa1111_remove - shutdown processing for SA-1111-based HCDs
163 * @dev: USB Host Controller being removed 221 * @dev: USB Host Controller being removed
164 * Context: !in_interrupt()
165 *
166 * Reverses the effect of usb_hcd_sa1111_probe(), first invoking
167 * the HCD's stop() method. It is always called from a thread
168 * context, normally "rmmod", "apmd", or something similar.
169 * 222 *
223 * Reverses the effect of ohci_hcd_sa1111_probe(), first invoking
224 * the HCD's stop() method.
170 */ 225 */
171void usb_hcd_sa1111_remove (struct usb_hcd *hcd, struct sa1111_dev *dev) 226static int ohci_hcd_sa1111_remove(struct sa1111_dev *dev)
172{ 227{
228 struct usb_hcd *hcd = sa1111_get_drvdata(dev);
229
173 usb_remove_hcd(hcd); 230 usb_remove_hcd(hcd);
174 sa1111_stop_hc(dev); 231 sa1111_stop_hc(dev);
175 release_mem_region(hcd->rsrc_start, hcd->rsrc_len); 232 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
176 usb_put_hcd(hcd); 233 usb_put_hcd(hcd);
177}
178
179/*-------------------------------------------------------------------------*/
180 234
181static int __devinit
182ohci_sa1111_start (struct usb_hcd *hcd)
183{
184 struct ohci_hcd *ohci = hcd_to_ohci (hcd);
185 int ret;
186
187 if ((ret = ohci_init(ohci)) < 0)
188 return ret;
189
190 if ((ret = ohci_run (ohci)) < 0) {
191 err ("can't start %s", hcd->self.bus_name);
192 ohci_stop (hcd);
193 return ret;
194 }
195 return 0; 235 return 0;
196} 236}
197 237
198/*-------------------------------------------------------------------------*/ 238static void ohci_hcd_sa1111_shutdown(struct sa1111_dev *dev)
199
200static const struct hc_driver ohci_sa1111_hc_driver = {
201 .description = hcd_name,
202 .product_desc = "SA-1111 OHCI",
203 .hcd_priv_size = sizeof(struct ohci_hcd),
204
205 /*
206 * generic hardware linkage
207 */
208 .irq = ohci_irq,
209 .flags = HCD_USB11 | HCD_MEMORY,
210
211 /*
212 * basic lifecycle operations
213 */
214 .start = ohci_sa1111_start,
215 .stop = ohci_stop,
216
217 /*
218 * managing i/o requests and associated device resources
219 */
220 .urb_enqueue = ohci_urb_enqueue,
221 .urb_dequeue = ohci_urb_dequeue,
222 .endpoint_disable = ohci_endpoint_disable,
223
224 /*
225 * scheduling support
226 */
227 .get_frame_number = ohci_get_frame,
228
229 /*
230 * root hub support
231 */
232 .hub_status_data = ohci_hub_status_data,
233 .hub_control = ohci_hub_control,
234#ifdef CONFIG_PM
235 .bus_suspend = ohci_bus_suspend,
236 .bus_resume = ohci_bus_resume,
237#endif
238 .start_port_reset = ohci_start_port_reset,
239};
240
241/*-------------------------------------------------------------------------*/
242
243static int ohci_hcd_sa1111_drv_probe(struct sa1111_dev *dev)
244{
245 int ret;
246
247 if (usb_disabled())
248 return -ENODEV;
249
250 ret = usb_hcd_sa1111_probe(&ohci_sa1111_hc_driver, dev);
251 return ret;
252}
253
254static int ohci_hcd_sa1111_drv_remove(struct sa1111_dev *dev)
255{ 239{
256 struct usb_hcd *hcd = sa1111_get_drvdata(dev); 240 struct usb_hcd *hcd = sa1111_get_drvdata(dev);
257 241
258 usb_hcd_sa1111_remove(hcd, dev); 242 if (test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) {
259 return 0; 243 hcd->driver->shutdown(hcd);
244 sa1111_stop_hc(dev);
245 }
260} 246}
261 247
262static struct sa1111_driver ohci_hcd_sa1111_driver = { 248static struct sa1111_driver ohci_hcd_sa1111_driver = {
263 .drv = { 249 .drv = {
264 .name = "sa1111-ohci", 250 .name = "sa1111-ohci",
251 .owner = THIS_MODULE,
265 }, 252 },
266 .devid = SA1111_DEVID_USB, 253 .devid = SA1111_DEVID_USB,
267 .probe = ohci_hcd_sa1111_drv_probe, 254 .probe = ohci_hcd_sa1111_probe,
268 .remove = ohci_hcd_sa1111_drv_remove, 255 .remove = ohci_hcd_sa1111_remove,
256 .shutdown = ohci_hcd_sa1111_shutdown,
269}; 257};
270
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index 6815701cf656..836cfa9a515f 100644
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -903,8 +903,10 @@ static const struct usb_device_id option_ids[] = {
903 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0165, 0xff, 0xff, 0xff) }, 903 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0165, 0xff, 0xff, 0xff) },
904 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0167, 0xff, 0xff, 0xff), 904 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0167, 0xff, 0xff, 0xff),
905 .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, 905 .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
906 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1008, 0xff, 0xff, 0xff) }, 906 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1008, 0xff, 0xff, 0xff),
907 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1010, 0xff, 0xff, 0xff) }, 907 .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
908 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1010, 0xff, 0xff, 0xff),
909 .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
908 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1012, 0xff, 0xff, 0xff) }, 910 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1012, 0xff, 0xff, 0xff) },
909 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1057, 0xff, 0xff, 0xff) }, 911 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1057, 0xff, 0xff, 0xff) },
910 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1058, 0xff, 0xff, 0xff) }, 912 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1058, 0xff, 0xff, 0xff) },