23 #include <linux/device.h>
24 #include <linux/errno.h>
30 #include <linux/kernel.h>
31 #include <linux/list.h>
32 #include <linux/module.h>
34 #include <linux/pci.h>
36 #include <linux/prefetch.h>
37 #include <linux/sched.h>
38 #include <linux/slab.h>
41 #include <linux/usb/ch9.h>
44 #include <asm/byteorder.h>
45 #include <asm/unaligned.h>
49 #define DRIVER_DESC "PLX NET2272 USB Peripheral Controller"
52 static const char driver_vers[] =
"2006 October 17/mainline";
55 static const char ep0name[] =
"ep0";
56 static const char *
const ep_name[] = {
58 "ep-a",
"ep-b",
"ep-c",
61 #define DMA_ADDR_INVALID (~(dma_addr_t)0)
62 #ifdef CONFIG_USB_GADGET_NET2272_DMA
109 static ushort fifo_mode = 0;
118 static ushort enable_suspend = 0;
121 static void assert_out_naking(
struct net2272_ep *ep,
const char *where)
129 tmp = net2272_ep_read(ep,
EP_STAT0);
132 ep->
ep.name, where, tmp);
136 #define ASSERT_OUT_NAKING(ep) assert_out_naking(ep, __func__)
138 static void stop_out_naking(
struct net2272_ep *ep)
146 #define PIPEDIR(bAddress) (usb_pipein(bAddress) ? "in" : "out")
154 default:
return "control";
158 static char *buf_state_string(
unsigned state)
165 default:
return "unknown";
169 static char *dma_mode_string(
void)
174 case 0:
return "SLOW DREQ";
175 case 1:
return "FAST DREQ";
176 case 2:
return "BURST";
177 default:
return "invalid";
181 static void net2272_dequeue_all(
struct net2272_ep *);
183 static int net2272_fifo_status(
struct usb_ep *);
199 if (!_ep || !desc || ep->
desc || _ep->
name == ep0name
206 max = usb_endpoint_maxp(desc) & 0x1fff;
218 net2272_ep_write(ep,
EP_MAXPKT1, (max & 0xff00) >> 8);
222 tmp = usb_endpoint_type(desc);
223 if (usb_endpoint_xfer_bulk(desc)) {
227 spin_unlock_irqrestore(&dev->
lock, flags);
231 ep->
is_iso = usb_endpoint_xfer_isoc(desc) ? 1 : 0;
238 ep->
is_in = usb_endpoint_dir_in(desc);
242 net2272_ep_write(ep,
EP_CFG, tmp);
245 tmp = (1 << ep->
num) | net2272_read(dev,
IRQENB0);
246 net2272_write(dev,
IRQENB0, tmp);
254 dev_dbg(dev->
dev,
"enabled %s (ep%d%s-%s) max %04x cfg %02x\n",
257 net2272_ep_read(ep,
EP_CFG));
259 spin_unlock_irqrestore(&dev->
lock, flags);
263 static void net2272_ep_reset(
struct net2272_ep *ep)
268 INIT_LIST_HEAD(&ep->
queue);
270 ep->
ep.maxpacket = ~0;
271 ep->
ep.ops = &net2272_ep_ops;
309 static int net2272_disable(
struct usb_ep *_ep)
315 if (!_ep || !ep->
desc || _ep->
name == ep0name)
319 net2272_dequeue_all(ep);
320 net2272_ep_reset(ep);
324 spin_unlock_irqrestore(&ep->
dev->lock, flags);
331 net2272_alloc_request(
struct usb_ep *_ep,
gfp_t gfp_flags)
340 req = kzalloc(
sizeof(*req), gfp_flags);
345 INIT_LIST_HEAD(&req->
queue);
372 if (ep->
dev->protocol_stall) {
379 list_del_init(&req->
queue);
384 status = req->
req.status;
392 dev_vdbg(dev->
dev,
"complete %s req %p stat %d len %u/%u buf %p\n",
393 ep->
ep.name, &req->
req, status,
394 req->
req.actual, req->
req.length, req->
req.buf);
398 spin_unlock(&dev->
lock);
399 req->
req.complete(&ep->
ep, &req->
req);
400 spin_lock(&dev->
lock);
413 length =
min(req->
req.length - req->
req.actual, max);
416 dev_vdbg(ep->
dev->dev,
"write packet %s req %p max %u len %u avail %u\n",
417 ep->
ep.name, req, max, length,
423 while (
likely(count >= 2)) {
448 dev_vdbg(ep->
dev->dev,
"write_fifo %s actual %d len %d\n",
449 ep->
ep.name, req->
req.actual, req->
req.length);
463 buf = req->
req.buf + req->
req.actual;
469 max = (net2272_ep_read(ep,
EP_AVAIL1) << 8) |
472 if (max < ep->ep.maxpacket)
473 max = (net2272_ep_read(ep,
EP_AVAIL1) << 8)
476 count = net2272_write_packet(ep, buf, req, max);
478 if (req->
req.length == req->
req.actual) {
480 if (count < ep->ep.maxpacket)
481 set_fifo_bytecount(ep, 0);
482 net2272_done(ep, req, 0);
484 if (!list_empty(&ep->
queue)) {
488 status = net2272_kick_dma(ep, req);
522 dev_vdbg(ep->
dev->dev,
"read packet %s req %p len %u avail %u\n",
523 ep->
ep.name, req, avail,
526 is_short = (avail < ep->
ep.maxpacket);
540 *bufp++ =
readw(ep_data);
564 dev_vdbg(ep->
dev->dev,
"read_fifo %s actual %d len %d\n",
565 ep->
ep.name, req->
req.actual, req->
req.length);
569 buf = req->
req.buf + req->
req.actual;
572 count = (net2272_ep_read(ep,
EP_AVAIL1) << 8)
579 tmp = req->
req.length - req->
req.actual;
582 if ((tmp % ep->
ep.maxpacket) != 0) {
584 "%s out fifo %d bytes, expected %d\n",
585 ep->
ep.name, count, tmp);
588 count = (tmp > 0) ? tmp : 0;
591 is_short = net2272_read_packet(ep, buf, req, count);
595 ((req->
req.actual == req->
req.length)
596 && !req->
req.zero))) {
599 net2272_out_flush(ep);
602 net2272_done(ep, req, 0);
614 if (!list_empty(&ep->
queue)) {
617 status = net2272_kick_dma(ep, req);
638 (ep->
is_in ? net2272_write_fifo : net2272_read_fifo)(ep, req);
643 net2272_request_dma(
struct net2272 *dev,
unsigned ep,
u32 buf,
644 unsigned len,
unsigned dir)
646 dev_vdbg(dev->
dev,
"request_dma ep %d buf %08x len %d dir %d\n",
656 if ((dir == 1) && (len > 0x1000000))
676 dev->rdk1.plx9054_base_addr +
DMAMODE0);
683 dev->rdk1.plx9054_base_addr +
DMADPR0);
686 dev->rdk1.plx9054_base_addr +
INTCSR);
692 net2272_write(dev,
DMAREQ,
707 net2272_start_dma(
struct net2272 *dev)
714 dev->rdk1.plx9054_base_addr +
DMACSR0);
733 if (req->
req.length & 1)
736 dev_vdbg(ep->
dev->dev,
"kick_dma %s req %p dma %08llx\n",
737 ep->
ep.name, req, (
unsigned long long) req->
req.dma);
742 if (ep->
dev->dma_busy)
748 size = req->
req.length;
754 if (net2272_request_dma(ep->
dev, ep->
num, req->
req.dma, size, 0))
761 tmp = net2272_ep_read(ep,
EP_STAT0);
764 if (net2272_request_dma(ep->
dev, ep->
num, req->
req.dma, size, 1))
799 net2272_start_dma(ep->
dev);
804 static void net2272_cancel_dma(
struct net2272 *dev)
817 dev->rdk1.plx9054_base_addr +
DMACSR0);
839 || !list_empty(&req->
queue))
842 if (!_ep || (!ep->
desc && ep->
num != 0))
856 dev_vdbg(dev->
dev,
"%s queue req %p, len %d buf %p dma %08llx %s\n",
858 (
unsigned long long) _req->
dma, _req->
zero ?
"zero" :
"!zero");
869 net2272_done(ep, req, 0);
880 dev_dbg(dev->
dev,
"WARNING: returning ZLP short packet termination!\n");
885 status = net2272_read_fifo(ep, req);
893 status = net2272_kick_dma(ep, req);
902 status = net2272_write_fifo(ep, req);
906 status = net2272_read_fifo(ep, req);
922 spin_unlock_irqrestore(&dev->
lock, flags);
936 while (!list_empty(&ep->
queue)) {
954 if (!_ep || (!ep->
desc && ep->
num != 0) || !_req)
963 if (&req->
req == _req)
966 if (&req->
req != _req) {
967 spin_unlock_irqrestore(&ep->
dev->lock, flags);
979 spin_unlock_irqrestore(&ep->
dev->lock, flags);
986 net2272_set_halt_and_wedge(
struct usb_ep *_ep,
int value,
int wedged)
993 if (!_ep || (!ep->
desc && ep->
num != 0))
997 if (ep->
desc && usb_endpoint_xfer_isoc(ep->
desc))
1001 if (!list_empty(&ep->
queue))
1003 else if (ep->
is_in && value && net2272_fifo_status(_ep) != 0)
1007 value ?
"set" :
"clear",
1008 wedged ?
"wedge" :
"halt");
1012 ep->
dev->protocol_stall = 1;
1022 spin_unlock_irqrestore(&ep->
dev->lock, flags);
1028 net2272_set_halt(
struct usb_ep *_ep,
int value)
1030 return net2272_set_halt_and_wedge(_ep, value, 0);
1034 net2272_set_wedge(
struct usb_ep *_ep)
1036 if (!_ep || _ep->
name == ep0name)
1038 return net2272_set_halt_and_wedge(_ep, 1, 1);
1042 net2272_fifo_status(
struct usb_ep *_ep)
1048 if (!_ep || (!ep->
desc && ep->
num != 0))
1053 avail = net2272_ep_read(ep,
EP_AVAIL1) << 8;
1054 avail |= net2272_ep_read(ep,
EP_AVAIL0);
1063 net2272_fifo_flush(
struct usb_ep *_ep)
1068 if (!_ep || (!ep->
desc && ep->
num != 0))
1077 .enable = net2272_enable,
1078 .disable = net2272_disable,
1080 .alloc_request = net2272_alloc_request,
1081 .free_request = net2272_free_request,
1083 .queue = net2272_queue,
1084 .dequeue = net2272_dequeue,
1086 .set_halt = net2272_set_halt,
1087 .set_wedge = net2272_set_wedge,
1088 .fifo_status = net2272_fifo_status,
1089 .fifo_flush = net2272_fifo_flush,
1095 net2272_get_frame(
struct usb_gadget *_gadget)
1098 unsigned long flags;
1106 ret = net2272_read(dev,
FRAME1) << 8;
1107 ret |= net2272_read(dev,
FRAME0);
1109 spin_unlock_irqrestore(&dev->
lock, flags);
1118 unsigned long flags;
1125 tmp = net2272_read(dev,
USBCTL0);
1129 spin_unlock_irqrestore(&dev->
lock, flags);
1135 net2272_set_selfpowered(
struct usb_gadget *_gadget,
int value)
1149 net2272_pullup(
struct usb_gadget *_gadget,
int is_on)
1153 unsigned long flags;
1160 tmp = net2272_read(dev,
USBCTL0);
1166 net2272_write(dev,
USBCTL0, tmp);
1167 spin_unlock_irqrestore(&dev->
lock, flags);
1172 static int net2272_start(
struct usb_gadget *_gadget,
1174 static int net2272_stop(
struct usb_gadget *_gadget,
1178 .get_frame = net2272_get_frame,
1179 .wakeup = net2272_wakeup,
1180 .set_selfpowered = net2272_set_selfpowered,
1181 .pullup = net2272_pullup,
1182 .udc_start = net2272_start,
1183 .udc_stop = net2272_stop,
1194 unsigned long flags;
1205 s = dev->
driver->driver.name;
1210 t =
scnprintf(next, size,
"%s version %s,"
1211 "chiprev %02x, locctl %02x\n"
1212 "irqenb0 %02x irqenb1 %02x "
1213 "irqstat0 %02x irqstat1 %02x\n",
1215 net2272_read(dev,
LOCCTL),
1224 t1 = net2272_read(dev,
DMAREQ);
1225 t =
scnprintf(next, size,
"\ndmareq %02x: %s %s%s%s%s\n",
1226 t1, ep_name[(t1 & 0x01) + 1],
1235 t1 = net2272_read(dev,
USBCTL1);
1246 "usbctl0 %02x usbctl1 %02x addr 0x%02x (%s)\n",
1247 net2272_read(dev,
USBCTL0), t1,
1248 net2272_read(dev,
OURADDR), s);
1253 for (i = 0; i < 4; ++
i) {
1260 t1 = net2272_ep_read(ep,
EP_CFG);
1263 "\n%s\tcfg %02x rsp (%02x) %s%s%s%s%s%s%s%s"
1265 ep->
ep.name, t1, t2,
1279 "\tstat0 %02x stat1 %02x avail %04x "
1285 ep->
is_in ?
"in" :
"out",
1286 type_string(t1 >> 5),
1292 "\tep_transfer %06x\n",
1302 "\tbuf-a %s buf-b %s\n",
1303 buf_state_string(t1),
1304 buf_state_string(t2));
1309 spin_unlock_irqrestore(&dev->
lock, flags);
1318 net2272_set_fifo_mode(
struct net2272 *dev,
int mode)
1322 tmp = net2272_read(dev,
LOCCTL) & 0x3f;
1324 net2272_write(dev,
LOCCTL, tmp);
1326 INIT_LIST_HEAD(&dev->
gadget.ep_list);
1334 dev->
ep[1].fifo_size = dev->
ep[2].fifo_size = 512;
1338 dev->
ep[1].fifo_size = 1024;
1339 dev->
ep[2].fifo_size = 512;
1343 dev->
ep[1].fifo_size = dev->
ep[2].fifo_size = 1024;
1346 dev->
ep[1].fifo_size = 1024;
1352 dev->
ep[3].fifo_size = 512;
1358 net2272_usb_reset(
struct net2272 *dev)
1362 net2272_cancel_dma(dev);
1364 net2272_write(dev,
IRQENB0, 0);
1365 net2272_write(dev,
IRQENB1, 0);
1368 net2272_write(dev,
IRQSTAT0, 0xff);
1371 net2272_write(dev,
DMAREQ,
1380 net2272_cancel_dma(dev);
1381 net2272_set_fifo_mode(dev, (fifo_mode <= 3) ? fifo_mode : 0);
1392 net2272_usb_reinit(
struct net2272 *dev)
1397 for (i = 0; i < 4; ++
i) {
1400 ep->
ep.name = ep_name[
i];
1408 if (i > 0 && i <= 3)
1412 net2272_ep_reset(ep);
1414 dev->
ep[0].ep.maxpacket = 64;
1417 dev->
ep[0].stopped = 0;
1418 INIT_LIST_HEAD(&dev->
gadget.ep0->ep_list);
1422 net2272_ep0_start(
struct net2272 *dev)
1452 static int net2272_start(
struct usb_gadget *_gadget,
1458 if (!driver || !driver->
unbind || !driver->
setup ||
1464 for (i = 0; i < 4; ++
i)
1465 dev->
ep[i].irqs = 0;
1475 net2272_ep0_start(dev);
1494 net2272_usb_reset(dev);
1495 for (i = 0; i < 4; ++
i)
1496 net2272_dequeue_all(&dev->
ep[i]);
1498 net2272_usb_reinit(dev);
1501 static int net2272_stop(
struct usb_gadget *_gadget,
1505 unsigned long flags;
1510 stop_activity(dev, driver);
1511 spin_unlock_irqrestore(&dev->
lock, flags);
1529 if (!list_empty(&ep->
queue))
1535 dev_vdbg(ep->
dev->dev,
"handle_dma %s req %p\n", ep->
ep.name, req);
1547 ep->
dev->dma_busy = 0;
1557 if ((req->
req.length % ep->
ep.maxpacket != 0) ||
1559 set_fifo_bytecount(ep, 0);
1561 net2272_done(ep, req, 0);
1562 if (!list_empty(&ep->
queue)) {
1565 status = net2272_kick_dma(ep, req);
1567 net2272_pio_advance(ep);
1576 net2272_cancel_dma(ep->
dev);
1591 req->
req.actual += len;
1594 net2272_pio_advance(ep);
1606 if (!list_empty(&ep->
queue))
1613 stat0 = net2272_ep_read(ep,
EP_STAT0);
1614 stat1 = net2272_ep_read(ep,
EP_STAT1);
1617 dev_vdbg(ep->
dev->dev,
"%s ack ep_stat0 %02x, ep_stat1 %02x, req %p\n",
1618 ep->
ep.name, stat0, stat1, req ? &req->
req : 0);
1620 net2272_ep_write(ep,
EP_STAT0, stat0 &
1623 net2272_ep_write(ep,
EP_STAT1, stat1);
1630 net2272_pio_advance(ep);
1633 net2272_pio_advance(ep);
1649 bEndpointAddress = ep->
desc->bEndpointAddress;
1650 if ((wIndex ^ bEndpointAddress) &
USB_DIR_IN)
1652 if ((wIndex & 0x0f) == (bEndpointAddress & 0x0f))
1667 static const u8 net2272_test_packet[] = {
1668 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1669 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA,
1670 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE,
1671 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
1672 0x7F, 0xBF, 0xDF, 0xEF, 0xF7, 0xFB, 0xFD,
1673 0xFC, 0x7E, 0xBF, 0xDF, 0xEF, 0xF7, 0xFD, 0x7E
1677 net2272_set_test_mode(
struct net2272 *dev,
int mode)
1684 net2272_write(dev,
IRQENB0, 0x00);
1685 net2272_write(dev,
IRQENB1, 0x00);
1690 net2272_write(dev,
PAGESEL, 0);
1699 while (!(net2272_read(dev,
EP_STAT0) &
1704 net2272_write(dev,
USBTEST, mode);
1707 if (mode == TEST_PACKET) {
1712 for (i = 0; i <
sizeof(net2272_test_packet); ++
i)
1713 net2272_write(dev,
EP_DATA, net2272_test_packet[i]);
1749 while (!list_empty(&ep->
queue)) {
1752 net2272_done(ep, req,
1781 net2272_write(dev,
PAGESEL, 0);
1786 u.raw[0] = net2272_read(dev,
SETUP0);
1787 u.raw[1] = net2272_read(dev,
SETUP1);
1788 u.raw[2] = net2272_read(dev,
SETUP2);
1789 u.raw[3] = net2272_read(dev,
SETUP3);
1790 u.raw[4] = net2272_read(dev,
SETUP4);
1791 u.raw[5] = net2272_read(dev,
SETUP5);
1792 u.raw[6] = net2272_read(dev,
SETUP6);
1793 u.raw[7] = net2272_read(dev,
SETUP7);
1814 stop_out_naking(ep);
1819 net2272_ep_write(ep,
EP_IRQENB, scratch);
1823 switch (
u.r.bRequest) {
1830 e = net2272_get_ep_by_addr(dev,
u.r.wIndex);
1831 if (!e ||
u.r.wLength > 2)
1841 set_fifo_bytecount(&dev->
ep[0], 0);
1844 ep->
ep.name, status);
1845 goto next_endpoints;
1847 if (
u.r.wLength > 2)
1855 set_fifo_bytecount(&dev->
ep[0], 0);
1858 goto next_endpoints;
1860 if (
u.r.wLength > 2)
1866 set_fifo_bytecount(&dev->
ep[0], 0);
1868 dev_vdbg(dev->
dev,
"interface status %02x\n", status);
1869 goto next_endpoints;
1882 e = net2272_get_ep_by_addr(dev,
u.r.wIndex);
1886 dev_vdbg(dev->
dev,
"%s wedged, halt not cleared\n",
1893 goto next_endpoints;
1900 net2272_set_test_mode(dev, (
u.r.wIndex >> 8));
1903 goto next_endpoints;
1909 e = net2272_get_ep_by_addr(dev,
u.r.wIndex);
1915 goto next_endpoints;
1918 net2272_write(dev,
OURADDR,
u.r.wValue & 0xff);
1926 u.r.bRequestType,
u.r.bRequest,
1927 u.r.wValue,
u.r.wIndex,
1928 net2272_ep_read(ep,
EP_CFG));
1929 spin_unlock(&dev->
lock);
1931 spin_lock(&dev->
lock);
1937 dev_vdbg(dev->
dev,
"req %02x.%02x protocol STALL; stat %d\n",
1938 u.r.bRequestType,
u.r.bRequest, tmp);
1943 net2272_cancel_dma(dev);
1950 net2272_handle_dma(ep);
1955 scratch = stat & 0x0f;
1957 for (num = 0;
scratch; num++) {
1962 if ((scratch & t) == 0)
1967 net2272_handle_ep(ep);
1974 dev_dbg(dev->
dev,
"unhandled irqstat0 %02x\n", stat);
1978 net2272_handle_stat1_irqs(
struct net2272 *dev,
u8 stat)
1989 ((net2272_read(dev,
USBCTL1) & mask) == 0))
1994 dev->
driver->driver.name);
1995 stop_activity(dev, dev->
driver);
1996 net2272_ep0_start(dev);
2009 if (dev->
driver->suspend)
2011 if (!enable_suspend) {
2013 dev_dbg(dev->
dev,
"Suspend disabled, ignoring\n");
2024 net2272_write(dev,
IRQSTAT1, stat);
2033 dev_dbg(dev->
dev,
"unhandled irqstat1 %02x\n", stat);
2036 static irqreturn_t net2272_irq(
int irq,
void *_dev)
2039 #if defined(PLX_PCI_RDK) || defined(PLX_PCI_RDK2)
2042 #if defined(PLX_PCI_RDK)
2045 spin_lock(&dev->
lock);
2046 #if defined(PLX_PCI_RDK)
2047 intcsr =
readl(dev->rdk1.plx9054_base_addr +
INTCSR);
2051 dev->rdk1.plx9054_base_addr +
INTCSR);
2052 net2272_handle_stat1_irqs(dev, net2272_read(dev,
IRQSTAT1));
2053 net2272_handle_stat0_irqs(dev, net2272_read(dev,
IRQSTAT0));
2054 intcsr =
readl(dev->rdk1.plx9054_base_addr +
INTCSR);
2056 dev->rdk1.plx9054_base_addr +
INTCSR);
2060 dev->rdk1.plx9054_base_addr +
DMACSR0);
2062 dmareq = net2272_read(dev,
DMAREQ);
2064 net2272_handle_dma(&dev->
ep[2]);
2066 net2272_handle_dma(&dev->
ep[1]);
2069 #if defined(PLX_PCI_RDK2)
2073 spin_unlock(&dev->
lock);
2079 #if !defined(PLX_PCI_RDK)
2080 net2272_handle_stat1_irqs(dev, net2272_read(dev,
IRQSTAT1));
2081 net2272_handle_stat0_irqs(dev, net2272_read(dev,
IRQSTAT0));
2083 spin_unlock(&dev->
lock);
2088 static int net2272_present(
struct net2272 *dev)
2103 refval = net2272_read(dev,
SCRATCH);
2104 for (ii = 0; ii < 0x100; ii += 7) {
2105 net2272_write(dev,
SCRATCH, ii);
2106 val = net2272_read(dev,
SCRATCH);
2109 "%s: write/read SCRATCH register test failed: "
2110 "wrote:0x%2.2x, read:0x%2.2x\n",
2116 net2272_write(dev,
SCRATCH, refval);
2120 for (ii = 0; ii < 0x100; ii += 7) {
2123 if (val != refval) {
2125 "%s: write/read CHIPREV register test failed: "
2126 "wrote 0x%2.2x, read:0x%2.2x expected:0x%2.2x\n",
2127 __func__, ii, val, refval);
2146 "%s: WARNING: UNEXPECTED NET2272 LEGACY REGISTER VALUE:\n"
2147 " - CHIPREV_LEGACY: expected 0x%2.2x, got:0x%2.2x. (Not NET2272?)\n",
2165 "%s: Rev 1 detected: newer silicon recommended for DMA support\n",
2173 "%s: unexpected silicon revision register value: "
2174 " CHIPREV_2272: 0x%2.2x\n",
2188 net2272_gadget_release(
struct device *_dev)
2197 net2272_remove(
struct net2272 *dev)
2204 dev_warn(dev->
dev,
"pci remove, driver '%s' is still registered\n",
2205 dev->
driver->driver.name);
2219 net2272_probe_init(
struct device *dev,
unsigned int irq)
2236 ret->
gadget.ops = &net2272_ops;
2243 ret->
gadget.dev.release = net2272_gadget_release;
2250 net2272_probe_fin(
struct net2272 *dev,
unsigned int irqflags)
2255 if (net2272_present(dev)) {
2261 net2272_usb_reset(dev);
2262 net2272_usb_reinit(dev);
2266 dev_err(dev->
dev,
"request interrupt %i failed\n", dev->
irq);
2274 dev_info(dev->
dev,
"irq %i, mem %p, chip rev %04x, dma %s\n",
2313 void __iomem *mem_mapped_addr[4];
2324 for (i = 0; i < 4; ++
i) {
2332 dev_dbg(dev->
dev,
"controller already in use\n");
2338 if (mem_mapped_addr[i] ==
NULL) {
2346 dev->rdk1.plx9054_base_addr = mem_mapped_addr[0];
2347 dev->rdk1.epld_base_addr = mem_mapped_addr[2];
2351 tmp =
readl(dev->rdk1.plx9054_base_addr +
LBRD1);
2353 dev->rdk1.plx9054_base_addr +
LBRD1);
2359 dev->rdk1.plx9054_base_addr +
INTCSR);
2362 dev->rdk1.plx9054_base_addr +
DMACSR0);
2396 void __iomem *mem_mapped_addr[2];
2405 for (i = 0; i < 2; ++
i) {
2410 dev_dbg(dev->
dev,
"controller already in use\n");
2416 if (mem_mapped_addr[i] ==
NULL) {
2424 dev->rdk2.fpga_base_addr = mem_mapped_addr[0];
2456 dev = net2272_probe_init(&pdev->
dev, pdev->
irq);
2458 return PTR_ERR(dev);
2476 ret = net2272_probe_fin(dev, 0);
2480 pci_set_drvdata(pdev, dev);
2500 dev->rdk1.plx9054_base_addr +
INTCSR);
2503 iounmap(dev->rdk1.plx9054_base_addr);
2504 iounmap(dev->rdk1.epld_base_addr);
2506 for (i = 0; i < 4; ++
i) {
2526 iounmap(dev->rdk2.fpga_base_addr);
2528 for (i = 0; i < 2; ++
i)
2534 net2272_pci_remove(
struct pci_dev *pdev)
2536 struct net2272 *dev = pci_get_drvdata(pdev);
2538 net2272_remove(dev);
2573 static struct pci_driver net2272_pci_driver = {
2575 .id_table = pci_ids,
2577 .probe = net2272_pci_probe,
2581 static int net2272_pci_register(
void)
2583 return pci_register_driver(&net2272_pci_driver);
2586 static void net2272_pci_unregister(
void)
2592 static inline int net2272_pci_register(
void) {
return 0; }
2593 static inline void net2272_pci_unregister(
void) { }
2603 unsigned int irqflags;
2605 struct resource *iomem, *iomem_bus, *irq_res;
2610 if (!irq_res || !iomem) {
2611 dev_err(&pdev->
dev,
"must provide irq/base addr");
2615 dev = net2272_probe_init(&pdev->
dev, irq_res->
start);
2617 return PTR_ERR(dev);
2629 base = iomem->
start;
2630 len = resource_size(iomem);
2635 dev_dbg(dev->
dev,
"get request memory region!\n");
2650 platform_set_drvdata(pdev, dev);
2651 dev_info(&pdev->
dev,
"running in 16-bit, %sbyte swap local bus mode\n",
2652 (net2272_read(dev,
LOCCTL) & (1 << BYTE_SWAP)) ?
"" :
"no ");
2667 struct net2272 *dev = platform_get_drvdata(pdev);
2669 net2272_remove(dev);
2672 resource_size(&pdev->
resource[0]));
2680 .probe = net2272_plat_probe,
2690 static int __init net2272_init(
void)
2694 ret = net2272_pci_register();
2703 net2272_pci_unregister();
2708 static void __exit net2272_cleanup(
void)
2710 net2272_pci_unregister();