diff options
Diffstat (limited to 'drivers/usb/gadget/net2280.c')
-rw-r--r-- | drivers/usb/gadget/net2280.c | 93 |
1 files changed, 71 insertions, 22 deletions
diff --git a/drivers/usb/gadget/net2280.c b/drivers/usb/gadget/net2280.c index fb73dc100535..6a4b93ad1082 100644 --- a/drivers/usb/gadget/net2280.c +++ b/drivers/usb/gadget/net2280.c | |||
@@ -26,6 +26,8 @@ | |||
26 | * Copyright (C) 2003 David Brownell | 26 | * Copyright (C) 2003 David Brownell |
27 | * Copyright (C) 2003-2005 PLX Technology, Inc. | 27 | * Copyright (C) 2003-2005 PLX Technology, Inc. |
28 | * | 28 | * |
29 | * Modified Seth Levy 2005 PLX Technology, Inc. to provide compatibility with 2282 chip | ||
30 | * | ||
29 | * This program is free software; you can redistribute it and/or modify | 31 | * This program is free software; you can redistribute it and/or modify |
30 | * it under the terms of the GNU General Public License as published by | 32 | * it under the terms of the GNU General Public License as published by |
31 | * the Free Software Foundation; either version 2 of the License, or | 33 | * the Free Software Foundation; either version 2 of the License, or |
@@ -71,8 +73,8 @@ | |||
71 | #include <asm/unaligned.h> | 73 | #include <asm/unaligned.h> |
72 | 74 | ||
73 | 75 | ||
74 | #define DRIVER_DESC "PLX NET2280 USB Peripheral Controller" | 76 | #define DRIVER_DESC "PLX NET228x USB Peripheral Controller" |
75 | #define DRIVER_VERSION "2005 Feb 03" | 77 | #define DRIVER_VERSION "2005 Sept 27" |
76 | 78 | ||
77 | #define DMA_ADDR_INVALID (~(dma_addr_t)0) | 79 | #define DMA_ADDR_INVALID (~(dma_addr_t)0) |
78 | #define EP_DONTUSE 13 /* nonzero */ | 80 | #define EP_DONTUSE 13 /* nonzero */ |
@@ -118,7 +120,7 @@ module_param (fifo_mode, ushort, 0644); | |||
118 | /* enable_suspend -- When enabled, the driver will respond to | 120 | /* enable_suspend -- When enabled, the driver will respond to |
119 | * USB suspend requests by powering down the NET2280. Otherwise, | 121 | * USB suspend requests by powering down the NET2280. Otherwise, |
120 | * USB suspend requests will be ignored. This is acceptible for | 122 | * USB suspend requests will be ignored. This is acceptible for |
121 | * self-powered devices, and helps avoid some quirks. | 123 | * self-powered devices |
122 | */ | 124 | */ |
123 | static int enable_suspend = 0; | 125 | static int enable_suspend = 0; |
124 | 126 | ||
@@ -223,6 +225,11 @@ net2280_enable (struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc) | |||
223 | ep->is_in = (tmp & USB_DIR_IN) != 0; | 225 | ep->is_in = (tmp & USB_DIR_IN) != 0; |
224 | if (!ep->is_in) | 226 | if (!ep->is_in) |
225 | writel ((1 << SET_NAK_OUT_PACKETS), &ep->regs->ep_rsp); | 227 | writel ((1 << SET_NAK_OUT_PACKETS), &ep->regs->ep_rsp); |
228 | else if (dev->pdev->device != 0x2280) { | ||
229 | /* Added for 2282, Don't use nak packets on an in endpoint, this was ignored on 2280 */ | ||
230 | writel ((1 << CLEAR_NAK_OUT_PACKETS) | ||
231 | | (1 << CLEAR_NAK_OUT_PACKETS_MODE), &ep->regs->ep_rsp); | ||
232 | } | ||
226 | 233 | ||
227 | writel (tmp, &ep->regs->ep_cfg); | 234 | writel (tmp, &ep->regs->ep_cfg); |
228 | 235 | ||
@@ -232,8 +239,9 @@ net2280_enable (struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc) | |||
232 | writel (tmp, &dev->regs->pciirqenb0); | 239 | writel (tmp, &dev->regs->pciirqenb0); |
233 | 240 | ||
234 | tmp = (1 << DATA_PACKET_RECEIVED_INTERRUPT_ENABLE) | 241 | tmp = (1 << DATA_PACKET_RECEIVED_INTERRUPT_ENABLE) |
235 | | (1 << DATA_PACKET_TRANSMITTED_INTERRUPT_ENABLE) | 242 | | (1 << DATA_PACKET_TRANSMITTED_INTERRUPT_ENABLE); |
236 | | readl (&ep->regs->ep_irqenb); | 243 | if (dev->pdev->device == 0x2280) |
244 | tmp |= readl (&ep->regs->ep_irqenb); | ||
237 | writel (tmp, &ep->regs->ep_irqenb); | 245 | writel (tmp, &ep->regs->ep_irqenb); |
238 | } else { /* dma, per-request */ | 246 | } else { /* dma, per-request */ |
239 | tmp = (1 << (8 + ep->num)); /* completion */ | 247 | tmp = (1 << (8 + ep->num)); /* completion */ |
@@ -314,10 +322,18 @@ static void ep_reset (struct net2280_regs __iomem *regs, struct net2280_ep *ep) | |||
314 | /* init to our chosen defaults, notably so that we NAK OUT | 322 | /* init to our chosen defaults, notably so that we NAK OUT |
315 | * packets until the driver queues a read (+note erratum 0112) | 323 | * packets until the driver queues a read (+note erratum 0112) |
316 | */ | 324 | */ |
317 | tmp = (1 << SET_NAK_OUT_PACKETS_MODE) | 325 | if (!ep->is_in || ep->dev->pdev->device == 0x2280) { |
326 | tmp = (1 << SET_NAK_OUT_PACKETS_MODE) | ||
318 | | (1 << SET_NAK_OUT_PACKETS) | 327 | | (1 << SET_NAK_OUT_PACKETS) |
319 | | (1 << CLEAR_EP_HIDE_STATUS_PHASE) | 328 | | (1 << CLEAR_EP_HIDE_STATUS_PHASE) |
320 | | (1 << CLEAR_INTERRUPT_MODE); | 329 | | (1 << CLEAR_INTERRUPT_MODE); |
330 | } else { | ||
331 | /* added for 2282 */ | ||
332 | tmp = (1 << CLEAR_NAK_OUT_PACKETS_MODE) | ||
333 | | (1 << CLEAR_NAK_OUT_PACKETS) | ||
334 | | (1 << CLEAR_EP_HIDE_STATUS_PHASE) | ||
335 | | (1 << CLEAR_INTERRUPT_MODE); | ||
336 | } | ||
321 | 337 | ||
322 | if (ep->num != 0) { | 338 | if (ep->num != 0) { |
323 | tmp |= (1 << CLEAR_ENDPOINT_TOGGLE) | 339 | tmp |= (1 << CLEAR_ENDPOINT_TOGGLE) |
@@ -326,14 +342,18 @@ static void ep_reset (struct net2280_regs __iomem *regs, struct net2280_ep *ep) | |||
326 | writel (tmp, &ep->regs->ep_rsp); | 342 | writel (tmp, &ep->regs->ep_rsp); |
327 | 343 | ||
328 | /* scrub most status bits, and flush any fifo state */ | 344 | /* scrub most status bits, and flush any fifo state */ |
329 | writel ( (1 << TIMEOUT) | 345 | if (ep->dev->pdev->device == 0x2280) |
346 | tmp = (1 << FIFO_OVERFLOW) | ||
347 | | (1 << FIFO_UNDERFLOW); | ||
348 | else | ||
349 | tmp = 0; | ||
350 | |||
351 | writel (tmp | (1 << TIMEOUT) | ||
330 | | (1 << USB_STALL_SENT) | 352 | | (1 << USB_STALL_SENT) |
331 | | (1 << USB_IN_NAK_SENT) | 353 | | (1 << USB_IN_NAK_SENT) |
332 | | (1 << USB_IN_ACK_RCVD) | 354 | | (1 << USB_IN_ACK_RCVD) |
333 | | (1 << USB_OUT_PING_NAK_SENT) | 355 | | (1 << USB_OUT_PING_NAK_SENT) |
334 | | (1 << USB_OUT_ACK_SENT) | 356 | | (1 << USB_OUT_ACK_SENT) |
335 | | (1 << FIFO_OVERFLOW) | ||
336 | | (1 << FIFO_UNDERFLOW) | ||
337 | | (1 << FIFO_FLUSH) | 357 | | (1 << FIFO_FLUSH) |
338 | | (1 << SHORT_PACKET_OUT_DONE_INTERRUPT) | 358 | | (1 << SHORT_PACKET_OUT_DONE_INTERRUPT) |
339 | | (1 << SHORT_PACKET_TRANSFERRED_INTERRUPT) | 359 | | (1 << SHORT_PACKET_TRANSFERRED_INTERRUPT) |
@@ -718,7 +738,7 @@ fill_dma_desc (struct net2280_ep *ep, struct net2280_request *req, int valid) | |||
718 | */ | 738 | */ |
719 | if (ep->is_in) | 739 | if (ep->is_in) |
720 | dmacount |= (1 << DMA_DIRECTION); | 740 | dmacount |= (1 << DMA_DIRECTION); |
721 | else if ((dmacount % ep->ep.maxpacket) != 0) | 741 | if ((!ep->is_in && (dmacount % ep->ep.maxpacket) != 0) || ep->dev->pdev->device != 0x2280) |
722 | dmacount |= (1 << END_OF_CHAIN); | 742 | dmacount |= (1 << END_OF_CHAIN); |
723 | 743 | ||
724 | req->valid = valid; | 744 | req->valid = valid; |
@@ -760,9 +780,12 @@ static inline void stop_dma (struct net2280_dma_regs __iomem *dma) | |||
760 | static void start_queue (struct net2280_ep *ep, u32 dmactl, u32 td_dma) | 780 | static void start_queue (struct net2280_ep *ep, u32 dmactl, u32 td_dma) |
761 | { | 781 | { |
762 | struct net2280_dma_regs __iomem *dma = ep->dma; | 782 | struct net2280_dma_regs __iomem *dma = ep->dma; |
783 | unsigned int tmp = (1 << VALID_BIT) | (ep->is_in << DMA_DIRECTION); | ||
763 | 784 | ||
764 | writel ((1 << VALID_BIT) | (ep->is_in << DMA_DIRECTION), | 785 | if (ep->dev->pdev->device != 0x2280) |
765 | &dma->dmacount); | 786 | tmp |= (1 << END_OF_CHAIN); |
787 | |||
788 | writel (tmp, &dma->dmacount); | ||
766 | writel (readl (&dma->dmastat), &dma->dmastat); | 789 | writel (readl (&dma->dmastat), &dma->dmastat); |
767 | 790 | ||
768 | writel (td_dma, &dma->dmadesc); | 791 | writel (td_dma, &dma->dmadesc); |
@@ -2110,7 +2133,11 @@ static void handle_ep_small (struct net2280_ep *ep) | |||
2110 | VDEBUG (ep->dev, "%s ack ep_stat %08x, req %p\n", | 2133 | VDEBUG (ep->dev, "%s ack ep_stat %08x, req %p\n", |
2111 | ep->ep.name, t, req ? &req->req : 0); | 2134 | ep->ep.name, t, req ? &req->req : 0); |
2112 | #endif | 2135 | #endif |
2113 | writel (t & ~(1 << NAK_OUT_PACKETS), &ep->regs->ep_stat); | 2136 | if (!ep->is_in || ep->dev->pdev->device == 0x2280) |
2137 | writel (t & ~(1 << NAK_OUT_PACKETS), &ep->regs->ep_stat); | ||
2138 | else | ||
2139 | /* Added for 2282 */ | ||
2140 | writel (t, &ep->regs->ep_stat); | ||
2114 | 2141 | ||
2115 | /* for ep0, monitor token irqs to catch data stage length errors | 2142 | /* for ep0, monitor token irqs to catch data stage length errors |
2116 | * and to synchronize on status. | 2143 | * and to synchronize on status. |
@@ -2214,7 +2241,8 @@ static void handle_ep_small (struct net2280_ep *ep) | |||
2214 | if (likely (req)) { | 2241 | if (likely (req)) { |
2215 | req->td->dmacount = 0; | 2242 | req->td->dmacount = 0; |
2216 | t = readl (&ep->regs->ep_avail); | 2243 | t = readl (&ep->regs->ep_avail); |
2217 | dma_done (ep, req, count, t); | 2244 | dma_done (ep, req, count, |
2245 | (ep->out_overflow || t) ? -EOVERFLOW : 0); | ||
2218 | } | 2246 | } |
2219 | 2247 | ||
2220 | /* also flush to prevent erratum 0106 trouble */ | 2248 | /* also flush to prevent erratum 0106 trouble */ |
@@ -2337,7 +2365,7 @@ static void handle_stat0_irqs (struct net2280 *dev, u32 stat) | |||
2337 | u32 raw [2]; | 2365 | u32 raw [2]; |
2338 | struct usb_ctrlrequest r; | 2366 | struct usb_ctrlrequest r; |
2339 | } u; | 2367 | } u; |
2340 | int tmp = 0; | 2368 | int tmp; |
2341 | struct net2280_request *req; | 2369 | struct net2280_request *req; |
2342 | 2370 | ||
2343 | if (dev->gadget.speed == USB_SPEED_UNKNOWN) { | 2371 | if (dev->gadget.speed == USB_SPEED_UNKNOWN) { |
@@ -2364,14 +2392,19 @@ static void handle_stat0_irqs (struct net2280 *dev, u32 stat) | |||
2364 | } | 2392 | } |
2365 | ep->stopped = 0; | 2393 | ep->stopped = 0; |
2366 | dev->protocol_stall = 0; | 2394 | dev->protocol_stall = 0; |
2367 | writel ( (1 << TIMEOUT) | 2395 | |
2396 | if (ep->dev->pdev->device == 0x2280) | ||
2397 | tmp = (1 << FIFO_OVERFLOW) | ||
2398 | | (1 << FIFO_UNDERFLOW); | ||
2399 | else | ||
2400 | tmp = 0; | ||
2401 | |||
2402 | writel (tmp | (1 << TIMEOUT) | ||
2368 | | (1 << USB_STALL_SENT) | 2403 | | (1 << USB_STALL_SENT) |
2369 | | (1 << USB_IN_NAK_SENT) | 2404 | | (1 << USB_IN_NAK_SENT) |
2370 | | (1 << USB_IN_ACK_RCVD) | 2405 | | (1 << USB_IN_ACK_RCVD) |
2371 | | (1 << USB_OUT_PING_NAK_SENT) | 2406 | | (1 << USB_OUT_PING_NAK_SENT) |
2372 | | (1 << USB_OUT_ACK_SENT) | 2407 | | (1 << USB_OUT_ACK_SENT) |
2373 | | (1 << FIFO_OVERFLOW) | ||
2374 | | (1 << FIFO_UNDERFLOW) | ||
2375 | | (1 << SHORT_PACKET_OUT_DONE_INTERRUPT) | 2408 | | (1 << SHORT_PACKET_OUT_DONE_INTERRUPT) |
2376 | | (1 << SHORT_PACKET_TRANSFERRED_INTERRUPT) | 2409 | | (1 << SHORT_PACKET_TRANSFERRED_INTERRUPT) |
2377 | | (1 << DATA_PACKET_RECEIVED_INTERRUPT) | 2410 | | (1 << DATA_PACKET_RECEIVED_INTERRUPT) |
@@ -2385,6 +2418,8 @@ static void handle_stat0_irqs (struct net2280 *dev, u32 stat) | |||
2385 | cpu_to_le32s (&u.raw [0]); | 2418 | cpu_to_le32s (&u.raw [0]); |
2386 | cpu_to_le32s (&u.raw [1]); | 2419 | cpu_to_le32s (&u.raw [1]); |
2387 | 2420 | ||
2421 | tmp = 0; | ||
2422 | |||
2388 | #define w_value le16_to_cpup (&u.r.wValue) | 2423 | #define w_value le16_to_cpup (&u.r.wValue) |
2389 | #define w_index le16_to_cpup (&u.r.wIndex) | 2424 | #define w_index le16_to_cpup (&u.r.wIndex) |
2390 | #define w_length le16_to_cpup (&u.r.wLength) | 2425 | #define w_length le16_to_cpup (&u.r.wLength) |
@@ -2594,10 +2629,17 @@ static void handle_stat1_irqs (struct net2280 *dev, u32 stat) | |||
2594 | writel (stat, &dev->regs->irqstat1); | 2629 | writel (stat, &dev->regs->irqstat1); |
2595 | 2630 | ||
2596 | /* some status we can just ignore */ | 2631 | /* some status we can just ignore */ |
2597 | stat &= ~((1 << CONTROL_STATUS_INTERRUPT) | 2632 | if (dev->pdev->device == 0x2280) |
2598 | | (1 << SUSPEND_REQUEST_INTERRUPT) | 2633 | stat &= ~((1 << CONTROL_STATUS_INTERRUPT) |
2599 | | (1 << RESUME_INTERRUPT) | 2634 | | (1 << SUSPEND_REQUEST_INTERRUPT) |
2600 | | (1 << SOF_INTERRUPT)); | 2635 | | (1 << RESUME_INTERRUPT) |
2636 | | (1 << SOF_INTERRUPT)); | ||
2637 | else | ||
2638 | stat &= ~((1 << CONTROL_STATUS_INTERRUPT) | ||
2639 | | (1 << RESUME_INTERRUPT) | ||
2640 | | (1 << SOF_DOWN_INTERRUPT) | ||
2641 | | (1 << SOF_INTERRUPT)); | ||
2642 | |||
2601 | if (!stat) | 2643 | if (!stat) |
2602 | return; | 2644 | return; |
2603 | // DEBUG (dev, "irqstat1 %08x\n", stat); | 2645 | // DEBUG (dev, "irqstat1 %08x\n", stat); |
@@ -2939,6 +2981,13 @@ static struct pci_device_id pci_ids [] = { { | |||
2939 | .device = 0x2280, | 2981 | .device = 0x2280, |
2940 | .subvendor = PCI_ANY_ID, | 2982 | .subvendor = PCI_ANY_ID, |
2941 | .subdevice = PCI_ANY_ID, | 2983 | .subdevice = PCI_ANY_ID, |
2984 | }, { | ||
2985 | .class = ((PCI_CLASS_SERIAL_USB << 8) | 0xfe), | ||
2986 | .class_mask = ~0, | ||
2987 | .vendor = 0x17cc, | ||
2988 | .device = 0x2282, | ||
2989 | .subvendor = PCI_ANY_ID, | ||
2990 | .subdevice = PCI_ANY_ID, | ||
2942 | 2991 | ||
2943 | }, { /* end: all zeroes */ } | 2992 | }, { /* end: all zeroes */ } |
2944 | }; | 2993 | }; |