aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-05-28 14:35:41 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-05-28 14:35:41 -0400
commit357d596ea7bea5abf1479cc72ae5888c738717dd (patch)
treec61ad0150643091c406e4f35bed769bebffcabc9 /drivers/usb
parentc624fa5e0ec09c99bff0ab7759fea55bb00d36c6 (diff)
Revert "usb: gadget: net2280: Add support for PLX USB338X"
This reverts commit c4128cac3557ddd5fa972cb6511c426cd94a7ccd. This should come through Felipe's tree first, and there was a bunch of other patches that are needed after this one as well that I didn't have. Cc: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com> Cc: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/gadget/Kconfig10
-rw-r--r--drivers/usb/gadget/net2280.c1115
-rw-r--r--drivers/usb/gadget/net2280.h97
3 files changed, 91 insertions, 1131 deletions
diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index 49e434ec527d..ba18e9c110cc 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -409,7 +409,7 @@ config USB_NET2272_DMA
409 If unsure, say "N" here. The driver works fine in PIO mode. 409 If unsure, say "N" here. The driver works fine in PIO mode.
410 410
411config USB_NET2280 411config USB_NET2280
412 tristate "NetChip 228x / PLX USB338x" 412 tristate "NetChip 228x"
413 depends on PCI 413 depends on PCI
414 help 414 help
415 NetChip 2280 / 2282 is a PCI based USB peripheral controller which 415 NetChip 2280 / 2282 is a PCI based USB peripheral controller which
@@ -419,14 +419,6 @@ config USB_NET2280
419 (for control transfers) and several endpoints with dedicated 419 (for control transfers) and several endpoints with dedicated
420 functions. 420 functions.
421 421
422 PLX 3380 / 3382 is a PCIe based USB peripheral controller which
423 supports full, high speed USB 2.0 and super speed USB 3.0
424 data transfers.
425
426 It has eight configurable endpoints, as well as endpoint zero
427 (for control transfers) and several endpoints with dedicated
428 functions.
429
430 Say "y" to link the driver statically, or "m" to build a 422 Say "y" to link the driver statically, or "m" to build a
431 dynamically linked module called "net2280" and force all 423 dynamically linked module called "net2280" and force all
432 gadget drivers to also be dynamically linked. 424 gadget drivers to also be dynamically linked.
diff --git a/drivers/usb/gadget/net2280.c b/drivers/usb/gadget/net2280.c
index 87789c9bf7fe..300b3a71383b 100644
--- a/drivers/usb/gadget/net2280.c
+++ b/drivers/usb/gadget/net2280.c
@@ -18,9 +18,6 @@
18 * hint to completely eliminate some IRQs, if a later IRQ is guaranteed 18 * hint to completely eliminate some IRQs, if a later IRQ is guaranteed
19 * and DMA chaining is enabled. 19 * and DMA chaining is enabled.
20 * 20 *
21 * MSI is enabled by default. The legacy IRQ is used if MSI couldn't
22 * be enabled.
23 *
24 * Note that almost all the errata workarounds here are only needed for 21 * Note that almost all the errata workarounds here are only needed for
25 * rev1 chips. Rev1a silicon (0110) fixes almost all of them. 22 * rev1 chips. Rev1a silicon (0110) fixes almost all of them.
26 */ 23 */
@@ -28,14 +25,10 @@
28/* 25/*
29 * Copyright (C) 2003 David Brownell 26 * Copyright (C) 2003 David Brownell
30 * Copyright (C) 2003-2005 PLX Technology, Inc. 27 * Copyright (C) 2003-2005 PLX Technology, Inc.
31 * Copyright (C) 2014 Ricardo Ribalda - Qtechnology/AS
32 * 28 *
33 * Modified Seth Levy 2005 PLX Technology, Inc. to provide compatibility 29 * Modified Seth Levy 2005 PLX Technology, Inc. to provide compatibility
34 * with 2282 chip 30 * with 2282 chip
35 * 31 *
36 * Modified Ricardo Ribalda Qtechnology AS to provide compatibility
37 * with usb 338x chip. Based on PLX driver
38 *
39 * This program is free software; you can redistribute it and/or modify 32 * This program is free software; you can redistribute it and/or modify
40 * it under the terms of the GNU General Public License as published by 33 * it under the terms of the GNU General Public License as published by
41 * the Free Software Foundation; either version 2 of the License, or 34 * the Free Software Foundation; either version 2 of the License, or
@@ -68,8 +61,9 @@
68#include <asm/irq.h> 61#include <asm/irq.h>
69#include <asm/unaligned.h> 62#include <asm/unaligned.h>
70 63
71#define DRIVER_DESC "PLX NET228x/USB338x USB Peripheral Controller" 64
72#define DRIVER_VERSION "2005 Sept 27/v3.0" 65#define DRIVER_DESC "PLX NET228x USB Peripheral Controller"
66#define DRIVER_VERSION "2005 Sept 27"
73 67
74#define EP_DONTUSE 13 /* nonzero */ 68#define EP_DONTUSE 13 /* nonzero */
75 69
@@ -79,12 +73,11 @@
79static const char driver_name [] = "net2280"; 73static const char driver_name [] = "net2280";
80static const char driver_desc [] = DRIVER_DESC; 74static const char driver_desc [] = DRIVER_DESC;
81 75
82static const u32 ep_bit[9] = { 0, 17, 2, 19, 4, 1, 18, 3, 20 };
83static const char ep0name [] = "ep0"; 76static const char ep0name [] = "ep0";
84static const char *const ep_name [] = { 77static const char *const ep_name [] = {
85 ep0name, 78 ep0name,
86 "ep-a", "ep-b", "ep-c", "ep-d", 79 "ep-a", "ep-b", "ep-c", "ep-d",
87 "ep-e", "ep-f", "ep-g", "ep-h", 80 "ep-e", "ep-f",
88}; 81};
89 82
90/* use_dma -- general goodness, fewer interrupts, less cpu load (vs PIO) 83/* use_dma -- general goodness, fewer interrupts, less cpu load (vs PIO)
@@ -97,12 +90,11 @@ static const char *const ep_name [] = {
97 */ 90 */
98static bool use_dma = 1; 91static bool use_dma = 1;
99static bool use_dma_chaining = 0; 92static bool use_dma_chaining = 0;
100static bool use_msi = 1;
101 93
102/* "modprobe net2280 use_dma=n" etc */ 94/* "modprobe net2280 use_dma=n" etc */
103module_param (use_dma, bool, S_IRUGO); 95module_param (use_dma, bool, S_IRUGO);
104module_param (use_dma_chaining, bool, S_IRUGO); 96module_param (use_dma_chaining, bool, S_IRUGO);
105module_param(use_msi, bool, S_IRUGO); 97
106 98
107/* mode 0 == ep-{a,b,c,d} 1K fifo each 99/* mode 0 == ep-{a,b,c,d} 1K fifo each
108 * mode 1 == ep-{a,b} 2K fifo each, ep-{c,d} unavailable 100 * mode 1 == ep-{a,b} 2K fifo each, ep-{c,d} unavailable
@@ -156,9 +148,6 @@ net2280_enable (struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc)
156 struct net2280_ep *ep; 148 struct net2280_ep *ep;
157 u32 max, tmp; 149 u32 max, tmp;
158 unsigned long flags; 150 unsigned long flags;
159 static const u32 ep_key[9] = { 1, 0, 1, 0, 1, 1, 0, 1, 0 };
160 static const u32 ep_enhanced[9] = { 0x10, 0x60, 0x30, 0x80,
161 0x50, 0x20, 0x70, 0x40, 0x90 };
162 151
163 ep = container_of (_ep, struct net2280_ep, ep); 152 ep = container_of (_ep, struct net2280_ep, ep);
164 if (!_ep || !desc || ep->desc || _ep->name == ep0name 153 if (!_ep || !desc || ep->desc || _ep->name == ep0name
@@ -172,20 +161,11 @@ net2280_enable (struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc)
172 if ((desc->bEndpointAddress & 0x0f) == EP_DONTUSE) 161 if ((desc->bEndpointAddress & 0x0f) == EP_DONTUSE)
173 return -EDOM; 162 return -EDOM;
174 163
175 if (dev->pdev->vendor == 0x10b5) {
176 if ((desc->bEndpointAddress & 0x0f) >= 0x0c)
177 return -EDOM;
178 ep->is_in = !!usb_endpoint_dir_in(desc);
179 if (dev->enhanced_mode && ep->is_in && ep_key[ep->num])
180 return -EINVAL;
181 }
182
183 /* sanity check ep-e/ep-f since their fifos are small */ 164 /* sanity check ep-e/ep-f since their fifos are small */
184 max = usb_endpoint_maxp (desc) & 0x1fff; 165 max = usb_endpoint_maxp (desc) & 0x1fff;
185 if (ep->num > 4 && max > 64 && (dev->pdev->vendor == 0x17cc)) 166 if (ep->num > 4 && max > 64)
186 return -ERANGE; 167 return -ERANGE;
187 168
188
189 spin_lock_irqsave (&dev->lock, flags); 169 spin_lock_irqsave (&dev->lock, flags);
190 _ep->maxpacket = max & 0x7ff; 170 _ep->maxpacket = max & 0x7ff;
191 ep->desc = desc; 171 ep->desc = desc;
@@ -196,8 +176,7 @@ net2280_enable (struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc)
196 ep->out_overflow = 0; 176 ep->out_overflow = 0;
197 177
198 /* set speed-dependent max packet; may kick in high bandwidth */ 178 /* set speed-dependent max packet; may kick in high bandwidth */
199 set_idx_reg(dev->regs, (dev->enhanced_mode) ? ep_enhanced[ep->num] 179 set_idx_reg (dev->regs, REG_EP_MAXPKT (dev, ep->num), max);
200 : REG_EP_MAXPKT(dev, ep->num), max);
201 180
202 /* FIFO lines can't go to different packets. PIO is ok, so 181 /* FIFO lines can't go to different packets. PIO is ok, so
203 * use it instead of troublesome (non-bulk) multi-packet DMA. 182 * use it instead of troublesome (non-bulk) multi-packet DMA.
@@ -220,43 +199,23 @@ net2280_enable (struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc)
220 &ep->regs->ep_rsp); 199 &ep->regs->ep_rsp);
221 } else if (tmp == USB_ENDPOINT_XFER_BULK) { 200 } else if (tmp == USB_ENDPOINT_XFER_BULK) {
222 /* catch some particularly blatant driver bugs */ 201 /* catch some particularly blatant driver bugs */
223 if ((dev->gadget.speed == USB_SPEED_SUPER && max != 1024) || 202 if ((dev->gadget.speed == USB_SPEED_HIGH
224 (dev->gadget.speed == USB_SPEED_HIGH && max != 512) || 203 && max != 512)
225 (dev->gadget.speed == USB_SPEED_FULL && max > 64)) { 204 || (dev->gadget.speed == USB_SPEED_FULL
226 spin_unlock_irqrestore(&dev->lock, flags); 205 && max > 64)) {
206 spin_unlock_irqrestore (&dev->lock, flags);
227 return -ERANGE; 207 return -ERANGE;
228 } 208 }
229 } 209 }
230 ep->is_iso = (tmp == USB_ENDPOINT_XFER_ISOC) ? 1 : 0; 210 ep->is_iso = (tmp == USB_ENDPOINT_XFER_ISOC) ? 1 : 0;
231 /* Enable this endpoint */ 211 tmp <<= ENDPOINT_TYPE;
232 if (dev->pdev->vendor == 0x17cc) { 212 tmp |= desc->bEndpointAddress;
233 tmp <<= ENDPOINT_TYPE; 213 tmp |= (4 << ENDPOINT_BYTE_COUNT); /* default full fifo lines */
234 tmp |= desc->bEndpointAddress; 214 tmp |= 1 << ENDPOINT_ENABLE;
235 /* default full fifo lines */ 215 wmb ();
236 tmp |= (4 << ENDPOINT_BYTE_COUNT);
237 tmp |= 1 << ENDPOINT_ENABLE;
238 ep->is_in = (tmp & USB_DIR_IN) != 0;
239 } else {
240 /* In Legacy mode, only OUT endpoints are used */
241 if (dev->enhanced_mode && ep->is_in) {
242 tmp <<= IN_ENDPOINT_TYPE;
243 tmp |= (1 << IN_ENDPOINT_ENABLE);
244 /* Not applicable to Legacy */
245 tmp |= (1 << ENDPOINT_DIRECTION);
246 } else {
247 tmp <<= OUT_ENDPOINT_TYPE;
248 tmp |= (1 << OUT_ENDPOINT_ENABLE);
249 tmp |= (ep->is_in << ENDPOINT_DIRECTION);
250 }
251
252 tmp |= usb_endpoint_num(desc);
253 tmp |= (ep->ep.maxburst << MAX_BURST_SIZE);
254 }
255
256 /* Make sure all the registers are written before ep_rsp*/
257 wmb();
258 216
259 /* for OUT transfers, block the rx fifo until a read is posted */ 217 /* for OUT transfers, block the rx fifo until a read is posted */
218 ep->is_in = (tmp & USB_DIR_IN) != 0;
260 if (!ep->is_in) 219 if (!ep->is_in)
261 writel ((1 << SET_NAK_OUT_PACKETS), &ep->regs->ep_rsp); 220 writel ((1 << SET_NAK_OUT_PACKETS), &ep->regs->ep_rsp);
262 else if (dev->pdev->device != 0x2280) { 221 else if (dev->pdev->device != 0x2280) {
@@ -267,13 +226,11 @@ net2280_enable (struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc)
267 | (1 << CLEAR_NAK_OUT_PACKETS_MODE), &ep->regs->ep_rsp); 226 | (1 << CLEAR_NAK_OUT_PACKETS_MODE), &ep->regs->ep_rsp);
268 } 227 }
269 228
270 writel(tmp, &ep->cfg->ep_cfg); 229 writel (tmp, &ep->regs->ep_cfg);
271 230
272 /* enable irqs */ 231 /* enable irqs */
273 if (!ep->dma) { /* pio, per-packet */ 232 if (!ep->dma) { /* pio, per-packet */
274 tmp = (dev->pdev->vendor == 0x17cc)?(1 << ep->num) 233 tmp = (1 << ep->num) | readl (&dev->regs->pciirqenb0);
275 : (1 << ep_bit[ep->num]);
276 tmp |= readl(&dev->regs->pciirqenb0);
277 writel (tmp, &dev->regs->pciirqenb0); 234 writel (tmp, &dev->regs->pciirqenb0);
278 235
279 tmp = (1 << DATA_PACKET_RECEIVED_INTERRUPT_ENABLE) 236 tmp = (1 << DATA_PACKET_RECEIVED_INTERRUPT_ENABLE)
@@ -294,10 +251,8 @@ net2280_enable (struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc)
294 tmp = (1 << SHORT_PACKET_TRANSFERRED_INTERRUPT_ENABLE); 251 tmp = (1 << SHORT_PACKET_TRANSFERRED_INTERRUPT_ENABLE);
295 writel (tmp, &ep->regs->ep_irqenb); 252 writel (tmp, &ep->regs->ep_irqenb);
296 253
297 tmp = (dev->pdev->vendor == 0x17cc)?(1 << ep->num) 254 tmp = (1 << ep->num) | readl (&dev->regs->pciirqenb0);
298 : (1 << ep_bit[ep->num]); 255 writel (tmp, &dev->regs->pciirqenb0);
299 tmp |= readl(&dev->regs->pciirqenb0);
300 writel(tmp, &dev->regs->pciirqenb0);
301 } 256 }
302 } 257 }
303 258
@@ -331,8 +286,7 @@ static int handshake (u32 __iomem *ptr, u32 mask, u32 done, int usec)
331 286
332static const struct usb_ep_ops net2280_ep_ops; 287static const struct usb_ep_ops net2280_ep_ops;
333 288
334static void ep_reset_228x(struct net2280_regs __iomem *regs, 289static void ep_reset (struct net2280_regs __iomem *regs, struct net2280_ep *ep)
335 struct net2280_ep *ep)
336{ 290{
337 u32 tmp; 291 u32 tmp;
338 292
@@ -407,55 +361,6 @@ static void ep_reset_228x(struct net2280_regs __iomem *regs,
407 /* fifo size is handled separately */ 361 /* fifo size is handled separately */
408} 362}
409 363
410static void ep_reset_338x(struct net2280_regs __iomem *regs,
411 struct net2280_ep *ep)
412{
413 u32 tmp, dmastat;
414
415 ep->desc = NULL;
416 INIT_LIST_HEAD(&ep->queue);
417
418 usb_ep_set_maxpacket_limit(&ep->ep, ~0);
419 ep->ep.ops = &net2280_ep_ops;
420
421 /* disable the dma, irqs, endpoint... */
422 if (ep->dma) {
423 writel(0, &ep->dma->dmactl);
424 writel((1 << DMA_ABORT_DONE_INTERRUPT) |
425 (1 << DMA_PAUSE_DONE_INTERRUPT) |
426 (1 << DMA_SCATTER_GATHER_DONE_INTERRUPT) |
427 (1 << DMA_TRANSACTION_DONE_INTERRUPT)
428 /* | (1 << DMA_ABORT) */
429 , &ep->dma->dmastat);
430
431 dmastat = readl(&ep->dma->dmastat);
432 if (dmastat == 0x5002) {
433 WARNING(ep->dev, "The dmastat return = %x!!\n",
434 dmastat);
435 writel(0x5a, &ep->dma->dmastat);
436 }
437
438 tmp = readl(&regs->pciirqenb0);
439 tmp &= ~(1 << ep_bit[ep->num]);
440 writel(tmp, &regs->pciirqenb0);
441 } else {
442 if (ep->num < 5) {
443 tmp = readl(&regs->pciirqenb1);
444 tmp &= ~(1 << (8 + ep->num)); /* completion */
445 writel(tmp, &regs->pciirqenb1);
446 }
447 }
448 writel(0, &ep->regs->ep_irqenb);
449
450 writel((1 << SHORT_PACKET_OUT_DONE_INTERRUPT) |
451 (1 << SHORT_PACKET_TRANSFERRED_INTERRUPT) |
452 (1 << FIFO_OVERFLOW) |
453 (1 << DATA_PACKET_RECEIVED_INTERRUPT) |
454 (1 << DATA_PACKET_TRANSMITTED_INTERRUPT) |
455 (1 << DATA_OUT_PING_TOKEN_INTERRUPT) |
456 (1 << DATA_IN_TOKEN_INTERRUPT), &ep->regs->ep_stat);
457}
458
459static void nuke (struct net2280_ep *); 364static void nuke (struct net2280_ep *);
460 365
461static int net2280_disable (struct usb_ep *_ep) 366static int net2280_disable (struct usb_ep *_ep)
@@ -469,17 +374,13 @@ static int net2280_disable (struct usb_ep *_ep)
469 374
470 spin_lock_irqsave (&ep->dev->lock, flags); 375 spin_lock_irqsave (&ep->dev->lock, flags);
471 nuke (ep); 376 nuke (ep);
472 377 ep_reset (ep->dev->regs, ep);
473 if (ep->dev->pdev->vendor == 0x10b5)
474 ep_reset_338x(ep->dev->regs, ep);
475 else
476 ep_reset_228x(ep->dev->regs, ep);
477 378
478 VDEBUG (ep->dev, "disabled %s %s\n", 379 VDEBUG (ep->dev, "disabled %s %s\n",
479 ep->dma ? "dma" : "pio", _ep->name); 380 ep->dma ? "dma" : "pio", _ep->name);
480 381
481 /* synch memory views with the device */ 382 /* synch memory views with the device */
482 (void)readl(&ep->cfg->ep_cfg); 383 (void) readl (&ep->regs->ep_cfg);
483 384
484 if (use_dma && !ep->dma && ep->num >= 1 && ep->num <= 4) 385 if (use_dma && !ep->dma && ep->num >= 1 && ep->num <= 4)
485 ep->dma = &ep->dev->dma [ep->num - 1]; 386 ep->dma = &ep->dev->dma [ep->num - 1];
@@ -797,8 +698,6 @@ static void start_queue (struct net2280_ep *ep, u32 dmactl, u32 td_dma)
797 writel (readl (&dma->dmastat), &dma->dmastat); 698 writel (readl (&dma->dmastat), &dma->dmastat);
798 699
799 writel (td_dma, &dma->dmadesc); 700 writel (td_dma, &dma->dmadesc);
800 if (ep->dev->pdev->vendor == 0x10b5)
801 dmactl |= (0x01 << DMA_REQUEST_OUTSTANDING);
802 writel (dmactl, &dma->dmactl); 701 writel (dmactl, &dma->dmactl);
803 702
804 /* erratum 0116 workaround part 3: pci arbiter away from net2280 */ 703 /* erratum 0116 workaround part 3: pci arbiter away from net2280 */
@@ -873,21 +772,6 @@ static void start_dma (struct net2280_ep *ep, struct net2280_request *req)
873 start_queue (ep, tmp, req->td_dma); 772 start_queue (ep, tmp, req->td_dma);
874} 773}
875 774
876static inline void resume_dma(struct net2280_ep *ep)
877{
878 writel(readl(&ep->dma->dmactl) | (1 << DMA_ENABLE), &ep->dma->dmactl);
879
880 ep->dma_started = true;
881}
882
883static inline void ep_stop_dma(struct net2280_ep *ep)
884{
885 writel(readl(&ep->dma->dmactl) & ~(1 << DMA_ENABLE), &ep->dma->dmactl);
886 spin_stop_dma(ep->dma);
887
888 ep->dma_started = false;
889}
890
891static inline void 775static inline void
892queue_dma (struct net2280_ep *ep, struct net2280_request *req, int valid) 776queue_dma (struct net2280_ep *ep, struct net2280_request *req, int valid)
893{ 777{
@@ -990,23 +874,8 @@ net2280_queue (struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags)
990 874
991 /* kickstart this i/o queue? */ 875 /* kickstart this i/o queue? */
992 if (list_empty (&ep->queue) && !ep->stopped) { 876 if (list_empty (&ep->queue) && !ep->stopped) {
993 /* DMA request while EP halted */
994 if (ep->dma &&
995 (readl(&ep->regs->ep_rsp) & (1 << CLEAR_ENDPOINT_HALT)) &&
996 (dev->pdev->vendor == 0x10b5)) {
997 int valid = 1;
998 if (ep->is_in) {
999 int expect;
1000 expect = likely(req->req.zero ||
1001 ((req->req.length %
1002 ep->ep.maxpacket) != 0));
1003 if (expect != ep->in_fifo_validate)
1004 valid = 0;
1005 }
1006 queue_dma(ep, req, valid);
1007 }
1008 /* use DMA if the endpoint supports it, else pio */ 877 /* use DMA if the endpoint supports it, else pio */
1009 else if (ep->dma) 878 if (ep->dma)
1010 start_dma (ep, req); 879 start_dma (ep, req);
1011 else { 880 else {
1012 /* maybe there's no control data, just status ack */ 881 /* maybe there's no control data, just status ack */
@@ -1124,8 +993,6 @@ static void scan_dma_completions (struct net2280_ep *ep)
1124 } else if (!ep->is_in 993 } else if (!ep->is_in
1125 && (req->req.length % ep->ep.maxpacket) != 0) { 994 && (req->req.length % ep->ep.maxpacket) != 0) {
1126 tmp = readl (&ep->regs->ep_stat); 995 tmp = readl (&ep->regs->ep_stat);
1127 if (ep->dev->pdev->vendor == 0x10b5)
1128 return dma_done(ep, req, tmp, 0);
1129 996
1130 /* AVOID TROUBLE HERE by not issuing short reads from 997 /* AVOID TROUBLE HERE by not issuing short reads from
1131 * your gadget driver. That helps avoids errata 0121, 998 * your gadget driver. That helps avoids errata 0121,
@@ -1212,7 +1079,7 @@ static void restart_dma (struct net2280_ep *ep)
1212 start_queue (ep, dmactl, req->td_dma); 1079 start_queue (ep, dmactl, req->td_dma);
1213} 1080}
1214 1081
1215static void abort_dma_228x(struct net2280_ep *ep) 1082static void abort_dma (struct net2280_ep *ep)
1216{ 1083{
1217 /* abort the current transfer */ 1084 /* abort the current transfer */
1218 if (likely (!list_empty (&ep->queue))) { 1085 if (likely (!list_empty (&ep->queue))) {
@@ -1224,19 +1091,6 @@ static void abort_dma_228x(struct net2280_ep *ep)
1224 scan_dma_completions (ep); 1091 scan_dma_completions (ep);
1225} 1092}
1226 1093
1227static void abort_dma_338x(struct net2280_ep *ep)
1228{
1229 writel((1 << DMA_ABORT), &ep->dma->dmastat);
1230 spin_stop_dma(ep->dma);
1231}
1232
1233static void abort_dma(struct net2280_ep *ep)
1234{
1235 if (ep->dev->pdev->vendor == 0x17cc)
1236 return abort_dma_228x(ep);
1237 return abort_dma_338x(ep);
1238}
1239
1240/* dequeue ALL requests */ 1094/* dequeue ALL requests */
1241static void nuke (struct net2280_ep *ep) 1095static void nuke (struct net2280_ep *ep)
1242{ 1096{
@@ -1390,9 +1244,6 @@ net2280_set_halt_and_wedge(struct usb_ep *_ep, int value, int wedged)
1390 ep->wedged = 1; 1244 ep->wedged = 1;
1391 } else { 1245 } else {
1392 clear_halt (ep); 1246 clear_halt (ep);
1393 if (ep->dev->pdev->vendor == 0x10b5 &&
1394 !list_empty(&ep->queue) && ep->td_dma)
1395 restart_dma(ep);
1396 ep->wedged = 0; 1247 ep->wedged = 0;
1397 } 1248 }
1398 (void) readl (&ep->regs->ep_rsp); 1249 (void) readl (&ep->regs->ep_rsp);
@@ -1516,13 +1367,10 @@ static int net2280_set_selfpowered (struct usb_gadget *_gadget, int value)
1516 1367
1517 spin_lock_irqsave (&dev->lock, flags); 1368 spin_lock_irqsave (&dev->lock, flags);
1518 tmp = readl (&dev->usb->usbctl); 1369 tmp = readl (&dev->usb->usbctl);
1519 if (value) { 1370 if (value)
1520 tmp |= (1 << SELF_POWERED_STATUS); 1371 tmp |= (1 << SELF_POWERED_STATUS);
1521 dev->selfpowered = 1; 1372 else
1522 } else {
1523 tmp &= ~(1 << SELF_POWERED_STATUS); 1373 tmp &= ~(1 << SELF_POWERED_STATUS);
1524 dev->selfpowered = 0;
1525 }
1526 writel (tmp, &dev->usb->usbctl); 1374 writel (tmp, &dev->usb->usbctl);
1527 spin_unlock_irqrestore (&dev->lock, flags); 1375 spin_unlock_irqrestore (&dev->lock, flags);
1528 1376
@@ -1656,14 +1504,14 @@ static ssize_t registers_show(struct device *_dev,
1656 /* DMA Control Registers */ 1504 /* DMA Control Registers */
1657 1505
1658 /* Configurable EP Control Registers */ 1506 /* Configurable EP Control Registers */
1659 for (i = 0; i < dev->n_ep; i++) { 1507 for (i = 0; i < 7; i++) {
1660 struct net2280_ep *ep; 1508 struct net2280_ep *ep;
1661 1509
1662 ep = &dev->ep [i]; 1510 ep = &dev->ep [i];
1663 if (i && !ep->desc) 1511 if (i && !ep->desc)
1664 continue; 1512 continue;
1665 1513
1666 t1 = readl(&ep->cfg->ep_cfg); 1514 t1 = readl (&ep->regs->ep_cfg);
1667 t2 = readl (&ep->regs->ep_rsp) & 0xff; 1515 t2 = readl (&ep->regs->ep_rsp) & 0xff;
1668 t = scnprintf (next, size, 1516 t = scnprintf (next, size,
1669 "\n%s\tcfg %05x rsp (%02x) %s%s%s%s%s%s%s%s" 1517 "\n%s\tcfg %05x rsp (%02x) %s%s%s%s%s%s%s%s"
@@ -1723,7 +1571,7 @@ static ssize_t registers_show(struct device *_dev,
1723 t = scnprintf (next, size, "\nirqs: "); 1571 t = scnprintf (next, size, "\nirqs: ");
1724 size -= t; 1572 size -= t;
1725 next += t; 1573 next += t;
1726 for (i = 0; i < dev->n_ep; i++) { 1574 for (i = 0; i < 7; i++) {
1727 struct net2280_ep *ep; 1575 struct net2280_ep *ep;
1728 1576
1729 ep = &dev->ep [i]; 1577 ep = &dev->ep [i];
@@ -1758,7 +1606,7 @@ static ssize_t queues_show(struct device *_dev, struct device_attribute *attr,
1758 size = PAGE_SIZE; 1606 size = PAGE_SIZE;
1759 spin_lock_irqsave (&dev->lock, flags); 1607 spin_lock_irqsave (&dev->lock, flags);
1760 1608
1761 for (i = 0; i < dev->n_ep; i++) { 1609 for (i = 0; i < 7; i++) {
1762 struct net2280_ep *ep = &dev->ep [i]; 1610 struct net2280_ep *ep = &dev->ep [i];
1763 struct net2280_request *req; 1611 struct net2280_request *req;
1764 int t; 1612 int t;
@@ -1887,121 +1735,6 @@ static void set_fifo_mode (struct net2280 *dev, int mode)
1887 list_add_tail (&dev->ep [6].ep.ep_list, &dev->gadget.ep_list); 1735 list_add_tail (&dev->ep [6].ep.ep_list, &dev->gadget.ep_list);
1888} 1736}
1889 1737
1890static void defect7374_disable_data_eps(struct net2280 *dev)
1891{
1892 /*
1893 * For Defect 7374, disable data EPs (and more):
1894 * - This phase undoes the earlier phase of the Defect 7374 workaround,
1895 * returing ep regs back to normal.
1896 */
1897 struct net2280_ep *ep;
1898 int i;
1899 unsigned char ep_sel;
1900 u32 tmp_reg;
1901
1902 for (i = 1; i < 5; i++) {
1903 ep = &dev->ep[i];
1904 writel(0, &ep->cfg->ep_cfg);
1905 }
1906
1907 /* CSROUT, CSRIN, PCIOUT, PCIIN, STATIN, RCIN */
1908 for (i = 0; i < 6; i++)
1909 writel(0, &dev->dep[i].dep_cfg);
1910
1911 for (ep_sel = 0; ep_sel <= 21; ep_sel++) {
1912 /* Select an endpoint for subsequent operations: */
1913 tmp_reg = readl(&dev->plregs->pl_ep_ctrl);
1914 writel(((tmp_reg & ~0x1f) | ep_sel), &dev->plregs->pl_ep_ctrl);
1915
1916 if (ep_sel < 2 || (ep_sel > 9 && ep_sel < 14) ||
1917 ep_sel == 18 || ep_sel == 20)
1918 continue;
1919
1920 /* Change settings on some selected endpoints */
1921 tmp_reg = readl(&dev->plregs->pl_ep_cfg_4);
1922 tmp_reg &= ~(1 << NON_CTRL_IN_TOLERATE_BAD_DIR);
1923 writel(tmp_reg, &dev->plregs->pl_ep_cfg_4);
1924 tmp_reg = readl(&dev->plregs->pl_ep_ctrl);
1925 tmp_reg |= (1 << EP_INITIALIZED);
1926 writel(tmp_reg, &dev->plregs->pl_ep_ctrl);
1927 }
1928}
1929
1930static void defect7374_enable_data_eps_zero(struct net2280 *dev)
1931{
1932 u32 tmp = 0, tmp_reg;
1933 u32 fsmvalue, scratch;
1934 int i;
1935 unsigned char ep_sel;
1936
1937 scratch = get_idx_reg(dev->regs, SCRATCH);
1938 fsmvalue = scratch & (0xf << DEFECT7374_FSM_FIELD);
1939 scratch &= ~(0xf << DEFECT7374_FSM_FIELD);
1940
1941 /*See if firmware needs to set up for workaround*/
1942 if (fsmvalue != DEFECT7374_FSM_SS_CONTROL_READ) {
1943 WARNING(dev, "Operate Defect 7374 workaround soft this time");
1944 WARNING(dev, "It will operate on cold-reboot and SS connect");
1945
1946 /*GPEPs:*/
1947 tmp = ((0 << ENDPOINT_NUMBER) | (1 << ENDPOINT_DIRECTION) |
1948 (2 << OUT_ENDPOINT_TYPE) | (2 << IN_ENDPOINT_TYPE) |
1949 ((dev->enhanced_mode) ?
1950 1 << OUT_ENDPOINT_ENABLE : 1 << ENDPOINT_ENABLE) |
1951 (1 << IN_ENDPOINT_ENABLE));
1952
1953 for (i = 1; i < 5; i++)
1954 writel(tmp, &dev->ep[i].cfg->ep_cfg);
1955
1956 /* CSRIN, PCIIN, STATIN, RCIN*/
1957 tmp = ((0 << ENDPOINT_NUMBER) | (1 << ENDPOINT_ENABLE));
1958 writel(tmp, &dev->dep[1].dep_cfg);
1959 writel(tmp, &dev->dep[3].dep_cfg);
1960 writel(tmp, &dev->dep[4].dep_cfg);
1961 writel(tmp, &dev->dep[5].dep_cfg);
1962
1963 /*Implemented for development and debug.
1964 * Can be refined/tuned later.*/
1965 for (ep_sel = 0; ep_sel <= 21; ep_sel++) {
1966 /* Select an endpoint for subsequent operations: */
1967 tmp_reg = readl(&dev->plregs->pl_ep_ctrl);
1968 writel(((tmp_reg & ~0x1f) | ep_sel),
1969 &dev->plregs->pl_ep_ctrl);
1970
1971 if (ep_sel == 1) {
1972 tmp =
1973 (readl(&dev->plregs->pl_ep_ctrl) |
1974 (1 << CLEAR_ACK_ERROR_CODE) | 0);
1975 writel(tmp, &dev->plregs->pl_ep_ctrl);
1976 continue;
1977 }
1978
1979 if (ep_sel == 0 || (ep_sel > 9 && ep_sel < 14) ||
1980 ep_sel == 18 || ep_sel == 20)
1981 continue;
1982
1983 tmp = (readl(&dev->plregs->pl_ep_cfg_4) |
1984 (1 << NON_CTRL_IN_TOLERATE_BAD_DIR) | 0);
1985 writel(tmp, &dev->plregs->pl_ep_cfg_4);
1986
1987 tmp = readl(&dev->plregs->pl_ep_ctrl) &
1988 ~(1 << EP_INITIALIZED);
1989 writel(tmp, &dev->plregs->pl_ep_ctrl);
1990
1991 }
1992
1993 /* Set FSM to focus on the first Control Read:
1994 * - Tip: Connection speed is known upon the first
1995 * setup request.*/
1996 scratch |= DEFECT7374_FSM_WAITING_FOR_CONTROL_READ;
1997 set_idx_reg(dev->regs, SCRATCH, scratch);
1998
1999 } else{
2000 WARNING(dev, "Defect 7374 workaround soft will NOT operate");
2001 WARNING(dev, "It will operate on cold-reboot and SS connect");
2002 }
2003}
2004
2005/* keeping it simple: 1738/* keeping it simple:
2006 * - one bus driver, initted first; 1739 * - one bus driver, initted first;
2007 * - one function driver, initted second 1740 * - one function driver, initted second
@@ -2011,7 +1744,7 @@ static void defect7374_enable_data_eps_zero(struct net2280 *dev)
2011 * perhaps to bind specific drivers to specific devices. 1744 * perhaps to bind specific drivers to specific devices.
2012 */ 1745 */
2013 1746
2014static void usb_reset_228x(struct net2280 *dev) 1747static void usb_reset (struct net2280 *dev)
2015{ 1748{
2016 u32 tmp; 1749 u32 tmp;
2017 1750
@@ -2027,11 +1760,11 @@ static void usb_reset_228x(struct net2280 *dev)
2027 1760
2028 /* clear old dma and irq state */ 1761 /* clear old dma and irq state */
2029 for (tmp = 0; tmp < 4; tmp++) { 1762 for (tmp = 0; tmp < 4; tmp++) {
2030 struct net2280_ep *ep = &dev->ep[tmp + 1]; 1763 struct net2280_ep *ep = &dev->ep [tmp + 1];
1764
2031 if (ep->dma) 1765 if (ep->dma)
2032 abort_dma(ep); 1766 abort_dma (ep);
2033 } 1767 }
2034
2035 writel (~0, &dev->regs->irqstat0), 1768 writel (~0, &dev->regs->irqstat0),
2036 writel (~(1 << SUSPEND_REQUEST_INTERRUPT), &dev->regs->irqstat1), 1769 writel (~(1 << SUSPEND_REQUEST_INTERRUPT), &dev->regs->irqstat1),
2037 1770
@@ -2047,67 +1780,7 @@ static void usb_reset_228x(struct net2280 *dev)
2047 set_fifo_mode (dev, (fifo_mode <= 2) ? fifo_mode : 0); 1780 set_fifo_mode (dev, (fifo_mode <= 2) ? fifo_mode : 0);
2048} 1781}
2049 1782
2050static void usb_reset_338x(struct net2280 *dev) 1783static void usb_reinit (struct net2280 *dev)
2051{
2052 u32 tmp;
2053 u32 fsmvalue;
2054
2055 dev->gadget.speed = USB_SPEED_UNKNOWN;
2056 (void)readl(&dev->usb->usbctl);
2057
2058 net2280_led_init(dev);
2059
2060 fsmvalue = get_idx_reg(dev->regs, SCRATCH) &
2061 (0xf << DEFECT7374_FSM_FIELD);
2062
2063 /* See if firmware needs to set up for workaround: */
2064 if (fsmvalue != DEFECT7374_FSM_SS_CONTROL_READ) {
2065 INFO(dev, "%s: Defect 7374 FsmValue 0x%08X\n", __func__,
2066 fsmvalue);
2067 } else {
2068 /* disable automatic responses, and irqs */
2069 writel(0, &dev->usb->stdrsp);
2070 writel(0, &dev->regs->pciirqenb0);
2071 writel(0, &dev->regs->pciirqenb1);
2072 }
2073
2074 /* clear old dma and irq state */
2075 for (tmp = 0; tmp < 4; tmp++) {
2076 struct net2280_ep *ep = &dev->ep[tmp + 1];
2077
2078 if (ep->dma)
2079 abort_dma(ep);
2080 }
2081
2082 writel(~0, &dev->regs->irqstat0), writel(~0, &dev->regs->irqstat1);
2083
2084 if (fsmvalue == DEFECT7374_FSM_SS_CONTROL_READ) {
2085 /* reset, and enable pci */
2086 tmp = readl(&dev->regs->devinit) |
2087 (1 << PCI_ENABLE) |
2088 (1 << FIFO_SOFT_RESET) |
2089 (1 << USB_SOFT_RESET) |
2090 (1 << M8051_RESET);
2091
2092 writel(tmp, &dev->regs->devinit);
2093 }
2094
2095 /* always ep-{1,2,3,4} ... maybe not ep-3 or ep-4 */
2096 INIT_LIST_HEAD(&dev->gadget.ep_list);
2097
2098 for (tmp = 1; tmp < dev->n_ep; tmp++)
2099 list_add_tail(&dev->ep[tmp].ep.ep_list, &dev->gadget.ep_list);
2100
2101}
2102
2103static void usb_reset(struct net2280 *dev)
2104{
2105 if (dev->pdev->vendor == 0x17cc)
2106 return usb_reset_228x(dev);
2107 return usb_reset_338x(dev);
2108}
2109
2110static void usb_reinit_228x(struct net2280 *dev)
2111{ 1784{
2112 u32 tmp; 1785 u32 tmp;
2113 int init_dma; 1786 int init_dma;
@@ -2130,8 +1803,7 @@ static void usb_reinit_228x(struct net2280 *dev)
2130 } else 1803 } else
2131 ep->fifo_size = 64; 1804 ep->fifo_size = 64;
2132 ep->regs = &dev->epregs [tmp]; 1805 ep->regs = &dev->epregs [tmp];
2133 ep->cfg = &dev->epregs[tmp]; 1806 ep_reset (dev->regs, ep);
2134 ep_reset_228x(dev->regs, ep);
2135 } 1807 }
2136 usb_ep_set_maxpacket_limit(&dev->ep [0].ep, 64); 1808 usb_ep_set_maxpacket_limit(&dev->ep [0].ep, 64);
2137 usb_ep_set_maxpacket_limit(&dev->ep [5].ep, 64); 1809 usb_ep_set_maxpacket_limit(&dev->ep [5].ep, 64);
@@ -2148,122 +1820,7 @@ static void usb_reinit_228x(struct net2280 *dev)
2148 writel (EP_DONTUSE, &dev->dep [tmp].dep_cfg); 1820 writel (EP_DONTUSE, &dev->dep [tmp].dep_cfg);
2149} 1821}
2150 1822
2151static void usb_reinit_338x(struct net2280 *dev) 1823static void ep0_start (struct net2280 *dev)
2152{
2153 int init_dma;
2154 int i;
2155 u32 tmp, val;
2156 u32 fsmvalue;
2157 static const u32 ne[9] = { 0, 1, 2, 3, 4, 1, 2, 3, 4 };
2158 static const u32 ep_reg_addr[9] = { 0x00, 0xC0, 0x00, 0xC0, 0x00,
2159 0x00, 0xC0, 0x00, 0xC0 };
2160
2161 /* use_dma changes are ignored till next device re-init */
2162 init_dma = use_dma;
2163
2164 /* basic endpoint init */
2165 for (i = 0; i < dev->n_ep; i++) {
2166 struct net2280_ep *ep = &dev->ep[i];
2167
2168 ep->ep.name = ep_name[i];
2169 ep->dev = dev;
2170 ep->num = i;
2171
2172 if (i > 0 && i <= 4 && init_dma)
2173 ep->dma = &dev->dma[i - 1];
2174
2175 if (dev->enhanced_mode) {
2176 ep->cfg = &dev->epregs[ne[i]];
2177 ep->regs = (struct net2280_ep_regs __iomem *)
2178 (((void *)&dev->epregs[ne[i]]) +
2179 ep_reg_addr[i]);
2180 ep->fiforegs = &dev->fiforegs[i];
2181 } else {
2182 ep->cfg = &dev->epregs[i];
2183 ep->regs = &dev->epregs[i];
2184 ep->fiforegs = &dev->fiforegs[i];
2185 }
2186
2187 ep->fifo_size = (i != 0) ? 2048 : 512;
2188
2189 ep_reset_338x(dev->regs, ep);
2190 }
2191 usb_ep_set_maxpacket_limit(&dev->ep[0].ep, 512);
2192
2193 dev->gadget.ep0 = &dev->ep[0].ep;
2194 dev->ep[0].stopped = 0;
2195
2196 /* Link layer set up */
2197 fsmvalue = get_idx_reg(dev->regs, SCRATCH) &
2198 (0xf << DEFECT7374_FSM_FIELD);
2199
2200 /* See if driver needs to set up for workaround: */
2201 if (fsmvalue != DEFECT7374_FSM_SS_CONTROL_READ)
2202 INFO(dev, "%s: Defect 7374 FsmValue %08x\n",
2203 __func__, fsmvalue);
2204 else {
2205 tmp = readl(&dev->usb_ext->usbctl2) &
2206 ~((1 << U1_ENABLE) | (1 << U2_ENABLE) | (1 << LTM_ENABLE));
2207 writel(tmp, &dev->usb_ext->usbctl2);
2208 }
2209
2210 /* Hardware Defect and Workaround */
2211 val = readl(&dev->ll_lfps_regs->ll_lfps_5);
2212 val &= ~(0xf << TIMER_LFPS_6US);
2213 val |= 0x5 << TIMER_LFPS_6US;
2214 writel(val, &dev->ll_lfps_regs->ll_lfps_5);
2215
2216 val = readl(&dev->ll_lfps_regs->ll_lfps_6);
2217 val &= ~(0xffff << TIMER_LFPS_80US);
2218 val |= 0x0100 << TIMER_LFPS_80US;
2219 writel(val, &dev->ll_lfps_regs->ll_lfps_6);
2220
2221 /*
2222 * AA_AB Errata. Issue 4. Workaround for SuperSpeed USB
2223 * Hot Reset Exit Handshake may Fail in Specific Case using
2224 * Default Register Settings. Workaround for Enumeration test.
2225 */
2226 val = readl(&dev->ll_tsn_regs->ll_tsn_counters_2);
2227 val &= ~(0x1f << HOT_TX_NORESET_TS2);
2228 val |= 0x10 << HOT_TX_NORESET_TS2;
2229 writel(val, &dev->ll_tsn_regs->ll_tsn_counters_2);
2230
2231 val = readl(&dev->ll_tsn_regs->ll_tsn_counters_3);
2232 val &= ~(0x1f << HOT_RX_RESET_TS2);
2233 val |= 0x3 << HOT_RX_RESET_TS2;
2234 writel(val, &dev->ll_tsn_regs->ll_tsn_counters_3);
2235
2236 /*
2237 * Set Recovery Idle to Recover bit:
2238 * - On SS connections, setting Recovery Idle to Recover Fmw improves
2239 * link robustness with various hosts and hubs.
2240 * - It is safe to set for all connection speeds; all chip revisions.
2241 * - R-M-W to leave other bits undisturbed.
2242 * - Reference PLX TT-7372
2243 */
2244 val = readl(&dev->ll_chicken_reg->ll_tsn_chicken_bit);
2245 val |= (1 << RECOVERY_IDLE_TO_RECOVER_FMW);
2246 writel(val, &dev->ll_chicken_reg->ll_tsn_chicken_bit);
2247
2248 INIT_LIST_HEAD(&dev->gadget.ep0->ep_list);
2249
2250 /* disable dedicated endpoints */
2251 writel(0x0D, &dev->dep[0].dep_cfg);
2252 writel(0x0D, &dev->dep[1].dep_cfg);
2253 writel(0x0E, &dev->dep[2].dep_cfg);
2254 writel(0x0E, &dev->dep[3].dep_cfg);
2255 writel(0x0F, &dev->dep[4].dep_cfg);
2256 writel(0x0C, &dev->dep[5].dep_cfg);
2257}
2258
2259static void usb_reinit(struct net2280 *dev)
2260{
2261 if (dev->pdev->vendor == 0x17cc)
2262 return usb_reinit_228x(dev);
2263 return usb_reinit_338x(dev);
2264}
2265
2266static void ep0_start_228x(struct net2280 *dev)
2267{ 1824{
2268 writel ( (1 << CLEAR_EP_HIDE_STATUS_PHASE) 1825 writel ( (1 << CLEAR_EP_HIDE_STATUS_PHASE)
2269 | (1 << CLEAR_NAK_OUT_PACKETS) 1826 | (1 << CLEAR_NAK_OUT_PACKETS)
@@ -2306,61 +1863,6 @@ static void ep0_start_228x(struct net2280 *dev)
2306 (void) readl (&dev->usb->usbctl); 1863 (void) readl (&dev->usb->usbctl);
2307} 1864}
2308 1865
2309static void ep0_start_338x(struct net2280 *dev)
2310{
2311 u32 fsmvalue;
2312
2313 fsmvalue = get_idx_reg(dev->regs, SCRATCH) &
2314 (0xf << DEFECT7374_FSM_FIELD);
2315
2316 if (fsmvalue != DEFECT7374_FSM_SS_CONTROL_READ)
2317 INFO(dev, "%s: Defect 7374 FsmValue %08x\n", __func__,
2318 fsmvalue);
2319 else
2320 writel((1 << CLEAR_NAK_OUT_PACKETS_MODE) |
2321 (1 << SET_EP_HIDE_STATUS_PHASE),
2322 &dev->epregs[0].ep_rsp);
2323
2324 /*
2325 * hardware optionally handles a bunch of standard requests
2326 * that the API hides from drivers anyway. have it do so.
2327 * endpoint status/features are handled in software, to
2328 * help pass tests for some dubious behavior.
2329 */
2330 writel((1 << SET_ISOCHRONOUS_DELAY) |
2331 (1 << SET_SEL) |
2332 (1 << SET_TEST_MODE) |
2333 (1 << SET_ADDRESS) |
2334 (1 << GET_INTERFACE_STATUS) |
2335 (1 << GET_DEVICE_STATUS),
2336 &dev->usb->stdrsp);
2337 dev->wakeup_enable = 1;
2338 writel((1 << USB_ROOT_PORT_WAKEUP_ENABLE) |
2339 (dev->softconnect << USB_DETECT_ENABLE) |
2340 (1 << DEVICE_REMOTE_WAKEUP_ENABLE),
2341 &dev->usb->usbctl);
2342
2343 /* enable irqs so we can see ep0 and general operation */
2344 writel((1 << SETUP_PACKET_INTERRUPT_ENABLE) |
2345 (1 << ENDPOINT_0_INTERRUPT_ENABLE)
2346 , &dev->regs->pciirqenb0);
2347 writel((1 << PCI_INTERRUPT_ENABLE) |
2348 (1 << ROOT_PORT_RESET_INTERRUPT_ENABLE) |
2349 (1 << SUSPEND_REQUEST_CHANGE_INTERRUPT_ENABLE) |
2350 (1 << VBUS_INTERRUPT_ENABLE),
2351 &dev->regs->pciirqenb1);
2352
2353 /* don't leave any writes posted */
2354 (void)readl(&dev->usb->usbctl);
2355}
2356
2357static void ep0_start(struct net2280 *dev)
2358{
2359 if (dev->pdev->vendor == 0x17cc)
2360 return ep0_start_228x(dev);
2361 return ep0_start_338x(dev);
2362}
2363
2364/* when a driver is successfully registered, it will receive 1866/* when a driver is successfully registered, it will receive
2365 * control requests including set_configuration(), which enables 1867 * control requests including set_configuration(), which enables
2366 * non-control requests. then usb traffic follows until a 1868 * non-control requests. then usb traffic follows until a
@@ -2384,7 +1886,7 @@ static int net2280_start(struct usb_gadget *_gadget,
2384 1886
2385 dev = container_of (_gadget, struct net2280, gadget); 1887 dev = container_of (_gadget, struct net2280, gadget);
2386 1888
2387 for (i = 0; i < dev->n_ep; i++) 1889 for (i = 0; i < 7; i++)
2388 dev->ep [i].irqs = 0; 1890 dev->ep [i].irqs = 0;
2389 1891
2390 /* hook up the driver ... */ 1892 /* hook up the driver ... */
@@ -2398,17 +1900,13 @@ static int net2280_start(struct usb_gadget *_gadget,
2398 if (retval) goto err_func; 1900 if (retval) goto err_func;
2399 1901
2400 /* Enable force-full-speed testing mode, if desired */ 1902 /* Enable force-full-speed testing mode, if desired */
2401 if (full_speed && dev->pdev->vendor == 0x17cc) 1903 if (full_speed)
2402 writel(1 << FORCE_FULL_SPEED_MODE, &dev->usb->xcvrdiag); 1904 writel(1 << FORCE_FULL_SPEED_MODE, &dev->usb->xcvrdiag);
2403 1905
2404 /* ... then enable host detection and ep0; and we're ready 1906 /* ... then enable host detection and ep0; and we're ready
2405 * for set_configuration as well as eventual disconnect. 1907 * for set_configuration as well as eventual disconnect.
2406 */ 1908 */
2407 net2280_led_active (dev, 1); 1909 net2280_led_active (dev, 1);
2408
2409 if (dev->pdev->vendor == 0x10b5)
2410 defect7374_enable_data_eps_zero(dev);
2411
2412 ep0_start (dev); 1910 ep0_start (dev);
2413 1911
2414 DEBUG (dev, "%s ready, usbctl %08x stdrsp %08x\n", 1912 DEBUG (dev, "%s ready, usbctl %08x stdrsp %08x\n",
@@ -2439,7 +1937,7 @@ stop_activity (struct net2280 *dev, struct usb_gadget_driver *driver)
2439 * and kill any outstanding requests. 1937 * and kill any outstanding requests.
2440 */ 1938 */
2441 usb_reset (dev); 1939 usb_reset (dev);
2442 for (i = 0; i < dev->n_ep; i++) 1940 for (i = 0; i < 7; i++)
2443 nuke (&dev->ep [i]); 1941 nuke (&dev->ep [i]);
2444 1942
2445 /* report disconnect; the driver is already quiesced */ 1943 /* report disconnect; the driver is already quiesced */
@@ -2469,8 +1967,7 @@ static int net2280_stop(struct usb_gadget *_gadget,
2469 net2280_led_active (dev, 0); 1967 net2280_led_active (dev, 0);
2470 1968
2471 /* Disable full-speed test mode */ 1969 /* Disable full-speed test mode */
2472 if (dev->pdev->vendor == 0x17cc) 1970 writel(0, &dev->usb->xcvrdiag);
2473 writel(0, &dev->usb->xcvrdiag);
2474 1971
2475 device_remove_file (&dev->pdev->dev, &dev_attr_function); 1972 device_remove_file (&dev->pdev->dev, &dev_attr_function);
2476 device_remove_file (&dev->pdev->dev, &dev_attr_queues); 1973 device_remove_file (&dev->pdev->dev, &dev_attr_queues);
@@ -2722,350 +2219,6 @@ get_ep_by_addr (struct net2280 *dev, u16 wIndex)
2722 return NULL; 2219 return NULL;
2723} 2220}
2724 2221
2725static void defect7374_workaround(struct net2280 *dev, struct usb_ctrlrequest r)
2726{
2727 u32 scratch, fsmvalue;
2728 u32 ack_wait_timeout, state;
2729
2730 /* Workaround for Defect 7374 (U1/U2 erroneously rejected): */
2731 scratch = get_idx_reg(dev->regs, SCRATCH);
2732 fsmvalue = scratch & (0xf << DEFECT7374_FSM_FIELD);
2733 scratch &= ~(0xf << DEFECT7374_FSM_FIELD);
2734
2735 if (!((fsmvalue == DEFECT7374_FSM_WAITING_FOR_CONTROL_READ) &&
2736 (r.bRequestType & USB_DIR_IN)))
2737 return;
2738
2739 /* This is the first Control Read for this connection: */
2740 if (!(readl(&dev->usb->usbstat) & (1 << SUPER_SPEED_MODE))) {
2741 /*
2742 * Connection is NOT SS:
2743 * - Connection must be FS or HS.
2744 * - This FSM state should allow workaround software to
2745 * run after the next USB connection.
2746 */
2747 scratch |= DEFECT7374_FSM_NON_SS_CONTROL_READ;
2748 goto restore_data_eps;
2749 }
2750
2751 /* Connection is SS: */
2752 for (ack_wait_timeout = 0;
2753 ack_wait_timeout < DEFECT_7374_NUMBEROF_MAX_WAIT_LOOPS;
2754 ack_wait_timeout++) {
2755
2756 state = readl(&dev->plregs->pl_ep_status_1)
2757 & (0xff << STATE);
2758 if ((state >= (ACK_GOOD_NORMAL << STATE)) &&
2759 (state <= (ACK_GOOD_MORE_ACKS_TO_COME << STATE))) {
2760 scratch |= DEFECT7374_FSM_SS_CONTROL_READ;
2761 break;
2762 }
2763
2764 /*
2765 * We have not yet received host's Data Phase ACK
2766 * - Wait and try again.
2767 */
2768 udelay(DEFECT_7374_PROCESSOR_WAIT_TIME);
2769
2770 continue;
2771 }
2772
2773
2774 if (ack_wait_timeout >= DEFECT_7374_NUMBEROF_MAX_WAIT_LOOPS) {
2775 ERROR(dev, "FAIL: Defect 7374 workaround waited but failed");
2776 ERROR(dev, "to detect SS host's data phase ACK.");
2777 ERROR(dev, "PL_EP_STATUS_1(23:16):.Expected from 0x11 to 0x16");
2778 ERROR(dev, "got 0x%2.2x.\n", state >> STATE);
2779 } else {
2780 WARNING(dev, "INFO: Defect 7374 workaround waited about\n");
2781 WARNING(dev, "%duSec for Control Read Data Phase ACK\n",
2782 DEFECT_7374_PROCESSOR_WAIT_TIME * ack_wait_timeout);
2783 }
2784
2785restore_data_eps:
2786 /*
2787 * Restore data EPs to their pre-workaround settings (disabled,
2788 * initialized, and other details).
2789 */
2790 defect7374_disable_data_eps(dev);
2791
2792 set_idx_reg(dev->regs, SCRATCH, scratch);
2793
2794 return;
2795}
2796
2797static void ep_stall(struct net2280_ep *ep, int stall)
2798{
2799 struct net2280 *dev = ep->dev;
2800 u32 val;
2801 static const u32 ep_pl[9] = { 0, 3, 4, 7, 8, 2, 5, 6, 9 };
2802
2803 if (stall) {
2804 writel((1 << SET_ENDPOINT_HALT) |
2805 /* (1 << SET_NAK_PACKETS) | */
2806 (1 << CLEAR_CONTROL_STATUS_PHASE_HANDSHAKE),
2807 &ep->regs->ep_rsp);
2808 ep->is_halt = 1;
2809 } else {
2810 if (dev->gadget.speed == USB_SPEED_SUPER) {
2811 /*
2812 * Workaround for SS SeqNum not cleared via
2813 * Endpoint Halt (Clear) bit. select endpoint
2814 */
2815 val = readl(&dev->plregs->pl_ep_ctrl);
2816 val = (val & ~0x1f) | ep_pl[ep->num];
2817 writel(val, &dev->plregs->pl_ep_ctrl);
2818
2819 val |= (1 << SEQUENCE_NUMBER_RESET);
2820 writel(val, &dev->plregs->pl_ep_ctrl);
2821 }
2822 val = readl(&ep->regs->ep_rsp);
2823 val |= (1 << CLEAR_ENDPOINT_HALT) |
2824 (1 << CLEAR_ENDPOINT_TOGGLE);
2825 writel(val
2826 /* | (1 << CLEAR_NAK_PACKETS)*/
2827 , &ep->regs->ep_rsp);
2828 ep->is_halt = 0;
2829 val = readl(&ep->regs->ep_rsp);
2830 }
2831}
2832
2833static void ep_stdrsp(struct net2280_ep *ep, int value, int wedged)
2834{
2835 /* set/clear, then synch memory views with the device */
2836 if (value) {
2837 ep->stopped = 1;
2838 if (ep->num == 0)
2839 ep->dev->protocol_stall = 1;
2840 else {
2841 if (ep->dma)
2842 ep_stop_dma(ep);
2843 ep_stall(ep, true);
2844 }
2845
2846 if (wedged)
2847 ep->wedged = 1;
2848 } else {
2849 ep->stopped = 0;
2850 ep->wedged = 0;
2851
2852 ep_stall(ep, false);
2853
2854 /* Flush the queue */
2855 if (!list_empty(&ep->queue)) {
2856 struct net2280_request *req =
2857 list_entry(ep->queue.next, struct net2280_request,
2858 queue);
2859 if (ep->dma)
2860 resume_dma(ep);
2861 else {
2862 if (ep->is_in)
2863 write_fifo(ep, &req->req);
2864 else {
2865 if (read_fifo(ep, req))
2866 done(ep, req, 0);
2867 }
2868 }
2869 }
2870 }
2871}
2872
2873static void handle_stat0_irqs_superspeed(struct net2280 *dev,
2874 struct net2280_ep *ep, struct usb_ctrlrequest r)
2875{
2876 int tmp = 0;
2877
2878#define w_value le16_to_cpu(r.wValue)
2879#define w_index le16_to_cpu(r.wIndex)
2880#define w_length le16_to_cpu(r.wLength)
2881
2882 switch (r.bRequest) {
2883 struct net2280_ep *e;
2884 u16 status;
2885
2886 case USB_REQ_SET_CONFIGURATION:
2887 dev->addressed_state = !w_value;
2888 goto usb3_delegate;
2889
2890 case USB_REQ_GET_STATUS:
2891 switch (r.bRequestType) {
2892 case (USB_DIR_IN | USB_TYPE_STANDARD | USB_RECIP_DEVICE):
2893 status = dev->wakeup_enable ? 0x02 : 0x00;
2894 if (dev->selfpowered)
2895 status |= 1 << 0;
2896 status |= (dev->u1_enable << 2 | dev->u2_enable << 3 |
2897 dev->ltm_enable << 4);
2898 writel(0, &dev->epregs[0].ep_irqenb);
2899 set_fifo_bytecount(ep, sizeof(status));
2900 writel((__force u32) status, &dev->epregs[0].ep_data);
2901 allow_status_338x(ep);
2902 break;
2903
2904 case (USB_DIR_IN | USB_TYPE_STANDARD | USB_RECIP_ENDPOINT):
2905 e = get_ep_by_addr(dev, w_index);
2906 if (!e)
2907 goto do_stall3;
2908 status = readl(&e->regs->ep_rsp) &
2909 (1 << CLEAR_ENDPOINT_HALT);
2910 writel(0, &dev->epregs[0].ep_irqenb);
2911 set_fifo_bytecount(ep, sizeof(status));
2912 writel((__force u32) status, &dev->epregs[0].ep_data);
2913 allow_status_338x(ep);
2914 break;
2915
2916 default:
2917 goto usb3_delegate;
2918 }
2919 break;
2920
2921 case USB_REQ_CLEAR_FEATURE:
2922 switch (r.bRequestType) {
2923 case (USB_DIR_OUT | USB_TYPE_STANDARD | USB_RECIP_DEVICE):
2924 if (!dev->addressed_state) {
2925 switch (w_value) {
2926 case USB_DEVICE_U1_ENABLE:
2927 dev->u1_enable = 0;
2928 writel(readl(&dev->usb_ext->usbctl2) &
2929 ~(1 << U1_ENABLE),
2930 &dev->usb_ext->usbctl2);
2931 allow_status_338x(ep);
2932 goto next_endpoints3;
2933
2934 case USB_DEVICE_U2_ENABLE:
2935 dev->u2_enable = 0;
2936 writel(readl(&dev->usb_ext->usbctl2) &
2937 ~(1 << U2_ENABLE),
2938 &dev->usb_ext->usbctl2);
2939 allow_status_338x(ep);
2940 goto next_endpoints3;
2941
2942 case USB_DEVICE_LTM_ENABLE:
2943 dev->ltm_enable = 0;
2944 writel(readl(&dev->usb_ext->usbctl2) &
2945 ~(1 << LTM_ENABLE),
2946 &dev->usb_ext->usbctl2);
2947 allow_status_338x(ep);
2948 goto next_endpoints3;
2949
2950 default:
2951 break;
2952 }
2953 }
2954 if (w_value == USB_DEVICE_REMOTE_WAKEUP) {
2955 dev->wakeup_enable = 0;
2956 writel(readl(&dev->usb->usbctl) &
2957 ~(1 << DEVICE_REMOTE_WAKEUP_ENABLE),
2958 &dev->usb->usbctl);
2959 allow_status_338x(ep);
2960 break;
2961 }
2962 goto usb3_delegate;
2963
2964 case (USB_DIR_OUT | USB_TYPE_STANDARD | USB_RECIP_ENDPOINT):
2965 e = get_ep_by_addr(dev, w_index);
2966 if (!e)
2967 goto do_stall3;
2968 if (w_value != USB_ENDPOINT_HALT)
2969 goto do_stall3;
2970 VDEBUG(dev, "%s clear halt\n", e->ep.name);
2971 ep_stall(e, false);
2972 if (!list_empty(&e->queue) && e->td_dma)
2973 restart_dma(e);
2974 allow_status(ep);
2975 ep->stopped = 1;
2976 break;
2977
2978 default:
2979 goto usb3_delegate;
2980 }
2981 break;
2982 case USB_REQ_SET_FEATURE:
2983 switch (r.bRequestType) {
2984 case (USB_DIR_OUT | USB_TYPE_STANDARD | USB_RECIP_DEVICE):
2985 if (!dev->addressed_state) {
2986 switch (w_value) {
2987 case USB_DEVICE_U1_ENABLE:
2988 dev->u1_enable = 1;
2989 writel(readl(&dev->usb_ext->usbctl2) |
2990 (1 << U1_ENABLE),
2991 &dev->usb_ext->usbctl2);
2992 allow_status_338x(ep);
2993 goto next_endpoints3;
2994
2995 case USB_DEVICE_U2_ENABLE:
2996 dev->u2_enable = 1;
2997 writel(readl(&dev->usb_ext->usbctl2) |
2998 (1 << U2_ENABLE),
2999 &dev->usb_ext->usbctl2);
3000 allow_status_338x(ep);
3001 goto next_endpoints3;
3002
3003 case USB_DEVICE_LTM_ENABLE:
3004 dev->ltm_enable = 1;
3005 writel(readl(&dev->usb_ext->usbctl2) |
3006 (1 << LTM_ENABLE),
3007 &dev->usb_ext->usbctl2);
3008 allow_status_338x(ep);
3009 goto next_endpoints3;
3010 default:
3011 break;
3012 }
3013 }
3014
3015 if (w_value == USB_DEVICE_REMOTE_WAKEUP) {
3016 dev->wakeup_enable = 1;
3017 writel(readl(&dev->usb->usbctl) |
3018 (1 << DEVICE_REMOTE_WAKEUP_ENABLE),
3019 &dev->usb->usbctl);
3020 allow_status_338x(ep);
3021 break;
3022 }
3023 goto usb3_delegate;
3024
3025 case (USB_DIR_OUT | USB_TYPE_STANDARD | USB_RECIP_ENDPOINT):
3026 e = get_ep_by_addr(dev, w_index);
3027 if (!e || (w_value != USB_ENDPOINT_HALT))
3028 goto do_stall3;
3029 ep_stdrsp(e, true, false);
3030 allow_status_338x(ep);
3031 break;
3032
3033 default:
3034 goto usb3_delegate;
3035 }
3036
3037 break;
3038 default:
3039
3040usb3_delegate:
3041 VDEBUG(dev, "setup %02x.%02x v%04x i%04x l%04x ep_cfg %08x\n",
3042 r.bRequestType, r.bRequest,
3043 w_value, w_index, w_length,
3044 readl(&ep->cfg->ep_cfg));
3045
3046 ep->responded = 0;
3047 spin_unlock(&dev->lock);
3048 tmp = dev->driver->setup(&dev->gadget, &r);
3049 spin_lock(&dev->lock);
3050 }
3051do_stall3:
3052 if (tmp < 0) {
3053 VDEBUG(dev, "req %02x.%02x protocol STALL; stat %d\n",
3054 r.bRequestType, r.bRequest, tmp);
3055 dev->protocol_stall = 1;
3056 /* TD 9.9 Halt Endpoint test. TD 9.22 Set feature test */
3057 ep_stall(ep, true);
3058 }
3059
3060next_endpoints3:
3061
3062#undef w_value
3063#undef w_index
3064#undef w_length
3065
3066 return;
3067}
3068
3069static void handle_stat0_irqs (struct net2280 *dev, u32 stat) 2222static void handle_stat0_irqs (struct net2280 *dev, u32 stat)
3070{ 2223{
3071 struct net2280_ep *ep; 2224 struct net2280_ep *ep;
@@ -3087,20 +2240,10 @@ static void handle_stat0_irqs (struct net2280 *dev, u32 stat)
3087 struct net2280_request *req; 2240 struct net2280_request *req;
3088 2241
3089 if (dev->gadget.speed == USB_SPEED_UNKNOWN) { 2242 if (dev->gadget.speed == USB_SPEED_UNKNOWN) {
3090 u32 val = readl(&dev->usb->usbstat); 2243 if (readl (&dev->usb->usbstat) & (1 << HIGH_SPEED))
3091 if (val & (1 << SUPER_SPEED)) {
3092 dev->gadget.speed = USB_SPEED_SUPER;
3093 usb_ep_set_maxpacket_limit(&dev->ep[0].ep,
3094 EP0_SS_MAX_PACKET_SIZE);
3095 } else if (val & (1 << HIGH_SPEED)) {
3096 dev->gadget.speed = USB_SPEED_HIGH; 2244 dev->gadget.speed = USB_SPEED_HIGH;
3097 usb_ep_set_maxpacket_limit(&dev->ep[0].ep, 2245 else
3098 EP0_HS_MAX_PACKET_SIZE);
3099 } else {
3100 dev->gadget.speed = USB_SPEED_FULL; 2246 dev->gadget.speed = USB_SPEED_FULL;
3101 usb_ep_set_maxpacket_limit(&dev->ep[0].ep,
3102 EP0_HS_MAX_PACKET_SIZE);
3103 }
3104 net2280_led_speed (dev, dev->gadget.speed); 2247 net2280_led_speed (dev, dev->gadget.speed);
3105 DEBUG(dev, "%s\n", usb_speed_string(dev->gadget.speed)); 2248 DEBUG(dev, "%s\n", usb_speed_string(dev->gadget.speed));
3106 } 2249 }
@@ -3118,38 +2261,32 @@ static void handle_stat0_irqs (struct net2280 *dev, u32 stat)
3118 } 2261 }
3119 ep->stopped = 0; 2262 ep->stopped = 0;
3120 dev->protocol_stall = 0; 2263 dev->protocol_stall = 0;
3121 if (dev->pdev->vendor == 0x10b5) 2264
3122 ep->is_halt = 0; 2265 if (ep->dev->pdev->device == 0x2280)
3123 else{ 2266 tmp = (1 << FIFO_OVERFLOW)
3124 if (ep->dev->pdev->device == 0x2280) 2267 | (1 << FIFO_UNDERFLOW);
3125 tmp = (1 << FIFO_OVERFLOW) | 2268 else
3126 (1 << FIFO_UNDERFLOW); 2269 tmp = 0;
3127 else 2270
3128 tmp = 0; 2271 writel (tmp | (1 << TIMEOUT)
3129 2272 | (1 << USB_STALL_SENT)
3130 writel(tmp | (1 << TIMEOUT) | 2273 | (1 << USB_IN_NAK_SENT)
3131 (1 << USB_STALL_SENT) | 2274 | (1 << USB_IN_ACK_RCVD)
3132 (1 << USB_IN_NAK_SENT) | 2275 | (1 << USB_OUT_PING_NAK_SENT)
3133 (1 << USB_IN_ACK_RCVD) | 2276 | (1 << USB_OUT_ACK_SENT)
3134 (1 << USB_OUT_PING_NAK_SENT) | 2277 | (1 << SHORT_PACKET_OUT_DONE_INTERRUPT)
3135 (1 << USB_OUT_ACK_SENT) | 2278 | (1 << SHORT_PACKET_TRANSFERRED_INTERRUPT)
3136 (1 << SHORT_PACKET_OUT_DONE_INTERRUPT) | 2279 | (1 << DATA_PACKET_RECEIVED_INTERRUPT)
3137 (1 << SHORT_PACKET_TRANSFERRED_INTERRUPT) | 2280 | (1 << DATA_PACKET_TRANSMITTED_INTERRUPT)
3138 (1 << DATA_PACKET_RECEIVED_INTERRUPT) | 2281 | (1 << DATA_OUT_PING_TOKEN_INTERRUPT)
3139 (1 << DATA_PACKET_TRANSMITTED_INTERRUPT) | 2282 | (1 << DATA_IN_TOKEN_INTERRUPT)
3140 (1 << DATA_OUT_PING_TOKEN_INTERRUPT) | 2283 , &ep->regs->ep_stat);
3141 (1 << DATA_IN_TOKEN_INTERRUPT) 2284 u.raw [0] = readl (&dev->usb->setup0123);
3142 , &ep->regs->ep_stat); 2285 u.raw [1] = readl (&dev->usb->setup4567);
3143 }
3144 u.raw[0] = readl(&dev->usb->setup0123);
3145 u.raw[1] = readl(&dev->usb->setup4567);
3146 2286
3147 cpu_to_le32s (&u.raw [0]); 2287 cpu_to_le32s (&u.raw [0]);
3148 cpu_to_le32s (&u.raw [1]); 2288 cpu_to_le32s (&u.raw [1]);
3149 2289
3150 if (dev->pdev->vendor == 0x10b5)
3151 defect7374_workaround(dev, u.r);
3152
3153 tmp = 0; 2290 tmp = 0;
3154 2291
3155#define w_value le16_to_cpu(u.r.wValue) 2292#define w_value le16_to_cpu(u.r.wValue)
@@ -3181,12 +2318,6 @@ static void handle_stat0_irqs (struct net2280 *dev, u32 stat)
3181 * everything else goes uplevel to the gadget code. 2318 * everything else goes uplevel to the gadget code.
3182 */ 2319 */
3183 ep->responded = 1; 2320 ep->responded = 1;
3184
3185 if (dev->gadget.speed == USB_SPEED_SUPER) {
3186 handle_stat0_irqs_superspeed(dev, ep, u.r);
3187 goto next_endpoints;
3188 }
3189
3190 switch (u.r.bRequest) { 2321 switch (u.r.bRequest) {
3191 case USB_REQ_GET_STATUS: { 2322 case USB_REQ_GET_STATUS: {
3192 struct net2280_ep *e; 2323 struct net2280_ep *e;
@@ -3229,11 +2360,8 @@ static void handle_stat0_irqs (struct net2280 *dev, u32 stat)
3229 VDEBUG(dev, "%s wedged, halt not cleared\n", 2360 VDEBUG(dev, "%s wedged, halt not cleared\n",
3230 ep->ep.name); 2361 ep->ep.name);
3231 } else { 2362 } else {
3232 VDEBUG(dev, "%s clear halt\n", e->ep.name); 2363 VDEBUG(dev, "%s clear halt\n", ep->ep.name);
3233 clear_halt(e); 2364 clear_halt(e);
3234 if (ep->dev->pdev->vendor == 0x10b5 &&
3235 !list_empty(&e->queue) && e->td_dma)
3236 restart_dma(e);
3237 } 2365 }
3238 allow_status (ep); 2366 allow_status (ep);
3239 goto next_endpoints; 2367 goto next_endpoints;
@@ -3253,8 +2381,6 @@ static void handle_stat0_irqs (struct net2280 *dev, u32 stat)
3253 if (e->ep.name == ep0name) 2381 if (e->ep.name == ep0name)
3254 goto do_stall; 2382 goto do_stall;
3255 set_halt (e); 2383 set_halt (e);
3256 if (dev->pdev->vendor == 0x10b5 && e->dma)
3257 abort_dma(e);
3258 allow_status (ep); 2384 allow_status (ep);
3259 VDEBUG (dev, "%s set halt\n", ep->ep.name); 2385 VDEBUG (dev, "%s set halt\n", ep->ep.name);
3260 goto next_endpoints; 2386 goto next_endpoints;
@@ -3266,7 +2392,7 @@ delegate:
3266 "ep_cfg %08x\n", 2392 "ep_cfg %08x\n",
3267 u.r.bRequestType, u.r.bRequest, 2393 u.r.bRequestType, u.r.bRequest,
3268 w_value, w_index, w_length, 2394 w_value, w_index, w_length,
3269 readl(&ep->cfg->ep_cfg)); 2395 readl (&ep->regs->ep_cfg));
3270 ep->responded = 0; 2396 ep->responded = 0;
3271 spin_unlock (&dev->lock); 2397 spin_unlock (&dev->lock);
3272 tmp = dev->driver->setup (&dev->gadget, &u.r); 2398 tmp = dev->driver->setup (&dev->gadget, &u.r);
@@ -3329,7 +2455,7 @@ static void handle_stat1_irqs (struct net2280 *dev, u32 stat)
3329 2455
3330 /* after disconnect there's nothing else to do! */ 2456 /* after disconnect there's nothing else to do! */
3331 tmp = (1 << VBUS_INTERRUPT) | (1 << ROOT_PORT_RESET_INTERRUPT); 2457 tmp = (1 << VBUS_INTERRUPT) | (1 << ROOT_PORT_RESET_INTERRUPT);
3332 mask = (1 << SUPER_SPEED) | (1 << HIGH_SPEED) | (1 << FULL_SPEED); 2458 mask = (1 << HIGH_SPEED) | (1 << FULL_SPEED);
3333 2459
3334 /* VBUS disconnect is indicated by VBUS_PIN and VBUS_INTERRUPT set. 2460 /* VBUS disconnect is indicated by VBUS_PIN and VBUS_INTERRUPT set.
3335 * Root Port Reset is indicated by ROOT_PORT_RESET_INTERRUPT set and 2461 * Root Port Reset is indicated by ROOT_PORT_RESET_INTERRUPT set and
@@ -3420,19 +2546,12 @@ static void handle_stat1_irqs (struct net2280 *dev, u32 stat)
3420 tmp = readl (&dma->dmastat); 2546 tmp = readl (&dma->dmastat);
3421 writel (tmp, &dma->dmastat); 2547 writel (tmp, &dma->dmastat);
3422 2548
3423 /* dma sync*/
3424 if (dev->pdev->vendor == 0x10b5) {
3425 u32 r_dmacount = readl(&dma->dmacount);
3426 if (!ep->is_in && (r_dmacount & 0x00FFFFFF) &&
3427 (tmp & (1 << DMA_TRANSACTION_DONE_INTERRUPT)))
3428 continue;
3429 }
3430
3431 /* chaining should stop on abort, short OUT from fifo, 2549 /* chaining should stop on abort, short OUT from fifo,
3432 * or (stat0 codepath) short OUT transfer. 2550 * or (stat0 codepath) short OUT transfer.
3433 */ 2551 */
3434 if (!use_dma_chaining) { 2552 if (!use_dma_chaining) {
3435 if (!(tmp & (1 << DMA_TRANSACTION_DONE_INTERRUPT))) { 2553 if ((tmp & (1 << DMA_TRANSACTION_DONE_INTERRUPT))
2554 == 0) {
3436 DEBUG (ep->dev, "%s no xact done? %08x\n", 2555 DEBUG (ep->dev, "%s no xact done? %08x\n",
3437 ep->ep.name, tmp); 2556 ep->ep.name, tmp);
3438 continue; 2557 continue;
@@ -3506,8 +2625,7 @@ static irqreturn_t net2280_irq (int irq, void *_dev)
3506 struct net2280 *dev = _dev; 2625 struct net2280 *dev = _dev;
3507 2626
3508 /* shared interrupt, not ours */ 2627 /* shared interrupt, not ours */
3509 if (dev->pdev->vendor == 0x17cc && 2628 if (!(readl(&dev->regs->irqstat0) & (1 << INTA_ASSERTED)))
3510 (!(readl(&dev->regs->irqstat0) & (1 << INTA_ASSERTED))))
3511 return IRQ_NONE; 2629 return IRQ_NONE;
3512 2630
3513 spin_lock (&dev->lock); 2631 spin_lock (&dev->lock);
@@ -3518,13 +2636,6 @@ static irqreturn_t net2280_irq (int irq, void *_dev)
3518 /* control requests and PIO */ 2636 /* control requests and PIO */
3519 handle_stat0_irqs (dev, readl (&dev->regs->irqstat0)); 2637 handle_stat0_irqs (dev, readl (&dev->regs->irqstat0));
3520 2638
3521 if (dev->pdev->vendor == 0x10b5) {
3522 /* re-enable interrupt to trigger any possible new interrupt */
3523 u32 pciirqenb1 = readl(&dev->regs->pciirqenb1);
3524 writel(pciirqenb1 & 0x7FFFFFFF, &dev->regs->pciirqenb1);
3525 writel(pciirqenb1, &dev->regs->pciirqenb1);
3526 }
3527
3528 spin_unlock (&dev->lock); 2639 spin_unlock (&dev->lock);
3529 2640
3530 return IRQ_HANDLED; 2641 return IRQ_HANDLED;
@@ -3563,8 +2674,6 @@ static void net2280_remove (struct pci_dev *pdev)
3563 } 2674 }
3564 if (dev->got_irq) 2675 if (dev->got_irq)
3565 free_irq (pdev->irq, dev); 2676 free_irq (pdev->irq, dev);
3566 if (use_msi && dev->pdev->vendor == 0x10b5)
3567 pci_disable_msi(pdev);
3568 if (dev->regs) 2677 if (dev->regs)
3569 iounmap (dev->regs); 2678 iounmap (dev->regs);
3570 if (dev->region) 2679 if (dev->region)
@@ -3599,8 +2708,7 @@ static int net2280_probe (struct pci_dev *pdev, const struct pci_device_id *id)
3599 spin_lock_init (&dev->lock); 2708 spin_lock_init (&dev->lock);
3600 dev->pdev = pdev; 2709 dev->pdev = pdev;
3601 dev->gadget.ops = &net2280_ops; 2710 dev->gadget.ops = &net2280_ops;
3602 dev->gadget.max_speed = (dev->pdev->vendor == 0x10b5) ? 2711 dev->gadget.max_speed = USB_SPEED_HIGH;
3603 USB_SPEED_SUPER : USB_SPEED_HIGH;
3604 2712
3605 /* the "gadget" abstracts/virtualizes the controller */ 2713 /* the "gadget" abstracts/virtualizes the controller */
3606 dev->gadget.name = driver_name; 2714 dev->gadget.name = driver_name;
@@ -3642,39 +2750,8 @@ static int net2280_probe (struct pci_dev *pdev, const struct pci_device_id *id)
3642 dev->dep = (struct net2280_dep_regs __iomem *) (base + 0x0200); 2750 dev->dep = (struct net2280_dep_regs __iomem *) (base + 0x0200);
3643 dev->epregs = (struct net2280_ep_regs __iomem *) (base + 0x0300); 2751 dev->epregs = (struct net2280_ep_regs __iomem *) (base + 0x0300);
3644 2752
3645 if (dev->pdev->vendor == 0x10b5) { 2753 /* put into initial config, link up all endpoints */
3646 u32 fsmvalue; 2754 writel (0, &dev->usb->usbctl);
3647 u32 usbstat;
3648 dev->usb_ext = (struct usb338x_usb_ext_regs __iomem *)
3649 (base + 0x00b4);
3650 dev->fiforegs = (struct usb338x_fifo_regs __iomem *)
3651 (base + 0x0500);
3652 dev->llregs = (struct usb338x_ll_regs __iomem *)
3653 (base + 0x0700);
3654 dev->ll_lfps_regs = (struct usb338x_ll_lfps_regs __iomem *)
3655 (base + 0x0748);
3656 dev->ll_tsn_regs = (struct usb338x_ll_tsn_regs __iomem *)
3657 (base + 0x077c);
3658 dev->ll_chicken_reg = (struct usb338x_ll_chi_regs __iomem *)
3659 (base + 0x079c);
3660 dev->plregs = (struct usb338x_pl_regs __iomem *)
3661 (base + 0x0800);
3662 usbstat = readl(&dev->usb->usbstat);
3663 dev->enhanced_mode = (usbstat & (1 << 11)) ? 1 : 0;
3664 dev->n_ep = (dev->enhanced_mode) ? 9 : 5;
3665 /* put into initial config, link up all endpoints */
3666 fsmvalue = get_idx_reg(dev->regs, SCRATCH) &
3667 (0xf << DEFECT7374_FSM_FIELD);
3668 /* See if firmware needs to set up for workaround: */
3669 if (fsmvalue == DEFECT7374_FSM_SS_CONTROL_READ)
3670 writel(0, &dev->usb->usbctl);
3671 } else{
3672 dev->enhanced_mode = 0;
3673 dev->n_ep = 7;
3674 /* put into initial config, link up all endpoints */
3675 writel(0, &dev->usb->usbctl);
3676 }
3677
3678 usb_reset (dev); 2755 usb_reset (dev);
3679 usb_reinit (dev); 2756 usb_reinit (dev);
3680 2757
@@ -3685,10 +2762,6 @@ static int net2280_probe (struct pci_dev *pdev, const struct pci_device_id *id)
3685 goto done; 2762 goto done;
3686 } 2763 }
3687 2764
3688 if (use_msi && dev->pdev->vendor == 0x10b5)
3689 if (pci_enable_msi(pdev))
3690 ERROR(dev, "Failed to enable MSI mode\n");
3691
3692 if (request_irq (pdev->irq, net2280_irq, IRQF_SHARED, driver_name, dev) 2765 if (request_irq (pdev->irq, net2280_irq, IRQF_SHARED, driver_name, dev)
3693 != 0) { 2766 != 0) {
3694 ERROR (dev, "request interrupt %d failed\n", pdev->irq); 2767 ERROR (dev, "request interrupt %d failed\n", pdev->irq);
@@ -3724,8 +2797,7 @@ static int net2280_probe (struct pci_dev *pdev, const struct pci_device_id *id)
3724 } 2797 }
3725 2798
3726 /* enable lower-overhead pci memory bursts during DMA */ 2799 /* enable lower-overhead pci memory bursts during DMA */
3727 if (dev->pdev->vendor == 0x17cc) 2800 writel ( (1 << DMA_MEMORY_WRITE_AND_INVALIDATE_ENABLE)
3728 writel((1 << DMA_MEMORY_WRITE_AND_INVALIDATE_ENABLE)
3729 // 256 write retries may not be enough... 2801 // 256 write retries may not be enough...
3730 // | (1 << PCI_RETRY_ABORT_ENABLE) 2802 // | (1 << PCI_RETRY_ABORT_ENABLE)
3731 | (1 << DMA_READ_MULTIPLE_ENABLE) 2803 | (1 << DMA_READ_MULTIPLE_ENABLE)
@@ -3742,10 +2814,10 @@ static int net2280_probe (struct pci_dev *pdev, const struct pci_device_id *id)
3742 INFO (dev, "%s\n", driver_desc); 2814 INFO (dev, "%s\n", driver_desc);
3743 INFO (dev, "irq %d, pci mem %p, chip rev %04x\n", 2815 INFO (dev, "irq %d, pci mem %p, chip rev %04x\n",
3744 pdev->irq, base, dev->chiprev); 2816 pdev->irq, base, dev->chiprev);
3745 INFO(dev, "version: " DRIVER_VERSION "; dma %s %s\n", 2817 INFO (dev, "version: " DRIVER_VERSION "; dma %s\n",
3746 use_dma ? (use_dma_chaining ? "chaining" : "enabled") 2818 use_dma
3747 : "disabled", 2819 ? (use_dma_chaining ? "chaining" : "enabled")
3748 dev->enhanced_mode ? "enhanced mode" : "legacy mode"); 2820 : "disabled");
3749 retval = device_create_file (&pdev->dev, &dev_attr_registers); 2821 retval = device_create_file (&pdev->dev, &dev_attr_registers);
3750 if (retval) goto done; 2822 if (retval) goto done;
3751 2823
@@ -3777,8 +2849,7 @@ static void net2280_shutdown (struct pci_dev *pdev)
3777 writel (0, &dev->usb->usbctl); 2849 writel (0, &dev->usb->usbctl);
3778 2850
3779 /* Disable full-speed test mode */ 2851 /* Disable full-speed test mode */
3780 if (dev->pdev->vendor == 0x17cc) 2852 writel(0, &dev->usb->xcvrdiag);
3781 writel(0, &dev->usb->xcvrdiag);
3782} 2853}
3783 2854
3784 2855
@@ -3798,24 +2869,8 @@ static const struct pci_device_id pci_ids [] = { {
3798 .device = 0x2282, 2869 .device = 0x2282,
3799 .subvendor = PCI_ANY_ID, 2870 .subvendor = PCI_ANY_ID,
3800 .subdevice = PCI_ANY_ID, 2871 .subdevice = PCI_ANY_ID,
3801}, 2872
3802 { 2873}, { /* end: all zeroes */ }
3803 .class = ((PCI_CLASS_SERIAL_USB << 8) | 0xfe),
3804 .class_mask = ~0,
3805 .vendor = 0x10b5,
3806 .device = 0x3380,
3807 .subvendor = PCI_ANY_ID,
3808 .subdevice = PCI_ANY_ID,
3809 },
3810 {
3811 .class = ((PCI_CLASS_SERIAL_USB << 8) | 0xfe),
3812 .class_mask = ~0,
3813 .vendor = 0x10b5,
3814 .device = 0x3382,
3815 .subvendor = PCI_ANY_ID,
3816 .subdevice = PCI_ANY_ID,
3817 },
3818{ /* end: all zeroes */ }
3819}; 2874};
3820MODULE_DEVICE_TABLE (pci, pci_ids); 2875MODULE_DEVICE_TABLE (pci, pci_ids);
3821 2876
diff --git a/drivers/usb/gadget/net2280.h b/drivers/usb/gadget/net2280.h
index f32c2746b6ae..a844be0d683a 100644
--- a/drivers/usb/gadget/net2280.h
+++ b/drivers/usb/gadget/net2280.h
@@ -6,7 +6,6 @@
6/* 6/*
7 * Copyright (C) 2002 NetChip Technology, Inc. (http://www.netchip.com) 7 * Copyright (C) 2002 NetChip Technology, Inc. (http://www.netchip.com)
8 * Copyright (C) 2003 David Brownell 8 * Copyright (C) 2003 David Brownell
9 * Copyright (C) 2014 Ricardo Ribalda - Qtechnology/AS
10 * 9 *
11 * This program is free software; you can redistribute it and/or modify 10 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by 11 * it under the terms of the GNU General Public License as published by
@@ -15,7 +14,6 @@
15 */ 14 */
16 15
17#include <linux/usb/net2280.h> 16#include <linux/usb/net2280.h>
18#include <linux/usb/usb338x.h>
19 17
20/*-------------------------------------------------------------------------*/ 18/*-------------------------------------------------------------------------*/
21 19
@@ -61,13 +59,6 @@ set_idx_reg (struct net2280_regs __iomem *regs, u32 index, u32 value)
61#define CHIPREV_1 0x0100 59#define CHIPREV_1 0x0100
62#define CHIPREV_1A 0x0110 60#define CHIPREV_1A 0x0110
63 61
64/* DEFECT 7374 */
65#define DEFECT_7374_NUMBEROF_MAX_WAIT_LOOPS 200
66#define DEFECT_7374_PROCESSOR_WAIT_TIME 10
67
68/* ep0 max packet size */
69#define EP0_SS_MAX_PACKET_SIZE 0x200
70#define EP0_HS_MAX_PACKET_SIZE 0x40
71#ifdef __KERNEL__ 62#ifdef __KERNEL__
72 63
73/* ep a-f highspeed and fullspeed maxpacket, addresses 64/* ep a-f highspeed and fullspeed maxpacket, addresses
@@ -94,15 +85,12 @@ struct net2280_dma {
94 85
95struct net2280_ep { 86struct net2280_ep {
96 struct usb_ep ep; 87 struct usb_ep ep;
97 struct net2280_ep_regs __iomem *cfg;
98 struct net2280_ep_regs __iomem *regs; 88 struct net2280_ep_regs __iomem *regs;
99 struct net2280_dma_regs __iomem *dma; 89 struct net2280_dma_regs __iomem *dma;
100 struct net2280_dma *dummy; 90 struct net2280_dma *dummy;
101 struct usb338x_fifo_regs __iomem *fiforegs;
102 dma_addr_t td_dma; /* of dummy */ 91 dma_addr_t td_dma; /* of dummy */
103 struct net2280 *dev; 92 struct net2280 *dev;
104 unsigned long irqs; 93 unsigned long irqs;
105 unsigned is_halt:1, dma_started:1;
106 94
107 /* analogous to a host-side qh */ 95 /* analogous to a host-side qh */
108 struct list_head queue; 96 struct list_head queue;
@@ -128,19 +116,10 @@ static inline void allow_status (struct net2280_ep *ep)
128 ep->stopped = 1; 116 ep->stopped = 1;
129} 117}
130 118
131static void allow_status_338x(struct net2280_ep *ep) 119/* count (<= 4) bytes in the next fifo write will be valid */
120static inline void set_fifo_bytecount (struct net2280_ep *ep, unsigned count)
132{ 121{
133 /* 122 writeb (count, 2 + (u8 __iomem *) &ep->regs->ep_cfg);
134 * Control Status Phase Handshake was set by the chip when the setup
135 * packet arrived. While set, the chip automatically NAKs the host's
136 * Status Phase tokens.
137 */
138 writel(1 << CLEAR_CONTROL_STATUS_PHASE_HANDSHAKE, &ep->regs->ep_rsp);
139
140 ep->stopped = 1;
141
142 /* TD 9.9 Halt Endpoint test. TD 9.22 set feature test. */
143 ep->responded = 0;
144} 123}
145 124
146struct net2280_request { 125struct net2280_request {
@@ -156,38 +135,23 @@ struct net2280 {
156 /* each pci device provides one gadget, several endpoints */ 135 /* each pci device provides one gadget, several endpoints */
157 struct usb_gadget gadget; 136 struct usb_gadget gadget;
158 spinlock_t lock; 137 spinlock_t lock;
159 struct net2280_ep ep[9]; 138 struct net2280_ep ep [7];
160 struct usb_gadget_driver *driver; 139 struct usb_gadget_driver *driver;
161 unsigned enabled : 1, 140 unsigned enabled : 1,
162 protocol_stall : 1, 141 protocol_stall : 1,
163 softconnect : 1, 142 softconnect : 1,
164 got_irq : 1, 143 got_irq : 1,
165 region:1, 144 region : 1;
166 u1_enable:1,
167 u2_enable:1,
168 ltm_enable:1,
169 wakeup_enable:1,
170 selfpowered:1,
171 addressed_state:1;
172 u16 chiprev; 145 u16 chiprev;
173 int enhanced_mode;
174 int n_ep;
175 146
176 /* pci state used to access those endpoints */ 147 /* pci state used to access those endpoints */
177 struct pci_dev *pdev; 148 struct pci_dev *pdev;
178 struct net2280_regs __iomem *regs; 149 struct net2280_regs __iomem *regs;
179 struct net2280_usb_regs __iomem *usb; 150 struct net2280_usb_regs __iomem *usb;
180 struct usb338x_usb_ext_regs __iomem *usb_ext;
181 struct net2280_pci_regs __iomem *pci; 151 struct net2280_pci_regs __iomem *pci;
182 struct net2280_dma_regs __iomem *dma; 152 struct net2280_dma_regs __iomem *dma;
183 struct net2280_dep_regs __iomem *dep; 153 struct net2280_dep_regs __iomem *dep;
184 struct net2280_ep_regs __iomem *epregs; 154 struct net2280_ep_regs __iomem *epregs;
185 struct usb338x_fifo_regs __iomem *fiforegs;
186 struct usb338x_ll_regs __iomem *llregs;
187 struct usb338x_ll_lfps_regs __iomem *ll_lfps_regs;
188 struct usb338x_ll_tsn_regs __iomem *ll_tsn_regs;
189 struct usb338x_ll_chi_regs __iomem *ll_chicken_reg;
190 struct usb338x_pl_regs __iomem *plregs;
191 155
192 struct pci_pool *requests; 156 struct pci_pool *requests;
193 // statistics... 157 // statistics...
@@ -215,43 +179,6 @@ static inline void clear_halt (struct net2280_ep *ep)
215 , &ep->regs->ep_rsp); 179 , &ep->regs->ep_rsp);
216} 180}
217 181
218/*
219 * FSM value for Defect 7374 (U1U2 Test) is managed in
220 * chip's SCRATCH register:
221 */
222#define DEFECT7374_FSM_FIELD 28
223
224/* Waiting for Control Read:
225 * - A transition to this state indicates a fresh USB connection,
226 * before the first Setup Packet. The connection speed is not
227 * known. Firmware is waiting for the first Control Read.
228 * - Starting state: This state can be thought of as the FSM's typical
229 * starting state.
230 * - Tip: Upon the first SS Control Read the FSM never
231 * returns to this state.
232 */
233#define DEFECT7374_FSM_WAITING_FOR_CONTROL_READ (1 << DEFECT7374_FSM_FIELD)
234
235/* Non-SS Control Read:
236 * - A transition to this state indicates detection of the first HS
237 * or FS Control Read.
238 * - Tip: Upon the first SS Control Read the FSM never
239 * returns to this state.
240 */
241#define DEFECT7374_FSM_NON_SS_CONTROL_READ (2 << DEFECT7374_FSM_FIELD)
242
243/* SS Control Read:
244 * - A transition to this state indicates detection of the
245 * first SS Control Read.
246 * - This state indicates workaround completion. Workarounds no longer
247 * need to be applied (as long as the chip remains powered up).
248 * - Tip: Once in this state the FSM state does not change (until
249 * the chip's power is lost and restored).
250 * - This can be thought of as the final state of the FSM;
251 * the FSM 'locks-up' in this state until the chip loses power.
252 */
253#define DEFECT7374_FSM_SS_CONTROL_READ (3 << DEFECT7374_FSM_FIELD)
254
255#ifdef USE_RDK_LEDS 182#ifdef USE_RDK_LEDS
256 183
257static inline void net2280_led_init (struct net2280 *dev) 184static inline void net2280_led_init (struct net2280 *dev)
@@ -271,9 +198,6 @@ void net2280_led_speed (struct net2280 *dev, enum usb_device_speed speed)
271{ 198{
272 u32 val = readl (&dev->regs->gpioctl); 199 u32 val = readl (&dev->regs->gpioctl);
273 switch (speed) { 200 switch (speed) {
274 case USB_SPEED_SUPER: /* green + red */
275 val |= (1 << GPIO0_DATA) | (1 << GPIO1_DATA);
276 break;
277 case USB_SPEED_HIGH: /* green */ 201 case USB_SPEED_HIGH: /* green */
278 val &= ~(1 << GPIO0_DATA); 202 val &= ~(1 << GPIO0_DATA);
279 val |= (1 << GPIO1_DATA); 203 val |= (1 << GPIO1_DATA);
@@ -347,17 +271,6 @@ static inline void net2280_led_shutdown (struct net2280 *dev)
347 271
348/*-------------------------------------------------------------------------*/ 272/*-------------------------------------------------------------------------*/
349 273
350static inline void set_fifo_bytecount(struct net2280_ep *ep, unsigned count)
351{
352 if (ep->dev->pdev->vendor == 0x17cc)
353 writeb(count, 2 + (u8 __iomem *) &ep->regs->ep_cfg);
354 else{
355 u32 tmp = readl(&ep->cfg->ep_cfg) &
356 (~(0x07 << EP_FIFO_BYTE_COUNT));
357 writel(tmp | (count << EP_FIFO_BYTE_COUNT), &ep->cfg->ep_cfg);
358 }
359}
360
361static inline void start_out_naking (struct net2280_ep *ep) 274static inline void start_out_naking (struct net2280_ep *ep)
362{ 275{
363 /* NOTE: hardware races lurk here, and PING protocol issues */ 276 /* NOTE: hardware races lurk here, and PING protocol issues */