2 * Driver for the PLX NET2280 USB device controller.
3 * Specs and errata are available from <http://www.plxtech.com>.
5 * PLX Technology Inc. (formerly NetChip Technology) supported the
6 * development of this driver.
9 * CODE STATUS HIGHLIGHTS
11 * This driver should work well with most "gadget" drivers, including
12 * the Mass Storage, Serial, and Ethernet/RNDIS gadget drivers
13 * as well as Gadget Zero and Gadgetfs.
15 * DMA is enabled by default.
17 * MSI is enabled by default. The legacy IRQ is used if MSI couldn't
20 * Note that almost all the errata workarounds here are only needed for
21 * rev1 chips. Rev1a silicon (0110) fixes almost all of them.
25 * Copyright (C) 2003 David Brownell
26 * Copyright (C) 2003-2005 PLX Technology, Inc.
27 * Copyright (C) 2014 Ricardo Ribalda - Qtechnology/AS
29 * Modified Seth Levy 2005 PLX Technology, Inc. to provide compatibility
32 * Modified Ricardo Ribalda Qtechnology AS to provide compatibility
33 * with usb 338x chip. Based on PLX driver
35 * This program is free software; you can redistribute it and/or modify
36 * it under the terms of the GNU General Public License as published by
37 * the Free Software Foundation; either version 2 of the License, or
38 * (at your option) any later version.
41 #include <linux/module.h>
42 #include <linux/pci.h>
43 #include <linux/dma-mapping.h>
44 #include <linux/kernel.h>
45 #include <linux/delay.h>
46 #include <linux/ioport.h>
47 #include <linux/slab.h>
48 #include <linux/errno.h>
49 #include <linux/init.h>
50 #include <linux/timer.h>
51 #include <linux/list.h>
52 #include <linux/interrupt.h>
53 #include <linux/moduleparam.h>
54 #include <linux/device.h>
55 #include <linux/usb/ch9.h>
56 #include <linux/usb/gadget.h>
57 #include <linux/prefetch.h>
60 #include <asm/byteorder.h>
62 #include <asm/unaligned.h>
64 #define DRIVER_DESC "PLX NET228x/USB338x USB Peripheral Controller"
65 #define DRIVER_VERSION "2005 Sept 27/v3.0"
67 #define EP_DONTUSE 13 /* nonzero */
69 #define USE_RDK_LEDS /* GPIO pins control three LEDs */
72 static const char driver_name
[] = "net2280";
73 static const char driver_desc
[] = DRIVER_DESC
;
75 static const u32 ep_bit
[9] = { 0, 17, 2, 19, 4, 1, 18, 3, 20 };
76 static const char ep0name
[] = "ep0";
77 static const char *const ep_name
[] = {
79 "ep-a", "ep-b", "ep-c", "ep-d",
80 "ep-e", "ep-f", "ep-g", "ep-h",
83 /* Endpoint names for usb3380 advance mode */
84 static const char *const ep_name_adv
[] = {
86 "ep1in", "ep2out", "ep3in", "ep4out",
87 "ep1out", "ep2in", "ep3out", "ep4in",
90 /* mode 0 == ep-{a,b,c,d} 1K fifo each
91 * mode 1 == ep-{a,b} 2K fifo each, ep-{c,d} unavailable
92 * mode 2 == ep-a 2K fifo, ep-{b,c} 1K each, ep-d unavailable
94 static ushort fifo_mode
;
96 /* "modprobe net2280 fifo_mode=1" etc */
97 module_param(fifo_mode
, ushort
, 0644);
99 /* enable_suspend -- When enabled, the driver will respond to
100 * USB suspend requests by powering down the NET2280. Otherwise,
101 * USB suspend requests will be ignored. This is acceptable for
102 * self-powered devices
104 static bool enable_suspend
;
106 /* "modprobe net2280 enable_suspend=1" etc */
107 module_param(enable_suspend
, bool, 0444);
109 #define DIR_STRING(bAddress) (((bAddress) & USB_DIR_IN) ? "in" : "out")
111 static char *type_string(u8 bmAttributes
)
113 switch ((bmAttributes
) & USB_ENDPOINT_XFERTYPE_MASK
) {
114 case USB_ENDPOINT_XFER_BULK
: return "bulk";
115 case USB_ENDPOINT_XFER_ISOC
: return "iso";
116 case USB_ENDPOINT_XFER_INT
: return "intr";
123 #define valid_bit cpu_to_le32(BIT(VALID_BIT))
124 #define dma_done_ie cpu_to_le32(BIT(DMA_DONE_INTERRUPT_ENABLE))
126 /*-------------------------------------------------------------------------*/
127 static inline void enable_pciirqenb(struct net2280_ep
*ep
)
129 u32 tmp
= readl(&ep
->dev
->regs
->pciirqenb0
);
131 if (ep
->dev
->quirks
& PLX_LEGACY
)
134 tmp
|= BIT(ep_bit
[ep
->num
]);
135 writel(tmp
, &ep
->dev
->regs
->pciirqenb0
);
141 net2280_enable(struct usb_ep
*_ep
, const struct usb_endpoint_descriptor
*desc
)
144 struct net2280_ep
*ep
;
147 static const u32 ep_key
[9] = { 1, 0, 1, 0, 1, 1, 0, 1, 0 };
149 ep
= container_of(_ep
, struct net2280_ep
, ep
);
150 if (!_ep
|| !desc
|| ep
->desc
|| _ep
->name
== ep0name
||
151 desc
->bDescriptorType
!= USB_DT_ENDPOINT
)
154 if (!dev
->driver
|| dev
->gadget
.speed
== USB_SPEED_UNKNOWN
)
157 /* erratum 0119 workaround ties up an endpoint number */
158 if ((desc
->bEndpointAddress
& 0x0f) == EP_DONTUSE
)
161 if (dev
->quirks
& PLX_SUPERSPEED
) {
162 if ((desc
->bEndpointAddress
& 0x0f) >= 0x0c)
164 ep
->is_in
= !!usb_endpoint_dir_in(desc
);
165 if (dev
->enhanced_mode
&& ep
->is_in
&& ep_key
[ep
->num
])
169 /* sanity check ep-e/ep-f since their fifos are small */
170 max
= usb_endpoint_maxp(desc
) & 0x1fff;
171 if (ep
->num
> 4 && max
> 64 && (dev
->quirks
& PLX_LEGACY
))
174 spin_lock_irqsave(&dev
->lock
, flags
);
175 _ep
->maxpacket
= max
& 0x7ff;
178 /* ep_reset() has already been called */
181 ep
->out_overflow
= 0;
183 /* set speed-dependent max packet; may kick in high bandwidth */
184 set_max_speed(ep
, max
);
186 /* set type, direction, address; reset fifo counters */
187 writel(BIT(FIFO_FLUSH
), &ep
->regs
->ep_stat
);
188 tmp
= (desc
->bmAttributes
& USB_ENDPOINT_XFERTYPE_MASK
);
189 if (tmp
== USB_ENDPOINT_XFER_INT
) {
190 /* erratum 0105 workaround prevents hs NYET */
191 if (dev
->chiprev
== 0100 &&
192 dev
->gadget
.speed
== USB_SPEED_HIGH
&&
193 !(desc
->bEndpointAddress
& USB_DIR_IN
))
194 writel(BIT(CLEAR_NAK_OUT_PACKETS_MODE
),
196 } else if (tmp
== USB_ENDPOINT_XFER_BULK
) {
197 /* catch some particularly blatant driver bugs */
198 if ((dev
->gadget
.speed
== USB_SPEED_SUPER
&& max
!= 1024) ||
199 (dev
->gadget
.speed
== USB_SPEED_HIGH
&& max
!= 512) ||
200 (dev
->gadget
.speed
== USB_SPEED_FULL
&& max
> 64)) {
201 spin_unlock_irqrestore(&dev
->lock
, flags
);
205 ep
->is_iso
= (tmp
== USB_ENDPOINT_XFER_ISOC
);
206 /* Enable this endpoint */
207 if (dev
->quirks
& PLX_LEGACY
) {
208 tmp
<<= ENDPOINT_TYPE
;
209 tmp
|= desc
->bEndpointAddress
;
210 /* default full fifo lines */
211 tmp
|= (4 << ENDPOINT_BYTE_COUNT
);
212 tmp
|= BIT(ENDPOINT_ENABLE
);
213 ep
->is_in
= (tmp
& USB_DIR_IN
) != 0;
215 /* In Legacy mode, only OUT endpoints are used */
216 if (dev
->enhanced_mode
&& ep
->is_in
) {
217 tmp
<<= IN_ENDPOINT_TYPE
;
218 tmp
|= BIT(IN_ENDPOINT_ENABLE
);
219 /* Not applicable to Legacy */
220 tmp
|= BIT(ENDPOINT_DIRECTION
);
222 tmp
<<= OUT_ENDPOINT_TYPE
;
223 tmp
|= BIT(OUT_ENDPOINT_ENABLE
);
224 tmp
|= (ep
->is_in
<< ENDPOINT_DIRECTION
);
227 tmp
|= usb_endpoint_num(desc
);
228 tmp
|= (ep
->ep
.maxburst
<< MAX_BURST_SIZE
);
231 /* Make sure all the registers are written before ep_rsp*/
234 /* for OUT transfers, block the rx fifo until a read is posted */
236 writel(BIT(SET_NAK_OUT_PACKETS
), &ep
->regs
->ep_rsp
);
237 else if (!(dev
->quirks
& PLX_2280
)) {
238 /* Added for 2282, Don't use nak packets on an in endpoint,
239 * this was ignored on 2280
241 writel(BIT(CLEAR_NAK_OUT_PACKETS
) |
242 BIT(CLEAR_NAK_OUT_PACKETS_MODE
), &ep
->regs
->ep_rsp
);
245 writel(tmp
, &ep
->cfg
->ep_cfg
);
248 if (!ep
->dma
) { /* pio, per-packet */
249 enable_pciirqenb(ep
);
251 tmp
= BIT(DATA_PACKET_RECEIVED_INTERRUPT_ENABLE
) |
252 BIT(DATA_PACKET_TRANSMITTED_INTERRUPT_ENABLE
);
253 if (dev
->quirks
& PLX_2280
)
254 tmp
|= readl(&ep
->regs
->ep_irqenb
);
255 writel(tmp
, &ep
->regs
->ep_irqenb
);
256 } else { /* dma, per-request */
257 tmp
= BIT((8 + ep
->num
)); /* completion */
258 tmp
|= readl(&dev
->regs
->pciirqenb1
);
259 writel(tmp
, &dev
->regs
->pciirqenb1
);
261 /* for short OUT transfers, dma completions can't
262 * advance the queue; do it pio-style, by hand.
263 * NOTE erratum 0112 workaround #2
265 if ((desc
->bEndpointAddress
& USB_DIR_IN
) == 0) {
266 tmp
= BIT(SHORT_PACKET_TRANSFERRED_INTERRUPT_ENABLE
);
267 writel(tmp
, &ep
->regs
->ep_irqenb
);
269 enable_pciirqenb(ep
);
273 tmp
= desc
->bEndpointAddress
;
274 ep_dbg(dev
, "enabled %s (ep%d%s-%s) %s max %04x\n",
275 _ep
->name
, tmp
& 0x0f, DIR_STRING(tmp
),
276 type_string(desc
->bmAttributes
),
277 ep
->dma
? "dma" : "pio", max
);
279 /* pci writes may still be posted */
280 spin_unlock_irqrestore(&dev
->lock
, flags
);
284 static int handshake(u32 __iomem
*ptr
, u32 mask
, u32 done
, int usec
)
290 if (result
== ~(u32
)0) /* "device unplugged" */
301 static const struct usb_ep_ops net2280_ep_ops
;
303 static void ep_reset_228x(struct net2280_regs __iomem
*regs
,
304 struct net2280_ep
*ep
)
309 INIT_LIST_HEAD(&ep
->queue
);
311 usb_ep_set_maxpacket_limit(&ep
->ep
, ~0);
312 ep
->ep
.ops
= &net2280_ep_ops
;
314 /* disable the dma, irqs, endpoint... */
316 writel(0, &ep
->dma
->dmactl
);
317 writel(BIT(DMA_SCATTER_GATHER_DONE_INTERRUPT
) |
318 BIT(DMA_TRANSACTION_DONE_INTERRUPT
) |
322 tmp
= readl(®s
->pciirqenb0
);
323 tmp
&= ~BIT(ep
->num
);
324 writel(tmp
, ®s
->pciirqenb0
);
326 tmp
= readl(®s
->pciirqenb1
);
327 tmp
&= ~BIT((8 + ep
->num
)); /* completion */
328 writel(tmp
, ®s
->pciirqenb1
);
330 writel(0, &ep
->regs
->ep_irqenb
);
332 /* init to our chosen defaults, notably so that we NAK OUT
333 * packets until the driver queues a read (+note erratum 0112)
335 if (!ep
->is_in
|| (ep
->dev
->quirks
& PLX_2280
)) {
336 tmp
= BIT(SET_NAK_OUT_PACKETS_MODE
) |
337 BIT(SET_NAK_OUT_PACKETS
) |
338 BIT(CLEAR_EP_HIDE_STATUS_PHASE
) |
339 BIT(CLEAR_INTERRUPT_MODE
);
342 tmp
= BIT(CLEAR_NAK_OUT_PACKETS_MODE
) |
343 BIT(CLEAR_NAK_OUT_PACKETS
) |
344 BIT(CLEAR_EP_HIDE_STATUS_PHASE
) |
345 BIT(CLEAR_INTERRUPT_MODE
);
349 tmp
|= BIT(CLEAR_ENDPOINT_TOGGLE
) |
350 BIT(CLEAR_ENDPOINT_HALT
);
352 writel(tmp
, &ep
->regs
->ep_rsp
);
354 /* scrub most status bits, and flush any fifo state */
355 if (ep
->dev
->quirks
& PLX_2280
)
356 tmp
= BIT(FIFO_OVERFLOW
) |
361 writel(tmp
| BIT(TIMEOUT
) |
362 BIT(USB_STALL_SENT
) |
363 BIT(USB_IN_NAK_SENT
) |
364 BIT(USB_IN_ACK_RCVD
) |
365 BIT(USB_OUT_PING_NAK_SENT
) |
366 BIT(USB_OUT_ACK_SENT
) |
368 BIT(SHORT_PACKET_OUT_DONE_INTERRUPT
) |
369 BIT(SHORT_PACKET_TRANSFERRED_INTERRUPT
) |
370 BIT(DATA_PACKET_RECEIVED_INTERRUPT
) |
371 BIT(DATA_PACKET_TRANSMITTED_INTERRUPT
) |
372 BIT(DATA_OUT_PING_TOKEN_INTERRUPT
) |
373 BIT(DATA_IN_TOKEN_INTERRUPT
),
376 /* fifo size is handled separately */
379 static void ep_reset_338x(struct net2280_regs __iomem
*regs
,
380 struct net2280_ep
*ep
)
385 INIT_LIST_HEAD(&ep
->queue
);
387 usb_ep_set_maxpacket_limit(&ep
->ep
, ~0);
388 ep
->ep
.ops
= &net2280_ep_ops
;
390 /* disable the dma, irqs, endpoint... */
392 writel(0, &ep
->dma
->dmactl
);
393 writel(BIT(DMA_ABORT_DONE_INTERRUPT
) |
394 BIT(DMA_PAUSE_DONE_INTERRUPT
) |
395 BIT(DMA_SCATTER_GATHER_DONE_INTERRUPT
) |
396 BIT(DMA_TRANSACTION_DONE_INTERRUPT
),
397 /* | BIT(DMA_ABORT), */
400 dmastat
= readl(&ep
->dma
->dmastat
);
401 if (dmastat
== 0x5002) {
402 ep_warn(ep
->dev
, "The dmastat return = %x!!\n",
404 writel(0x5a, &ep
->dma
->dmastat
);
407 tmp
= readl(®s
->pciirqenb0
);
408 tmp
&= ~BIT(ep_bit
[ep
->num
]);
409 writel(tmp
, ®s
->pciirqenb0
);
412 tmp
= readl(®s
->pciirqenb1
);
413 tmp
&= ~BIT((8 + ep
->num
)); /* completion */
414 writel(tmp
, ®s
->pciirqenb1
);
417 writel(0, &ep
->regs
->ep_irqenb
);
419 writel(BIT(SHORT_PACKET_OUT_DONE_INTERRUPT
) |
420 BIT(SHORT_PACKET_TRANSFERRED_INTERRUPT
) |
422 BIT(DATA_PACKET_RECEIVED_INTERRUPT
) |
423 BIT(DATA_PACKET_TRANSMITTED_INTERRUPT
) |
424 BIT(DATA_OUT_PING_TOKEN_INTERRUPT
) |
425 BIT(DATA_IN_TOKEN_INTERRUPT
), &ep
->regs
->ep_stat
);
428 static void nuke(struct net2280_ep
*);
430 static int net2280_disable(struct usb_ep
*_ep
)
432 struct net2280_ep
*ep
;
435 ep
= container_of(_ep
, struct net2280_ep
, ep
);
436 if (!_ep
|| !ep
->desc
|| _ep
->name
== ep0name
)
439 spin_lock_irqsave(&ep
->dev
->lock
, flags
);
442 if (ep
->dev
->quirks
& PLX_SUPERSPEED
)
443 ep_reset_338x(ep
->dev
->regs
, ep
);
445 ep_reset_228x(ep
->dev
->regs
, ep
);
447 ep_vdbg(ep
->dev
, "disabled %s %s\n",
448 ep
->dma
? "dma" : "pio", _ep
->name
);
450 /* synch memory views with the device */
451 (void)readl(&ep
->cfg
->ep_cfg
);
453 if (!ep
->dma
&& ep
->num
>= 1 && ep
->num
<= 4)
454 ep
->dma
= &ep
->dev
->dma
[ep
->num
- 1];
456 spin_unlock_irqrestore(&ep
->dev
->lock
, flags
);
460 /*-------------------------------------------------------------------------*/
462 static struct usb_request
463 *net2280_alloc_request(struct usb_ep
*_ep
, gfp_t gfp_flags
)
465 struct net2280_ep
*ep
;
466 struct net2280_request
*req
;
470 ep
= container_of(_ep
, struct net2280_ep
, ep
);
472 req
= kzalloc(sizeof(*req
), gfp_flags
);
476 INIT_LIST_HEAD(&req
->queue
);
478 /* this dma descriptor may be swapped with the previous dummy */
480 struct net2280_dma
*td
;
482 td
= pci_pool_alloc(ep
->dev
->requests
, gfp_flags
,
488 td
->dmacount
= 0; /* not VALID */
489 td
->dmadesc
= td
->dmaaddr
;
495 static void net2280_free_request(struct usb_ep
*_ep
, struct usb_request
*_req
)
497 struct net2280_ep
*ep
;
498 struct net2280_request
*req
;
500 ep
= container_of(_ep
, struct net2280_ep
, ep
);
504 req
= container_of(_req
, struct net2280_request
, req
);
505 WARN_ON(!list_empty(&req
->queue
));
507 pci_pool_free(ep
->dev
->requests
, req
->td
, req
->td_dma
);
511 /*-------------------------------------------------------------------------*/
513 /* load a packet into the fifo we use for usb IN transfers.
514 * works for all endpoints.
516 * NOTE: pio with ep-a..ep-d could stuff multiple packets into the fifo
517 * at a time, but this code is simpler because it knows it only writes
518 * one packet. ep-a..ep-d should use dma instead.
520 static void write_fifo(struct net2280_ep
*ep
, struct usb_request
*req
)
522 struct net2280_ep_regs __iomem
*regs
= ep
->regs
;
525 unsigned count
, total
;
527 /* INVARIANT: fifo is currently empty. (testable) */
530 buf
= req
->buf
+ req
->actual
;
532 total
= req
->length
- req
->actual
;
538 /* write just one packet at a time */
539 count
= ep
->ep
.maxpacket
;
540 if (count
> total
) /* min() cannot be used on a bitfield */
543 ep_vdbg(ep
->dev
, "write %s fifo (IN) %d bytes%s req %p\n",
545 (count
!= ep
->ep
.maxpacket
) ? " (short)" : "",
548 /* NOTE be careful if you try to align these. fifo lines
549 * should normally be full (4 bytes) and successive partial
550 * lines are ok only in certain cases.
552 tmp
= get_unaligned((u32
*)buf
);
554 writel(tmp
, ®s
->ep_data
);
559 /* last fifo entry is "short" unless we wrote a full packet.
560 * also explicitly validate last word in (periodic) transfers
561 * when maxpacket is not a multiple of 4 bytes.
563 if (count
|| total
< ep
->ep
.maxpacket
) {
564 tmp
= count
? get_unaligned((u32
*)buf
) : count
;
566 set_fifo_bytecount(ep
, count
& 0x03);
567 writel(tmp
, ®s
->ep_data
);
570 /* pci writes may still be posted */
573 /* work around erratum 0106: PCI and USB race over the OUT fifo.
574 * caller guarantees chiprev 0100, out endpoint is NAKing, and
575 * there's no real data in the fifo.
577 * NOTE: also used in cases where that erratum doesn't apply:
578 * where the host wrote "too much" data to us.
580 static void out_flush(struct net2280_ep
*ep
)
585 statp
= &ep
->regs
->ep_stat
;
588 if (tmp
& BIT(NAK_OUT_PACKETS
)) {
589 ep_dbg(ep
->dev
, "%s %s %08x !NAK\n",
590 ep
->ep
.name
, __func__
, tmp
);
591 writel(BIT(SET_NAK_OUT_PACKETS
), &ep
->regs
->ep_rsp
);
594 writel(BIT(DATA_OUT_PING_TOKEN_INTERRUPT
) |
595 BIT(DATA_PACKET_RECEIVED_INTERRUPT
),
597 writel(BIT(FIFO_FLUSH
), statp
);
598 /* Make sure that stap is written */
601 if (tmp
& BIT(DATA_OUT_PING_TOKEN_INTERRUPT
) &&
602 /* high speed did bulk NYET; fifo isn't filling */
603 ep
->dev
->gadget
.speed
== USB_SPEED_FULL
) {
606 usec
= 50; /* 64 byte bulk/interrupt */
607 handshake(statp
, BIT(USB_OUT_PING_NAK_SENT
),
608 BIT(USB_OUT_PING_NAK_SENT
), usec
);
609 /* NAK done; now CLEAR_NAK_OUT_PACKETS is safe */
613 /* unload packet(s) from the fifo we use for usb OUT transfers.
614 * returns true iff the request completed, because of short packet
615 * or the request buffer having filled with full packets.
617 * for ep-a..ep-d this will read multiple packets out when they
618 * have been accepted.
620 static int read_fifo(struct net2280_ep
*ep
, struct net2280_request
*req
)
622 struct net2280_ep_regs __iomem
*regs
= ep
->regs
;
623 u8
*buf
= req
->req
.buf
+ req
->req
.actual
;
624 unsigned count
, tmp
, is_short
;
625 unsigned cleanup
= 0, prevent
= 0;
627 /* erratum 0106 ... packets coming in during fifo reads might
628 * be incompletely rejected. not all cases have workarounds.
630 if (ep
->dev
->chiprev
== 0x0100 &&
631 ep
->dev
->gadget
.speed
== USB_SPEED_FULL
) {
633 tmp
= readl(&ep
->regs
->ep_stat
);
634 if ((tmp
& BIT(NAK_OUT_PACKETS
)))
636 else if ((tmp
& BIT(FIFO_FULL
))) {
637 start_out_naking(ep
);
640 /* else: hope we don't see the problem */
643 /* never overflow the rx buffer. the fifo reads packets until
644 * it sees a short one; we might not be ready for them all.
647 count
= readl(®s
->ep_avail
);
648 if (unlikely(count
== 0)) {
650 tmp
= readl(&ep
->regs
->ep_stat
);
651 count
= readl(®s
->ep_avail
);
652 /* handled that data already? */
653 if (count
== 0 && (tmp
& BIT(NAK_OUT_PACKETS
)) == 0)
657 tmp
= req
->req
.length
- req
->req
.actual
;
659 /* as with DMA, data overflow gets flushed */
660 if ((tmp
% ep
->ep
.maxpacket
) != 0) {
662 "%s out fifo %d bytes, expected %d\n",
663 ep
->ep
.name
, count
, tmp
);
664 req
->req
.status
= -EOVERFLOW
;
666 /* NAK_OUT_PACKETS will be set, so flushing is safe;
667 * the next read will start with the next packet
669 } /* else it's a ZLP, no worries */
672 req
->req
.actual
+= count
;
674 is_short
= (count
== 0) || ((count
% ep
->ep
.maxpacket
) != 0);
676 ep_vdbg(ep
->dev
, "read %s fifo (OUT) %d bytes%s%s%s req %p %d/%d\n",
677 ep
->ep
.name
, count
, is_short
? " (short)" : "",
678 cleanup
? " flush" : "", prevent
? " nak" : "",
679 req
, req
->req
.actual
, req
->req
.length
);
682 tmp
= readl(®s
->ep_data
);
684 put_unaligned(tmp
, (u32
*)buf
);
689 tmp
= readl(®s
->ep_data
);
690 /* LE conversion is implicit here: */
699 writel(BIT(CLEAR_NAK_OUT_PACKETS
), &ep
->regs
->ep_rsp
);
700 (void) readl(&ep
->regs
->ep_rsp
);
703 return is_short
|| ((req
->req
.actual
== req
->req
.length
) &&
707 /* fill out dma descriptor to match a given request */
708 static void fill_dma_desc(struct net2280_ep
*ep
,
709 struct net2280_request
*req
, int valid
)
711 struct net2280_dma
*td
= req
->td
;
712 u32 dmacount
= req
->req
.length
;
714 /* don't let DMA continue after a short OUT packet,
715 * so overruns can't affect the next transfer.
716 * in case of overruns on max-size packets, we can't
717 * stop the fifo from filling but we can flush it.
720 dmacount
|= BIT(DMA_DIRECTION
);
721 if ((!ep
->is_in
&& (dmacount
% ep
->ep
.maxpacket
) != 0) ||
722 !(ep
->dev
->quirks
& PLX_2280
))
723 dmacount
|= BIT(END_OF_CHAIN
);
727 dmacount
|= BIT(VALID_BIT
);
728 dmacount
|= BIT(DMA_DONE_INTERRUPT_ENABLE
);
730 /* td->dmadesc = previously set by caller */
731 td
->dmaaddr
= cpu_to_le32 (req
->req
.dma
);
733 /* 2280 may be polling VALID_BIT through ep->dma->dmadesc */
735 td
->dmacount
= cpu_to_le32(dmacount
);
738 static const u32 dmactl_default
=
739 BIT(DMA_SCATTER_GATHER_DONE_INTERRUPT
) |
740 BIT(DMA_CLEAR_COUNT_ENABLE
) |
741 /* erratum 0116 workaround part 1 (use POLLING) */
742 (POLL_100_USEC
<< DESCRIPTOR_POLLING_RATE
) |
743 BIT(DMA_VALID_BIT_POLLING_ENABLE
) |
744 BIT(DMA_VALID_BIT_ENABLE
) |
745 BIT(DMA_SCATTER_GATHER_ENABLE
) |
746 /* erratum 0116 workaround part 2 (no AUTOSTART) */
749 static inline void spin_stop_dma(struct net2280_dma_regs __iomem
*dma
)
751 handshake(&dma
->dmactl
, BIT(DMA_ENABLE
), 0, 50);
754 static inline void stop_dma(struct net2280_dma_regs __iomem
*dma
)
756 writel(readl(&dma
->dmactl
) & ~BIT(DMA_ENABLE
), &dma
->dmactl
);
760 static void start_queue(struct net2280_ep
*ep
, u32 dmactl
, u32 td_dma
)
762 struct net2280_dma_regs __iomem
*dma
= ep
->dma
;
763 unsigned int tmp
= BIT(VALID_BIT
) | (ep
->is_in
<< DMA_DIRECTION
);
765 if (!(ep
->dev
->quirks
& PLX_2280
))
766 tmp
|= BIT(END_OF_CHAIN
);
768 writel(tmp
, &dma
->dmacount
);
769 writel(readl(&dma
->dmastat
), &dma
->dmastat
);
771 writel(td_dma
, &dma
->dmadesc
);
772 if (ep
->dev
->quirks
& PLX_SUPERSPEED
)
773 dmactl
|= BIT(DMA_REQUEST_OUTSTANDING
);
774 writel(dmactl
, &dma
->dmactl
);
776 /* erratum 0116 workaround part 3: pci arbiter away from net2280 */
777 (void) readl(&ep
->dev
->pci
->pcimstctl
);
779 writel(BIT(DMA_START
), &dma
->dmastat
);
785 static void start_dma(struct net2280_ep
*ep
, struct net2280_request
*req
)
788 struct net2280_dma_regs __iomem
*dma
= ep
->dma
;
790 /* FIXME can't use DMA for ZLPs */
792 /* on this path we "know" there's no dma active (yet) */
793 WARN_ON(readl(&dma
->dmactl
) & BIT(DMA_ENABLE
));
794 writel(0, &ep
->dma
->dmactl
);
796 /* previous OUT packet might have been short */
797 if (!ep
->is_in
&& (readl(&ep
->regs
->ep_stat
) &
798 BIT(NAK_OUT_PACKETS
))) {
799 writel(BIT(SHORT_PACKET_TRANSFERRED_INTERRUPT
),
802 tmp
= readl(&ep
->regs
->ep_avail
);
804 writel(readl(&dma
->dmastat
), &dma
->dmastat
);
806 /* transfer all/some fifo data */
807 writel(req
->req
.dma
, &dma
->dmaaddr
);
808 tmp
= min(tmp
, req
->req
.length
);
810 /* dma irq, faking scatterlist status */
811 req
->td
->dmacount
= cpu_to_le32(req
->req
.length
- tmp
);
812 writel(BIT(DMA_DONE_INTERRUPT_ENABLE
) | tmp
,
814 req
->td
->dmadesc
= 0;
817 writel(BIT(DMA_ENABLE
), &dma
->dmactl
);
818 writel(BIT(DMA_START
), &dma
->dmastat
);
823 tmp
= dmactl_default
;
825 /* force packet boundaries between dma requests, but prevent the
826 * controller from automagically writing a last "short" packet
827 * (zero length) unless the driver explicitly said to do that.
830 if (likely((req
->req
.length
% ep
->ep
.maxpacket
) ||
832 tmp
|= BIT(DMA_FIFO_VALIDATE
);
833 ep
->in_fifo_validate
= 1;
835 ep
->in_fifo_validate
= 0;
838 /* init req->td, pointing to the current dummy */
839 req
->td
->dmadesc
= cpu_to_le32 (ep
->td_dma
);
840 fill_dma_desc(ep
, req
, 1);
842 req
->td
->dmacount
|= cpu_to_le32(BIT(END_OF_CHAIN
));
844 start_queue(ep
, tmp
, req
->td_dma
);
848 queue_dma(struct net2280_ep
*ep
, struct net2280_request
*req
, int valid
)
850 struct net2280_dma
*end
;
853 /* swap new dummy for old, link; fill and maybe activate */
859 ep
->td_dma
= req
->td_dma
;
862 end
->dmadesc
= cpu_to_le32 (ep
->td_dma
);
864 fill_dma_desc(ep
, req
, valid
);
868 done(struct net2280_ep
*ep
, struct net2280_request
*req
, int status
)
871 unsigned stopped
= ep
->stopped
;
873 list_del_init(&req
->queue
);
875 if (req
->req
.status
== -EINPROGRESS
)
876 req
->req
.status
= status
;
878 status
= req
->req
.status
;
882 usb_gadget_unmap_request(&dev
->gadget
, &req
->req
, ep
->is_in
);
884 if (status
&& status
!= -ESHUTDOWN
)
885 ep_vdbg(dev
, "complete %s req %p stat %d len %u/%u\n",
886 ep
->ep
.name
, &req
->req
, status
,
887 req
->req
.actual
, req
->req
.length
);
889 /* don't modify queue heads during completion callback */
891 spin_unlock(&dev
->lock
);
892 usb_gadget_giveback_request(&ep
->ep
, &req
->req
);
893 spin_lock(&dev
->lock
);
894 ep
->stopped
= stopped
;
897 /*-------------------------------------------------------------------------*/
900 net2280_queue(struct usb_ep
*_ep
, struct usb_request
*_req
, gfp_t gfp_flags
)
902 struct net2280_request
*req
;
903 struct net2280_ep
*ep
;
907 /* we always require a cpu-view buffer, so that we can
908 * always use pio (as fallback or whatever).
910 req
= container_of(_req
, struct net2280_request
, req
);
911 if (!_req
|| !_req
->complete
|| !_req
->buf
||
912 !list_empty(&req
->queue
))
914 if (_req
->length
> (~0 & DMA_BYTE_COUNT_MASK
))
916 ep
= container_of(_ep
, struct net2280_ep
, ep
);
917 if (!_ep
|| (!ep
->desc
&& ep
->num
!= 0))
920 if (!dev
->driver
|| dev
->gadget
.speed
== USB_SPEED_UNKNOWN
)
923 /* FIXME implement PIO fallback for ZLPs with DMA */
924 if (ep
->dma
&& _req
->length
== 0)
927 /* set up dma mapping in case the caller didn't */
931 ret
= usb_gadget_map_request(&dev
->gadget
, _req
,
937 ep_vdbg(dev
, "%s queue req %p, len %d buf %p\n",
938 _ep
->name
, _req
, _req
->length
, _req
->buf
);
940 spin_lock_irqsave(&dev
->lock
, flags
);
942 _req
->status
= -EINPROGRESS
;
945 /* kickstart this i/o queue? */
946 if (list_empty(&ep
->queue
) && !ep
->stopped
&&
947 !((dev
->quirks
& PLX_SUPERSPEED
) && ep
->dma
&&
948 (readl(&ep
->regs
->ep_rsp
) & BIT(CLEAR_ENDPOINT_HALT
)))) {
950 /* use DMA if the endpoint supports it, else pio */
954 /* maybe there's no control data, just status ack */
955 if (ep
->num
== 0 && _req
->length
== 0) {
958 ep_vdbg(dev
, "%s status ack\n", ep
->ep
.name
);
962 /* PIO ... stuff the fifo, or unblock it. */
964 write_fifo(ep
, _req
);
965 else if (list_empty(&ep
->queue
)) {
968 /* OUT FIFO might have packet(s) buffered */
969 s
= readl(&ep
->regs
->ep_stat
);
970 if ((s
& BIT(FIFO_EMPTY
)) == 0) {
971 /* note: _req->short_not_ok is
972 * ignored here since PIO _always_
973 * stops queue advance here, and
974 * _req->status doesn't change for
975 * short reads (only _req->actual)
977 if (read_fifo(ep
, req
) &&
983 } else if (read_fifo(ep
, req
) &&
988 s
= readl(&ep
->regs
->ep_stat
);
991 /* don't NAK, let the fifo fill */
992 if (req
&& (s
& BIT(NAK_OUT_PACKETS
)))
993 writel(BIT(CLEAR_NAK_OUT_PACKETS
),
998 } else if (ep
->dma
) {
1004 /* preventing magic zlps is per-engine state, not
1005 * per-transfer; irq logic must recover hiccups.
1007 expect
= likely(req
->req
.zero
||
1008 (req
->req
.length
% ep
->ep
.maxpacket
));
1009 if (expect
!= ep
->in_fifo_validate
)
1012 queue_dma(ep
, req
, valid
);
1014 } /* else the irq handler advances the queue. */
1018 list_add_tail(&req
->queue
, &ep
->queue
);
1020 spin_unlock_irqrestore(&dev
->lock
, flags
);
1022 /* pci writes may still be posted */
1027 dma_done(struct net2280_ep
*ep
, struct net2280_request
*req
, u32 dmacount
,
1030 req
->req
.actual
= req
->req
.length
- (DMA_BYTE_COUNT_MASK
& dmacount
);
1031 done(ep
, req
, status
);
1034 static void scan_dma_completions(struct net2280_ep
*ep
)
1036 /* only look at descriptors that were "naturally" retired,
1037 * so fifo and list head state won't matter
1039 while (!list_empty(&ep
->queue
)) {
1040 struct net2280_request
*req
;
1043 req
= list_entry(ep
->queue
.next
,
1044 struct net2280_request
, queue
);
1048 tmp
= le32_to_cpup(&req
->td
->dmacount
);
1049 if ((tmp
& BIT(VALID_BIT
)) != 0)
1052 /* SHORT_PACKET_TRANSFERRED_INTERRUPT handles "usb-short"
1053 * cases where DMA must be aborted; this code handles
1054 * all non-abort DMA completions.
1056 if (unlikely(req
->td
->dmadesc
== 0)) {
1058 tmp
= readl(&ep
->dma
->dmacount
);
1059 if (tmp
& DMA_BYTE_COUNT_MASK
)
1061 /* single transfer mode */
1062 dma_done(ep
, req
, tmp
, 0);
1064 } else if (!ep
->is_in
&&
1065 (req
->req
.length
% ep
->ep
.maxpacket
) &&
1066 !(ep
->dev
->quirks
& PLX_SUPERSPEED
)) {
1068 tmp
= readl(&ep
->regs
->ep_stat
);
1069 /* AVOID TROUBLE HERE by not issuing short reads from
1070 * your gadget driver. That helps avoids errata 0121,
1071 * 0122, and 0124; not all cases trigger the warning.
1073 if ((tmp
& BIT(NAK_OUT_PACKETS
)) == 0) {
1074 ep_warn(ep
->dev
, "%s lost packet sync!\n",
1076 req
->req
.status
= -EOVERFLOW
;
1078 tmp
= readl(&ep
->regs
->ep_avail
);
1080 /* fifo gets flushed later */
1081 ep
->out_overflow
= 1;
1083 "%s dma, discard %d len %d\n",
1086 req
->req
.status
= -EOVERFLOW
;
1090 dma_done(ep
, req
, tmp
, 0);
1094 static void restart_dma(struct net2280_ep
*ep
)
1096 struct net2280_request
*req
;
1100 req
= list_entry(ep
->queue
.next
, struct net2280_request
, queue
);
1105 static void abort_dma(struct net2280_ep
*ep
)
1107 /* abort the current transfer */
1108 if (likely(!list_empty(&ep
->queue
))) {
1109 /* FIXME work around errata 0121, 0122, 0124 */
1110 writel(BIT(DMA_ABORT
), &ep
->dma
->dmastat
);
1111 spin_stop_dma(ep
->dma
);
1114 scan_dma_completions(ep
);
1117 /* dequeue ALL requests */
1118 static void nuke(struct net2280_ep
*ep
)
1120 struct net2280_request
*req
;
1122 /* called with spinlock held */
1126 while (!list_empty(&ep
->queue
)) {
1127 req
= list_entry(ep
->queue
.next
,
1128 struct net2280_request
,
1130 done(ep
, req
, -ESHUTDOWN
);
1134 /* dequeue JUST ONE request */
1135 static int net2280_dequeue(struct usb_ep
*_ep
, struct usb_request
*_req
)
1137 struct net2280_ep
*ep
;
1138 struct net2280_request
*req
;
1139 unsigned long flags
;
1143 ep
= container_of(_ep
, struct net2280_ep
, ep
);
1144 if (!_ep
|| (!ep
->desc
&& ep
->num
!= 0) || !_req
)
1147 spin_lock_irqsave(&ep
->dev
->lock
, flags
);
1148 stopped
= ep
->stopped
;
1150 /* quiesce dma while we patch the queue */
1154 dmactl
= readl(&ep
->dma
->dmactl
);
1155 /* WARNING erratum 0127 may kick in ... */
1157 scan_dma_completions(ep
);
1160 /* make sure it's still queued on this endpoint */
1161 list_for_each_entry(req
, &ep
->queue
, queue
) {
1162 if (&req
->req
== _req
)
1165 if (&req
->req
!= _req
) {
1166 spin_unlock_irqrestore(&ep
->dev
->lock
, flags
);
1170 /* queue head may be partially complete. */
1171 if (ep
->queue
.next
== &req
->queue
) {
1173 ep_dbg(ep
->dev
, "unlink (%s) dma\n", _ep
->name
);
1174 _req
->status
= -ECONNRESET
;
1176 if (likely(ep
->queue
.next
== &req
->queue
)) {
1177 /* NOTE: misreports single-transfer mode*/
1178 req
->td
->dmacount
= 0; /* invalidate */
1180 readl(&ep
->dma
->dmacount
),
1184 ep_dbg(ep
->dev
, "unlink (%s) pio\n", _ep
->name
);
1185 done(ep
, req
, -ECONNRESET
);
1191 done(ep
, req
, -ECONNRESET
);
1192 ep
->stopped
= stopped
;
1195 /* turn off dma on inactive queues */
1196 if (list_empty(&ep
->queue
))
1198 else if (!ep
->stopped
) {
1199 /* resume current request, or start new one */
1201 writel(dmactl
, &ep
->dma
->dmactl
);
1203 start_dma(ep
, list_entry(ep
->queue
.next
,
1204 struct net2280_request
, queue
));
1208 spin_unlock_irqrestore(&ep
->dev
->lock
, flags
);
1212 /*-------------------------------------------------------------------------*/
1214 static int net2280_fifo_status(struct usb_ep
*_ep
);
1217 net2280_set_halt_and_wedge(struct usb_ep
*_ep
, int value
, int wedged
)
1219 struct net2280_ep
*ep
;
1220 unsigned long flags
;
1223 ep
= container_of(_ep
, struct net2280_ep
, ep
);
1224 if (!_ep
|| (!ep
->desc
&& ep
->num
!= 0))
1226 if (!ep
->dev
->driver
|| ep
->dev
->gadget
.speed
== USB_SPEED_UNKNOWN
)
1228 if (ep
->desc
/* not ep0 */ && (ep
->desc
->bmAttributes
& 0x03)
1229 == USB_ENDPOINT_XFER_ISOC
)
1232 spin_lock_irqsave(&ep
->dev
->lock
, flags
);
1233 if (!list_empty(&ep
->queue
))
1235 else if (ep
->is_in
&& value
&& net2280_fifo_status(_ep
) != 0)
1238 ep_vdbg(ep
->dev
, "%s %s %s\n", _ep
->name
,
1239 value
? "set" : "clear",
1240 wedged
? "wedge" : "halt");
1241 /* set/clear, then synch memory views with the device */
1244 ep
->dev
->protocol_stall
= 1;
1251 if (ep
->dev
->quirks
& PLX_SUPERSPEED
&&
1252 !list_empty(&ep
->queue
) && ep
->td_dma
)
1256 (void) readl(&ep
->regs
->ep_rsp
);
1258 spin_unlock_irqrestore(&ep
->dev
->lock
, flags
);
1263 static int net2280_set_halt(struct usb_ep
*_ep
, int value
)
1265 return net2280_set_halt_and_wedge(_ep
, value
, 0);
1268 static int net2280_set_wedge(struct usb_ep
*_ep
)
1270 if (!_ep
|| _ep
->name
== ep0name
)
1272 return net2280_set_halt_and_wedge(_ep
, 1, 1);
1275 static int net2280_fifo_status(struct usb_ep
*_ep
)
1277 struct net2280_ep
*ep
;
1280 ep
= container_of(_ep
, struct net2280_ep
, ep
);
1281 if (!_ep
|| (!ep
->desc
&& ep
->num
!= 0))
1283 if (!ep
->dev
->driver
|| ep
->dev
->gadget
.speed
== USB_SPEED_UNKNOWN
)
1286 avail
= readl(&ep
->regs
->ep_avail
) & (BIT(12) - 1);
1287 if (avail
> ep
->fifo_size
)
1290 avail
= ep
->fifo_size
- avail
;
1294 static void net2280_fifo_flush(struct usb_ep
*_ep
)
1296 struct net2280_ep
*ep
;
1298 ep
= container_of(_ep
, struct net2280_ep
, ep
);
1299 if (!_ep
|| (!ep
->desc
&& ep
->num
!= 0))
1301 if (!ep
->dev
->driver
|| ep
->dev
->gadget
.speed
== USB_SPEED_UNKNOWN
)
1304 writel(BIT(FIFO_FLUSH
), &ep
->regs
->ep_stat
);
1305 (void) readl(&ep
->regs
->ep_rsp
);
1308 static const struct usb_ep_ops net2280_ep_ops
= {
1309 .enable
= net2280_enable
,
1310 .disable
= net2280_disable
,
1312 .alloc_request
= net2280_alloc_request
,
1313 .free_request
= net2280_free_request
,
1315 .queue
= net2280_queue
,
1316 .dequeue
= net2280_dequeue
,
1318 .set_halt
= net2280_set_halt
,
1319 .set_wedge
= net2280_set_wedge
,
1320 .fifo_status
= net2280_fifo_status
,
1321 .fifo_flush
= net2280_fifo_flush
,
1324 /*-------------------------------------------------------------------------*/
1326 static int net2280_get_frame(struct usb_gadget
*_gadget
)
1328 struct net2280
*dev
;
1329 unsigned long flags
;
1334 dev
= container_of(_gadget
, struct net2280
, gadget
);
1335 spin_lock_irqsave(&dev
->lock
, flags
);
1336 retval
= get_idx_reg(dev
->regs
, REG_FRAME
) & 0x03ff;
1337 spin_unlock_irqrestore(&dev
->lock
, flags
);
1341 static int net2280_wakeup(struct usb_gadget
*_gadget
)
1343 struct net2280
*dev
;
1345 unsigned long flags
;
1349 dev
= container_of(_gadget
, struct net2280
, gadget
);
1351 spin_lock_irqsave(&dev
->lock
, flags
);
1352 tmp
= readl(&dev
->usb
->usbctl
);
1353 if (tmp
& BIT(DEVICE_REMOTE_WAKEUP_ENABLE
))
1354 writel(BIT(GENERATE_RESUME
), &dev
->usb
->usbstat
);
1355 spin_unlock_irqrestore(&dev
->lock
, flags
);
1357 /* pci writes may still be posted */
1361 static int net2280_set_selfpowered(struct usb_gadget
*_gadget
, int value
)
1363 struct net2280
*dev
;
1365 unsigned long flags
;
1369 dev
= container_of(_gadget
, struct net2280
, gadget
);
1371 spin_lock_irqsave(&dev
->lock
, flags
);
1372 tmp
= readl(&dev
->usb
->usbctl
);
1374 tmp
|= BIT(SELF_POWERED_STATUS
);
1375 _gadget
->is_selfpowered
= 1;
1377 tmp
&= ~BIT(SELF_POWERED_STATUS
);
1378 _gadget
->is_selfpowered
= 0;
1380 writel(tmp
, &dev
->usb
->usbctl
);
1381 spin_unlock_irqrestore(&dev
->lock
, flags
);
1386 static int net2280_pullup(struct usb_gadget
*_gadget
, int is_on
)
1388 struct net2280
*dev
;
1390 unsigned long flags
;
1394 dev
= container_of(_gadget
, struct net2280
, gadget
);
1396 spin_lock_irqsave(&dev
->lock
, flags
);
1397 tmp
= readl(&dev
->usb
->usbctl
);
1398 dev
->softconnect
= (is_on
!= 0);
1400 tmp
|= BIT(USB_DETECT_ENABLE
);
1402 tmp
&= ~BIT(USB_DETECT_ENABLE
);
1403 writel(tmp
, &dev
->usb
->usbctl
);
1404 spin_unlock_irqrestore(&dev
->lock
, flags
);
1409 static int net2280_start(struct usb_gadget
*_gadget
,
1410 struct usb_gadget_driver
*driver
);
1411 static int net2280_stop(struct usb_gadget
*_gadget
);
1413 static const struct usb_gadget_ops net2280_ops
= {
1414 .get_frame
= net2280_get_frame
,
1415 .wakeup
= net2280_wakeup
,
1416 .set_selfpowered
= net2280_set_selfpowered
,
1417 .pullup
= net2280_pullup
,
1418 .udc_start
= net2280_start
,
1419 .udc_stop
= net2280_stop
,
1422 /*-------------------------------------------------------------------------*/
1424 #ifdef CONFIG_USB_GADGET_DEBUG_FILES
1426 /* FIXME move these into procfs, and use seq_file.
1427 * Sysfs _still_ doesn't behave for arbitrarily sized files,
1428 * and also doesn't help products using this with 2.4 kernels.
1431 /* "function" sysfs attribute */
1432 static ssize_t
function_show(struct device
*_dev
, struct device_attribute
*attr
,
1435 struct net2280
*dev
= dev_get_drvdata(_dev
);
1437 if (!dev
->driver
|| !dev
->driver
->function
||
1438 strlen(dev
->driver
->function
) > PAGE_SIZE
)
1440 return scnprintf(buf
, PAGE_SIZE
, "%s\n", dev
->driver
->function
);
1442 static DEVICE_ATTR_RO(function
);
1444 static ssize_t
registers_show(struct device
*_dev
,
1445 struct device_attribute
*attr
, char *buf
)
1447 struct net2280
*dev
;
1450 unsigned long flags
;
1455 dev
= dev_get_drvdata(_dev
);
1458 spin_lock_irqsave(&dev
->lock
, flags
);
1461 s
= dev
->driver
->driver
.name
;
1465 /* Main Control Registers */
1466 t
= scnprintf(next
, size
, "%s version " DRIVER_VERSION
1467 ", chiprev %04x\n\n"
1468 "devinit %03x fifoctl %08x gadget '%s'\n"
1469 "pci irqenb0 %02x irqenb1 %08x "
1470 "irqstat0 %04x irqstat1 %08x\n",
1471 driver_name
, dev
->chiprev
,
1472 readl(&dev
->regs
->devinit
),
1473 readl(&dev
->regs
->fifoctl
),
1475 readl(&dev
->regs
->pciirqenb0
),
1476 readl(&dev
->regs
->pciirqenb1
),
1477 readl(&dev
->regs
->irqstat0
),
1478 readl(&dev
->regs
->irqstat1
));
1482 /* USB Control Registers */
1483 t1
= readl(&dev
->usb
->usbctl
);
1484 t2
= readl(&dev
->usb
->usbstat
);
1485 if (t1
& BIT(VBUS_PIN
)) {
1486 if (t2
& BIT(HIGH_SPEED
))
1488 else if (dev
->gadget
.speed
== USB_SPEED_UNKNOWN
)
1492 /* full speed bit (6) not working?? */
1495 t
= scnprintf(next
, size
,
1496 "stdrsp %08x usbctl %08x usbstat %08x "
1497 "addr 0x%02x (%s)\n",
1498 readl(&dev
->usb
->stdrsp
), t1
, t2
,
1499 readl(&dev
->usb
->ouraddr
), s
);
1503 /* PCI Master Control Registers */
1505 /* DMA Control Registers */
1507 /* Configurable EP Control Registers */
1508 for (i
= 0; i
< dev
->n_ep
; i
++) {
1509 struct net2280_ep
*ep
;
1515 t1
= readl(&ep
->cfg
->ep_cfg
);
1516 t2
= readl(&ep
->regs
->ep_rsp
) & 0xff;
1517 t
= scnprintf(next
, size
,
1518 "\n%s\tcfg %05x rsp (%02x) %s%s%s%s%s%s%s%s"
1520 ep
->ep
.name
, t1
, t2
,
1521 (t2
& BIT(CLEAR_NAK_OUT_PACKETS
))
1523 (t2
& BIT(CLEAR_EP_HIDE_STATUS_PHASE
))
1525 (t2
& BIT(CLEAR_EP_FORCE_CRC_ERROR
))
1527 (t2
& BIT(CLEAR_INTERRUPT_MODE
))
1528 ? "interrupt " : "",
1529 (t2
& BIT(CLEAR_CONTROL_STATUS_PHASE_HANDSHAKE
))
1531 (t2
& BIT(CLEAR_NAK_OUT_PACKETS_MODE
))
1533 (t2
& BIT(CLEAR_ENDPOINT_TOGGLE
))
1534 ? "DATA1 " : "DATA0 ",
1535 (t2
& BIT(CLEAR_ENDPOINT_HALT
))
1537 readl(&ep
->regs
->ep_irqenb
));
1541 t
= scnprintf(next
, size
,
1542 "\tstat %08x avail %04x "
1544 readl(&ep
->regs
->ep_stat
),
1545 readl(&ep
->regs
->ep_avail
),
1546 t1
& 0x0f, DIR_STRING(t1
),
1547 type_string(t1
>> 8),
1548 ep
->stopped
? "*" : "");
1555 t
= scnprintf(next
, size
,
1556 " dma\tctl %08x stat %08x count %08x\n"
1557 "\taddr %08x desc %08x\n",
1558 readl(&ep
->dma
->dmactl
),
1559 readl(&ep
->dma
->dmastat
),
1560 readl(&ep
->dma
->dmacount
),
1561 readl(&ep
->dma
->dmaaddr
),
1562 readl(&ep
->dma
->dmadesc
));
1568 /* Indexed Registers (none yet) */
1571 t
= scnprintf(next
, size
, "\nirqs: ");
1574 for (i
= 0; i
< dev
->n_ep
; i
++) {
1575 struct net2280_ep
*ep
;
1580 t
= scnprintf(next
, size
, " %s/%lu", ep
->ep
.name
, ep
->irqs
);
1585 t
= scnprintf(next
, size
, "\n");
1589 spin_unlock_irqrestore(&dev
->lock
, flags
);
1591 return PAGE_SIZE
- size
;
1593 static DEVICE_ATTR_RO(registers
);
1595 static ssize_t
queues_show(struct device
*_dev
, struct device_attribute
*attr
,
1598 struct net2280
*dev
;
1601 unsigned long flags
;
1604 dev
= dev_get_drvdata(_dev
);
1607 spin_lock_irqsave(&dev
->lock
, flags
);
1609 for (i
= 0; i
< dev
->n_ep
; i
++) {
1610 struct net2280_ep
*ep
= &dev
->ep
[i
];
1611 struct net2280_request
*req
;
1615 const struct usb_endpoint_descriptor
*d
;
1620 t
= d
->bEndpointAddress
;
1621 t
= scnprintf(next
, size
,
1622 "\n%s (ep%d%s-%s) max %04x %s fifo %d\n",
1623 ep
->ep
.name
, t
& USB_ENDPOINT_NUMBER_MASK
,
1624 (t
& USB_DIR_IN
) ? "in" : "out",
1625 type_string(d
->bmAttributes
),
1626 usb_endpoint_maxp(d
) & 0x1fff,
1627 ep
->dma
? "dma" : "pio", ep
->fifo_size
1629 } else /* ep0 should only have one transfer queued */
1630 t
= scnprintf(next
, size
, "ep0 max 64 pio %s\n",
1631 ep
->is_in
? "in" : "out");
1632 if (t
<= 0 || t
> size
)
1637 if (list_empty(&ep
->queue
)) {
1638 t
= scnprintf(next
, size
, "\t(nothing queued)\n");
1639 if (t
<= 0 || t
> size
)
1645 list_for_each_entry(req
, &ep
->queue
, queue
) {
1646 if (ep
->dma
&& req
->td_dma
== readl(&ep
->dma
->dmadesc
))
1647 t
= scnprintf(next
, size
,
1648 "\treq %p len %d/%d "
1649 "buf %p (dmacount %08x)\n",
1650 &req
->req
, req
->req
.actual
,
1651 req
->req
.length
, req
->req
.buf
,
1652 readl(&ep
->dma
->dmacount
));
1654 t
= scnprintf(next
, size
,
1655 "\treq %p len %d/%d buf %p\n",
1656 &req
->req
, req
->req
.actual
,
1657 req
->req
.length
, req
->req
.buf
);
1658 if (t
<= 0 || t
> size
)
1664 struct net2280_dma
*td
;
1667 t
= scnprintf(next
, size
, "\t td %08x "
1668 " count %08x buf %08x desc %08x\n",
1670 le32_to_cpu(td
->dmacount
),
1671 le32_to_cpu(td
->dmaaddr
),
1672 le32_to_cpu(td
->dmadesc
));
1673 if (t
<= 0 || t
> size
)
1682 spin_unlock_irqrestore(&dev
->lock
, flags
);
1683 return PAGE_SIZE
- size
;
1685 static DEVICE_ATTR_RO(queues
);
1690 #define device_create_file(a, b) (0)
1691 #define device_remove_file(a, b) do { } while (0)
1695 /*-------------------------------------------------------------------------*/
1697 /* another driver-specific mode might be a request type doing dma
1698 * to/from another device fifo instead of to/from memory.
1701 static void set_fifo_mode(struct net2280
*dev
, int mode
)
1703 /* keeping high bits preserves BAR2 */
1704 writel((0xffff << PCI_BASE2_RANGE
) | mode
, &dev
->regs
->fifoctl
);
1706 /* always ep-{a,b,e,f} ... maybe not ep-c or ep-d */
1707 INIT_LIST_HEAD(&dev
->gadget
.ep_list
);
1708 list_add_tail(&dev
->ep
[1].ep
.ep_list
, &dev
->gadget
.ep_list
);
1709 list_add_tail(&dev
->ep
[2].ep
.ep_list
, &dev
->gadget
.ep_list
);
1712 list_add_tail(&dev
->ep
[3].ep
.ep_list
, &dev
->gadget
.ep_list
);
1713 list_add_tail(&dev
->ep
[4].ep
.ep_list
, &dev
->gadget
.ep_list
);
1714 dev
->ep
[1].fifo_size
= dev
->ep
[2].fifo_size
= 1024;
1717 dev
->ep
[1].fifo_size
= dev
->ep
[2].fifo_size
= 2048;
1720 list_add_tail(&dev
->ep
[3].ep
.ep_list
, &dev
->gadget
.ep_list
);
1721 dev
->ep
[1].fifo_size
= 2048;
1722 dev
->ep
[2].fifo_size
= 1024;
1725 /* fifo sizes for ep0, ep-c, ep-d, ep-e, and ep-f never change */
1726 list_add_tail(&dev
->ep
[5].ep
.ep_list
, &dev
->gadget
.ep_list
);
1727 list_add_tail(&dev
->ep
[6].ep
.ep_list
, &dev
->gadget
.ep_list
);
1730 static void defect7374_disable_data_eps(struct net2280
*dev
)
1733 * For Defect 7374, disable data EPs (and more):
1734 * - This phase undoes the earlier phase of the Defect 7374 workaround,
1735 * returing ep regs back to normal.
1737 struct net2280_ep
*ep
;
1739 unsigned char ep_sel
;
1742 for (i
= 1; i
< 5; i
++) {
1744 writel(0, &ep
->cfg
->ep_cfg
);
1747 /* CSROUT, CSRIN, PCIOUT, PCIIN, STATIN, RCIN */
1748 for (i
= 0; i
< 6; i
++)
1749 writel(0, &dev
->dep
[i
].dep_cfg
);
1751 for (ep_sel
= 0; ep_sel
<= 21; ep_sel
++) {
1752 /* Select an endpoint for subsequent operations: */
1753 tmp_reg
= readl(&dev
->plregs
->pl_ep_ctrl
);
1754 writel(((tmp_reg
& ~0x1f) | ep_sel
), &dev
->plregs
->pl_ep_ctrl
);
1756 if (ep_sel
< 2 || (ep_sel
> 9 && ep_sel
< 14) ||
1757 ep_sel
== 18 || ep_sel
== 20)
1760 /* Change settings on some selected endpoints */
1761 tmp_reg
= readl(&dev
->plregs
->pl_ep_cfg_4
);
1762 tmp_reg
&= ~BIT(NON_CTRL_IN_TOLERATE_BAD_DIR
);
1763 writel(tmp_reg
, &dev
->plregs
->pl_ep_cfg_4
);
1764 tmp_reg
= readl(&dev
->plregs
->pl_ep_ctrl
);
1765 tmp_reg
|= BIT(EP_INITIALIZED
);
1766 writel(tmp_reg
, &dev
->plregs
->pl_ep_ctrl
);
1770 static void defect7374_enable_data_eps_zero(struct net2280
*dev
)
1772 u32 tmp
= 0, tmp_reg
;
1775 unsigned char ep_sel
;
1777 scratch
= get_idx_reg(dev
->regs
, SCRATCH
);
1779 WARN_ON((scratch
& (0xf << DEFECT7374_FSM_FIELD
))
1780 == DEFECT7374_FSM_SS_CONTROL_READ
);
1782 scratch
&= ~(0xf << DEFECT7374_FSM_FIELD
);
1784 ep_warn(dev
, "Operate Defect 7374 workaround soft this time");
1785 ep_warn(dev
, "It will operate on cold-reboot and SS connect");
1788 tmp
= ((0 << ENDPOINT_NUMBER
) | BIT(ENDPOINT_DIRECTION
) |
1789 (2 << OUT_ENDPOINT_TYPE
) | (2 << IN_ENDPOINT_TYPE
) |
1790 ((dev
->enhanced_mode
) ?
1791 BIT(OUT_ENDPOINT_ENABLE
) : BIT(ENDPOINT_ENABLE
)) |
1792 BIT(IN_ENDPOINT_ENABLE
));
1794 for (i
= 1; i
< 5; i
++)
1795 writel(tmp
, &dev
->ep
[i
].cfg
->ep_cfg
);
1797 /* CSRIN, PCIIN, STATIN, RCIN*/
1798 tmp
= ((0 << ENDPOINT_NUMBER
) | BIT(ENDPOINT_ENABLE
));
1799 writel(tmp
, &dev
->dep
[1].dep_cfg
);
1800 writel(tmp
, &dev
->dep
[3].dep_cfg
);
1801 writel(tmp
, &dev
->dep
[4].dep_cfg
);
1802 writel(tmp
, &dev
->dep
[5].dep_cfg
);
1804 /*Implemented for development and debug.
1805 * Can be refined/tuned later.*/
1806 for (ep_sel
= 0; ep_sel
<= 21; ep_sel
++) {
1807 /* Select an endpoint for subsequent operations: */
1808 tmp_reg
= readl(&dev
->plregs
->pl_ep_ctrl
);
1809 writel(((tmp_reg
& ~0x1f) | ep_sel
),
1810 &dev
->plregs
->pl_ep_ctrl
);
1814 (readl(&dev
->plregs
->pl_ep_ctrl
) |
1815 BIT(CLEAR_ACK_ERROR_CODE
) | 0);
1816 writel(tmp
, &dev
->plregs
->pl_ep_ctrl
);
1820 if (ep_sel
== 0 || (ep_sel
> 9 && ep_sel
< 14) ||
1821 ep_sel
== 18 || ep_sel
== 20)
1824 tmp
= (readl(&dev
->plregs
->pl_ep_cfg_4
) |
1825 BIT(NON_CTRL_IN_TOLERATE_BAD_DIR
) | 0);
1826 writel(tmp
, &dev
->plregs
->pl_ep_cfg_4
);
1828 tmp
= readl(&dev
->plregs
->pl_ep_ctrl
) &
1829 ~BIT(EP_INITIALIZED
);
1830 writel(tmp
, &dev
->plregs
->pl_ep_ctrl
);
1834 /* Set FSM to focus on the first Control Read:
1835 * - Tip: Connection speed is known upon the first
1837 scratch
|= DEFECT7374_FSM_WAITING_FOR_CONTROL_READ
;
1838 set_idx_reg(dev
->regs
, SCRATCH
, scratch
);
1842 /* keeping it simple:
1843 * - one bus driver, initted first;
1844 * - one function driver, initted second
1846 * most of the work to support multiple net2280 controllers would
1847 * be to associate this gadget driver (yes?) with all of them, or
1848 * perhaps to bind specific drivers to specific devices.
1851 static void usb_reset_228x(struct net2280
*dev
)
1855 dev
->gadget
.speed
= USB_SPEED_UNKNOWN
;
1856 (void) readl(&dev
->usb
->usbctl
);
1858 net2280_led_init(dev
);
1860 /* disable automatic responses, and irqs */
1861 writel(0, &dev
->usb
->stdrsp
);
1862 writel(0, &dev
->regs
->pciirqenb0
);
1863 writel(0, &dev
->regs
->pciirqenb1
);
1865 /* clear old dma and irq state */
1866 for (tmp
= 0; tmp
< 4; tmp
++) {
1867 struct net2280_ep
*ep
= &dev
->ep
[tmp
+ 1];
1872 writel(~0, &dev
->regs
->irqstat0
),
1873 writel(~(u32
)BIT(SUSPEND_REQUEST_INTERRUPT
), &dev
->regs
->irqstat1
),
1875 /* reset, and enable pci */
1876 tmp
= readl(&dev
->regs
->devinit
) |
1878 BIT(FIFO_SOFT_RESET
) |
1879 BIT(USB_SOFT_RESET
) |
1881 writel(tmp
, &dev
->regs
->devinit
);
1883 /* standard fifo and endpoint allocations */
1884 set_fifo_mode(dev
, (fifo_mode
<= 2) ? fifo_mode
: 0);
1887 static void usb_reset_338x(struct net2280
*dev
)
1891 dev
->gadget
.speed
= USB_SPEED_UNKNOWN
;
1892 (void)readl(&dev
->usb
->usbctl
);
1894 net2280_led_init(dev
);
1896 if (dev
->bug7734_patched
) {
1897 /* disable automatic responses, and irqs */
1898 writel(0, &dev
->usb
->stdrsp
);
1899 writel(0, &dev
->regs
->pciirqenb0
);
1900 writel(0, &dev
->regs
->pciirqenb1
);
1903 /* clear old dma and irq state */
1904 for (tmp
= 0; tmp
< 4; tmp
++) {
1905 struct net2280_ep
*ep
= &dev
->ep
[tmp
+ 1];
1911 writel(~0, &dev
->regs
->irqstat0
), writel(~0, &dev
->regs
->irqstat1
);
1913 if (dev
->bug7734_patched
) {
1914 /* reset, and enable pci */
1915 tmp
= readl(&dev
->regs
->devinit
) |
1917 BIT(FIFO_SOFT_RESET
) |
1918 BIT(USB_SOFT_RESET
) |
1921 writel(tmp
, &dev
->regs
->devinit
);
1924 /* always ep-{1,2,3,4} ... maybe not ep-3 or ep-4 */
1925 INIT_LIST_HEAD(&dev
->gadget
.ep_list
);
1927 for (tmp
= 1; tmp
< dev
->n_ep
; tmp
++)
1928 list_add_tail(&dev
->ep
[tmp
].ep
.ep_list
, &dev
->gadget
.ep_list
);
1932 static void usb_reset(struct net2280
*dev
)
1934 if (dev
->quirks
& PLX_LEGACY
)
1935 return usb_reset_228x(dev
);
1936 return usb_reset_338x(dev
);
1939 static void usb_reinit_228x(struct net2280
*dev
)
1943 /* basic endpoint init */
1944 for (tmp
= 0; tmp
< 7; tmp
++) {
1945 struct net2280_ep
*ep
= &dev
->ep
[tmp
];
1947 ep
->ep
.name
= ep_name
[tmp
];
1951 if (tmp
> 0 && tmp
<= 4) {
1952 ep
->fifo_size
= 1024;
1953 ep
->dma
= &dev
->dma
[tmp
- 1];
1956 ep
->regs
= &dev
->epregs
[tmp
];
1957 ep
->cfg
= &dev
->epregs
[tmp
];
1958 ep_reset_228x(dev
->regs
, ep
);
1960 usb_ep_set_maxpacket_limit(&dev
->ep
[0].ep
, 64);
1961 usb_ep_set_maxpacket_limit(&dev
->ep
[5].ep
, 64);
1962 usb_ep_set_maxpacket_limit(&dev
->ep
[6].ep
, 64);
1964 dev
->gadget
.ep0
= &dev
->ep
[0].ep
;
1965 dev
->ep
[0].stopped
= 0;
1966 INIT_LIST_HEAD(&dev
->gadget
.ep0
->ep_list
);
1968 /* we want to prevent lowlevel/insecure access from the USB host,
1969 * but erratum 0119 means this enable bit is ignored
1971 for (tmp
= 0; tmp
< 5; tmp
++)
1972 writel(EP_DONTUSE
, &dev
->dep
[tmp
].dep_cfg
);
1975 static void usb_reinit_338x(struct net2280
*dev
)
1979 static const u32 ne
[9] = { 0, 1, 2, 3, 4, 1, 2, 3, 4 };
1980 static const u32 ep_reg_addr
[9] = { 0x00, 0xC0, 0x00, 0xC0, 0x00,
1981 0x00, 0xC0, 0x00, 0xC0 };
1983 /* basic endpoint init */
1984 for (i
= 0; i
< dev
->n_ep
; i
++) {
1985 struct net2280_ep
*ep
= &dev
->ep
[i
];
1987 ep
->ep
.name
= dev
->enhanced_mode
? ep_name_adv
[i
] : ep_name
[i
];
1991 if (i
> 0 && i
<= 4)
1992 ep
->dma
= &dev
->dma
[i
- 1];
1994 if (dev
->enhanced_mode
) {
1995 ep
->cfg
= &dev
->epregs
[ne
[i
]];
1996 ep
->regs
= (struct net2280_ep_regs __iomem
*)
1997 (((void __iomem
*)&dev
->epregs
[ne
[i
]]) +
1999 ep
->fiforegs
= &dev
->fiforegs
[i
];
2001 ep
->cfg
= &dev
->epregs
[i
];
2002 ep
->regs
= &dev
->epregs
[i
];
2003 ep
->fiforegs
= &dev
->fiforegs
[i
];
2006 ep
->fifo_size
= (i
!= 0) ? 2048 : 512;
2008 ep_reset_338x(dev
->regs
, ep
);
2010 usb_ep_set_maxpacket_limit(&dev
->ep
[0].ep
, 512);
2012 dev
->gadget
.ep0
= &dev
->ep
[0].ep
;
2013 dev
->ep
[0].stopped
= 0;
2015 /* Link layer set up */
2016 if (dev
->bug7734_patched
) {
2017 tmp
= readl(&dev
->usb_ext
->usbctl2
) &
2018 ~(BIT(U1_ENABLE
) | BIT(U2_ENABLE
) | BIT(LTM_ENABLE
));
2019 writel(tmp
, &dev
->usb_ext
->usbctl2
);
2022 /* Hardware Defect and Workaround */
2023 val
= readl(&dev
->ll_lfps_regs
->ll_lfps_5
);
2024 val
&= ~(0xf << TIMER_LFPS_6US
);
2025 val
|= 0x5 << TIMER_LFPS_6US
;
2026 writel(val
, &dev
->ll_lfps_regs
->ll_lfps_5
);
2028 val
= readl(&dev
->ll_lfps_regs
->ll_lfps_6
);
2029 val
&= ~(0xffff << TIMER_LFPS_80US
);
2030 val
|= 0x0100 << TIMER_LFPS_80US
;
2031 writel(val
, &dev
->ll_lfps_regs
->ll_lfps_6
);
2034 * AA_AB Errata. Issue 4. Workaround for SuperSpeed USB
2035 * Hot Reset Exit Handshake may Fail in Specific Case using
2036 * Default Register Settings. Workaround for Enumeration test.
2038 val
= readl(&dev
->ll_tsn_regs
->ll_tsn_counters_2
);
2039 val
&= ~(0x1f << HOT_TX_NORESET_TS2
);
2040 val
|= 0x10 << HOT_TX_NORESET_TS2
;
2041 writel(val
, &dev
->ll_tsn_regs
->ll_tsn_counters_2
);
2043 val
= readl(&dev
->ll_tsn_regs
->ll_tsn_counters_3
);
2044 val
&= ~(0x1f << HOT_RX_RESET_TS2
);
2045 val
|= 0x3 << HOT_RX_RESET_TS2
;
2046 writel(val
, &dev
->ll_tsn_regs
->ll_tsn_counters_3
);
2049 * Set Recovery Idle to Recover bit:
2050 * - On SS connections, setting Recovery Idle to Recover Fmw improves
2051 * link robustness with various hosts and hubs.
2052 * - It is safe to set for all connection speeds; all chip revisions.
2053 * - R-M-W to leave other bits undisturbed.
2054 * - Reference PLX TT-7372
2056 val
= readl(&dev
->ll_chicken_reg
->ll_tsn_chicken_bit
);
2057 val
|= BIT(RECOVERY_IDLE_TO_RECOVER_FMW
);
2058 writel(val
, &dev
->ll_chicken_reg
->ll_tsn_chicken_bit
);
2060 INIT_LIST_HEAD(&dev
->gadget
.ep0
->ep_list
);
2062 /* disable dedicated endpoints */
2063 writel(0x0D, &dev
->dep
[0].dep_cfg
);
2064 writel(0x0D, &dev
->dep
[1].dep_cfg
);
2065 writel(0x0E, &dev
->dep
[2].dep_cfg
);
2066 writel(0x0E, &dev
->dep
[3].dep_cfg
);
2067 writel(0x0F, &dev
->dep
[4].dep_cfg
);
2068 writel(0x0C, &dev
->dep
[5].dep_cfg
);
2071 static void usb_reinit(struct net2280
*dev
)
2073 if (dev
->quirks
& PLX_LEGACY
)
2074 return usb_reinit_228x(dev
);
2075 return usb_reinit_338x(dev
);
2078 static void ep0_start_228x(struct net2280
*dev
)
2080 writel(BIT(CLEAR_EP_HIDE_STATUS_PHASE
) |
2081 BIT(CLEAR_NAK_OUT_PACKETS
) |
2082 BIT(CLEAR_CONTROL_STATUS_PHASE_HANDSHAKE
),
2083 &dev
->epregs
[0].ep_rsp
);
2086 * hardware optionally handles a bunch of standard requests
2087 * that the API hides from drivers anyway. have it do so.
2088 * endpoint status/features are handled in software, to
2089 * help pass tests for some dubious behavior.
2091 writel(BIT(SET_TEST_MODE
) |
2093 BIT(DEVICE_SET_CLEAR_DEVICE_REMOTE_WAKEUP
) |
2094 BIT(GET_DEVICE_STATUS
) |
2095 BIT(GET_INTERFACE_STATUS
),
2097 writel(BIT(USB_ROOT_PORT_WAKEUP_ENABLE
) |
2098 BIT(SELF_POWERED_USB_DEVICE
) |
2099 BIT(REMOTE_WAKEUP_SUPPORT
) |
2100 (dev
->softconnect
<< USB_DETECT_ENABLE
) |
2101 BIT(SELF_POWERED_STATUS
),
2104 /* enable irqs so we can see ep0 and general operation */
2105 writel(BIT(SETUP_PACKET_INTERRUPT_ENABLE
) |
2106 BIT(ENDPOINT_0_INTERRUPT_ENABLE
),
2107 &dev
->regs
->pciirqenb0
);
2108 writel(BIT(PCI_INTERRUPT_ENABLE
) |
2109 BIT(PCI_MASTER_ABORT_RECEIVED_INTERRUPT_ENABLE
) |
2110 BIT(PCI_TARGET_ABORT_RECEIVED_INTERRUPT_ENABLE
) |
2111 BIT(PCI_RETRY_ABORT_INTERRUPT_ENABLE
) |
2112 BIT(VBUS_INTERRUPT_ENABLE
) |
2113 BIT(ROOT_PORT_RESET_INTERRUPT_ENABLE
) |
2114 BIT(SUSPEND_REQUEST_CHANGE_INTERRUPT_ENABLE
),
2115 &dev
->regs
->pciirqenb1
);
2117 /* don't leave any writes posted */
2118 (void) readl(&dev
->usb
->usbctl
);
2121 static void ep0_start_338x(struct net2280
*dev
)
2124 if (dev
->bug7734_patched
)
2125 writel(BIT(CLEAR_NAK_OUT_PACKETS_MODE
) |
2126 BIT(SET_EP_HIDE_STATUS_PHASE
),
2127 &dev
->epregs
[0].ep_rsp
);
2130 * hardware optionally handles a bunch of standard requests
2131 * that the API hides from drivers anyway. have it do so.
2132 * endpoint status/features are handled in software, to
2133 * help pass tests for some dubious behavior.
2135 writel(BIT(SET_ISOCHRONOUS_DELAY
) |
2137 BIT(SET_TEST_MODE
) |
2139 BIT(GET_INTERFACE_STATUS
) |
2140 BIT(GET_DEVICE_STATUS
),
2142 dev
->wakeup_enable
= 1;
2143 writel(BIT(USB_ROOT_PORT_WAKEUP_ENABLE
) |
2144 (dev
->softconnect
<< USB_DETECT_ENABLE
) |
2145 BIT(DEVICE_REMOTE_WAKEUP_ENABLE
),
2148 /* enable irqs so we can see ep0 and general operation */
2149 writel(BIT(SETUP_PACKET_INTERRUPT_ENABLE
) |
2150 BIT(ENDPOINT_0_INTERRUPT_ENABLE
),
2151 &dev
->regs
->pciirqenb0
);
2152 writel(BIT(PCI_INTERRUPT_ENABLE
) |
2153 BIT(ROOT_PORT_RESET_INTERRUPT_ENABLE
) |
2154 BIT(SUSPEND_REQUEST_CHANGE_INTERRUPT_ENABLE
) |
2155 BIT(VBUS_INTERRUPT_ENABLE
),
2156 &dev
->regs
->pciirqenb1
);
2158 /* don't leave any writes posted */
2159 (void)readl(&dev
->usb
->usbctl
);
2162 static void ep0_start(struct net2280
*dev
)
2164 if (dev
->quirks
& PLX_LEGACY
)
2165 return ep0_start_228x(dev
);
2166 return ep0_start_338x(dev
);
2169 /* when a driver is successfully registered, it will receive
2170 * control requests including set_configuration(), which enables
2171 * non-control requests. then usb traffic follows until a
2172 * disconnect is reported. then a host may connect again, or
2173 * the driver might get unbound.
2175 static int net2280_start(struct usb_gadget
*_gadget
,
2176 struct usb_gadget_driver
*driver
)
2178 struct net2280
*dev
;
2182 /* insist on high speed support from the driver, since
2183 * (dev->usb->xcvrdiag & FORCE_FULL_SPEED_MODE)
2184 * "must not be used in normal operation"
2186 if (!driver
|| driver
->max_speed
< USB_SPEED_HIGH
||
2190 dev
= container_of(_gadget
, struct net2280
, gadget
);
2192 for (i
= 0; i
< dev
->n_ep
; i
++)
2193 dev
->ep
[i
].irqs
= 0;
2195 /* hook up the driver ... */
2196 dev
->softconnect
= 1;
2197 driver
->driver
.bus
= NULL
;
2198 dev
->driver
= driver
;
2200 retval
= device_create_file(&dev
->pdev
->dev
, &dev_attr_function
);
2203 retval
= device_create_file(&dev
->pdev
->dev
, &dev_attr_queues
);
2207 /* enable host detection and ep0; and we're ready
2208 * for set_configuration as well as eventual disconnect.
2210 net2280_led_active(dev
, 1);
2212 if ((dev
->quirks
& PLX_SUPERSPEED
) && !dev
->bug7734_patched
)
2213 defect7374_enable_data_eps_zero(dev
);
2217 /* pci writes may still be posted */
2221 device_remove_file(&dev
->pdev
->dev
, &dev_attr_function
);
2227 static void stop_activity(struct net2280
*dev
, struct usb_gadget_driver
*driver
)
2231 /* don't disconnect if it's not connected */
2232 if (dev
->gadget
.speed
== USB_SPEED_UNKNOWN
)
2235 /* stop hardware; prevent new request submissions;
2236 * and kill any outstanding requests.
2239 for (i
= 0; i
< dev
->n_ep
; i
++)
2242 /* report disconnect; the driver is already quiesced */
2244 spin_unlock(&dev
->lock
);
2245 driver
->disconnect(&dev
->gadget
);
2246 spin_lock(&dev
->lock
);
2252 static int net2280_stop(struct usb_gadget
*_gadget
)
2254 struct net2280
*dev
;
2255 unsigned long flags
;
2257 dev
= container_of(_gadget
, struct net2280
, gadget
);
2259 spin_lock_irqsave(&dev
->lock
, flags
);
2260 stop_activity(dev
, NULL
);
2261 spin_unlock_irqrestore(&dev
->lock
, flags
);
2263 net2280_led_active(dev
, 0);
2265 device_remove_file(&dev
->pdev
->dev
, &dev_attr_function
);
2266 device_remove_file(&dev
->pdev
->dev
, &dev_attr_queues
);
2273 /*-------------------------------------------------------------------------*/
2275 /* handle ep0, ep-e, ep-f with 64 byte packets: packet per irq.
2276 * also works for dma-capable endpoints, in pio mode or just
2277 * to manually advance the queue after short OUT transfers.
2279 static void handle_ep_small(struct net2280_ep
*ep
)
2281 struct net2280_request
*req
;
2283 /* 0 error, 1 mid-data, 2 done */
2286 if (!list_empty(&ep
->queue
))
2287 req
= list_entry(ep
->queue
.next
,
2288 struct net2280_request
, queue
);
2292 /* ack all, and handle what we care about */
2293 t
= readl(&ep
->regs
->ep_stat
);
2296 ep_vdbg(ep
->dev
, "%s ack ep_stat %08x, req %p\n",
2297 ep
->ep
.name
, t
, req
? &req
->req
: NULL
);
2299 if (!ep
->is_in
|| (ep
->dev
->quirks
& PLX_2280
))
2300 writel(t
& ~BIT(NAK_OUT_PACKETS
), &ep
->regs
->ep_stat
);
2302 /* Added for 2282 */
2303 writel(t
, &ep
->regs
->ep_stat
);
2305 /* for ep0, monitor token irqs to catch data stage length errors
2306 * and to synchronize on status.
2308 * also, to defer reporting of protocol stalls ... here's where
2309 * data or status first appears, handling stalls here should never
2310 * cause trouble on the host side..
2312 * control requests could be slightly faster without token synch for
2313 * status, but status can jam up that way.
2315 if (unlikely(ep
->num
== 0)) {
2317 /* status; stop NAKing */
2318 if (t
& BIT(DATA_OUT_PING_TOKEN_INTERRUPT
)) {
2319 if (ep
->dev
->protocol_stall
) {
2326 /* reply to extra IN data tokens with a zlp */
2327 } else if (t
& BIT(DATA_IN_TOKEN_INTERRUPT
)) {
2328 if (ep
->dev
->protocol_stall
) {
2332 } else if (ep
->responded
&&
2333 !req
&& !ep
->stopped
)
2334 write_fifo(ep
, NULL
);
2337 /* status; stop NAKing */
2338 if (t
& BIT(DATA_IN_TOKEN_INTERRUPT
)) {
2339 if (ep
->dev
->protocol_stall
) {
2344 /* an extra OUT token is an error */
2345 } else if (((t
& BIT(DATA_OUT_PING_TOKEN_INTERRUPT
)) &&
2347 req
->req
.actual
== req
->req
.length
) ||
2348 (ep
->responded
&& !req
)) {
2349 ep
->dev
->protocol_stall
= 1;
2353 done(ep
, req
, -EOVERFLOW
);
2362 /* manual DMA queue advance after short OUT */
2363 if (likely(ep
->dma
)) {
2364 if (t
& BIT(SHORT_PACKET_TRANSFERRED_INTERRUPT
)) {
2366 int stopped
= ep
->stopped
;
2368 /* TRANSFERRED works around OUT_DONE erratum 0112.
2369 * we expect (N <= maxpacket) bytes; host wrote M.
2370 * iff (M < N) we won't ever see a DMA interrupt.
2373 for (count
= 0; ; t
= readl(&ep
->regs
->ep_stat
)) {
2375 /* any preceding dma transfers must finish.
2376 * dma handles (M >= N), may empty the queue
2378 scan_dma_completions(ep
);
2379 if (unlikely(list_empty(&ep
->queue
) ||
2380 ep
->out_overflow
)) {
2384 req
= list_entry(ep
->queue
.next
,
2385 struct net2280_request
, queue
);
2387 /* here either (M < N), a "real" short rx;
2388 * or (M == N) and the queue didn't empty
2390 if (likely(t
& BIT(FIFO_EMPTY
))) {
2391 count
= readl(&ep
->dma
->dmacount
);
2392 count
&= DMA_BYTE_COUNT_MASK
;
2393 if (readl(&ep
->dma
->dmadesc
)
2401 /* stop DMA, leave ep NAKing */
2402 writel(BIT(DMA_ABORT
), &ep
->dma
->dmastat
);
2403 spin_stop_dma(ep
->dma
);
2406 req
->td
->dmacount
= 0;
2407 t
= readl(&ep
->regs
->ep_avail
);
2408 dma_done(ep
, req
, count
,
2409 (ep
->out_overflow
|| t
)
2413 /* also flush to prevent erratum 0106 trouble */
2414 if (unlikely(ep
->out_overflow
||
2415 (ep
->dev
->chiprev
== 0x0100 &&
2416 ep
->dev
->gadget
.speed
2417 == USB_SPEED_FULL
))) {
2419 ep
->out_overflow
= 0;
2422 /* (re)start dma if needed, stop NAKing */
2423 ep
->stopped
= stopped
;
2424 if (!list_empty(&ep
->queue
))
2427 ep_dbg(ep
->dev
, "%s dma ep_stat %08x ??\n",
2431 /* data packet(s) received (in the fifo, OUT) */
2432 } else if (t
& BIT(DATA_PACKET_RECEIVED_INTERRUPT
)) {
2433 if (read_fifo(ep
, req
) && ep
->num
!= 0)
2436 /* data packet(s) transmitted (IN) */
2437 } else if (t
& BIT(DATA_PACKET_TRANSMITTED_INTERRUPT
)) {
2440 len
= req
->req
.length
- req
->req
.actual
;
2441 if (len
> ep
->ep
.maxpacket
)
2442 len
= ep
->ep
.maxpacket
;
2443 req
->req
.actual
+= len
;
2445 /* if we wrote it all, we're usually done */
2446 /* send zlps until the status stage */
2447 if ((req
->req
.actual
== req
->req
.length
) &&
2448 (!req
->req
.zero
|| len
!= ep
->ep
.maxpacket
) && ep
->num
)
2451 /* there was nothing to do ... */
2452 } else if (mode
== 1)
2457 /* stream endpoints often resubmit/unlink in completion */
2460 /* maybe advance queue to next request */
2462 /* NOTE: net2280 could let gadget driver start the
2463 * status stage later. since not all controllers let
2464 * them control that, the api doesn't (yet) allow it.
2470 if (!list_empty(&ep
->queue
) && !ep
->stopped
)
2471 req
= list_entry(ep
->queue
.next
,
2472 struct net2280_request
, queue
);
2475 if (req
&& !ep
->is_in
)
2476 stop_out_naking(ep
);
2480 /* is there a buffer for the next packet?
2481 * for best streaming performance, make sure there is one.
2483 if (req
&& !ep
->stopped
) {
2485 /* load IN fifo with next packet (may be zlp) */
2486 if (t
& BIT(DATA_PACKET_TRANSMITTED_INTERRUPT
))
2487 write_fifo(ep
, &req
->req
);
2491 static struct net2280_ep
*get_ep_by_addr(struct net2280
*dev
, u16 wIndex
)
2493 struct net2280_ep
*ep
;
2495 if ((wIndex
& USB_ENDPOINT_NUMBER_MASK
) == 0)
2497 list_for_each_entry(ep
, &dev
->gadget
.ep_list
, ep
.ep_list
) {
2498 u8 bEndpointAddress
;
2502 bEndpointAddress
= ep
->desc
->bEndpointAddress
;
2503 if ((wIndex
^ bEndpointAddress
) & USB_DIR_IN
)
2505 if ((wIndex
& 0x0f) == (bEndpointAddress
& 0x0f))
2511 static void defect7374_workaround(struct net2280
*dev
, struct usb_ctrlrequest r
)
2513 u32 scratch
, fsmvalue
;
2514 u32 ack_wait_timeout
, state
;
2516 /* Workaround for Defect 7374 (U1/U2 erroneously rejected): */
2517 scratch
= get_idx_reg(dev
->regs
, SCRATCH
);
2518 fsmvalue
= scratch
& (0xf << DEFECT7374_FSM_FIELD
);
2519 scratch
&= ~(0xf << DEFECT7374_FSM_FIELD
);
2521 if (!((fsmvalue
== DEFECT7374_FSM_WAITING_FOR_CONTROL_READ
) &&
2522 (r
.bRequestType
& USB_DIR_IN
)))
2525 /* This is the first Control Read for this connection: */
2526 if (!(readl(&dev
->usb
->usbstat
) & BIT(SUPER_SPEED_MODE
))) {
2528 * Connection is NOT SS:
2529 * - Connection must be FS or HS.
2530 * - This FSM state should allow workaround software to
2531 * run after the next USB connection.
2533 scratch
|= DEFECT7374_FSM_NON_SS_CONTROL_READ
;
2534 dev
->bug7734_patched
= 1;
2535 goto restore_data_eps
;
2538 /* Connection is SS: */
2539 for (ack_wait_timeout
= 0;
2540 ack_wait_timeout
< DEFECT_7374_NUMBEROF_MAX_WAIT_LOOPS
;
2541 ack_wait_timeout
++) {
2543 state
= readl(&dev
->plregs
->pl_ep_status_1
)
2545 if ((state
>= (ACK_GOOD_NORMAL
<< STATE
)) &&
2546 (state
<= (ACK_GOOD_MORE_ACKS_TO_COME
<< STATE
))) {
2547 scratch
|= DEFECT7374_FSM_SS_CONTROL_READ
;
2548 dev
->bug7734_patched
= 1;
2553 * We have not yet received host's Data Phase ACK
2554 * - Wait and try again.
2556 udelay(DEFECT_7374_PROCESSOR_WAIT_TIME
);
2562 if (ack_wait_timeout
>= DEFECT_7374_NUMBEROF_MAX_WAIT_LOOPS
) {
2563 ep_err(dev
, "FAIL: Defect 7374 workaround waited but failed "
2564 "to detect SS host's data phase ACK.");
2565 ep_err(dev
, "PL_EP_STATUS_1(23:16):.Expected from 0x11 to 0x16"
2566 "got 0x%2.2x.\n", state
>> STATE
);
2568 ep_warn(dev
, "INFO: Defect 7374 workaround waited about\n"
2569 "%duSec for Control Read Data Phase ACK\n",
2570 DEFECT_7374_PROCESSOR_WAIT_TIME
* ack_wait_timeout
);
2575 * Restore data EPs to their pre-workaround settings (disabled,
2576 * initialized, and other details).
2578 defect7374_disable_data_eps(dev
);
2580 set_idx_reg(dev
->regs
, SCRATCH
, scratch
);
2585 static void ep_clear_seqnum(struct net2280_ep
*ep
)
2587 struct net2280
*dev
= ep
->dev
;
2589 static const u32 ep_pl
[9] = { 0, 3, 4, 7, 8, 2, 5, 6, 9 };
2591 val
= readl(&dev
->plregs
->pl_ep_ctrl
) & ~0x1f;
2592 val
|= ep_pl
[ep
->num
];
2593 writel(val
, &dev
->plregs
->pl_ep_ctrl
);
2594 val
|= BIT(SEQUENCE_NUMBER_RESET
);
2595 writel(val
, &dev
->plregs
->pl_ep_ctrl
);
2600 static void handle_stat0_irqs_superspeed(struct net2280
*dev
,
2601 struct net2280_ep
*ep
, struct usb_ctrlrequest r
)
2605 #define w_value le16_to_cpu(r.wValue)
2606 #define w_index le16_to_cpu(r.wIndex)
2607 #define w_length le16_to_cpu(r.wLength)
2609 switch (r
.bRequest
) {
2610 struct net2280_ep
*e
;
2613 case USB_REQ_SET_CONFIGURATION
:
2614 dev
->addressed_state
= !w_value
;
2617 case USB_REQ_GET_STATUS
:
2618 switch (r
.bRequestType
) {
2619 case (USB_DIR_IN
| USB_TYPE_STANDARD
| USB_RECIP_DEVICE
):
2620 status
= dev
->wakeup_enable
? 0x02 : 0x00;
2621 if (dev
->gadget
.is_selfpowered
)
2623 status
|= (dev
->u1_enable
<< 2 | dev
->u2_enable
<< 3 |
2624 dev
->ltm_enable
<< 4);
2625 writel(0, &dev
->epregs
[0].ep_irqenb
);
2626 set_fifo_bytecount(ep
, sizeof(status
));
2627 writel((__force u32
) status
, &dev
->epregs
[0].ep_data
);
2628 allow_status_338x(ep
);
2631 case (USB_DIR_IN
| USB_TYPE_STANDARD
| USB_RECIP_ENDPOINT
):
2632 e
= get_ep_by_addr(dev
, w_index
);
2635 status
= readl(&e
->regs
->ep_rsp
) &
2636 BIT(CLEAR_ENDPOINT_HALT
);
2637 writel(0, &dev
->epregs
[0].ep_irqenb
);
2638 set_fifo_bytecount(ep
, sizeof(status
));
2639 writel((__force u32
) status
, &dev
->epregs
[0].ep_data
);
2640 allow_status_338x(ep
);
2648 case USB_REQ_CLEAR_FEATURE
:
2649 switch (r
.bRequestType
) {
2650 case (USB_DIR_OUT
| USB_TYPE_STANDARD
| USB_RECIP_DEVICE
):
2651 if (!dev
->addressed_state
) {
2653 case USB_DEVICE_U1_ENABLE
:
2655 writel(readl(&dev
->usb_ext
->usbctl2
) &
2657 &dev
->usb_ext
->usbctl2
);
2658 allow_status_338x(ep
);
2659 goto next_endpoints3
;
2661 case USB_DEVICE_U2_ENABLE
:
2663 writel(readl(&dev
->usb_ext
->usbctl2
) &
2665 &dev
->usb_ext
->usbctl2
);
2666 allow_status_338x(ep
);
2667 goto next_endpoints3
;
2669 case USB_DEVICE_LTM_ENABLE
:
2670 dev
->ltm_enable
= 0;
2671 writel(readl(&dev
->usb_ext
->usbctl2
) &
2673 &dev
->usb_ext
->usbctl2
);
2674 allow_status_338x(ep
);
2675 goto next_endpoints3
;
2681 if (w_value
== USB_DEVICE_REMOTE_WAKEUP
) {
2682 dev
->wakeup_enable
= 0;
2683 writel(readl(&dev
->usb
->usbctl
) &
2684 ~BIT(DEVICE_REMOTE_WAKEUP_ENABLE
),
2686 allow_status_338x(ep
);
2691 case (USB_DIR_OUT
| USB_TYPE_STANDARD
| USB_RECIP_ENDPOINT
):
2692 e
= get_ep_by_addr(dev
, w_index
);
2695 if (w_value
!= USB_ENDPOINT_HALT
)
2697 ep_vdbg(dev
, "%s clear halt\n", e
->ep
.name
);
2699 * Workaround for SS SeqNum not cleared via
2700 * Endpoint Halt (Clear) bit. select endpoint
2704 if (!list_empty(&e
->queue
) && e
->td_dma
)
2714 case USB_REQ_SET_FEATURE
:
2715 switch (r
.bRequestType
) {
2716 case (USB_DIR_OUT
| USB_TYPE_STANDARD
| USB_RECIP_DEVICE
):
2717 if (!dev
->addressed_state
) {
2719 case USB_DEVICE_U1_ENABLE
:
2721 writel(readl(&dev
->usb_ext
->usbctl2
) |
2723 &dev
->usb_ext
->usbctl2
);
2724 allow_status_338x(ep
);
2725 goto next_endpoints3
;
2727 case USB_DEVICE_U2_ENABLE
:
2729 writel(readl(&dev
->usb_ext
->usbctl2
) |
2731 &dev
->usb_ext
->usbctl2
);
2732 allow_status_338x(ep
);
2733 goto next_endpoints3
;
2735 case USB_DEVICE_LTM_ENABLE
:
2736 dev
->ltm_enable
= 1;
2737 writel(readl(&dev
->usb_ext
->usbctl2
) |
2739 &dev
->usb_ext
->usbctl2
);
2740 allow_status_338x(ep
);
2741 goto next_endpoints3
;
2747 if (w_value
== USB_DEVICE_REMOTE_WAKEUP
) {
2748 dev
->wakeup_enable
= 1;
2749 writel(readl(&dev
->usb
->usbctl
) |
2750 BIT(DEVICE_REMOTE_WAKEUP_ENABLE
),
2752 allow_status_338x(ep
);
2757 case (USB_DIR_OUT
| USB_TYPE_STANDARD
| USB_RECIP_ENDPOINT
):
2758 e
= get_ep_by_addr(dev
, w_index
);
2759 if (!e
|| (w_value
!= USB_ENDPOINT_HALT
))
2763 ep
->dev
->protocol_stall
= 1;
2769 allow_status_338x(ep
);
2780 ep_vdbg(dev
, "setup %02x.%02x v%04x i%04x l%04x ep_cfg %08x\n",
2781 r
.bRequestType
, r
.bRequest
,
2782 w_value
, w_index
, w_length
,
2783 readl(&ep
->cfg
->ep_cfg
));
2786 spin_unlock(&dev
->lock
);
2787 tmp
= dev
->driver
->setup(&dev
->gadget
, &r
);
2788 spin_lock(&dev
->lock
);
2792 ep_vdbg(dev
, "req %02x.%02x protocol STALL; stat %d\n",
2793 r
.bRequestType
, r
.bRequest
, tmp
);
2794 dev
->protocol_stall
= 1;
2795 /* TD 9.9 Halt Endpoint test. TD 9.22 Set feature test */
2808 static void handle_stat0_irqs(struct net2280
*dev
, u32 stat
)
2810 struct net2280_ep
*ep
;
2813 /* most of these don't need individual acks */
2814 stat
&= ~BIT(INTA_ASSERTED
);
2817 /* ep_dbg(dev, "irqstat0 %04x\n", stat); */
2819 /* starting a control request? */
2820 if (unlikely(stat
& BIT(SETUP_PACKET_INTERRUPT
))) {
2823 struct usb_ctrlrequest r
;
2826 struct net2280_request
*req
;
2828 if (dev
->gadget
.speed
== USB_SPEED_UNKNOWN
) {
2829 u32 val
= readl(&dev
->usb
->usbstat
);
2830 if (val
& BIT(SUPER_SPEED
)) {
2831 dev
->gadget
.speed
= USB_SPEED_SUPER
;
2832 usb_ep_set_maxpacket_limit(&dev
->ep
[0].ep
,
2833 EP0_SS_MAX_PACKET_SIZE
);
2834 } else if (val
& BIT(HIGH_SPEED
)) {
2835 dev
->gadget
.speed
= USB_SPEED_HIGH
;
2836 usb_ep_set_maxpacket_limit(&dev
->ep
[0].ep
,
2837 EP0_HS_MAX_PACKET_SIZE
);
2839 dev
->gadget
.speed
= USB_SPEED_FULL
;
2840 usb_ep_set_maxpacket_limit(&dev
->ep
[0].ep
,
2841 EP0_HS_MAX_PACKET_SIZE
);
2843 net2280_led_speed(dev
, dev
->gadget
.speed
);
2845 usb_speed_string(dev
->gadget
.speed
));
2851 /* make sure any leftover request state is cleared */
2852 stat
&= ~BIT(ENDPOINT_0_INTERRUPT
);
2853 while (!list_empty(&ep
->queue
)) {
2854 req
= list_entry(ep
->queue
.next
,
2855 struct net2280_request
, queue
);
2856 done(ep
, req
, (req
->req
.actual
== req
->req
.length
)
2860 dev
->protocol_stall
= 0;
2861 if (!(dev
->quirks
& PLX_SUPERSPEED
)) {
2862 if (ep
->dev
->quirks
& PLX_2280
)
2863 tmp
= BIT(FIFO_OVERFLOW
) |
2864 BIT(FIFO_UNDERFLOW
);
2868 writel(tmp
| BIT(TIMEOUT
) |
2869 BIT(USB_STALL_SENT
) |
2870 BIT(USB_IN_NAK_SENT
) |
2871 BIT(USB_IN_ACK_RCVD
) |
2872 BIT(USB_OUT_PING_NAK_SENT
) |
2873 BIT(USB_OUT_ACK_SENT
) |
2874 BIT(SHORT_PACKET_OUT_DONE_INTERRUPT
) |
2875 BIT(SHORT_PACKET_TRANSFERRED_INTERRUPT
) |
2876 BIT(DATA_PACKET_RECEIVED_INTERRUPT
) |
2877 BIT(DATA_PACKET_TRANSMITTED_INTERRUPT
) |
2878 BIT(DATA_OUT_PING_TOKEN_INTERRUPT
) |
2879 BIT(DATA_IN_TOKEN_INTERRUPT
),
2880 &ep
->regs
->ep_stat
);
2882 u
.raw
[0] = readl(&dev
->usb
->setup0123
);
2883 u
.raw
[1] = readl(&dev
->usb
->setup4567
);
2885 cpu_to_le32s(&u
.raw
[0]);
2886 cpu_to_le32s(&u
.raw
[1]);
2888 if ((dev
->quirks
& PLX_SUPERSPEED
) && !dev
->bug7734_patched
)
2889 defect7374_workaround(dev
, u
.r
);
2893 #define w_value le16_to_cpu(u.r.wValue)
2894 #define w_index le16_to_cpu(u.r.wIndex)
2895 #define w_length le16_to_cpu(u.r.wLength)
2898 writel(BIT(SETUP_PACKET_INTERRUPT
), &dev
->regs
->irqstat0
);
2899 stat
^= BIT(SETUP_PACKET_INTERRUPT
);
2901 /* watch control traffic at the token level, and force
2902 * synchronization before letting the status stage happen.
2903 * FIXME ignore tokens we'll NAK, until driver responds.
2904 * that'll mean a lot less irqs for some drivers.
2906 ep
->is_in
= (u
.r
.bRequestType
& USB_DIR_IN
) != 0;
2908 scratch
= BIT(DATA_PACKET_TRANSMITTED_INTERRUPT
) |
2909 BIT(DATA_OUT_PING_TOKEN_INTERRUPT
) |
2910 BIT(DATA_IN_TOKEN_INTERRUPT
);
2911 stop_out_naking(ep
);
2913 scratch
= BIT(DATA_PACKET_RECEIVED_INTERRUPT
) |
2914 BIT(DATA_OUT_PING_TOKEN_INTERRUPT
) |
2915 BIT(DATA_IN_TOKEN_INTERRUPT
);
2916 writel(scratch
, &dev
->epregs
[0].ep_irqenb
);
2918 /* we made the hardware handle most lowlevel requests;
2919 * everything else goes uplevel to the gadget code.
2923 if (dev
->gadget
.speed
== USB_SPEED_SUPER
) {
2924 handle_stat0_irqs_superspeed(dev
, ep
, u
.r
);
2925 goto next_endpoints
;
2928 switch (u
.r
.bRequest
) {
2929 case USB_REQ_GET_STATUS
: {
2930 struct net2280_ep
*e
;
2933 /* hw handles device and interface status */
2934 if (u
.r
.bRequestType
!= (USB_DIR_IN
|USB_RECIP_ENDPOINT
))
2936 e
= get_ep_by_addr(dev
, w_index
);
2937 if (!e
|| w_length
> 2)
2940 if (readl(&e
->regs
->ep_rsp
) & BIT(SET_ENDPOINT_HALT
))
2941 status
= cpu_to_le32(1);
2943 status
= cpu_to_le32(0);
2945 /* don't bother with a request object! */
2946 writel(0, &dev
->epregs
[0].ep_irqenb
);
2947 set_fifo_bytecount(ep
, w_length
);
2948 writel((__force u32
)status
, &dev
->epregs
[0].ep_data
);
2950 ep_vdbg(dev
, "%s stat %02x\n", ep
->ep
.name
, status
);
2951 goto next_endpoints
;
2954 case USB_REQ_CLEAR_FEATURE
: {
2955 struct net2280_ep
*e
;
2957 /* hw handles device features */
2958 if (u
.r
.bRequestType
!= USB_RECIP_ENDPOINT
)
2960 if (w_value
!= USB_ENDPOINT_HALT
|| w_length
!= 0)
2962 e
= get_ep_by_addr(dev
, w_index
);
2966 ep_vdbg(dev
, "%s wedged, halt not cleared\n",
2969 ep_vdbg(dev
, "%s clear halt\n", e
->ep
.name
);
2971 if ((ep
->dev
->quirks
& PLX_SUPERSPEED
) &&
2972 !list_empty(&e
->queue
) && e
->td_dma
)
2976 goto next_endpoints
;
2979 case USB_REQ_SET_FEATURE
: {
2980 struct net2280_ep
*e
;
2982 /* hw handles device features */
2983 if (u
.r
.bRequestType
!= USB_RECIP_ENDPOINT
)
2985 if (w_value
!= USB_ENDPOINT_HALT
|| w_length
!= 0)
2987 e
= get_ep_by_addr(dev
, w_index
);
2990 if (e
->ep
.name
== ep0name
)
2993 if ((dev
->quirks
& PLX_SUPERSPEED
) && e
->dma
)
2996 ep_vdbg(dev
, "%s set halt\n", ep
->ep
.name
);
2997 goto next_endpoints
;
3002 ep_vdbg(dev
, "setup %02x.%02x v%04x i%04x l%04x "
3004 u
.r
.bRequestType
, u
.r
.bRequest
,
3005 w_value
, w_index
, w_length
,
3006 readl(&ep
->cfg
->ep_cfg
));
3008 spin_unlock(&dev
->lock
);
3009 tmp
= dev
->driver
->setup(&dev
->gadget
, &u
.r
);
3010 spin_lock(&dev
->lock
);
3013 /* stall ep0 on error */
3016 ep_vdbg(dev
, "req %02x.%02x protocol STALL; stat %d\n",
3017 u
.r
.bRequestType
, u
.r
.bRequest
, tmp
);
3018 dev
->protocol_stall
= 1;
3021 /* some in/out token irq should follow; maybe stall then.
3022 * driver must queue a request (even zlp) or halt ep0
3023 * before the host times out.
3032 /* endpoint data irq ? */
3033 scratch
= stat
& 0x7f;
3035 for (num
= 0; scratch
; num
++) {
3038 /* do this endpoint's FIFO and queue need tending? */
3040 if ((scratch
& t
) == 0)
3045 handle_ep_small(ep
);
3049 ep_dbg(dev
, "unhandled irqstat0 %08x\n", stat
);
3052 #define DMA_INTERRUPTS (BIT(DMA_D_INTERRUPT) | \
3053 BIT(DMA_C_INTERRUPT) | \
3054 BIT(DMA_B_INTERRUPT) | \
3055 BIT(DMA_A_INTERRUPT))
3056 #define PCI_ERROR_INTERRUPTS ( \
3057 BIT(PCI_MASTER_ABORT_RECEIVED_INTERRUPT) | \
3058 BIT(PCI_TARGET_ABORT_RECEIVED_INTERRUPT) | \
3059 BIT(PCI_RETRY_ABORT_INTERRUPT))
3061 static void handle_stat1_irqs(struct net2280
*dev
, u32 stat
)
3063 struct net2280_ep
*ep
;
3064 u32 tmp
, num
, mask
, scratch
;
3066 /* after disconnect there's nothing else to do! */
3067 tmp
= BIT(VBUS_INTERRUPT
) | BIT(ROOT_PORT_RESET_INTERRUPT
);
3068 mask
= BIT(SUPER_SPEED
) | BIT(HIGH_SPEED
) | BIT(FULL_SPEED
);
3070 /* VBUS disconnect is indicated by VBUS_PIN and VBUS_INTERRUPT set.
3071 * Root Port Reset is indicated by ROOT_PORT_RESET_INTERRUPT set and
3072 * both HIGH_SPEED and FULL_SPEED clear (as ROOT_PORT_RESET_INTERRUPT
3073 * only indicates a change in the reset state).
3077 bool disconnect
= false;
3080 * Ignore disconnects and resets if the speed hasn't been set.
3081 * VBUS can bounce and there's always an initial reset.
3083 writel(tmp
, &dev
->regs
->irqstat1
);
3084 if (dev
->gadget
.speed
!= USB_SPEED_UNKNOWN
) {
3085 if ((stat
& BIT(VBUS_INTERRUPT
)) &&
3086 (readl(&dev
->usb
->usbctl
) &
3087 BIT(VBUS_PIN
)) == 0) {
3089 ep_dbg(dev
, "disconnect %s\n",
3090 dev
->driver
->driver
.name
);
3091 } else if ((stat
& BIT(ROOT_PORT_RESET_INTERRUPT
)) &&
3092 (readl(&dev
->usb
->usbstat
) & mask
)
3095 ep_dbg(dev
, "reset %s\n",
3096 dev
->driver
->driver
.name
);
3099 if (disconnect
|| reset
) {
3100 stop_activity(dev
, dev
->driver
);
3102 spin_unlock(&dev
->lock
);
3104 usb_gadget_udc_reset
3105 (&dev
->gadget
, dev
->driver
);
3107 (dev
->driver
->disconnect
)
3109 spin_lock(&dev
->lock
);
3115 /* vBUS can bounce ... one of many reasons to ignore the
3116 * notion of hotplug events on bus connect/disconnect!
3122 /* NOTE: chip stays in PCI D0 state for now, but it could
3123 * enter D1 to save more power
3125 tmp
= BIT(SUSPEND_REQUEST_CHANGE_INTERRUPT
);
3127 writel(tmp
, &dev
->regs
->irqstat1
);
3128 if (stat
& BIT(SUSPEND_REQUEST_INTERRUPT
)) {
3129 if (dev
->driver
->suspend
)
3130 dev
->driver
->suspend(&dev
->gadget
);
3131 if (!enable_suspend
)
3132 stat
&= ~BIT(SUSPEND_REQUEST_INTERRUPT
);
3134 if (dev
->driver
->resume
)
3135 dev
->driver
->resume(&dev
->gadget
);
3136 /* at high speed, note erratum 0133 */
3141 /* clear any other status/irqs */
3143 writel(stat
, &dev
->regs
->irqstat1
);
3145 /* some status we can just ignore */
3146 if (dev
->quirks
& PLX_2280
)
3147 stat
&= ~(BIT(CONTROL_STATUS_INTERRUPT
) |
3148 BIT(SUSPEND_REQUEST_INTERRUPT
) |
3149 BIT(RESUME_INTERRUPT
) |
3150 BIT(SOF_INTERRUPT
));
3152 stat
&= ~(BIT(CONTROL_STATUS_INTERRUPT
) |
3153 BIT(RESUME_INTERRUPT
) |
3154 BIT(SOF_DOWN_INTERRUPT
) |
3155 BIT(SOF_INTERRUPT
));
3159 /* ep_dbg(dev, "irqstat1 %08x\n", stat);*/
3161 /* DMA status, for ep-{a,b,c,d} */
3162 scratch
= stat
& DMA_INTERRUPTS
;
3163 stat
&= ~DMA_INTERRUPTS
;
3165 for (num
= 0; scratch
; num
++) {
3166 struct net2280_dma_regs __iomem
*dma
;
3169 if ((tmp
& scratch
) == 0)
3173 ep
= &dev
->ep
[num
+ 1];
3179 /* clear ep's dma status */
3180 tmp
= readl(&dma
->dmastat
);
3181 writel(tmp
, &dma
->dmastat
);
3184 if (dev
->quirks
& PLX_SUPERSPEED
) {
3185 u32 r_dmacount
= readl(&dma
->dmacount
);
3186 if (!ep
->is_in
&& (r_dmacount
& 0x00FFFFFF) &&
3187 (tmp
& BIT(DMA_TRANSACTION_DONE_INTERRUPT
)))
3191 if (!(tmp
& BIT(DMA_TRANSACTION_DONE_INTERRUPT
))) {
3192 ep_dbg(ep
->dev
, "%s no xact done? %08x\n",
3198 /* OUT transfers terminate when the data from the
3199 * host is in our memory. Process whatever's done.
3200 * On this path, we know transfer's last packet wasn't
3201 * less than req->length. NAK_OUT_PACKETS may be set,
3202 * or the FIFO may already be holding new packets.
3204 * IN transfers can linger in the FIFO for a very
3205 * long time ... we ignore that for now, accounting
3206 * precisely (like PIO does) needs per-packet irqs
3208 scan_dma_completions(ep
);
3210 /* disable dma on inactive queues; else maybe restart */
3211 if (!list_empty(&ep
->queue
)) {
3212 tmp
= readl(&dma
->dmactl
);
3218 /* NOTE: there are other PCI errors we might usefully notice.
3219 * if they appear very often, here's where to try recovering.
3221 if (stat
& PCI_ERROR_INTERRUPTS
) {
3222 ep_err(dev
, "pci dma error; stat %08x\n", stat
);
3223 stat
&= ~PCI_ERROR_INTERRUPTS
;
3224 /* these are fatal errors, but "maybe" they won't
3227 stop_activity(dev
, dev
->driver
);
3233 ep_dbg(dev
, "unhandled irqstat1 %08x\n", stat
);
3236 static irqreturn_t
net2280_irq(int irq
, void *_dev
)
3238 struct net2280
*dev
= _dev
;
3240 /* shared interrupt, not ours */
3241 if ((dev
->quirks
& PLX_LEGACY
) &&
3242 (!(readl(&dev
->regs
->irqstat0
) & BIT(INTA_ASSERTED
))))
3245 spin_lock(&dev
->lock
);
3247 /* handle disconnect, dma, and more */
3248 handle_stat1_irqs(dev
, readl(&dev
->regs
->irqstat1
));
3250 /* control requests and PIO */
3251 handle_stat0_irqs(dev
, readl(&dev
->regs
->irqstat0
));
3253 if (dev
->quirks
& PLX_SUPERSPEED
) {
3254 /* re-enable interrupt to trigger any possible new interrupt */
3255 u32 pciirqenb1
= readl(&dev
->regs
->pciirqenb1
);
3256 writel(pciirqenb1
& 0x7FFFFFFF, &dev
->regs
->pciirqenb1
);
3257 writel(pciirqenb1
, &dev
->regs
->pciirqenb1
);
3260 spin_unlock(&dev
->lock
);
3265 /*-------------------------------------------------------------------------*/
3267 static void gadget_release(struct device
*_dev
)
3269 struct net2280
*dev
= dev_get_drvdata(_dev
);
3274 /* tear down the binding between this driver and the pci device */
3276 static void net2280_remove(struct pci_dev
*pdev
)
3278 struct net2280
*dev
= pci_get_drvdata(pdev
);
3280 usb_del_gadget_udc(&dev
->gadget
);
3282 BUG_ON(dev
->driver
);
3284 /* then clean up the resources we allocated during probe() */
3285 net2280_led_shutdown(dev
);
3286 if (dev
->requests
) {
3288 for (i
= 1; i
< 5; i
++) {
3289 if (!dev
->ep
[i
].dummy
)
3291 pci_pool_free(dev
->requests
, dev
->ep
[i
].dummy
,
3294 pci_pool_destroy(dev
->requests
);
3297 free_irq(pdev
->irq
, dev
);
3298 if (dev
->quirks
& PLX_SUPERSPEED
)
3299 pci_disable_msi(pdev
);
3303 release_mem_region(pci_resource_start(pdev
, 0),
3304 pci_resource_len(pdev
, 0));
3306 pci_disable_device(pdev
);
3307 device_remove_file(&pdev
->dev
, &dev_attr_registers
);
3309 ep_info(dev
, "unbind\n");
3312 /* wrap this driver around the specified device, but
3313 * don't respond over USB until a gadget driver binds to us.
3316 static int net2280_probe(struct pci_dev
*pdev
, const struct pci_device_id
*id
)
3318 struct net2280
*dev
;
3319 unsigned long resource
, len
;
3320 void __iomem
*base
= NULL
;
3323 /* alloc, and start init */
3324 dev
= kzalloc(sizeof(*dev
), GFP_KERNEL
);
3330 pci_set_drvdata(pdev
, dev
);
3331 spin_lock_init(&dev
->lock
);
3332 dev
->quirks
= id
->driver_data
;
3334 dev
->gadget
.ops
= &net2280_ops
;
3335 dev
->gadget
.max_speed
= (dev
->quirks
& PLX_SUPERSPEED
) ?
3336 USB_SPEED_SUPER
: USB_SPEED_HIGH
;
3338 /* the "gadget" abstracts/virtualizes the controller */
3339 dev
->gadget
.name
= driver_name
;
3341 /* now all the pci goodies ... */
3342 if (pci_enable_device(pdev
) < 0) {
3348 /* BAR 0 holds all the registers
3349 * BAR 1 is 8051 memory; unused here (note erratum 0103)
3350 * BAR 2 is fifo memory; unused here
3352 resource
= pci_resource_start(pdev
, 0);
3353 len
= pci_resource_len(pdev
, 0);
3354 if (!request_mem_region(resource
, len
, driver_name
)) {
3355 ep_dbg(dev
, "controller already in use\n");
3361 /* FIXME provide firmware download interface to put
3362 * 8051 code into the chip, e.g. to turn on PCI PM.
3365 base
= ioremap_nocache(resource
, len
);
3367 ep_dbg(dev
, "can't map memory\n");
3371 dev
->regs
= (struct net2280_regs __iomem
*) base
;
3372 dev
->usb
= (struct net2280_usb_regs __iomem
*) (base
+ 0x0080);
3373 dev
->pci
= (struct net2280_pci_regs __iomem
*) (base
+ 0x0100);
3374 dev
->dma
= (struct net2280_dma_regs __iomem
*) (base
+ 0x0180);
3375 dev
->dep
= (struct net2280_dep_regs __iomem
*) (base
+ 0x0200);
3376 dev
->epregs
= (struct net2280_ep_regs __iomem
*) (base
+ 0x0300);
3378 if (dev
->quirks
& PLX_SUPERSPEED
) {
3381 dev
->usb_ext
= (struct usb338x_usb_ext_regs __iomem
*)
3383 dev
->fiforegs
= (struct usb338x_fifo_regs __iomem
*)
3385 dev
->llregs
= (struct usb338x_ll_regs __iomem
*)
3387 dev
->ll_lfps_regs
= (struct usb338x_ll_lfps_regs __iomem
*)
3389 dev
->ll_tsn_regs
= (struct usb338x_ll_tsn_regs __iomem
*)
3391 dev
->ll_chicken_reg
= (struct usb338x_ll_chi_regs __iomem
*)
3393 dev
->plregs
= (struct usb338x_pl_regs __iomem
*)
3395 usbstat
= readl(&dev
->usb
->usbstat
);
3396 dev
->enhanced_mode
= !!(usbstat
& BIT(11));
3397 dev
->n_ep
= (dev
->enhanced_mode
) ? 9 : 5;
3398 /* put into initial config, link up all endpoints */
3399 fsmvalue
= get_idx_reg(dev
->regs
, SCRATCH
) &
3400 (0xf << DEFECT7374_FSM_FIELD
);
3401 /* See if firmware needs to set up for workaround: */
3402 if (fsmvalue
== DEFECT7374_FSM_SS_CONTROL_READ
) {
3403 dev
->bug7734_patched
= 1;
3404 writel(0, &dev
->usb
->usbctl
);
3406 dev
->bug7734_patched
= 0;
3408 dev
->enhanced_mode
= 0;
3410 /* put into initial config, link up all endpoints */
3411 writel(0, &dev
->usb
->usbctl
);
3417 /* irq setup after old hardware is cleaned up */
3419 ep_err(dev
, "No IRQ. Check PCI setup!\n");
3424 if (dev
->quirks
& PLX_SUPERSPEED
)
3425 if (pci_enable_msi(pdev
))
3426 ep_err(dev
, "Failed to enable MSI mode\n");
3428 if (request_irq(pdev
->irq
, net2280_irq
, IRQF_SHARED
,
3429 driver_name
, dev
)) {
3430 ep_err(dev
, "request interrupt %d failed\n", pdev
->irq
);
3437 /* NOTE: we know only the 32 LSBs of dma addresses may be nonzero */
3438 dev
->requests
= pci_pool_create("requests", pdev
,
3439 sizeof(struct net2280_dma
),
3440 0 /* no alignment requirements */,
3441 0 /* or page-crossing issues */);
3442 if (!dev
->requests
) {
3443 ep_dbg(dev
, "can't get request pool\n");
3447 for (i
= 1; i
< 5; i
++) {
3448 struct net2280_dma
*td
;
3450 td
= pci_pool_alloc(dev
->requests
, GFP_KERNEL
,
3451 &dev
->ep
[i
].td_dma
);
3453 ep_dbg(dev
, "can't get dummy %d\n", i
);
3457 td
->dmacount
= 0; /* not VALID */
3458 td
->dmadesc
= td
->dmaaddr
;
3459 dev
->ep
[i
].dummy
= td
;
3462 /* enable lower-overhead pci memory bursts during DMA */
3463 if (dev
->quirks
& PLX_LEGACY
)
3464 writel(BIT(DMA_MEMORY_WRITE_AND_INVALIDATE_ENABLE
) |
3466 * 256 write retries may not be enough...
3467 BIT(PCI_RETRY_ABORT_ENABLE) |
3469 BIT(DMA_READ_MULTIPLE_ENABLE
) |
3470 BIT(DMA_READ_LINE_ENABLE
),
3471 &dev
->pci
->pcimstctl
);
3472 /* erratum 0115 shouldn't appear: Linux inits PCI_LATENCY_TIMER */
3473 pci_set_master(pdev
);
3474 pci_try_set_mwi(pdev
);
3476 /* ... also flushes any posted pci writes */
3477 dev
->chiprev
= get_idx_reg(dev
->regs
, REG_CHIPREV
) & 0xffff;
3480 ep_info(dev
, "%s\n", driver_desc
);
3481 ep_info(dev
, "irq %d, pci mem %p, chip rev %04x\n",
3482 pdev
->irq
, base
, dev
->chiprev
);
3483 ep_info(dev
, "version: " DRIVER_VERSION
"; %s\n",
3484 dev
->enhanced_mode
? "enhanced mode" : "legacy mode");
3485 retval
= device_create_file(&pdev
->dev
, &dev_attr_registers
);
3489 retval
= usb_add_gadget_udc_release(&pdev
->dev
, &dev
->gadget
,
3497 net2280_remove(pdev
);
3501 /* make sure the board is quiescent; otherwise it will continue
3502 * generating IRQs across the upcoming reboot.
3505 static void net2280_shutdown(struct pci_dev
*pdev
)
3507 struct net2280
*dev
= pci_get_drvdata(pdev
);
3510 writel(0, &dev
->regs
->pciirqenb0
);
3511 writel(0, &dev
->regs
->pciirqenb1
);
3513 /* disable the pullup so the host will think we're gone */
3514 writel(0, &dev
->usb
->usbctl
);
3519 /*-------------------------------------------------------------------------*/
3521 static const struct pci_device_id pci_ids
[] = { {
3522 .class = ((PCI_CLASS_SERIAL_USB
<< 8) | 0xfe),
3524 .vendor
= PCI_VENDOR_ID_PLX_LEGACY
,
3526 .subvendor
= PCI_ANY_ID
,
3527 .subdevice
= PCI_ANY_ID
,
3528 .driver_data
= PLX_LEGACY
| PLX_2280
,
3530 .class = ((PCI_CLASS_SERIAL_USB
<< 8) | 0xfe),
3532 .vendor
= PCI_VENDOR_ID_PLX_LEGACY
,
3534 .subvendor
= PCI_ANY_ID
,
3535 .subdevice
= PCI_ANY_ID
,
3536 .driver_data
= PLX_LEGACY
,
3539 .class = ((PCI_CLASS_SERIAL_USB
<< 8) | 0xfe),
3541 .vendor
= PCI_VENDOR_ID_PLX
,
3543 .subvendor
= PCI_ANY_ID
,
3544 .subdevice
= PCI_ANY_ID
,
3545 .driver_data
= PLX_SUPERSPEED
,
3548 .class = ((PCI_CLASS_SERIAL_USB
<< 8) | 0xfe),
3550 .vendor
= PCI_VENDOR_ID_PLX
,
3552 .subvendor
= PCI_ANY_ID
,
3553 .subdevice
= PCI_ANY_ID
,
3554 .driver_data
= PLX_SUPERSPEED
,
3556 { /* end: all zeroes */ }
3558 MODULE_DEVICE_TABLE(pci
, pci_ids
);
3560 /* pci driver glue; this is a "new style" PCI driver module */
3561 static struct pci_driver net2280_pci_driver
= {
3562 .name
= (char *) driver_name
,
3563 .id_table
= pci_ids
,
3565 .probe
= net2280_probe
,
3566 .remove
= net2280_remove
,
3567 .shutdown
= net2280_shutdown
,
3569 /* FIXME add power management support */
3572 module_pci_driver(net2280_pci_driver
);
3574 MODULE_DESCRIPTION(DRIVER_DESC
);
3575 MODULE_AUTHOR("David Brownell");
3576 MODULE_LICENSE("GPL");