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 /* mode 0 == ep-{a,b,c,d} 1K fifo each
84 * mode 1 == ep-{a,b} 2K fifo each, ep-{c,d} unavailable
85 * mode 2 == ep-a 2K fifo, ep-{b,c} 1K each, ep-d unavailable
87 static ushort fifo_mode
;
89 /* "modprobe net2280 fifo_mode=1" etc */
90 module_param(fifo_mode
, ushort
, 0644);
92 /* enable_suspend -- When enabled, the driver will respond to
93 * USB suspend requests by powering down the NET2280. Otherwise,
94 * USB suspend requests will be ignored. This is acceptable for
95 * self-powered devices
97 static bool enable_suspend
;
99 /* "modprobe net2280 enable_suspend=1" etc */
100 module_param(enable_suspend
, bool, 0444);
102 #define DIR_STRING(bAddress) (((bAddress) & USB_DIR_IN) ? "in" : "out")
104 static char *type_string(u8 bmAttributes
)
106 switch ((bmAttributes
) & USB_ENDPOINT_XFERTYPE_MASK
) {
107 case USB_ENDPOINT_XFER_BULK
: return "bulk";
108 case USB_ENDPOINT_XFER_ISOC
: return "iso";
109 case USB_ENDPOINT_XFER_INT
: return "intr";
116 #define valid_bit cpu_to_le32(BIT(VALID_BIT))
117 #define dma_done_ie cpu_to_le32(BIT(DMA_DONE_INTERRUPT_ENABLE))
119 /*-------------------------------------------------------------------------*/
120 static inline void enable_pciirqenb(struct net2280_ep
*ep
)
122 u32 tmp
= readl(&ep
->dev
->regs
->pciirqenb0
);
124 if (ep
->dev
->quirks
& PLX_LEGACY
)
127 tmp
|= BIT(ep_bit
[ep
->num
]);
128 writel(tmp
, &ep
->dev
->regs
->pciirqenb0
);
134 net2280_enable(struct usb_ep
*_ep
, const struct usb_endpoint_descriptor
*desc
)
137 struct net2280_ep
*ep
;
140 static const u32 ep_key
[9] = { 1, 0, 1, 0, 1, 1, 0, 1, 0 };
142 ep
= container_of(_ep
, struct net2280_ep
, ep
);
143 if (!_ep
|| !desc
|| ep
->desc
|| _ep
->name
== ep0name
||
144 desc
->bDescriptorType
!= USB_DT_ENDPOINT
)
147 if (!dev
->driver
|| dev
->gadget
.speed
== USB_SPEED_UNKNOWN
)
150 /* erratum 0119 workaround ties up an endpoint number */
151 if ((desc
->bEndpointAddress
& 0x0f) == EP_DONTUSE
)
154 if (dev
->quirks
& PLX_SUPERSPEED
) {
155 if ((desc
->bEndpointAddress
& 0x0f) >= 0x0c)
157 ep
->is_in
= !!usb_endpoint_dir_in(desc
);
158 if (dev
->enhanced_mode
&& ep
->is_in
&& ep_key
[ep
->num
])
162 /* sanity check ep-e/ep-f since their fifos are small */
163 max
= usb_endpoint_maxp(desc
) & 0x1fff;
164 if (ep
->num
> 4 && max
> 64 && (dev
->quirks
& PLX_LEGACY
))
167 spin_lock_irqsave(&dev
->lock
, flags
);
168 _ep
->maxpacket
= max
& 0x7ff;
171 /* ep_reset() has already been called */
174 ep
->out_overflow
= 0;
176 /* set speed-dependent max packet; may kick in high bandwidth */
177 set_max_speed(ep
, max
);
179 /* set type, direction, address; reset fifo counters */
180 writel(BIT(FIFO_FLUSH
), &ep
->regs
->ep_stat
);
181 tmp
= (desc
->bmAttributes
& USB_ENDPOINT_XFERTYPE_MASK
);
182 if (tmp
== USB_ENDPOINT_XFER_INT
) {
183 /* erratum 0105 workaround prevents hs NYET */
184 if (dev
->chiprev
== 0100 &&
185 dev
->gadget
.speed
== USB_SPEED_HIGH
&&
186 !(desc
->bEndpointAddress
& USB_DIR_IN
))
187 writel(BIT(CLEAR_NAK_OUT_PACKETS_MODE
),
189 } else if (tmp
== USB_ENDPOINT_XFER_BULK
) {
190 /* catch some particularly blatant driver bugs */
191 if ((dev
->gadget
.speed
== USB_SPEED_SUPER
&& max
!= 1024) ||
192 (dev
->gadget
.speed
== USB_SPEED_HIGH
&& max
!= 512) ||
193 (dev
->gadget
.speed
== USB_SPEED_FULL
&& max
> 64)) {
194 spin_unlock_irqrestore(&dev
->lock
, flags
);
198 ep
->is_iso
= (tmp
== USB_ENDPOINT_XFER_ISOC
);
199 /* Enable this endpoint */
200 if (dev
->quirks
& PLX_LEGACY
) {
201 tmp
<<= ENDPOINT_TYPE
;
202 tmp
|= desc
->bEndpointAddress
;
203 /* default full fifo lines */
204 tmp
|= (4 << ENDPOINT_BYTE_COUNT
);
205 tmp
|= BIT(ENDPOINT_ENABLE
);
206 ep
->is_in
= (tmp
& USB_DIR_IN
) != 0;
208 /* In Legacy mode, only OUT endpoints are used */
209 if (dev
->enhanced_mode
&& ep
->is_in
) {
210 tmp
<<= IN_ENDPOINT_TYPE
;
211 tmp
|= BIT(IN_ENDPOINT_ENABLE
);
212 /* Not applicable to Legacy */
213 tmp
|= BIT(ENDPOINT_DIRECTION
);
215 tmp
<<= OUT_ENDPOINT_TYPE
;
216 tmp
|= BIT(OUT_ENDPOINT_ENABLE
);
217 tmp
|= (ep
->is_in
<< ENDPOINT_DIRECTION
);
220 tmp
|= usb_endpoint_num(desc
);
221 tmp
|= (ep
->ep
.maxburst
<< MAX_BURST_SIZE
);
224 /* Make sure all the registers are written before ep_rsp*/
227 /* for OUT transfers, block the rx fifo until a read is posted */
229 writel(BIT(SET_NAK_OUT_PACKETS
), &ep
->regs
->ep_rsp
);
230 else if (!(dev
->quirks
& PLX_2280
)) {
231 /* Added for 2282, Don't use nak packets on an in endpoint,
232 * this was ignored on 2280
234 writel(BIT(CLEAR_NAK_OUT_PACKETS
) |
235 BIT(CLEAR_NAK_OUT_PACKETS_MODE
), &ep
->regs
->ep_rsp
);
238 writel(tmp
, &ep
->cfg
->ep_cfg
);
241 if (!ep
->dma
) { /* pio, per-packet */
242 enable_pciirqenb(ep
);
244 tmp
= BIT(DATA_PACKET_RECEIVED_INTERRUPT_ENABLE
) |
245 BIT(DATA_PACKET_TRANSMITTED_INTERRUPT_ENABLE
);
246 if (dev
->quirks
& PLX_2280
)
247 tmp
|= readl(&ep
->regs
->ep_irqenb
);
248 writel(tmp
, &ep
->regs
->ep_irqenb
);
249 } else { /* dma, per-request */
250 tmp
= BIT((8 + ep
->num
)); /* completion */
251 tmp
|= readl(&dev
->regs
->pciirqenb1
);
252 writel(tmp
, &dev
->regs
->pciirqenb1
);
254 /* for short OUT transfers, dma completions can't
255 * advance the queue; do it pio-style, by hand.
256 * NOTE erratum 0112 workaround #2
258 if ((desc
->bEndpointAddress
& USB_DIR_IN
) == 0) {
259 tmp
= BIT(SHORT_PACKET_TRANSFERRED_INTERRUPT_ENABLE
);
260 writel(tmp
, &ep
->regs
->ep_irqenb
);
262 enable_pciirqenb(ep
);
266 tmp
= desc
->bEndpointAddress
;
267 ep_dbg(dev
, "enabled %s (ep%d%s-%s) %s max %04x\n",
268 _ep
->name
, tmp
& 0x0f, DIR_STRING(tmp
),
269 type_string(desc
->bmAttributes
),
270 ep
->dma
? "dma" : "pio", max
);
272 /* pci writes may still be posted */
273 spin_unlock_irqrestore(&dev
->lock
, flags
);
277 static int handshake(u32 __iomem
*ptr
, u32 mask
, u32 done
, int usec
)
283 if (result
== ~(u32
)0) /* "device unplugged" */
294 static const struct usb_ep_ops net2280_ep_ops
;
296 static void ep_reset_228x(struct net2280_regs __iomem
*regs
,
297 struct net2280_ep
*ep
)
302 INIT_LIST_HEAD(&ep
->queue
);
304 usb_ep_set_maxpacket_limit(&ep
->ep
, ~0);
305 ep
->ep
.ops
= &net2280_ep_ops
;
307 /* disable the dma, irqs, endpoint... */
309 writel(0, &ep
->dma
->dmactl
);
310 writel(BIT(DMA_SCATTER_GATHER_DONE_INTERRUPT
) |
311 BIT(DMA_TRANSACTION_DONE_INTERRUPT
) |
315 tmp
= readl(®s
->pciirqenb0
);
316 tmp
&= ~BIT(ep
->num
);
317 writel(tmp
, ®s
->pciirqenb0
);
319 tmp
= readl(®s
->pciirqenb1
);
320 tmp
&= ~BIT((8 + ep
->num
)); /* completion */
321 writel(tmp
, ®s
->pciirqenb1
);
323 writel(0, &ep
->regs
->ep_irqenb
);
325 /* init to our chosen defaults, notably so that we NAK OUT
326 * packets until the driver queues a read (+note erratum 0112)
328 if (!ep
->is_in
|| (ep
->dev
->quirks
& PLX_2280
)) {
329 tmp
= BIT(SET_NAK_OUT_PACKETS_MODE
) |
330 BIT(SET_NAK_OUT_PACKETS
) |
331 BIT(CLEAR_EP_HIDE_STATUS_PHASE
) |
332 BIT(CLEAR_INTERRUPT_MODE
);
335 tmp
= BIT(CLEAR_NAK_OUT_PACKETS_MODE
) |
336 BIT(CLEAR_NAK_OUT_PACKETS
) |
337 BIT(CLEAR_EP_HIDE_STATUS_PHASE
) |
338 BIT(CLEAR_INTERRUPT_MODE
);
342 tmp
|= BIT(CLEAR_ENDPOINT_TOGGLE
) |
343 BIT(CLEAR_ENDPOINT_HALT
);
345 writel(tmp
, &ep
->regs
->ep_rsp
);
347 /* scrub most status bits, and flush any fifo state */
348 if (ep
->dev
->quirks
& PLX_2280
)
349 tmp
= BIT(FIFO_OVERFLOW
) |
354 writel(tmp
| BIT(TIMEOUT
) |
355 BIT(USB_STALL_SENT
) |
356 BIT(USB_IN_NAK_SENT
) |
357 BIT(USB_IN_ACK_RCVD
) |
358 BIT(USB_OUT_PING_NAK_SENT
) |
359 BIT(USB_OUT_ACK_SENT
) |
361 BIT(SHORT_PACKET_OUT_DONE_INTERRUPT
) |
362 BIT(SHORT_PACKET_TRANSFERRED_INTERRUPT
) |
363 BIT(DATA_PACKET_RECEIVED_INTERRUPT
) |
364 BIT(DATA_PACKET_TRANSMITTED_INTERRUPT
) |
365 BIT(DATA_OUT_PING_TOKEN_INTERRUPT
) |
366 BIT(DATA_IN_TOKEN_INTERRUPT
),
369 /* fifo size is handled separately */
372 static void ep_reset_338x(struct net2280_regs __iomem
*regs
,
373 struct net2280_ep
*ep
)
378 INIT_LIST_HEAD(&ep
->queue
);
380 usb_ep_set_maxpacket_limit(&ep
->ep
, ~0);
381 ep
->ep
.ops
= &net2280_ep_ops
;
383 /* disable the dma, irqs, endpoint... */
385 writel(0, &ep
->dma
->dmactl
);
386 writel(BIT(DMA_ABORT_DONE_INTERRUPT
) |
387 BIT(DMA_PAUSE_DONE_INTERRUPT
) |
388 BIT(DMA_SCATTER_GATHER_DONE_INTERRUPT
) |
389 BIT(DMA_TRANSACTION_DONE_INTERRUPT
),
390 /* | BIT(DMA_ABORT), */
393 dmastat
= readl(&ep
->dma
->dmastat
);
394 if (dmastat
== 0x5002) {
395 ep_warn(ep
->dev
, "The dmastat return = %x!!\n",
397 writel(0x5a, &ep
->dma
->dmastat
);
400 tmp
= readl(®s
->pciirqenb0
);
401 tmp
&= ~BIT(ep_bit
[ep
->num
]);
402 writel(tmp
, ®s
->pciirqenb0
);
405 tmp
= readl(®s
->pciirqenb1
);
406 tmp
&= ~BIT((8 + ep
->num
)); /* completion */
407 writel(tmp
, ®s
->pciirqenb1
);
410 writel(0, &ep
->regs
->ep_irqenb
);
412 writel(BIT(SHORT_PACKET_OUT_DONE_INTERRUPT
) |
413 BIT(SHORT_PACKET_TRANSFERRED_INTERRUPT
) |
415 BIT(DATA_PACKET_RECEIVED_INTERRUPT
) |
416 BIT(DATA_PACKET_TRANSMITTED_INTERRUPT
) |
417 BIT(DATA_OUT_PING_TOKEN_INTERRUPT
) |
418 BIT(DATA_IN_TOKEN_INTERRUPT
), &ep
->regs
->ep_stat
);
421 static void nuke(struct net2280_ep
*);
423 static int net2280_disable(struct usb_ep
*_ep
)
425 struct net2280_ep
*ep
;
428 ep
= container_of(_ep
, struct net2280_ep
, ep
);
429 if (!_ep
|| !ep
->desc
|| _ep
->name
== ep0name
)
432 spin_lock_irqsave(&ep
->dev
->lock
, flags
);
435 if (ep
->dev
->quirks
& PLX_SUPERSPEED
)
436 ep_reset_338x(ep
->dev
->regs
, ep
);
438 ep_reset_228x(ep
->dev
->regs
, ep
);
440 ep_vdbg(ep
->dev
, "disabled %s %s\n",
441 ep
->dma
? "dma" : "pio", _ep
->name
);
443 /* synch memory views with the device */
444 (void)readl(&ep
->cfg
->ep_cfg
);
446 if (!ep
->dma
&& ep
->num
>= 1 && ep
->num
<= 4)
447 ep
->dma
= &ep
->dev
->dma
[ep
->num
- 1];
449 spin_unlock_irqrestore(&ep
->dev
->lock
, flags
);
453 /*-------------------------------------------------------------------------*/
455 static struct usb_request
456 *net2280_alloc_request(struct usb_ep
*_ep
, gfp_t gfp_flags
)
458 struct net2280_ep
*ep
;
459 struct net2280_request
*req
;
463 ep
= container_of(_ep
, struct net2280_ep
, ep
);
465 req
= kzalloc(sizeof(*req
), gfp_flags
);
469 INIT_LIST_HEAD(&req
->queue
);
471 /* this dma descriptor may be swapped with the previous dummy */
473 struct net2280_dma
*td
;
475 td
= pci_pool_alloc(ep
->dev
->requests
, gfp_flags
,
481 td
->dmacount
= 0; /* not VALID */
482 td
->dmadesc
= td
->dmaaddr
;
488 static void net2280_free_request(struct usb_ep
*_ep
, struct usb_request
*_req
)
490 struct net2280_ep
*ep
;
491 struct net2280_request
*req
;
493 ep
= container_of(_ep
, struct net2280_ep
, ep
);
497 req
= container_of(_req
, struct net2280_request
, req
);
498 WARN_ON(!list_empty(&req
->queue
));
500 pci_pool_free(ep
->dev
->requests
, req
->td
, req
->td_dma
);
504 /*-------------------------------------------------------------------------*/
506 /* load a packet into the fifo we use for usb IN transfers.
507 * works for all endpoints.
509 * NOTE: pio with ep-a..ep-d could stuff multiple packets into the fifo
510 * at a time, but this code is simpler because it knows it only writes
511 * one packet. ep-a..ep-d should use dma instead.
513 static void write_fifo(struct net2280_ep
*ep
, struct usb_request
*req
)
515 struct net2280_ep_regs __iomem
*regs
= ep
->regs
;
518 unsigned count
, total
;
520 /* INVARIANT: fifo is currently empty. (testable) */
523 buf
= req
->buf
+ req
->actual
;
525 total
= req
->length
- req
->actual
;
531 /* write just one packet at a time */
532 count
= ep
->ep
.maxpacket
;
533 if (count
> total
) /* min() cannot be used on a bitfield */
536 ep_vdbg(ep
->dev
, "write %s fifo (IN) %d bytes%s req %p\n",
538 (count
!= ep
->ep
.maxpacket
) ? " (short)" : "",
541 /* NOTE be careful if you try to align these. fifo lines
542 * should normally be full (4 bytes) and successive partial
543 * lines are ok only in certain cases.
545 tmp
= get_unaligned((u32
*)buf
);
547 writel(tmp
, ®s
->ep_data
);
552 /* last fifo entry is "short" unless we wrote a full packet.
553 * also explicitly validate last word in (periodic) transfers
554 * when maxpacket is not a multiple of 4 bytes.
556 if (count
|| total
< ep
->ep
.maxpacket
) {
557 tmp
= count
? get_unaligned((u32
*)buf
) : count
;
559 set_fifo_bytecount(ep
, count
& 0x03);
560 writel(tmp
, ®s
->ep_data
);
563 /* pci writes may still be posted */
566 /* work around erratum 0106: PCI and USB race over the OUT fifo.
567 * caller guarantees chiprev 0100, out endpoint is NAKing, and
568 * there's no real data in the fifo.
570 * NOTE: also used in cases where that erratum doesn't apply:
571 * where the host wrote "too much" data to us.
573 static void out_flush(struct net2280_ep
*ep
)
578 statp
= &ep
->regs
->ep_stat
;
581 if (tmp
& BIT(NAK_OUT_PACKETS
)) {
582 ep_dbg(ep
->dev
, "%s %s %08x !NAK\n",
583 ep
->ep
.name
, __func__
, tmp
);
584 writel(BIT(SET_NAK_OUT_PACKETS
), &ep
->regs
->ep_rsp
);
587 writel(BIT(DATA_OUT_PING_TOKEN_INTERRUPT
) |
588 BIT(DATA_PACKET_RECEIVED_INTERRUPT
),
590 writel(BIT(FIFO_FLUSH
), statp
);
591 /* Make sure that stap is written */
594 if (tmp
& BIT(DATA_OUT_PING_TOKEN_INTERRUPT
) &&
595 /* high speed did bulk NYET; fifo isn't filling */
596 ep
->dev
->gadget
.speed
== USB_SPEED_FULL
) {
599 usec
= 50; /* 64 byte bulk/interrupt */
600 handshake(statp
, BIT(USB_OUT_PING_NAK_SENT
),
601 BIT(USB_OUT_PING_NAK_SENT
), usec
);
602 /* NAK done; now CLEAR_NAK_OUT_PACKETS is safe */
606 /* unload packet(s) from the fifo we use for usb OUT transfers.
607 * returns true iff the request completed, because of short packet
608 * or the request buffer having filled with full packets.
610 * for ep-a..ep-d this will read multiple packets out when they
611 * have been accepted.
613 static int read_fifo(struct net2280_ep
*ep
, struct net2280_request
*req
)
615 struct net2280_ep_regs __iomem
*regs
= ep
->regs
;
616 u8
*buf
= req
->req
.buf
+ req
->req
.actual
;
617 unsigned count
, tmp
, is_short
;
618 unsigned cleanup
= 0, prevent
= 0;
620 /* erratum 0106 ... packets coming in during fifo reads might
621 * be incompletely rejected. not all cases have workarounds.
623 if (ep
->dev
->chiprev
== 0x0100 &&
624 ep
->dev
->gadget
.speed
== USB_SPEED_FULL
) {
626 tmp
= readl(&ep
->regs
->ep_stat
);
627 if ((tmp
& BIT(NAK_OUT_PACKETS
)))
629 else if ((tmp
& BIT(FIFO_FULL
))) {
630 start_out_naking(ep
);
633 /* else: hope we don't see the problem */
636 /* never overflow the rx buffer. the fifo reads packets until
637 * it sees a short one; we might not be ready for them all.
640 count
= readl(®s
->ep_avail
);
641 if (unlikely(count
== 0)) {
643 tmp
= readl(&ep
->regs
->ep_stat
);
644 count
= readl(®s
->ep_avail
);
645 /* handled that data already? */
646 if (count
== 0 && (tmp
& BIT(NAK_OUT_PACKETS
)) == 0)
650 tmp
= req
->req
.length
- req
->req
.actual
;
652 /* as with DMA, data overflow gets flushed */
653 if ((tmp
% ep
->ep
.maxpacket
) != 0) {
655 "%s out fifo %d bytes, expected %d\n",
656 ep
->ep
.name
, count
, tmp
);
657 req
->req
.status
= -EOVERFLOW
;
659 /* NAK_OUT_PACKETS will be set, so flushing is safe;
660 * the next read will start with the next packet
662 } /* else it's a ZLP, no worries */
665 req
->req
.actual
+= count
;
667 is_short
= (count
== 0) || ((count
% ep
->ep
.maxpacket
) != 0);
669 ep_vdbg(ep
->dev
, "read %s fifo (OUT) %d bytes%s%s%s req %p %d/%d\n",
670 ep
->ep
.name
, count
, is_short
? " (short)" : "",
671 cleanup
? " flush" : "", prevent
? " nak" : "",
672 req
, req
->req
.actual
, req
->req
.length
);
675 tmp
= readl(®s
->ep_data
);
677 put_unaligned(tmp
, (u32
*)buf
);
682 tmp
= readl(®s
->ep_data
);
683 /* LE conversion is implicit here: */
692 writel(BIT(CLEAR_NAK_OUT_PACKETS
), &ep
->regs
->ep_rsp
);
693 (void) readl(&ep
->regs
->ep_rsp
);
696 return is_short
|| ((req
->req
.actual
== req
->req
.length
) &&
700 /* fill out dma descriptor to match a given request */
701 static void fill_dma_desc(struct net2280_ep
*ep
,
702 struct net2280_request
*req
, int valid
)
704 struct net2280_dma
*td
= req
->td
;
705 u32 dmacount
= req
->req
.length
;
707 /* don't let DMA continue after a short OUT packet,
708 * so overruns can't affect the next transfer.
709 * in case of overruns on max-size packets, we can't
710 * stop the fifo from filling but we can flush it.
713 dmacount
|= BIT(DMA_DIRECTION
);
714 if ((!ep
->is_in
&& (dmacount
% ep
->ep
.maxpacket
) != 0) ||
715 !(ep
->dev
->quirks
& PLX_2280
))
716 dmacount
|= BIT(END_OF_CHAIN
);
720 dmacount
|= BIT(VALID_BIT
);
721 dmacount
|= BIT(DMA_DONE_INTERRUPT_ENABLE
);
723 /* td->dmadesc = previously set by caller */
724 td
->dmaaddr
= cpu_to_le32 (req
->req
.dma
);
726 /* 2280 may be polling VALID_BIT through ep->dma->dmadesc */
728 td
->dmacount
= cpu_to_le32(dmacount
);
731 static const u32 dmactl_default
=
732 BIT(DMA_SCATTER_GATHER_DONE_INTERRUPT
) |
733 BIT(DMA_CLEAR_COUNT_ENABLE
) |
734 /* erratum 0116 workaround part 1 (use POLLING) */
735 (POLL_100_USEC
<< DESCRIPTOR_POLLING_RATE
) |
736 BIT(DMA_VALID_BIT_POLLING_ENABLE
) |
737 BIT(DMA_VALID_BIT_ENABLE
) |
738 BIT(DMA_SCATTER_GATHER_ENABLE
) |
739 /* erratum 0116 workaround part 2 (no AUTOSTART) */
742 static inline void spin_stop_dma(struct net2280_dma_regs __iomem
*dma
)
744 handshake(&dma
->dmactl
, BIT(DMA_ENABLE
), 0, 50);
747 static inline void stop_dma(struct net2280_dma_regs __iomem
*dma
)
749 writel(readl(&dma
->dmactl
) & ~BIT(DMA_ENABLE
), &dma
->dmactl
);
753 static void start_queue(struct net2280_ep
*ep
, u32 dmactl
, u32 td_dma
)
755 struct net2280_dma_regs __iomem
*dma
= ep
->dma
;
756 unsigned int tmp
= BIT(VALID_BIT
) | (ep
->is_in
<< DMA_DIRECTION
);
758 if (!(ep
->dev
->quirks
& PLX_2280
))
759 tmp
|= BIT(END_OF_CHAIN
);
761 writel(tmp
, &dma
->dmacount
);
762 writel(readl(&dma
->dmastat
), &dma
->dmastat
);
764 writel(td_dma
, &dma
->dmadesc
);
765 if (ep
->dev
->quirks
& PLX_SUPERSPEED
)
766 dmactl
|= BIT(DMA_REQUEST_OUTSTANDING
);
767 writel(dmactl
, &dma
->dmactl
);
769 /* erratum 0116 workaround part 3: pci arbiter away from net2280 */
770 (void) readl(&ep
->dev
->pci
->pcimstctl
);
772 writel(BIT(DMA_START
), &dma
->dmastat
);
778 static void start_dma(struct net2280_ep
*ep
, struct net2280_request
*req
)
781 struct net2280_dma_regs __iomem
*dma
= ep
->dma
;
783 /* FIXME can't use DMA for ZLPs */
785 /* on this path we "know" there's no dma active (yet) */
786 WARN_ON(readl(&dma
->dmactl
) & BIT(DMA_ENABLE
));
787 writel(0, &ep
->dma
->dmactl
);
789 /* previous OUT packet might have been short */
790 if (!ep
->is_in
&& (readl(&ep
->regs
->ep_stat
) &
791 BIT(NAK_OUT_PACKETS
))) {
792 writel(BIT(SHORT_PACKET_TRANSFERRED_INTERRUPT
),
795 tmp
= readl(&ep
->regs
->ep_avail
);
797 writel(readl(&dma
->dmastat
), &dma
->dmastat
);
799 /* transfer all/some fifo data */
800 writel(req
->req
.dma
, &dma
->dmaaddr
);
801 tmp
= min(tmp
, req
->req
.length
);
803 /* dma irq, faking scatterlist status */
804 req
->td
->dmacount
= cpu_to_le32(req
->req
.length
- tmp
);
805 writel(BIT(DMA_DONE_INTERRUPT_ENABLE
) | tmp
,
807 req
->td
->dmadesc
= 0;
810 writel(BIT(DMA_ENABLE
), &dma
->dmactl
);
811 writel(BIT(DMA_START
), &dma
->dmastat
);
816 tmp
= dmactl_default
;
818 /* force packet boundaries between dma requests, but prevent the
819 * controller from automagically writing a last "short" packet
820 * (zero length) unless the driver explicitly said to do that.
823 if (likely((req
->req
.length
% ep
->ep
.maxpacket
) ||
825 tmp
|= BIT(DMA_FIFO_VALIDATE
);
826 ep
->in_fifo_validate
= 1;
828 ep
->in_fifo_validate
= 0;
831 /* init req->td, pointing to the current dummy */
832 req
->td
->dmadesc
= cpu_to_le32 (ep
->td_dma
);
833 fill_dma_desc(ep
, req
, 1);
835 req
->td
->dmacount
|= cpu_to_le32(BIT(END_OF_CHAIN
));
837 start_queue(ep
, tmp
, req
->td_dma
);
841 queue_dma(struct net2280_ep
*ep
, struct net2280_request
*req
, int valid
)
843 struct net2280_dma
*end
;
846 /* swap new dummy for old, link; fill and maybe activate */
852 ep
->td_dma
= req
->td_dma
;
855 end
->dmadesc
= cpu_to_le32 (ep
->td_dma
);
857 fill_dma_desc(ep
, req
, valid
);
861 done(struct net2280_ep
*ep
, struct net2280_request
*req
, int status
)
864 unsigned stopped
= ep
->stopped
;
866 list_del_init(&req
->queue
);
868 if (req
->req
.status
== -EINPROGRESS
)
869 req
->req
.status
= status
;
871 status
= req
->req
.status
;
875 usb_gadget_unmap_request(&dev
->gadget
, &req
->req
, ep
->is_in
);
877 if (status
&& status
!= -ESHUTDOWN
)
878 ep_vdbg(dev
, "complete %s req %p stat %d len %u/%u\n",
879 ep
->ep
.name
, &req
->req
, status
,
880 req
->req
.actual
, req
->req
.length
);
882 /* don't modify queue heads during completion callback */
884 spin_unlock(&dev
->lock
);
885 usb_gadget_giveback_request(&ep
->ep
, &req
->req
);
886 spin_lock(&dev
->lock
);
887 ep
->stopped
= stopped
;
890 /*-------------------------------------------------------------------------*/
893 net2280_queue(struct usb_ep
*_ep
, struct usb_request
*_req
, gfp_t gfp_flags
)
895 struct net2280_request
*req
;
896 struct net2280_ep
*ep
;
900 /* we always require a cpu-view buffer, so that we can
901 * always use pio (as fallback or whatever).
903 req
= container_of(_req
, struct net2280_request
, req
);
904 if (!_req
|| !_req
->complete
|| !_req
->buf
||
905 !list_empty(&req
->queue
))
907 if (_req
->length
> (~0 & DMA_BYTE_COUNT_MASK
))
909 ep
= container_of(_ep
, struct net2280_ep
, ep
);
910 if (!_ep
|| (!ep
->desc
&& ep
->num
!= 0))
913 if (!dev
->driver
|| dev
->gadget
.speed
== USB_SPEED_UNKNOWN
)
916 /* FIXME implement PIO fallback for ZLPs with DMA */
917 if (ep
->dma
&& _req
->length
== 0)
920 /* set up dma mapping in case the caller didn't */
924 ret
= usb_gadget_map_request(&dev
->gadget
, _req
,
930 ep_vdbg(dev
, "%s queue req %p, len %d buf %p\n",
931 _ep
->name
, _req
, _req
->length
, _req
->buf
);
933 spin_lock_irqsave(&dev
->lock
, flags
);
935 _req
->status
= -EINPROGRESS
;
938 /* kickstart this i/o queue? */
939 if (list_empty(&ep
->queue
) && !ep
->stopped
&&
940 !((dev
->quirks
& PLX_SUPERSPEED
) && ep
->dma
&&
941 (readl(&ep
->regs
->ep_rsp
) & BIT(CLEAR_ENDPOINT_HALT
)))) {
943 /* use DMA if the endpoint supports it, else pio */
947 /* maybe there's no control data, just status ack */
948 if (ep
->num
== 0 && _req
->length
== 0) {
951 ep_vdbg(dev
, "%s status ack\n", ep
->ep
.name
);
955 /* PIO ... stuff the fifo, or unblock it. */
957 write_fifo(ep
, _req
);
958 else if (list_empty(&ep
->queue
)) {
961 /* OUT FIFO might have packet(s) buffered */
962 s
= readl(&ep
->regs
->ep_stat
);
963 if ((s
& BIT(FIFO_EMPTY
)) == 0) {
964 /* note: _req->short_not_ok is
965 * ignored here since PIO _always_
966 * stops queue advance here, and
967 * _req->status doesn't change for
968 * short reads (only _req->actual)
970 if (read_fifo(ep
, req
) &&
976 } else if (read_fifo(ep
, req
) &&
981 s
= readl(&ep
->regs
->ep_stat
);
984 /* don't NAK, let the fifo fill */
985 if (req
&& (s
& BIT(NAK_OUT_PACKETS
)))
986 writel(BIT(CLEAR_NAK_OUT_PACKETS
),
991 } else if (ep
->dma
) {
997 /* preventing magic zlps is per-engine state, not
998 * per-transfer; irq logic must recover hiccups.
1000 expect
= likely(req
->req
.zero
||
1001 (req
->req
.length
% ep
->ep
.maxpacket
));
1002 if (expect
!= ep
->in_fifo_validate
)
1005 queue_dma(ep
, req
, valid
);
1007 } /* else the irq handler advances the queue. */
1011 list_add_tail(&req
->queue
, &ep
->queue
);
1013 spin_unlock_irqrestore(&dev
->lock
, flags
);
1015 /* pci writes may still be posted */
1020 dma_done(struct net2280_ep
*ep
, struct net2280_request
*req
, u32 dmacount
,
1023 req
->req
.actual
= req
->req
.length
- (DMA_BYTE_COUNT_MASK
& dmacount
);
1024 done(ep
, req
, status
);
1027 static void scan_dma_completions(struct net2280_ep
*ep
)
1029 /* only look at descriptors that were "naturally" retired,
1030 * so fifo and list head state won't matter
1032 while (!list_empty(&ep
->queue
)) {
1033 struct net2280_request
*req
;
1036 req
= list_entry(ep
->queue
.next
,
1037 struct net2280_request
, queue
);
1041 tmp
= le32_to_cpup(&req
->td
->dmacount
);
1042 if ((tmp
& BIT(VALID_BIT
)) != 0)
1045 /* SHORT_PACKET_TRANSFERRED_INTERRUPT handles "usb-short"
1046 * cases where DMA must be aborted; this code handles
1047 * all non-abort DMA completions.
1049 if (unlikely(req
->td
->dmadesc
== 0)) {
1051 tmp
= readl(&ep
->dma
->dmacount
);
1052 if (tmp
& DMA_BYTE_COUNT_MASK
)
1054 /* single transfer mode */
1055 dma_done(ep
, req
, tmp
, 0);
1057 } else if (!ep
->is_in
&&
1058 (req
->req
.length
% ep
->ep
.maxpacket
) &&
1059 !(ep
->dev
->quirks
& PLX_SUPERSPEED
)) {
1061 tmp
= readl(&ep
->regs
->ep_stat
);
1062 /* AVOID TROUBLE HERE by not issuing short reads from
1063 * your gadget driver. That helps avoids errata 0121,
1064 * 0122, and 0124; not all cases trigger the warning.
1066 if ((tmp
& BIT(NAK_OUT_PACKETS
)) == 0) {
1067 ep_warn(ep
->dev
, "%s lost packet sync!\n",
1069 req
->req
.status
= -EOVERFLOW
;
1071 tmp
= readl(&ep
->regs
->ep_avail
);
1073 /* fifo gets flushed later */
1074 ep
->out_overflow
= 1;
1076 "%s dma, discard %d len %d\n",
1079 req
->req
.status
= -EOVERFLOW
;
1083 dma_done(ep
, req
, tmp
, 0);
1087 static void restart_dma(struct net2280_ep
*ep
)
1089 struct net2280_request
*req
;
1093 req
= list_entry(ep
->queue
.next
, struct net2280_request
, queue
);
1098 static void abort_dma(struct net2280_ep
*ep
)
1100 /* abort the current transfer */
1101 if (likely(!list_empty(&ep
->queue
))) {
1102 /* FIXME work around errata 0121, 0122, 0124 */
1103 writel(BIT(DMA_ABORT
), &ep
->dma
->dmastat
);
1104 spin_stop_dma(ep
->dma
);
1107 scan_dma_completions(ep
);
1110 /* dequeue ALL requests */
1111 static void nuke(struct net2280_ep
*ep
)
1113 struct net2280_request
*req
;
1115 /* called with spinlock held */
1119 while (!list_empty(&ep
->queue
)) {
1120 req
= list_entry(ep
->queue
.next
,
1121 struct net2280_request
,
1123 done(ep
, req
, -ESHUTDOWN
);
1127 /* dequeue JUST ONE request */
1128 static int net2280_dequeue(struct usb_ep
*_ep
, struct usb_request
*_req
)
1130 struct net2280_ep
*ep
;
1131 struct net2280_request
*req
;
1132 unsigned long flags
;
1136 ep
= container_of(_ep
, struct net2280_ep
, ep
);
1137 if (!_ep
|| (!ep
->desc
&& ep
->num
!= 0) || !_req
)
1140 spin_lock_irqsave(&ep
->dev
->lock
, flags
);
1141 stopped
= ep
->stopped
;
1143 /* quiesce dma while we patch the queue */
1147 dmactl
= readl(&ep
->dma
->dmactl
);
1148 /* WARNING erratum 0127 may kick in ... */
1150 scan_dma_completions(ep
);
1153 /* make sure it's still queued on this endpoint */
1154 list_for_each_entry(req
, &ep
->queue
, queue
) {
1155 if (&req
->req
== _req
)
1158 if (&req
->req
!= _req
) {
1159 spin_unlock_irqrestore(&ep
->dev
->lock
, flags
);
1163 /* queue head may be partially complete. */
1164 if (ep
->queue
.next
== &req
->queue
) {
1166 ep_dbg(ep
->dev
, "unlink (%s) dma\n", _ep
->name
);
1167 _req
->status
= -ECONNRESET
;
1169 if (likely(ep
->queue
.next
== &req
->queue
)) {
1170 /* NOTE: misreports single-transfer mode*/
1171 req
->td
->dmacount
= 0; /* invalidate */
1173 readl(&ep
->dma
->dmacount
),
1177 ep_dbg(ep
->dev
, "unlink (%s) pio\n", _ep
->name
);
1178 done(ep
, req
, -ECONNRESET
);
1184 done(ep
, req
, -ECONNRESET
);
1185 ep
->stopped
= stopped
;
1188 /* turn off dma on inactive queues */
1189 if (list_empty(&ep
->queue
))
1191 else if (!ep
->stopped
) {
1192 /* resume current request, or start new one */
1194 writel(dmactl
, &ep
->dma
->dmactl
);
1196 start_dma(ep
, list_entry(ep
->queue
.next
,
1197 struct net2280_request
, queue
));
1201 spin_unlock_irqrestore(&ep
->dev
->lock
, flags
);
1205 /*-------------------------------------------------------------------------*/
1207 static int net2280_fifo_status(struct usb_ep
*_ep
);
1210 net2280_set_halt_and_wedge(struct usb_ep
*_ep
, int value
, int wedged
)
1212 struct net2280_ep
*ep
;
1213 unsigned long flags
;
1216 ep
= container_of(_ep
, struct net2280_ep
, ep
);
1217 if (!_ep
|| (!ep
->desc
&& ep
->num
!= 0))
1219 if (!ep
->dev
->driver
|| ep
->dev
->gadget
.speed
== USB_SPEED_UNKNOWN
)
1221 if (ep
->desc
/* not ep0 */ && (ep
->desc
->bmAttributes
& 0x03)
1222 == USB_ENDPOINT_XFER_ISOC
)
1225 spin_lock_irqsave(&ep
->dev
->lock
, flags
);
1226 if (!list_empty(&ep
->queue
))
1228 else if (ep
->is_in
&& value
&& net2280_fifo_status(_ep
) != 0)
1231 ep_vdbg(ep
->dev
, "%s %s %s\n", _ep
->name
,
1232 value
? "set" : "clear",
1233 wedged
? "wedge" : "halt");
1234 /* set/clear, then synch memory views with the device */
1237 ep
->dev
->protocol_stall
= 1;
1244 if (ep
->dev
->quirks
& PLX_SUPERSPEED
&&
1245 !list_empty(&ep
->queue
) && ep
->td_dma
)
1249 (void) readl(&ep
->regs
->ep_rsp
);
1251 spin_unlock_irqrestore(&ep
->dev
->lock
, flags
);
1256 static int net2280_set_halt(struct usb_ep
*_ep
, int value
)
1258 return net2280_set_halt_and_wedge(_ep
, value
, 0);
1261 static int net2280_set_wedge(struct usb_ep
*_ep
)
1263 if (!_ep
|| _ep
->name
== ep0name
)
1265 return net2280_set_halt_and_wedge(_ep
, 1, 1);
1268 static int net2280_fifo_status(struct usb_ep
*_ep
)
1270 struct net2280_ep
*ep
;
1273 ep
= container_of(_ep
, struct net2280_ep
, ep
);
1274 if (!_ep
|| (!ep
->desc
&& ep
->num
!= 0))
1276 if (!ep
->dev
->driver
|| ep
->dev
->gadget
.speed
== USB_SPEED_UNKNOWN
)
1279 avail
= readl(&ep
->regs
->ep_avail
) & (BIT(12) - 1);
1280 if (avail
> ep
->fifo_size
)
1283 avail
= ep
->fifo_size
- avail
;
1287 static void net2280_fifo_flush(struct usb_ep
*_ep
)
1289 struct net2280_ep
*ep
;
1291 ep
= container_of(_ep
, struct net2280_ep
, ep
);
1292 if (!_ep
|| (!ep
->desc
&& ep
->num
!= 0))
1294 if (!ep
->dev
->driver
|| ep
->dev
->gadget
.speed
== USB_SPEED_UNKNOWN
)
1297 writel(BIT(FIFO_FLUSH
), &ep
->regs
->ep_stat
);
1298 (void) readl(&ep
->regs
->ep_rsp
);
1301 static const struct usb_ep_ops net2280_ep_ops
= {
1302 .enable
= net2280_enable
,
1303 .disable
= net2280_disable
,
1305 .alloc_request
= net2280_alloc_request
,
1306 .free_request
= net2280_free_request
,
1308 .queue
= net2280_queue
,
1309 .dequeue
= net2280_dequeue
,
1311 .set_halt
= net2280_set_halt
,
1312 .set_wedge
= net2280_set_wedge
,
1313 .fifo_status
= net2280_fifo_status
,
1314 .fifo_flush
= net2280_fifo_flush
,
1317 /*-------------------------------------------------------------------------*/
1319 static int net2280_get_frame(struct usb_gadget
*_gadget
)
1321 struct net2280
*dev
;
1322 unsigned long flags
;
1327 dev
= container_of(_gadget
, struct net2280
, gadget
);
1328 spin_lock_irqsave(&dev
->lock
, flags
);
1329 retval
= get_idx_reg(dev
->regs
, REG_FRAME
) & 0x03ff;
1330 spin_unlock_irqrestore(&dev
->lock
, flags
);
1334 static int net2280_wakeup(struct usb_gadget
*_gadget
)
1336 struct net2280
*dev
;
1338 unsigned long flags
;
1342 dev
= container_of(_gadget
, struct net2280
, gadget
);
1344 spin_lock_irqsave(&dev
->lock
, flags
);
1345 tmp
= readl(&dev
->usb
->usbctl
);
1346 if (tmp
& BIT(DEVICE_REMOTE_WAKEUP_ENABLE
))
1347 writel(BIT(GENERATE_RESUME
), &dev
->usb
->usbstat
);
1348 spin_unlock_irqrestore(&dev
->lock
, flags
);
1350 /* pci writes may still be posted */
1354 static int net2280_set_selfpowered(struct usb_gadget
*_gadget
, int value
)
1356 struct net2280
*dev
;
1358 unsigned long flags
;
1362 dev
= container_of(_gadget
, struct net2280
, gadget
);
1364 spin_lock_irqsave(&dev
->lock
, flags
);
1365 tmp
= readl(&dev
->usb
->usbctl
);
1367 tmp
|= BIT(SELF_POWERED_STATUS
);
1368 _gadget
->is_selfpowered
= 1;
1370 tmp
&= ~BIT(SELF_POWERED_STATUS
);
1371 _gadget
->is_selfpowered
= 0;
1373 writel(tmp
, &dev
->usb
->usbctl
);
1374 spin_unlock_irqrestore(&dev
->lock
, flags
);
1379 static int net2280_pullup(struct usb_gadget
*_gadget
, int is_on
)
1381 struct net2280
*dev
;
1383 unsigned long flags
;
1387 dev
= container_of(_gadget
, struct net2280
, gadget
);
1389 spin_lock_irqsave(&dev
->lock
, flags
);
1390 tmp
= readl(&dev
->usb
->usbctl
);
1391 dev
->softconnect
= (is_on
!= 0);
1393 tmp
|= BIT(USB_DETECT_ENABLE
);
1395 tmp
&= ~BIT(USB_DETECT_ENABLE
);
1396 writel(tmp
, &dev
->usb
->usbctl
);
1397 spin_unlock_irqrestore(&dev
->lock
, flags
);
1402 static int net2280_start(struct usb_gadget
*_gadget
,
1403 struct usb_gadget_driver
*driver
);
1404 static int net2280_stop(struct usb_gadget
*_gadget
);
1406 static const struct usb_gadget_ops net2280_ops
= {
1407 .get_frame
= net2280_get_frame
,
1408 .wakeup
= net2280_wakeup
,
1409 .set_selfpowered
= net2280_set_selfpowered
,
1410 .pullup
= net2280_pullup
,
1411 .udc_start
= net2280_start
,
1412 .udc_stop
= net2280_stop
,
1415 /*-------------------------------------------------------------------------*/
1417 #ifdef CONFIG_USB_GADGET_DEBUG_FILES
1419 /* FIXME move these into procfs, and use seq_file.
1420 * Sysfs _still_ doesn't behave for arbitrarily sized files,
1421 * and also doesn't help products using this with 2.4 kernels.
1424 /* "function" sysfs attribute */
1425 static ssize_t
function_show(struct device
*_dev
, struct device_attribute
*attr
,
1428 struct net2280
*dev
= dev_get_drvdata(_dev
);
1430 if (!dev
->driver
|| !dev
->driver
->function
||
1431 strlen(dev
->driver
->function
) > PAGE_SIZE
)
1433 return scnprintf(buf
, PAGE_SIZE
, "%s\n", dev
->driver
->function
);
1435 static DEVICE_ATTR_RO(function
);
1437 static ssize_t
registers_show(struct device
*_dev
,
1438 struct device_attribute
*attr
, char *buf
)
1440 struct net2280
*dev
;
1443 unsigned long flags
;
1448 dev
= dev_get_drvdata(_dev
);
1451 spin_lock_irqsave(&dev
->lock
, flags
);
1454 s
= dev
->driver
->driver
.name
;
1458 /* Main Control Registers */
1459 t
= scnprintf(next
, size
, "%s version " DRIVER_VERSION
1460 ", chiprev %04x\n\n"
1461 "devinit %03x fifoctl %08x gadget '%s'\n"
1462 "pci irqenb0 %02x irqenb1 %08x "
1463 "irqstat0 %04x irqstat1 %08x\n",
1464 driver_name
, dev
->chiprev
,
1465 readl(&dev
->regs
->devinit
),
1466 readl(&dev
->regs
->fifoctl
),
1468 readl(&dev
->regs
->pciirqenb0
),
1469 readl(&dev
->regs
->pciirqenb1
),
1470 readl(&dev
->regs
->irqstat0
),
1471 readl(&dev
->regs
->irqstat1
));
1475 /* USB Control Registers */
1476 t1
= readl(&dev
->usb
->usbctl
);
1477 t2
= readl(&dev
->usb
->usbstat
);
1478 if (t1
& BIT(VBUS_PIN
)) {
1479 if (t2
& BIT(HIGH_SPEED
))
1481 else if (dev
->gadget
.speed
== USB_SPEED_UNKNOWN
)
1485 /* full speed bit (6) not working?? */
1488 t
= scnprintf(next
, size
,
1489 "stdrsp %08x usbctl %08x usbstat %08x "
1490 "addr 0x%02x (%s)\n",
1491 readl(&dev
->usb
->stdrsp
), t1
, t2
,
1492 readl(&dev
->usb
->ouraddr
), s
);
1496 /* PCI Master Control Registers */
1498 /* DMA Control Registers */
1500 /* Configurable EP Control Registers */
1501 for (i
= 0; i
< dev
->n_ep
; i
++) {
1502 struct net2280_ep
*ep
;
1508 t1
= readl(&ep
->cfg
->ep_cfg
);
1509 t2
= readl(&ep
->regs
->ep_rsp
) & 0xff;
1510 t
= scnprintf(next
, size
,
1511 "\n%s\tcfg %05x rsp (%02x) %s%s%s%s%s%s%s%s"
1513 ep
->ep
.name
, t1
, t2
,
1514 (t2
& BIT(CLEAR_NAK_OUT_PACKETS
))
1516 (t2
& BIT(CLEAR_EP_HIDE_STATUS_PHASE
))
1518 (t2
& BIT(CLEAR_EP_FORCE_CRC_ERROR
))
1520 (t2
& BIT(CLEAR_INTERRUPT_MODE
))
1521 ? "interrupt " : "",
1522 (t2
& BIT(CLEAR_CONTROL_STATUS_PHASE_HANDSHAKE
))
1524 (t2
& BIT(CLEAR_NAK_OUT_PACKETS_MODE
))
1526 (t2
& BIT(CLEAR_ENDPOINT_TOGGLE
))
1527 ? "DATA1 " : "DATA0 ",
1528 (t2
& BIT(CLEAR_ENDPOINT_HALT
))
1530 readl(&ep
->regs
->ep_irqenb
));
1534 t
= scnprintf(next
, size
,
1535 "\tstat %08x avail %04x "
1537 readl(&ep
->regs
->ep_stat
),
1538 readl(&ep
->regs
->ep_avail
),
1539 t1
& 0x0f, DIR_STRING(t1
),
1540 type_string(t1
>> 8),
1541 ep
->stopped
? "*" : "");
1548 t
= scnprintf(next
, size
,
1549 " dma\tctl %08x stat %08x count %08x\n"
1550 "\taddr %08x desc %08x\n",
1551 readl(&ep
->dma
->dmactl
),
1552 readl(&ep
->dma
->dmastat
),
1553 readl(&ep
->dma
->dmacount
),
1554 readl(&ep
->dma
->dmaaddr
),
1555 readl(&ep
->dma
->dmadesc
));
1561 /* Indexed Registers (none yet) */
1564 t
= scnprintf(next
, size
, "\nirqs: ");
1567 for (i
= 0; i
< dev
->n_ep
; i
++) {
1568 struct net2280_ep
*ep
;
1573 t
= scnprintf(next
, size
, " %s/%lu", ep
->ep
.name
, ep
->irqs
);
1578 t
= scnprintf(next
, size
, "\n");
1582 spin_unlock_irqrestore(&dev
->lock
, flags
);
1584 return PAGE_SIZE
- size
;
1586 static DEVICE_ATTR_RO(registers
);
1588 static ssize_t
queues_show(struct device
*_dev
, struct device_attribute
*attr
,
1591 struct net2280
*dev
;
1594 unsigned long flags
;
1597 dev
= dev_get_drvdata(_dev
);
1600 spin_lock_irqsave(&dev
->lock
, flags
);
1602 for (i
= 0; i
< dev
->n_ep
; i
++) {
1603 struct net2280_ep
*ep
= &dev
->ep
[i
];
1604 struct net2280_request
*req
;
1608 const struct usb_endpoint_descriptor
*d
;
1613 t
= d
->bEndpointAddress
;
1614 t
= scnprintf(next
, size
,
1615 "\n%s (ep%d%s-%s) max %04x %s fifo %d\n",
1616 ep
->ep
.name
, t
& USB_ENDPOINT_NUMBER_MASK
,
1617 (t
& USB_DIR_IN
) ? "in" : "out",
1618 type_string(d
->bmAttributes
),
1619 usb_endpoint_maxp(d
) & 0x1fff,
1620 ep
->dma
? "dma" : "pio", ep
->fifo_size
1622 } else /* ep0 should only have one transfer queued */
1623 t
= scnprintf(next
, size
, "ep0 max 64 pio %s\n",
1624 ep
->is_in
? "in" : "out");
1625 if (t
<= 0 || t
> size
)
1630 if (list_empty(&ep
->queue
)) {
1631 t
= scnprintf(next
, size
, "\t(nothing queued)\n");
1632 if (t
<= 0 || t
> size
)
1638 list_for_each_entry(req
, &ep
->queue
, queue
) {
1639 if (ep
->dma
&& req
->td_dma
== readl(&ep
->dma
->dmadesc
))
1640 t
= scnprintf(next
, size
,
1641 "\treq %p len %d/%d "
1642 "buf %p (dmacount %08x)\n",
1643 &req
->req
, req
->req
.actual
,
1644 req
->req
.length
, req
->req
.buf
,
1645 readl(&ep
->dma
->dmacount
));
1647 t
= scnprintf(next
, size
,
1648 "\treq %p len %d/%d buf %p\n",
1649 &req
->req
, req
->req
.actual
,
1650 req
->req
.length
, req
->req
.buf
);
1651 if (t
<= 0 || t
> size
)
1657 struct net2280_dma
*td
;
1660 t
= scnprintf(next
, size
, "\t td %08x "
1661 " count %08x buf %08x desc %08x\n",
1663 le32_to_cpu(td
->dmacount
),
1664 le32_to_cpu(td
->dmaaddr
),
1665 le32_to_cpu(td
->dmadesc
));
1666 if (t
<= 0 || t
> size
)
1675 spin_unlock_irqrestore(&dev
->lock
, flags
);
1676 return PAGE_SIZE
- size
;
1678 static DEVICE_ATTR_RO(queues
);
1683 #define device_create_file(a, b) (0)
1684 #define device_remove_file(a, b) do { } while (0)
1688 /*-------------------------------------------------------------------------*/
1690 /* another driver-specific mode might be a request type doing dma
1691 * to/from another device fifo instead of to/from memory.
1694 static void set_fifo_mode(struct net2280
*dev
, int mode
)
1696 /* keeping high bits preserves BAR2 */
1697 writel((0xffff << PCI_BASE2_RANGE
) | mode
, &dev
->regs
->fifoctl
);
1699 /* always ep-{a,b,e,f} ... maybe not ep-c or ep-d */
1700 INIT_LIST_HEAD(&dev
->gadget
.ep_list
);
1701 list_add_tail(&dev
->ep
[1].ep
.ep_list
, &dev
->gadget
.ep_list
);
1702 list_add_tail(&dev
->ep
[2].ep
.ep_list
, &dev
->gadget
.ep_list
);
1705 list_add_tail(&dev
->ep
[3].ep
.ep_list
, &dev
->gadget
.ep_list
);
1706 list_add_tail(&dev
->ep
[4].ep
.ep_list
, &dev
->gadget
.ep_list
);
1707 dev
->ep
[1].fifo_size
= dev
->ep
[2].fifo_size
= 1024;
1710 dev
->ep
[1].fifo_size
= dev
->ep
[2].fifo_size
= 2048;
1713 list_add_tail(&dev
->ep
[3].ep
.ep_list
, &dev
->gadget
.ep_list
);
1714 dev
->ep
[1].fifo_size
= 2048;
1715 dev
->ep
[2].fifo_size
= 1024;
1718 /* fifo sizes for ep0, ep-c, ep-d, ep-e, and ep-f never change */
1719 list_add_tail(&dev
->ep
[5].ep
.ep_list
, &dev
->gadget
.ep_list
);
1720 list_add_tail(&dev
->ep
[6].ep
.ep_list
, &dev
->gadget
.ep_list
);
1723 static void defect7374_disable_data_eps(struct net2280
*dev
)
1726 * For Defect 7374, disable data EPs (and more):
1727 * - This phase undoes the earlier phase of the Defect 7374 workaround,
1728 * returing ep regs back to normal.
1730 struct net2280_ep
*ep
;
1732 unsigned char ep_sel
;
1735 for (i
= 1; i
< 5; i
++) {
1737 writel(0, &ep
->cfg
->ep_cfg
);
1740 /* CSROUT, CSRIN, PCIOUT, PCIIN, STATIN, RCIN */
1741 for (i
= 0; i
< 6; i
++)
1742 writel(0, &dev
->dep
[i
].dep_cfg
);
1744 for (ep_sel
= 0; ep_sel
<= 21; ep_sel
++) {
1745 /* Select an endpoint for subsequent operations: */
1746 tmp_reg
= readl(&dev
->plregs
->pl_ep_ctrl
);
1747 writel(((tmp_reg
& ~0x1f) | ep_sel
), &dev
->plregs
->pl_ep_ctrl
);
1749 if (ep_sel
< 2 || (ep_sel
> 9 && ep_sel
< 14) ||
1750 ep_sel
== 18 || ep_sel
== 20)
1753 /* Change settings on some selected endpoints */
1754 tmp_reg
= readl(&dev
->plregs
->pl_ep_cfg_4
);
1755 tmp_reg
&= ~BIT(NON_CTRL_IN_TOLERATE_BAD_DIR
);
1756 writel(tmp_reg
, &dev
->plregs
->pl_ep_cfg_4
);
1757 tmp_reg
= readl(&dev
->plregs
->pl_ep_ctrl
);
1758 tmp_reg
|= BIT(EP_INITIALIZED
);
1759 writel(tmp_reg
, &dev
->plregs
->pl_ep_ctrl
);
1763 static void defect7374_enable_data_eps_zero(struct net2280
*dev
)
1765 u32 tmp
= 0, tmp_reg
;
1768 unsigned char ep_sel
;
1770 scratch
= get_idx_reg(dev
->regs
, SCRATCH
);
1772 WARN_ON((scratch
& (0xf << DEFECT7374_FSM_FIELD
))
1773 == DEFECT7374_FSM_SS_CONTROL_READ
);
1775 scratch
&= ~(0xf << DEFECT7374_FSM_FIELD
);
1777 ep_warn(dev
, "Operate Defect 7374 workaround soft this time");
1778 ep_warn(dev
, "It will operate on cold-reboot and SS connect");
1781 tmp
= ((0 << ENDPOINT_NUMBER
) | BIT(ENDPOINT_DIRECTION
) |
1782 (2 << OUT_ENDPOINT_TYPE
) | (2 << IN_ENDPOINT_TYPE
) |
1783 ((dev
->enhanced_mode
) ?
1784 BIT(OUT_ENDPOINT_ENABLE
) : BIT(ENDPOINT_ENABLE
)) |
1785 BIT(IN_ENDPOINT_ENABLE
));
1787 for (i
= 1; i
< 5; i
++)
1788 writel(tmp
, &dev
->ep
[i
].cfg
->ep_cfg
);
1790 /* CSRIN, PCIIN, STATIN, RCIN*/
1791 tmp
= ((0 << ENDPOINT_NUMBER
) | BIT(ENDPOINT_ENABLE
));
1792 writel(tmp
, &dev
->dep
[1].dep_cfg
);
1793 writel(tmp
, &dev
->dep
[3].dep_cfg
);
1794 writel(tmp
, &dev
->dep
[4].dep_cfg
);
1795 writel(tmp
, &dev
->dep
[5].dep_cfg
);
1797 /*Implemented for development and debug.
1798 * Can be refined/tuned later.*/
1799 for (ep_sel
= 0; ep_sel
<= 21; ep_sel
++) {
1800 /* Select an endpoint for subsequent operations: */
1801 tmp_reg
= readl(&dev
->plregs
->pl_ep_ctrl
);
1802 writel(((tmp_reg
& ~0x1f) | ep_sel
),
1803 &dev
->plregs
->pl_ep_ctrl
);
1807 (readl(&dev
->plregs
->pl_ep_ctrl
) |
1808 BIT(CLEAR_ACK_ERROR_CODE
) | 0);
1809 writel(tmp
, &dev
->plregs
->pl_ep_ctrl
);
1813 if (ep_sel
== 0 || (ep_sel
> 9 && ep_sel
< 14) ||
1814 ep_sel
== 18 || ep_sel
== 20)
1817 tmp
= (readl(&dev
->plregs
->pl_ep_cfg_4
) |
1818 BIT(NON_CTRL_IN_TOLERATE_BAD_DIR
) | 0);
1819 writel(tmp
, &dev
->plregs
->pl_ep_cfg_4
);
1821 tmp
= readl(&dev
->plregs
->pl_ep_ctrl
) &
1822 ~BIT(EP_INITIALIZED
);
1823 writel(tmp
, &dev
->plregs
->pl_ep_ctrl
);
1827 /* Set FSM to focus on the first Control Read:
1828 * - Tip: Connection speed is known upon the first
1830 scratch
|= DEFECT7374_FSM_WAITING_FOR_CONTROL_READ
;
1831 set_idx_reg(dev
->regs
, SCRATCH
, scratch
);
1835 /* keeping it simple:
1836 * - one bus driver, initted first;
1837 * - one function driver, initted second
1839 * most of the work to support multiple net2280 controllers would
1840 * be to associate this gadget driver (yes?) with all of them, or
1841 * perhaps to bind specific drivers to specific devices.
1844 static void usb_reset_228x(struct net2280
*dev
)
1848 dev
->gadget
.speed
= USB_SPEED_UNKNOWN
;
1849 (void) readl(&dev
->usb
->usbctl
);
1851 net2280_led_init(dev
);
1853 /* disable automatic responses, and irqs */
1854 writel(0, &dev
->usb
->stdrsp
);
1855 writel(0, &dev
->regs
->pciirqenb0
);
1856 writel(0, &dev
->regs
->pciirqenb1
);
1858 /* clear old dma and irq state */
1859 for (tmp
= 0; tmp
< 4; tmp
++) {
1860 struct net2280_ep
*ep
= &dev
->ep
[tmp
+ 1];
1865 writel(~0, &dev
->regs
->irqstat0
),
1866 writel(~(u32
)BIT(SUSPEND_REQUEST_INTERRUPT
), &dev
->regs
->irqstat1
),
1868 /* reset, and enable pci */
1869 tmp
= readl(&dev
->regs
->devinit
) |
1871 BIT(FIFO_SOFT_RESET
) |
1872 BIT(USB_SOFT_RESET
) |
1874 writel(tmp
, &dev
->regs
->devinit
);
1876 /* standard fifo and endpoint allocations */
1877 set_fifo_mode(dev
, (fifo_mode
<= 2) ? fifo_mode
: 0);
1880 static void usb_reset_338x(struct net2280
*dev
)
1884 dev
->gadget
.speed
= USB_SPEED_UNKNOWN
;
1885 (void)readl(&dev
->usb
->usbctl
);
1887 net2280_led_init(dev
);
1889 if (dev
->bug7734_patched
) {
1890 /* disable automatic responses, and irqs */
1891 writel(0, &dev
->usb
->stdrsp
);
1892 writel(0, &dev
->regs
->pciirqenb0
);
1893 writel(0, &dev
->regs
->pciirqenb1
);
1896 /* clear old dma and irq state */
1897 for (tmp
= 0; tmp
< 4; tmp
++) {
1898 struct net2280_ep
*ep
= &dev
->ep
[tmp
+ 1];
1904 writel(~0, &dev
->regs
->irqstat0
), writel(~0, &dev
->regs
->irqstat1
);
1906 if (dev
->bug7734_patched
) {
1907 /* reset, and enable pci */
1908 tmp
= readl(&dev
->regs
->devinit
) |
1910 BIT(FIFO_SOFT_RESET
) |
1911 BIT(USB_SOFT_RESET
) |
1914 writel(tmp
, &dev
->regs
->devinit
);
1917 /* always ep-{1,2,3,4} ... maybe not ep-3 or ep-4 */
1918 INIT_LIST_HEAD(&dev
->gadget
.ep_list
);
1920 for (tmp
= 1; tmp
< dev
->n_ep
; tmp
++)
1921 list_add_tail(&dev
->ep
[tmp
].ep
.ep_list
, &dev
->gadget
.ep_list
);
1925 static void usb_reset(struct net2280
*dev
)
1927 if (dev
->quirks
& PLX_LEGACY
)
1928 return usb_reset_228x(dev
);
1929 return usb_reset_338x(dev
);
1932 static void usb_reinit_228x(struct net2280
*dev
)
1936 /* basic endpoint init */
1937 for (tmp
= 0; tmp
< 7; tmp
++) {
1938 struct net2280_ep
*ep
= &dev
->ep
[tmp
];
1940 ep
->ep
.name
= ep_name
[tmp
];
1944 if (tmp
> 0 && tmp
<= 4) {
1945 ep
->fifo_size
= 1024;
1946 ep
->dma
= &dev
->dma
[tmp
- 1];
1949 ep
->regs
= &dev
->epregs
[tmp
];
1950 ep
->cfg
= &dev
->epregs
[tmp
];
1951 ep_reset_228x(dev
->regs
, ep
);
1953 usb_ep_set_maxpacket_limit(&dev
->ep
[0].ep
, 64);
1954 usb_ep_set_maxpacket_limit(&dev
->ep
[5].ep
, 64);
1955 usb_ep_set_maxpacket_limit(&dev
->ep
[6].ep
, 64);
1957 dev
->gadget
.ep0
= &dev
->ep
[0].ep
;
1958 dev
->ep
[0].stopped
= 0;
1959 INIT_LIST_HEAD(&dev
->gadget
.ep0
->ep_list
);
1961 /* we want to prevent lowlevel/insecure access from the USB host,
1962 * but erratum 0119 means this enable bit is ignored
1964 for (tmp
= 0; tmp
< 5; tmp
++)
1965 writel(EP_DONTUSE
, &dev
->dep
[tmp
].dep_cfg
);
1968 static void usb_reinit_338x(struct net2280
*dev
)
1972 static const u32 ne
[9] = { 0, 1, 2, 3, 4, 1, 2, 3, 4 };
1973 static const u32 ep_reg_addr
[9] = { 0x00, 0xC0, 0x00, 0xC0, 0x00,
1974 0x00, 0xC0, 0x00, 0xC0 };
1976 /* basic endpoint init */
1977 for (i
= 0; i
< dev
->n_ep
; i
++) {
1978 struct net2280_ep
*ep
= &dev
->ep
[i
];
1980 ep
->ep
.name
= ep_name
[i
];
1984 if (i
> 0 && i
<= 4)
1985 ep
->dma
= &dev
->dma
[i
- 1];
1987 if (dev
->enhanced_mode
) {
1988 ep
->cfg
= &dev
->epregs
[ne
[i
]];
1989 ep
->regs
= (struct net2280_ep_regs __iomem
*)
1990 (((void __iomem
*)&dev
->epregs
[ne
[i
]]) +
1992 ep
->fiforegs
= &dev
->fiforegs
[i
];
1994 ep
->cfg
= &dev
->epregs
[i
];
1995 ep
->regs
= &dev
->epregs
[i
];
1996 ep
->fiforegs
= &dev
->fiforegs
[i
];
1999 ep
->fifo_size
= (i
!= 0) ? 2048 : 512;
2001 ep_reset_338x(dev
->regs
, ep
);
2003 usb_ep_set_maxpacket_limit(&dev
->ep
[0].ep
, 512);
2005 dev
->gadget
.ep0
= &dev
->ep
[0].ep
;
2006 dev
->ep
[0].stopped
= 0;
2008 /* Link layer set up */
2009 if (dev
->bug7734_patched
) {
2010 tmp
= readl(&dev
->usb_ext
->usbctl2
) &
2011 ~(BIT(U1_ENABLE
) | BIT(U2_ENABLE
) | BIT(LTM_ENABLE
));
2012 writel(tmp
, &dev
->usb_ext
->usbctl2
);
2015 /* Hardware Defect and Workaround */
2016 val
= readl(&dev
->ll_lfps_regs
->ll_lfps_5
);
2017 val
&= ~(0xf << TIMER_LFPS_6US
);
2018 val
|= 0x5 << TIMER_LFPS_6US
;
2019 writel(val
, &dev
->ll_lfps_regs
->ll_lfps_5
);
2021 val
= readl(&dev
->ll_lfps_regs
->ll_lfps_6
);
2022 val
&= ~(0xffff << TIMER_LFPS_80US
);
2023 val
|= 0x0100 << TIMER_LFPS_80US
;
2024 writel(val
, &dev
->ll_lfps_regs
->ll_lfps_6
);
2027 * AA_AB Errata. Issue 4. Workaround for SuperSpeed USB
2028 * Hot Reset Exit Handshake may Fail in Specific Case using
2029 * Default Register Settings. Workaround for Enumeration test.
2031 val
= readl(&dev
->ll_tsn_regs
->ll_tsn_counters_2
);
2032 val
&= ~(0x1f << HOT_TX_NORESET_TS2
);
2033 val
|= 0x10 << HOT_TX_NORESET_TS2
;
2034 writel(val
, &dev
->ll_tsn_regs
->ll_tsn_counters_2
);
2036 val
= readl(&dev
->ll_tsn_regs
->ll_tsn_counters_3
);
2037 val
&= ~(0x1f << HOT_RX_RESET_TS2
);
2038 val
|= 0x3 << HOT_RX_RESET_TS2
;
2039 writel(val
, &dev
->ll_tsn_regs
->ll_tsn_counters_3
);
2042 * Set Recovery Idle to Recover bit:
2043 * - On SS connections, setting Recovery Idle to Recover Fmw improves
2044 * link robustness with various hosts and hubs.
2045 * - It is safe to set for all connection speeds; all chip revisions.
2046 * - R-M-W to leave other bits undisturbed.
2047 * - Reference PLX TT-7372
2049 val
= readl(&dev
->ll_chicken_reg
->ll_tsn_chicken_bit
);
2050 val
|= BIT(RECOVERY_IDLE_TO_RECOVER_FMW
);
2051 writel(val
, &dev
->ll_chicken_reg
->ll_tsn_chicken_bit
);
2053 INIT_LIST_HEAD(&dev
->gadget
.ep0
->ep_list
);
2055 /* disable dedicated endpoints */
2056 writel(0x0D, &dev
->dep
[0].dep_cfg
);
2057 writel(0x0D, &dev
->dep
[1].dep_cfg
);
2058 writel(0x0E, &dev
->dep
[2].dep_cfg
);
2059 writel(0x0E, &dev
->dep
[3].dep_cfg
);
2060 writel(0x0F, &dev
->dep
[4].dep_cfg
);
2061 writel(0x0C, &dev
->dep
[5].dep_cfg
);
2064 static void usb_reinit(struct net2280
*dev
)
2066 if (dev
->quirks
& PLX_LEGACY
)
2067 return usb_reinit_228x(dev
);
2068 return usb_reinit_338x(dev
);
2071 static void ep0_start_228x(struct net2280
*dev
)
2073 writel(BIT(CLEAR_EP_HIDE_STATUS_PHASE
) |
2074 BIT(CLEAR_NAK_OUT_PACKETS
) |
2075 BIT(CLEAR_CONTROL_STATUS_PHASE_HANDSHAKE
),
2076 &dev
->epregs
[0].ep_rsp
);
2079 * hardware optionally handles a bunch of standard requests
2080 * that the API hides from drivers anyway. have it do so.
2081 * endpoint status/features are handled in software, to
2082 * help pass tests for some dubious behavior.
2084 writel(BIT(SET_TEST_MODE
) |
2086 BIT(DEVICE_SET_CLEAR_DEVICE_REMOTE_WAKEUP
) |
2087 BIT(GET_DEVICE_STATUS
) |
2088 BIT(GET_INTERFACE_STATUS
),
2090 writel(BIT(USB_ROOT_PORT_WAKEUP_ENABLE
) |
2091 BIT(SELF_POWERED_USB_DEVICE
) |
2092 BIT(REMOTE_WAKEUP_SUPPORT
) |
2093 (dev
->softconnect
<< USB_DETECT_ENABLE
) |
2094 BIT(SELF_POWERED_STATUS
),
2097 /* enable irqs so we can see ep0 and general operation */
2098 writel(BIT(SETUP_PACKET_INTERRUPT_ENABLE
) |
2099 BIT(ENDPOINT_0_INTERRUPT_ENABLE
),
2100 &dev
->regs
->pciirqenb0
);
2101 writel(BIT(PCI_INTERRUPT_ENABLE
) |
2102 BIT(PCI_MASTER_ABORT_RECEIVED_INTERRUPT_ENABLE
) |
2103 BIT(PCI_TARGET_ABORT_RECEIVED_INTERRUPT_ENABLE
) |
2104 BIT(PCI_RETRY_ABORT_INTERRUPT_ENABLE
) |
2105 BIT(VBUS_INTERRUPT_ENABLE
) |
2106 BIT(ROOT_PORT_RESET_INTERRUPT_ENABLE
) |
2107 BIT(SUSPEND_REQUEST_CHANGE_INTERRUPT_ENABLE
),
2108 &dev
->regs
->pciirqenb1
);
2110 /* don't leave any writes posted */
2111 (void) readl(&dev
->usb
->usbctl
);
2114 static void ep0_start_338x(struct net2280
*dev
)
2117 if (dev
->bug7734_patched
)
2118 writel(BIT(CLEAR_NAK_OUT_PACKETS_MODE
) |
2119 BIT(SET_EP_HIDE_STATUS_PHASE
),
2120 &dev
->epregs
[0].ep_rsp
);
2123 * hardware optionally handles a bunch of standard requests
2124 * that the API hides from drivers anyway. have it do so.
2125 * endpoint status/features are handled in software, to
2126 * help pass tests for some dubious behavior.
2128 writel(BIT(SET_ISOCHRONOUS_DELAY
) |
2130 BIT(SET_TEST_MODE
) |
2132 BIT(GET_INTERFACE_STATUS
) |
2133 BIT(GET_DEVICE_STATUS
),
2135 dev
->wakeup_enable
= 1;
2136 writel(BIT(USB_ROOT_PORT_WAKEUP_ENABLE
) |
2137 (dev
->softconnect
<< USB_DETECT_ENABLE
) |
2138 BIT(DEVICE_REMOTE_WAKEUP_ENABLE
),
2141 /* enable irqs so we can see ep0 and general operation */
2142 writel(BIT(SETUP_PACKET_INTERRUPT_ENABLE
) |
2143 BIT(ENDPOINT_0_INTERRUPT_ENABLE
),
2144 &dev
->regs
->pciirqenb0
);
2145 writel(BIT(PCI_INTERRUPT_ENABLE
) |
2146 BIT(ROOT_PORT_RESET_INTERRUPT_ENABLE
) |
2147 BIT(SUSPEND_REQUEST_CHANGE_INTERRUPT_ENABLE
) |
2148 BIT(VBUS_INTERRUPT_ENABLE
),
2149 &dev
->regs
->pciirqenb1
);
2151 /* don't leave any writes posted */
2152 (void)readl(&dev
->usb
->usbctl
);
2155 static void ep0_start(struct net2280
*dev
)
2157 if (dev
->quirks
& PLX_LEGACY
)
2158 return ep0_start_228x(dev
);
2159 return ep0_start_338x(dev
);
2162 /* when a driver is successfully registered, it will receive
2163 * control requests including set_configuration(), which enables
2164 * non-control requests. then usb traffic follows until a
2165 * disconnect is reported. then a host may connect again, or
2166 * the driver might get unbound.
2168 static int net2280_start(struct usb_gadget
*_gadget
,
2169 struct usb_gadget_driver
*driver
)
2171 struct net2280
*dev
;
2175 /* insist on high speed support from the driver, since
2176 * (dev->usb->xcvrdiag & FORCE_FULL_SPEED_MODE)
2177 * "must not be used in normal operation"
2179 if (!driver
|| driver
->max_speed
< USB_SPEED_HIGH
||
2183 dev
= container_of(_gadget
, struct net2280
, gadget
);
2185 for (i
= 0; i
< dev
->n_ep
; i
++)
2186 dev
->ep
[i
].irqs
= 0;
2188 /* hook up the driver ... */
2189 dev
->softconnect
= 1;
2190 driver
->driver
.bus
= NULL
;
2191 dev
->driver
= driver
;
2193 retval
= device_create_file(&dev
->pdev
->dev
, &dev_attr_function
);
2196 retval
= device_create_file(&dev
->pdev
->dev
, &dev_attr_queues
);
2200 /* enable host detection and ep0; and we're ready
2201 * for set_configuration as well as eventual disconnect.
2203 net2280_led_active(dev
, 1);
2205 if ((dev
->quirks
& PLX_SUPERSPEED
) && !dev
->bug7734_patched
)
2206 defect7374_enable_data_eps_zero(dev
);
2210 /* pci writes may still be posted */
2214 device_remove_file(&dev
->pdev
->dev
, &dev_attr_function
);
2220 static void stop_activity(struct net2280
*dev
, struct usb_gadget_driver
*driver
)
2224 /* don't disconnect if it's not connected */
2225 if (dev
->gadget
.speed
== USB_SPEED_UNKNOWN
)
2228 /* stop hardware; prevent new request submissions;
2229 * and kill any outstanding requests.
2232 for (i
= 0; i
< dev
->n_ep
; i
++)
2235 /* report disconnect; the driver is already quiesced */
2237 spin_unlock(&dev
->lock
);
2238 driver
->disconnect(&dev
->gadget
);
2239 spin_lock(&dev
->lock
);
2245 static int net2280_stop(struct usb_gadget
*_gadget
)
2247 struct net2280
*dev
;
2248 unsigned long flags
;
2250 dev
= container_of(_gadget
, struct net2280
, gadget
);
2252 spin_lock_irqsave(&dev
->lock
, flags
);
2253 stop_activity(dev
, NULL
);
2254 spin_unlock_irqrestore(&dev
->lock
, flags
);
2256 net2280_led_active(dev
, 0);
2258 device_remove_file(&dev
->pdev
->dev
, &dev_attr_function
);
2259 device_remove_file(&dev
->pdev
->dev
, &dev_attr_queues
);
2266 /*-------------------------------------------------------------------------*/
2268 /* handle ep0, ep-e, ep-f with 64 byte packets: packet per irq.
2269 * also works for dma-capable endpoints, in pio mode or just
2270 * to manually advance the queue after short OUT transfers.
2272 static void handle_ep_small(struct net2280_ep
*ep
)
2274 struct net2280_request
*req
;
2276 /* 0 error, 1 mid-data, 2 done */
2279 if (!list_empty(&ep
->queue
))
2280 req
= list_entry(ep
->queue
.next
,
2281 struct net2280_request
, queue
);
2285 /* ack all, and handle what we care about */
2286 t
= readl(&ep
->regs
->ep_stat
);
2289 ep_vdbg(ep
->dev
, "%s ack ep_stat %08x, req %p\n",
2290 ep
->ep
.name
, t
, req
? &req
->req
: NULL
);
2292 if (!ep
->is_in
|| (ep
->dev
->quirks
& PLX_2280
))
2293 writel(t
& ~BIT(NAK_OUT_PACKETS
), &ep
->regs
->ep_stat
);
2295 /* Added for 2282 */
2296 writel(t
, &ep
->regs
->ep_stat
);
2298 /* for ep0, monitor token irqs to catch data stage length errors
2299 * and to synchronize on status.
2301 * also, to defer reporting of protocol stalls ... here's where
2302 * data or status first appears, handling stalls here should never
2303 * cause trouble on the host side..
2305 * control requests could be slightly faster without token synch for
2306 * status, but status can jam up that way.
2308 if (unlikely(ep
->num
== 0)) {
2310 /* status; stop NAKing */
2311 if (t
& BIT(DATA_OUT_PING_TOKEN_INTERRUPT
)) {
2312 if (ep
->dev
->protocol_stall
) {
2319 /* reply to extra IN data tokens with a zlp */
2320 } else if (t
& BIT(DATA_IN_TOKEN_INTERRUPT
)) {
2321 if (ep
->dev
->protocol_stall
) {
2325 } else if (ep
->responded
&&
2326 !req
&& !ep
->stopped
)
2327 write_fifo(ep
, NULL
);
2330 /* status; stop NAKing */
2331 if (t
& BIT(DATA_IN_TOKEN_INTERRUPT
)) {
2332 if (ep
->dev
->protocol_stall
) {
2337 /* an extra OUT token is an error */
2338 } else if (((t
& BIT(DATA_OUT_PING_TOKEN_INTERRUPT
)) &&
2340 req
->req
.actual
== req
->req
.length
) ||
2341 (ep
->responded
&& !req
)) {
2342 ep
->dev
->protocol_stall
= 1;
2346 done(ep
, req
, -EOVERFLOW
);
2355 /* manual DMA queue advance after short OUT */
2356 if (likely(ep
->dma
)) {
2357 if (t
& BIT(SHORT_PACKET_TRANSFERRED_INTERRUPT
)) {
2359 int stopped
= ep
->stopped
;
2361 /* TRANSFERRED works around OUT_DONE erratum 0112.
2362 * we expect (N <= maxpacket) bytes; host wrote M.
2363 * iff (M < N) we won't ever see a DMA interrupt.
2366 for (count
= 0; ; t
= readl(&ep
->regs
->ep_stat
)) {
2368 /* any preceding dma transfers must finish.
2369 * dma handles (M >= N), may empty the queue
2371 scan_dma_completions(ep
);
2372 if (unlikely(list_empty(&ep
->queue
) ||
2373 ep
->out_overflow
)) {
2377 req
= list_entry(ep
->queue
.next
,
2378 struct net2280_request
, queue
);
2380 /* here either (M < N), a "real" short rx;
2381 * or (M == N) and the queue didn't empty
2383 if (likely(t
& BIT(FIFO_EMPTY
))) {
2384 count
= readl(&ep
->dma
->dmacount
);
2385 count
&= DMA_BYTE_COUNT_MASK
;
2386 if (readl(&ep
->dma
->dmadesc
)
2394 /* stop DMA, leave ep NAKing */
2395 writel(BIT(DMA_ABORT
), &ep
->dma
->dmastat
);
2396 spin_stop_dma(ep
->dma
);
2399 req
->td
->dmacount
= 0;
2400 t
= readl(&ep
->regs
->ep_avail
);
2401 dma_done(ep
, req
, count
,
2402 (ep
->out_overflow
|| t
)
2406 /* also flush to prevent erratum 0106 trouble */
2407 if (unlikely(ep
->out_overflow
||
2408 (ep
->dev
->chiprev
== 0x0100 &&
2409 ep
->dev
->gadget
.speed
2410 == USB_SPEED_FULL
))) {
2412 ep
->out_overflow
= 0;
2415 /* (re)start dma if needed, stop NAKing */
2416 ep
->stopped
= stopped
;
2417 if (!list_empty(&ep
->queue
))
2420 ep_dbg(ep
->dev
, "%s dma ep_stat %08x ??\n",
2424 /* data packet(s) received (in the fifo, OUT) */
2425 } else if (t
& BIT(DATA_PACKET_RECEIVED_INTERRUPT
)) {
2426 if (read_fifo(ep
, req
) && ep
->num
!= 0)
2429 /* data packet(s) transmitted (IN) */
2430 } else if (t
& BIT(DATA_PACKET_TRANSMITTED_INTERRUPT
)) {
2433 len
= req
->req
.length
- req
->req
.actual
;
2434 if (len
> ep
->ep
.maxpacket
)
2435 len
= ep
->ep
.maxpacket
;
2436 req
->req
.actual
+= len
;
2438 /* if we wrote it all, we're usually done */
2439 /* send zlps until the status stage */
2440 if ((req
->req
.actual
== req
->req
.length
) &&
2441 (!req
->req
.zero
|| len
!= ep
->ep
.maxpacket
) && ep
->num
)
2444 /* there was nothing to do ... */
2445 } else if (mode
== 1)
2450 /* stream endpoints often resubmit/unlink in completion */
2453 /* maybe advance queue to next request */
2455 /* NOTE: net2280 could let gadget driver start the
2456 * status stage later. since not all controllers let
2457 * them control that, the api doesn't (yet) allow it.
2463 if (!list_empty(&ep
->queue
) && !ep
->stopped
)
2464 req
= list_entry(ep
->queue
.next
,
2465 struct net2280_request
, queue
);
2468 if (req
&& !ep
->is_in
)
2469 stop_out_naking(ep
);
2473 /* is there a buffer for the next packet?
2474 * for best streaming performance, make sure there is one.
2476 if (req
&& !ep
->stopped
) {
2478 /* load IN fifo with next packet (may be zlp) */
2479 if (t
& BIT(DATA_PACKET_TRANSMITTED_INTERRUPT
))
2480 write_fifo(ep
, &req
->req
);
2484 static struct net2280_ep
*get_ep_by_addr(struct net2280
*dev
, u16 wIndex
)
2486 struct net2280_ep
*ep
;
2488 if ((wIndex
& USB_ENDPOINT_NUMBER_MASK
) == 0)
2490 list_for_each_entry(ep
, &dev
->gadget
.ep_list
, ep
.ep_list
) {
2491 u8 bEndpointAddress
;
2495 bEndpointAddress
= ep
->desc
->bEndpointAddress
;
2496 if ((wIndex
^ bEndpointAddress
) & USB_DIR_IN
)
2498 if ((wIndex
& 0x0f) == (bEndpointAddress
& 0x0f))
2504 static void defect7374_workaround(struct net2280
*dev
, struct usb_ctrlrequest r
)
2506 u32 scratch
, fsmvalue
;
2507 u32 ack_wait_timeout
, state
;
2509 /* Workaround for Defect 7374 (U1/U2 erroneously rejected): */
2510 scratch
= get_idx_reg(dev
->regs
, SCRATCH
);
2511 fsmvalue
= scratch
& (0xf << DEFECT7374_FSM_FIELD
);
2512 scratch
&= ~(0xf << DEFECT7374_FSM_FIELD
);
2514 if (!((fsmvalue
== DEFECT7374_FSM_WAITING_FOR_CONTROL_READ
) &&
2515 (r
.bRequestType
& USB_DIR_IN
)))
2518 /* This is the first Control Read for this connection: */
2519 if (!(readl(&dev
->usb
->usbstat
) & BIT(SUPER_SPEED_MODE
))) {
2521 * Connection is NOT SS:
2522 * - Connection must be FS or HS.
2523 * - This FSM state should allow workaround software to
2524 * run after the next USB connection.
2526 scratch
|= DEFECT7374_FSM_NON_SS_CONTROL_READ
;
2527 dev
->bug7734_patched
= 1;
2528 goto restore_data_eps
;
2531 /* Connection is SS: */
2532 for (ack_wait_timeout
= 0;
2533 ack_wait_timeout
< DEFECT_7374_NUMBEROF_MAX_WAIT_LOOPS
;
2534 ack_wait_timeout
++) {
2536 state
= readl(&dev
->plregs
->pl_ep_status_1
)
2538 if ((state
>= (ACK_GOOD_NORMAL
<< STATE
)) &&
2539 (state
<= (ACK_GOOD_MORE_ACKS_TO_COME
<< STATE
))) {
2540 scratch
|= DEFECT7374_FSM_SS_CONTROL_READ
;
2541 dev
->bug7734_patched
= 1;
2546 * We have not yet received host's Data Phase ACK
2547 * - Wait and try again.
2549 udelay(DEFECT_7374_PROCESSOR_WAIT_TIME
);
2555 if (ack_wait_timeout
>= DEFECT_7374_NUMBEROF_MAX_WAIT_LOOPS
) {
2556 ep_err(dev
, "FAIL: Defect 7374 workaround waited but failed "
2557 "to detect SS host's data phase ACK.");
2558 ep_err(dev
, "PL_EP_STATUS_1(23:16):.Expected from 0x11 to 0x16"
2559 "got 0x%2.2x.\n", state
>> STATE
);
2561 ep_warn(dev
, "INFO: Defect 7374 workaround waited about\n"
2562 "%duSec for Control Read Data Phase ACK\n",
2563 DEFECT_7374_PROCESSOR_WAIT_TIME
* ack_wait_timeout
);
2568 * Restore data EPs to their pre-workaround settings (disabled,
2569 * initialized, and other details).
2571 defect7374_disable_data_eps(dev
);
2573 set_idx_reg(dev
->regs
, SCRATCH
, scratch
);
2578 static void ep_clear_seqnum(struct net2280_ep
*ep
)
2580 struct net2280
*dev
= ep
->dev
;
2582 static const u32 ep_pl
[9] = { 0, 3, 4, 7, 8, 2, 5, 6, 9 };
2584 val
= readl(&dev
->plregs
->pl_ep_ctrl
) & ~0x1f;
2585 val
|= ep_pl
[ep
->num
];
2586 writel(val
, &dev
->plregs
->pl_ep_ctrl
);
2587 val
|= BIT(SEQUENCE_NUMBER_RESET
);
2588 writel(val
, &dev
->plregs
->pl_ep_ctrl
);
2593 static void handle_stat0_irqs_superspeed(struct net2280
*dev
,
2594 struct net2280_ep
*ep
, struct usb_ctrlrequest r
)
2598 #define w_value le16_to_cpu(r.wValue)
2599 #define w_index le16_to_cpu(r.wIndex)
2600 #define w_length le16_to_cpu(r.wLength)
2602 switch (r
.bRequest
) {
2603 struct net2280_ep
*e
;
2606 case USB_REQ_SET_CONFIGURATION
:
2607 dev
->addressed_state
= !w_value
;
2610 case USB_REQ_GET_STATUS
:
2611 switch (r
.bRequestType
) {
2612 case (USB_DIR_IN
| USB_TYPE_STANDARD
| USB_RECIP_DEVICE
):
2613 status
= dev
->wakeup_enable
? 0x02 : 0x00;
2614 if (dev
->gadget
.is_selfpowered
)
2616 status
|= (dev
->u1_enable
<< 2 | dev
->u2_enable
<< 3 |
2617 dev
->ltm_enable
<< 4);
2618 writel(0, &dev
->epregs
[0].ep_irqenb
);
2619 set_fifo_bytecount(ep
, sizeof(status
));
2620 writel((__force u32
) status
, &dev
->epregs
[0].ep_data
);
2621 allow_status_338x(ep
);
2624 case (USB_DIR_IN
| USB_TYPE_STANDARD
| USB_RECIP_ENDPOINT
):
2625 e
= get_ep_by_addr(dev
, w_index
);
2628 status
= readl(&e
->regs
->ep_rsp
) &
2629 BIT(CLEAR_ENDPOINT_HALT
);
2630 writel(0, &dev
->epregs
[0].ep_irqenb
);
2631 set_fifo_bytecount(ep
, sizeof(status
));
2632 writel((__force u32
) status
, &dev
->epregs
[0].ep_data
);
2633 allow_status_338x(ep
);
2641 case USB_REQ_CLEAR_FEATURE
:
2642 switch (r
.bRequestType
) {
2643 case (USB_DIR_OUT
| USB_TYPE_STANDARD
| USB_RECIP_DEVICE
):
2644 if (!dev
->addressed_state
) {
2646 case USB_DEVICE_U1_ENABLE
:
2648 writel(readl(&dev
->usb_ext
->usbctl2
) &
2650 &dev
->usb_ext
->usbctl2
);
2651 allow_status_338x(ep
);
2652 goto next_endpoints3
;
2654 case USB_DEVICE_U2_ENABLE
:
2656 writel(readl(&dev
->usb_ext
->usbctl2
) &
2658 &dev
->usb_ext
->usbctl2
);
2659 allow_status_338x(ep
);
2660 goto next_endpoints3
;
2662 case USB_DEVICE_LTM_ENABLE
:
2663 dev
->ltm_enable
= 0;
2664 writel(readl(&dev
->usb_ext
->usbctl2
) &
2666 &dev
->usb_ext
->usbctl2
);
2667 allow_status_338x(ep
);
2668 goto next_endpoints3
;
2674 if (w_value
== USB_DEVICE_REMOTE_WAKEUP
) {
2675 dev
->wakeup_enable
= 0;
2676 writel(readl(&dev
->usb
->usbctl
) &
2677 ~BIT(DEVICE_REMOTE_WAKEUP_ENABLE
),
2679 allow_status_338x(ep
);
2684 case (USB_DIR_OUT
| USB_TYPE_STANDARD
| USB_RECIP_ENDPOINT
):
2685 e
= get_ep_by_addr(dev
, w_index
);
2688 if (w_value
!= USB_ENDPOINT_HALT
)
2690 ep_vdbg(dev
, "%s clear halt\n", e
->ep
.name
);
2692 * Workaround for SS SeqNum not cleared via
2693 * Endpoint Halt (Clear) bit. select endpoint
2697 if (!list_empty(&e
->queue
) && e
->td_dma
)
2707 case USB_REQ_SET_FEATURE
:
2708 switch (r
.bRequestType
) {
2709 case (USB_DIR_OUT
| USB_TYPE_STANDARD
| USB_RECIP_DEVICE
):
2710 if (!dev
->addressed_state
) {
2712 case USB_DEVICE_U1_ENABLE
:
2714 writel(readl(&dev
->usb_ext
->usbctl2
) |
2716 &dev
->usb_ext
->usbctl2
);
2717 allow_status_338x(ep
);
2718 goto next_endpoints3
;
2720 case USB_DEVICE_U2_ENABLE
:
2722 writel(readl(&dev
->usb_ext
->usbctl2
) |
2724 &dev
->usb_ext
->usbctl2
);
2725 allow_status_338x(ep
);
2726 goto next_endpoints3
;
2728 case USB_DEVICE_LTM_ENABLE
:
2729 dev
->ltm_enable
= 1;
2730 writel(readl(&dev
->usb_ext
->usbctl2
) |
2732 &dev
->usb_ext
->usbctl2
);
2733 allow_status_338x(ep
);
2734 goto next_endpoints3
;
2740 if (w_value
== USB_DEVICE_REMOTE_WAKEUP
) {
2741 dev
->wakeup_enable
= 1;
2742 writel(readl(&dev
->usb
->usbctl
) |
2743 BIT(DEVICE_REMOTE_WAKEUP_ENABLE
),
2745 allow_status_338x(ep
);
2750 case (USB_DIR_OUT
| USB_TYPE_STANDARD
| USB_RECIP_ENDPOINT
):
2751 e
= get_ep_by_addr(dev
, w_index
);
2752 if (!e
|| (w_value
!= USB_ENDPOINT_HALT
))
2756 ep
->dev
->protocol_stall
= 1;
2762 allow_status_338x(ep
);
2773 ep_vdbg(dev
, "setup %02x.%02x v%04x i%04x l%04x ep_cfg %08x\n",
2774 r
.bRequestType
, r
.bRequest
,
2775 w_value
, w_index
, w_length
,
2776 readl(&ep
->cfg
->ep_cfg
));
2779 spin_unlock(&dev
->lock
);
2780 tmp
= dev
->driver
->setup(&dev
->gadget
, &r
);
2781 spin_lock(&dev
->lock
);
2785 ep_vdbg(dev
, "req %02x.%02x protocol STALL; stat %d\n",
2786 r
.bRequestType
, r
.bRequest
, tmp
);
2787 dev
->protocol_stall
= 1;
2788 /* TD 9.9 Halt Endpoint test. TD 9.22 Set feature test */
2801 static void handle_stat0_irqs(struct net2280
*dev
, u32 stat
)
2803 struct net2280_ep
*ep
;
2806 /* most of these don't need individual acks */
2807 stat
&= ~BIT(INTA_ASSERTED
);
2810 /* ep_dbg(dev, "irqstat0 %04x\n", stat); */
2812 /* starting a control request? */
2813 if (unlikely(stat
& BIT(SETUP_PACKET_INTERRUPT
))) {
2816 struct usb_ctrlrequest r
;
2819 struct net2280_request
*req
;
2821 if (dev
->gadget
.speed
== USB_SPEED_UNKNOWN
) {
2822 u32 val
= readl(&dev
->usb
->usbstat
);
2823 if (val
& BIT(SUPER_SPEED
)) {
2824 dev
->gadget
.speed
= USB_SPEED_SUPER
;
2825 usb_ep_set_maxpacket_limit(&dev
->ep
[0].ep
,
2826 EP0_SS_MAX_PACKET_SIZE
);
2827 } else if (val
& BIT(HIGH_SPEED
)) {
2828 dev
->gadget
.speed
= USB_SPEED_HIGH
;
2829 usb_ep_set_maxpacket_limit(&dev
->ep
[0].ep
,
2830 EP0_HS_MAX_PACKET_SIZE
);
2832 dev
->gadget
.speed
= USB_SPEED_FULL
;
2833 usb_ep_set_maxpacket_limit(&dev
->ep
[0].ep
,
2834 EP0_HS_MAX_PACKET_SIZE
);
2836 net2280_led_speed(dev
, dev
->gadget
.speed
);
2838 usb_speed_string(dev
->gadget
.speed
));
2844 /* make sure any leftover request state is cleared */
2845 stat
&= ~BIT(ENDPOINT_0_INTERRUPT
);
2846 while (!list_empty(&ep
->queue
)) {
2847 req
= list_entry(ep
->queue
.next
,
2848 struct net2280_request
, queue
);
2849 done(ep
, req
, (req
->req
.actual
== req
->req
.length
)
2853 dev
->protocol_stall
= 0;
2854 if (!(dev
->quirks
& PLX_SUPERSPEED
)) {
2855 if (ep
->dev
->quirks
& PLX_2280
)
2856 tmp
= BIT(FIFO_OVERFLOW
) |
2857 BIT(FIFO_UNDERFLOW
);
2861 writel(tmp
| BIT(TIMEOUT
) |
2862 BIT(USB_STALL_SENT
) |
2863 BIT(USB_IN_NAK_SENT
) |
2864 BIT(USB_IN_ACK_RCVD
) |
2865 BIT(USB_OUT_PING_NAK_SENT
) |
2866 BIT(USB_OUT_ACK_SENT
) |
2867 BIT(SHORT_PACKET_OUT_DONE_INTERRUPT
) |
2868 BIT(SHORT_PACKET_TRANSFERRED_INTERRUPT
) |
2869 BIT(DATA_PACKET_RECEIVED_INTERRUPT
) |
2870 BIT(DATA_PACKET_TRANSMITTED_INTERRUPT
) |
2871 BIT(DATA_OUT_PING_TOKEN_INTERRUPT
) |
2872 BIT(DATA_IN_TOKEN_INTERRUPT
),
2873 &ep
->regs
->ep_stat
);
2875 u
.raw
[0] = readl(&dev
->usb
->setup0123
);
2876 u
.raw
[1] = readl(&dev
->usb
->setup4567
);
2878 cpu_to_le32s(&u
.raw
[0]);
2879 cpu_to_le32s(&u
.raw
[1]);
2881 if ((dev
->quirks
& PLX_SUPERSPEED
) && !dev
->bug7734_patched
)
2882 defect7374_workaround(dev
, u
.r
);
2886 #define w_value le16_to_cpu(u.r.wValue)
2887 #define w_index le16_to_cpu(u.r.wIndex)
2888 #define w_length le16_to_cpu(u.r.wLength)
2891 writel(BIT(SETUP_PACKET_INTERRUPT
), &dev
->regs
->irqstat0
);
2892 stat
^= BIT(SETUP_PACKET_INTERRUPT
);
2894 /* watch control traffic at the token level, and force
2895 * synchronization before letting the status stage happen.
2896 * FIXME ignore tokens we'll NAK, until driver responds.
2897 * that'll mean a lot less irqs for some drivers.
2899 ep
->is_in
= (u
.r
.bRequestType
& USB_DIR_IN
) != 0;
2901 scratch
= BIT(DATA_PACKET_TRANSMITTED_INTERRUPT
) |
2902 BIT(DATA_OUT_PING_TOKEN_INTERRUPT
) |
2903 BIT(DATA_IN_TOKEN_INTERRUPT
);
2904 stop_out_naking(ep
);
2906 scratch
= BIT(DATA_PACKET_RECEIVED_INTERRUPT
) |
2907 BIT(DATA_OUT_PING_TOKEN_INTERRUPT
) |
2908 BIT(DATA_IN_TOKEN_INTERRUPT
);
2909 writel(scratch
, &dev
->epregs
[0].ep_irqenb
);
2911 /* we made the hardware handle most lowlevel requests;
2912 * everything else goes uplevel to the gadget code.
2916 if (dev
->gadget
.speed
== USB_SPEED_SUPER
) {
2917 handle_stat0_irqs_superspeed(dev
, ep
, u
.r
);
2918 goto next_endpoints
;
2921 switch (u
.r
.bRequest
) {
2922 case USB_REQ_GET_STATUS
: {
2923 struct net2280_ep
*e
;
2926 /* hw handles device and interface status */
2927 if (u
.r
.bRequestType
!= (USB_DIR_IN
|USB_RECIP_ENDPOINT
))
2929 e
= get_ep_by_addr(dev
, w_index
);
2930 if (!e
|| w_length
> 2)
2933 if (readl(&e
->regs
->ep_rsp
) & BIT(SET_ENDPOINT_HALT
))
2934 status
= cpu_to_le32(1);
2936 status
= cpu_to_le32(0);
2938 /* don't bother with a request object! */
2939 writel(0, &dev
->epregs
[0].ep_irqenb
);
2940 set_fifo_bytecount(ep
, w_length
);
2941 writel((__force u32
)status
, &dev
->epregs
[0].ep_data
);
2943 ep_vdbg(dev
, "%s stat %02x\n", ep
->ep
.name
, status
);
2944 goto next_endpoints
;
2947 case USB_REQ_CLEAR_FEATURE
: {
2948 struct net2280_ep
*e
;
2950 /* hw handles device features */
2951 if (u
.r
.bRequestType
!= USB_RECIP_ENDPOINT
)
2953 if (w_value
!= USB_ENDPOINT_HALT
|| w_length
!= 0)
2955 e
= get_ep_by_addr(dev
, w_index
);
2959 ep_vdbg(dev
, "%s wedged, halt not cleared\n",
2962 ep_vdbg(dev
, "%s clear halt\n", e
->ep
.name
);
2964 if ((ep
->dev
->quirks
& PLX_SUPERSPEED
) &&
2965 !list_empty(&e
->queue
) && e
->td_dma
)
2969 goto next_endpoints
;
2972 case USB_REQ_SET_FEATURE
: {
2973 struct net2280_ep
*e
;
2975 /* hw handles device features */
2976 if (u
.r
.bRequestType
!= USB_RECIP_ENDPOINT
)
2978 if (w_value
!= USB_ENDPOINT_HALT
|| w_length
!= 0)
2980 e
= get_ep_by_addr(dev
, w_index
);
2983 if (e
->ep
.name
== ep0name
)
2986 if ((dev
->quirks
& PLX_SUPERSPEED
) && e
->dma
)
2989 ep_vdbg(dev
, "%s set halt\n", ep
->ep
.name
);
2990 goto next_endpoints
;
2995 ep_vdbg(dev
, "setup %02x.%02x v%04x i%04x l%04x "
2997 u
.r
.bRequestType
, u
.r
.bRequest
,
2998 w_value
, w_index
, w_length
,
2999 readl(&ep
->cfg
->ep_cfg
));
3001 spin_unlock(&dev
->lock
);
3002 tmp
= dev
->driver
->setup(&dev
->gadget
, &u
.r
);
3003 spin_lock(&dev
->lock
);
3006 /* stall ep0 on error */
3009 ep_vdbg(dev
, "req %02x.%02x protocol STALL; stat %d\n",
3010 u
.r
.bRequestType
, u
.r
.bRequest
, tmp
);
3011 dev
->protocol_stall
= 1;
3014 /* some in/out token irq should follow; maybe stall then.
3015 * driver must queue a request (even zlp) or halt ep0
3016 * before the host times out.
3025 /* endpoint data irq ? */
3026 scratch
= stat
& 0x7f;
3028 for (num
= 0; scratch
; num
++) {
3031 /* do this endpoint's FIFO and queue need tending? */
3033 if ((scratch
& t
) == 0)
3038 handle_ep_small(ep
);
3042 ep_dbg(dev
, "unhandled irqstat0 %08x\n", stat
);
3045 #define DMA_INTERRUPTS (BIT(DMA_D_INTERRUPT) | \
3046 BIT(DMA_C_INTERRUPT) | \
3047 BIT(DMA_B_INTERRUPT) | \
3048 BIT(DMA_A_INTERRUPT))
3049 #define PCI_ERROR_INTERRUPTS ( \
3050 BIT(PCI_MASTER_ABORT_RECEIVED_INTERRUPT) | \
3051 BIT(PCI_TARGET_ABORT_RECEIVED_INTERRUPT) | \
3052 BIT(PCI_RETRY_ABORT_INTERRUPT))
3054 static void handle_stat1_irqs(struct net2280
*dev
, u32 stat
)
3056 struct net2280_ep
*ep
;
3057 u32 tmp
, num
, mask
, scratch
;
3059 /* after disconnect there's nothing else to do! */
3060 tmp
= BIT(VBUS_INTERRUPT
) | BIT(ROOT_PORT_RESET_INTERRUPT
);
3061 mask
= BIT(SUPER_SPEED
) | BIT(HIGH_SPEED
) | BIT(FULL_SPEED
);
3063 /* VBUS disconnect is indicated by VBUS_PIN and VBUS_INTERRUPT set.
3064 * Root Port Reset is indicated by ROOT_PORT_RESET_INTERRUPT set and
3065 * both HIGH_SPEED and FULL_SPEED clear (as ROOT_PORT_RESET_INTERRUPT
3066 * only indicates a change in the reset state).
3070 bool disconnect
= false;
3073 * Ignore disconnects and resets if the speed hasn't been set.
3074 * VBUS can bounce and there's always an initial reset.
3076 writel(tmp
, &dev
->regs
->irqstat1
);
3077 if (dev
->gadget
.speed
!= USB_SPEED_UNKNOWN
) {
3078 if ((stat
& BIT(VBUS_INTERRUPT
)) &&
3079 (readl(&dev
->usb
->usbctl
) &
3080 BIT(VBUS_PIN
)) == 0) {
3082 ep_dbg(dev
, "disconnect %s\n",
3083 dev
->driver
->driver
.name
);
3084 } else if ((stat
& BIT(ROOT_PORT_RESET_INTERRUPT
)) &&
3085 (readl(&dev
->usb
->usbstat
) & mask
)
3088 ep_dbg(dev
, "reset %s\n",
3089 dev
->driver
->driver
.name
);
3092 if (disconnect
|| reset
) {
3093 stop_activity(dev
, dev
->driver
);
3095 spin_unlock(&dev
->lock
);
3097 usb_gadget_udc_reset
3098 (&dev
->gadget
, dev
->driver
);
3100 (dev
->driver
->disconnect
)
3102 spin_lock(&dev
->lock
);
3108 /* vBUS can bounce ... one of many reasons to ignore the
3109 * notion of hotplug events on bus connect/disconnect!
3115 /* NOTE: chip stays in PCI D0 state for now, but it could
3116 * enter D1 to save more power
3118 tmp
= BIT(SUSPEND_REQUEST_CHANGE_INTERRUPT
);
3120 writel(tmp
, &dev
->regs
->irqstat1
);
3121 if (stat
& BIT(SUSPEND_REQUEST_INTERRUPT
)) {
3122 if (dev
->driver
->suspend
)
3123 dev
->driver
->suspend(&dev
->gadget
);
3124 if (!enable_suspend
)
3125 stat
&= ~BIT(SUSPEND_REQUEST_INTERRUPT
);
3127 if (dev
->driver
->resume
)
3128 dev
->driver
->resume(&dev
->gadget
);
3129 /* at high speed, note erratum 0133 */
3134 /* clear any other status/irqs */
3136 writel(stat
, &dev
->regs
->irqstat1
);
3138 /* some status we can just ignore */
3139 if (dev
->quirks
& PLX_2280
)
3140 stat
&= ~(BIT(CONTROL_STATUS_INTERRUPT
) |
3141 BIT(SUSPEND_REQUEST_INTERRUPT
) |
3142 BIT(RESUME_INTERRUPT
) |
3143 BIT(SOF_INTERRUPT
));
3145 stat
&= ~(BIT(CONTROL_STATUS_INTERRUPT
) |
3146 BIT(RESUME_INTERRUPT
) |
3147 BIT(SOF_DOWN_INTERRUPT
) |
3148 BIT(SOF_INTERRUPT
));
3152 /* ep_dbg(dev, "irqstat1 %08x\n", stat);*/
3154 /* DMA status, for ep-{a,b,c,d} */
3155 scratch
= stat
& DMA_INTERRUPTS
;
3156 stat
&= ~DMA_INTERRUPTS
;
3158 for (num
= 0; scratch
; num
++) {
3159 struct net2280_dma_regs __iomem
*dma
;
3162 if ((tmp
& scratch
) == 0)
3166 ep
= &dev
->ep
[num
+ 1];
3172 /* clear ep's dma status */
3173 tmp
= readl(&dma
->dmastat
);
3174 writel(tmp
, &dma
->dmastat
);
3177 if (dev
->quirks
& PLX_SUPERSPEED
) {
3178 u32 r_dmacount
= readl(&dma
->dmacount
);
3179 if (!ep
->is_in
&& (r_dmacount
& 0x00FFFFFF) &&
3180 (tmp
& BIT(DMA_TRANSACTION_DONE_INTERRUPT
)))
3184 if (!(tmp
& BIT(DMA_TRANSACTION_DONE_INTERRUPT
))) {
3185 ep_dbg(ep
->dev
, "%s no xact done? %08x\n",
3191 /* OUT transfers terminate when the data from the
3192 * host is in our memory. Process whatever's done.
3193 * On this path, we know transfer's last packet wasn't
3194 * less than req->length. NAK_OUT_PACKETS may be set,
3195 * or the FIFO may already be holding new packets.
3197 * IN transfers can linger in the FIFO for a very
3198 * long time ... we ignore that for now, accounting
3199 * precisely (like PIO does) needs per-packet irqs
3201 scan_dma_completions(ep
);
3203 /* disable dma on inactive queues; else maybe restart */
3204 if (!list_empty(&ep
->queue
)) {
3205 tmp
= readl(&dma
->dmactl
);
3211 /* NOTE: there are other PCI errors we might usefully notice.
3212 * if they appear very often, here's where to try recovering.
3214 if (stat
& PCI_ERROR_INTERRUPTS
) {
3215 ep_err(dev
, "pci dma error; stat %08x\n", stat
);
3216 stat
&= ~PCI_ERROR_INTERRUPTS
;
3217 /* these are fatal errors, but "maybe" they won't
3220 stop_activity(dev
, dev
->driver
);
3226 ep_dbg(dev
, "unhandled irqstat1 %08x\n", stat
);
3229 static irqreturn_t
net2280_irq(int irq
, void *_dev
)
3231 struct net2280
*dev
= _dev
;
3233 /* shared interrupt, not ours */
3234 if ((dev
->quirks
& PLX_LEGACY
) &&
3235 (!(readl(&dev
->regs
->irqstat0
) & BIT(INTA_ASSERTED
))))
3238 spin_lock(&dev
->lock
);
3240 /* handle disconnect, dma, and more */
3241 handle_stat1_irqs(dev
, readl(&dev
->regs
->irqstat1
));
3243 /* control requests and PIO */
3244 handle_stat0_irqs(dev
, readl(&dev
->regs
->irqstat0
));
3246 if (dev
->quirks
& PLX_SUPERSPEED
) {
3247 /* re-enable interrupt to trigger any possible new interrupt */
3248 u32 pciirqenb1
= readl(&dev
->regs
->pciirqenb1
);
3249 writel(pciirqenb1
& 0x7FFFFFFF, &dev
->regs
->pciirqenb1
);
3250 writel(pciirqenb1
, &dev
->regs
->pciirqenb1
);
3253 spin_unlock(&dev
->lock
);
3258 /*-------------------------------------------------------------------------*/
3260 static void gadget_release(struct device
*_dev
)
3262 struct net2280
*dev
= dev_get_drvdata(_dev
);
3267 /* tear down the binding between this driver and the pci device */
3269 static void net2280_remove(struct pci_dev
*pdev
)
3271 struct net2280
*dev
= pci_get_drvdata(pdev
);
3273 usb_del_gadget_udc(&dev
->gadget
);
3275 BUG_ON(dev
->driver
);
3277 /* then clean up the resources we allocated during probe() */
3278 net2280_led_shutdown(dev
);
3279 if (dev
->requests
) {
3281 for (i
= 1; i
< 5; i
++) {
3282 if (!dev
->ep
[i
].dummy
)
3284 pci_pool_free(dev
->requests
, dev
->ep
[i
].dummy
,
3287 pci_pool_destroy(dev
->requests
);
3290 free_irq(pdev
->irq
, dev
);
3291 if (dev
->quirks
& PLX_SUPERSPEED
)
3292 pci_disable_msi(pdev
);
3296 release_mem_region(pci_resource_start(pdev
, 0),
3297 pci_resource_len(pdev
, 0));
3299 pci_disable_device(pdev
);
3300 device_remove_file(&pdev
->dev
, &dev_attr_registers
);
3302 ep_info(dev
, "unbind\n");
3305 /* wrap this driver around the specified device, but
3306 * don't respond over USB until a gadget driver binds to us.
3309 static int net2280_probe(struct pci_dev
*pdev
, const struct pci_device_id
*id
)
3311 struct net2280
*dev
;
3312 unsigned long resource
, len
;
3313 void __iomem
*base
= NULL
;
3316 /* alloc, and start init */
3317 dev
= kzalloc(sizeof(*dev
), GFP_KERNEL
);
3323 pci_set_drvdata(pdev
, dev
);
3324 spin_lock_init(&dev
->lock
);
3325 dev
->quirks
= id
->driver_data
;
3327 dev
->gadget
.ops
= &net2280_ops
;
3328 dev
->gadget
.max_speed
= (dev
->quirks
& PLX_SUPERSPEED
) ?
3329 USB_SPEED_SUPER
: USB_SPEED_HIGH
;
3331 /* the "gadget" abstracts/virtualizes the controller */
3332 dev
->gadget
.name
= driver_name
;
3334 /* now all the pci goodies ... */
3335 if (pci_enable_device(pdev
) < 0) {
3341 /* BAR 0 holds all the registers
3342 * BAR 1 is 8051 memory; unused here (note erratum 0103)
3343 * BAR 2 is fifo memory; unused here
3345 resource
= pci_resource_start(pdev
, 0);
3346 len
= pci_resource_len(pdev
, 0);
3347 if (!request_mem_region(resource
, len
, driver_name
)) {
3348 ep_dbg(dev
, "controller already in use\n");
3354 /* FIXME provide firmware download interface to put
3355 * 8051 code into the chip, e.g. to turn on PCI PM.
3358 base
= ioremap_nocache(resource
, len
);
3360 ep_dbg(dev
, "can't map memory\n");
3364 dev
->regs
= (struct net2280_regs __iomem
*) base
;
3365 dev
->usb
= (struct net2280_usb_regs __iomem
*) (base
+ 0x0080);
3366 dev
->pci
= (struct net2280_pci_regs __iomem
*) (base
+ 0x0100);
3367 dev
->dma
= (struct net2280_dma_regs __iomem
*) (base
+ 0x0180);
3368 dev
->dep
= (struct net2280_dep_regs __iomem
*) (base
+ 0x0200);
3369 dev
->epregs
= (struct net2280_ep_regs __iomem
*) (base
+ 0x0300);
3371 if (dev
->quirks
& PLX_SUPERSPEED
) {
3374 dev
->usb_ext
= (struct usb338x_usb_ext_regs __iomem
*)
3376 dev
->fiforegs
= (struct usb338x_fifo_regs __iomem
*)
3378 dev
->llregs
= (struct usb338x_ll_regs __iomem
*)
3380 dev
->ll_lfps_regs
= (struct usb338x_ll_lfps_regs __iomem
*)
3382 dev
->ll_tsn_regs
= (struct usb338x_ll_tsn_regs __iomem
*)
3384 dev
->ll_chicken_reg
= (struct usb338x_ll_chi_regs __iomem
*)
3386 dev
->plregs
= (struct usb338x_pl_regs __iomem
*)
3388 usbstat
= readl(&dev
->usb
->usbstat
);
3389 dev
->enhanced_mode
= !!(usbstat
& BIT(11));
3390 dev
->n_ep
= (dev
->enhanced_mode
) ? 9 : 5;
3391 /* put into initial config, link up all endpoints */
3392 fsmvalue
= get_idx_reg(dev
->regs
, SCRATCH
) &
3393 (0xf << DEFECT7374_FSM_FIELD
);
3394 /* See if firmware needs to set up for workaround: */
3395 if (fsmvalue
== DEFECT7374_FSM_SS_CONTROL_READ
) {
3396 dev
->bug7734_patched
= 1;
3397 writel(0, &dev
->usb
->usbctl
);
3399 dev
->bug7734_patched
= 0;
3401 dev
->enhanced_mode
= 0;
3403 /* put into initial config, link up all endpoints */
3404 writel(0, &dev
->usb
->usbctl
);
3410 /* irq setup after old hardware is cleaned up */
3412 ep_err(dev
, "No IRQ. Check PCI setup!\n");
3417 if (dev
->quirks
& PLX_SUPERSPEED
)
3418 if (pci_enable_msi(pdev
))
3419 ep_err(dev
, "Failed to enable MSI mode\n");
3421 if (request_irq(pdev
->irq
, net2280_irq
, IRQF_SHARED
,
3422 driver_name
, dev
)) {
3423 ep_err(dev
, "request interrupt %d failed\n", pdev
->irq
);
3430 /* NOTE: we know only the 32 LSBs of dma addresses may be nonzero */
3431 dev
->requests
= pci_pool_create("requests", pdev
,
3432 sizeof(struct net2280_dma
),
3433 0 /* no alignment requirements */,
3434 0 /* or page-crossing issues */);
3435 if (!dev
->requests
) {
3436 ep_dbg(dev
, "can't get request pool\n");
3440 for (i
= 1; i
< 5; i
++) {
3441 struct net2280_dma
*td
;
3443 td
= pci_pool_alloc(dev
->requests
, GFP_KERNEL
,
3444 &dev
->ep
[i
].td_dma
);
3446 ep_dbg(dev
, "can't get dummy %d\n", i
);
3450 td
->dmacount
= 0; /* not VALID */
3451 td
->dmadesc
= td
->dmaaddr
;
3452 dev
->ep
[i
].dummy
= td
;
3455 /* enable lower-overhead pci memory bursts during DMA */
3456 if (dev
->quirks
& PLX_LEGACY
)
3457 writel(BIT(DMA_MEMORY_WRITE_AND_INVALIDATE_ENABLE
) |
3459 * 256 write retries may not be enough...
3460 BIT(PCI_RETRY_ABORT_ENABLE) |
3462 BIT(DMA_READ_MULTIPLE_ENABLE
) |
3463 BIT(DMA_READ_LINE_ENABLE
),
3464 &dev
->pci
->pcimstctl
);
3465 /* erratum 0115 shouldn't appear: Linux inits PCI_LATENCY_TIMER */
3466 pci_set_master(pdev
);
3467 pci_try_set_mwi(pdev
);
3469 /* ... also flushes any posted pci writes */
3470 dev
->chiprev
= get_idx_reg(dev
->regs
, REG_CHIPREV
) & 0xffff;
3473 ep_info(dev
, "%s\n", driver_desc
);
3474 ep_info(dev
, "irq %d, pci mem %p, chip rev %04x\n",
3475 pdev
->irq
, base
, dev
->chiprev
);
3476 ep_info(dev
, "version: " DRIVER_VERSION
"; %s\n",
3477 dev
->enhanced_mode
? "enhanced mode" : "legacy mode");
3478 retval
= device_create_file(&pdev
->dev
, &dev_attr_registers
);
3482 retval
= usb_add_gadget_udc_release(&pdev
->dev
, &dev
->gadget
,
3490 net2280_remove(pdev
);
3494 /* make sure the board is quiescent; otherwise it will continue
3495 * generating IRQs across the upcoming reboot.
3498 static void net2280_shutdown(struct pci_dev
*pdev
)
3500 struct net2280
*dev
= pci_get_drvdata(pdev
);
3503 writel(0, &dev
->regs
->pciirqenb0
);
3504 writel(0, &dev
->regs
->pciirqenb1
);
3506 /* disable the pullup so the host will think we're gone */
3507 writel(0, &dev
->usb
->usbctl
);
3512 /*-------------------------------------------------------------------------*/
3514 static const struct pci_device_id pci_ids
[] = { {
3515 .class = ((PCI_CLASS_SERIAL_USB
<< 8) | 0xfe),
3517 .vendor
= PCI_VENDOR_ID_PLX_LEGACY
,
3519 .subvendor
= PCI_ANY_ID
,
3520 .subdevice
= PCI_ANY_ID
,
3521 .driver_data
= PLX_LEGACY
| PLX_2280
,
3523 .class = ((PCI_CLASS_SERIAL_USB
<< 8) | 0xfe),
3525 .vendor
= PCI_VENDOR_ID_PLX_LEGACY
,
3527 .subvendor
= PCI_ANY_ID
,
3528 .subdevice
= PCI_ANY_ID
,
3529 .driver_data
= PLX_LEGACY
,
3532 .class = ((PCI_CLASS_SERIAL_USB
<< 8) | 0xfe),
3534 .vendor
= PCI_VENDOR_ID_PLX
,
3536 .subvendor
= PCI_ANY_ID
,
3537 .subdevice
= PCI_ANY_ID
,
3538 .driver_data
= PLX_SUPERSPEED
,
3541 .class = ((PCI_CLASS_SERIAL_USB
<< 8) | 0xfe),
3543 .vendor
= PCI_VENDOR_ID_PLX
,
3545 .subvendor
= PCI_ANY_ID
,
3546 .subdevice
= PCI_ANY_ID
,
3547 .driver_data
= PLX_SUPERSPEED
,
3549 { /* end: all zeroes */ }
3551 MODULE_DEVICE_TABLE(pci
, pci_ids
);
3553 /* pci driver glue; this is a "new style" PCI driver module */
3554 static struct pci_driver net2280_pci_driver
= {
3555 .name
= (char *) driver_name
,
3556 .id_table
= pci_ids
,
3558 .probe
= net2280_probe
,
3559 .remove
= net2280_remove
,
3560 .shutdown
= net2280_shutdown
,
3562 /* FIXME add power management support */
3565 module_pci_driver(net2280_pci_driver
);
3567 MODULE_DESCRIPTION(DRIVER_DESC
);
3568 MODULE_AUTHOR("David Brownell");
3569 MODULE_LICENSE("GPL");