blob: 6b4e925aa7f1e7df0f82db350ca21e7059dc7cdf [file] [log] [blame]
Olof Johanssonf5cd7872007-01-31 21:43:54 -06001/*
2 * Copyright (C) 2006-2007 PA Semi, Inc
3 *
4 * Driver for the PA Semi PWRficient onchip 1G/10G Ethernet MACs
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19
20#include <linux/init.h>
21#include <linux/module.h>
22#include <linux/pci.h>
23#include <linux/interrupt.h>
24#include <linux/dmaengine.h>
25#include <linux/delay.h>
26#include <linux/netdevice.h>
27#include <linux/etherdevice.h>
28#include <asm/dma-mapping.h>
29#include <linux/in.h>
30#include <linux/skbuff.h>
31
32#include <linux/ip.h>
33#include <linux/tcp.h>
34#include <net/checksum.h>
35
Olof Johansson771f7402007-05-08 00:47:21 -050036#include <asm/irq.h>
37
Olof Johanssonf5cd7872007-01-31 21:43:54 -060038#include "pasemi_mac.h"
39
40
41/* TODO list
42 *
43 * - Get rid of pci_{read,write}_config(), map registers with ioremap
44 * for performance
45 * - PHY support
46 * - Multicast support
47 * - Large MTU support
48 * - Other performance improvements
49 */
50
51
52/* Must be a power of two */
53#define RX_RING_SIZE 512
54#define TX_RING_SIZE 512
55
56#define TX_DESC(mac, num) ((mac)->tx->desc[(num) & (TX_RING_SIZE-1)])
57#define TX_DESC_INFO(mac, num) ((mac)->tx->desc_info[(num) & (TX_RING_SIZE-1)])
58#define RX_DESC(mac, num) ((mac)->rx->desc[(num) & (RX_RING_SIZE-1)])
59#define RX_DESC_INFO(mac, num) ((mac)->rx->desc_info[(num) & (RX_RING_SIZE-1)])
60#define RX_BUFF(mac, num) ((mac)->rx->buffers[(num) & (RX_RING_SIZE-1)])
61
62#define BUF_SIZE 1646 /* 1500 MTU + ETH_HLEN + VLAN_HLEN + 2 64B cachelines */
63
Olof Johanssonf5cd7872007-01-31 21:43:54 -060064static struct pasdma_status *dma_status;
65
66static int pasemi_get_mac_addr(struct pasemi_mac *mac)
67{
68 struct pci_dev *pdev = mac->pdev;
69 struct device_node *dn = pci_device_to_OF_node(pdev);
70 const u8 *maddr;
71 u8 addr[6];
72
73 if (!dn) {
74 dev_dbg(&pdev->dev,
75 "No device node for mac, not configuring\n");
76 return -ENOENT;
77 }
78
79 maddr = get_property(dn, "mac-address", NULL);
80 if (maddr == NULL) {
81 dev_warn(&pdev->dev,
82 "no mac address in device tree, not configuring\n");
83 return -ENOENT;
84 }
85
86 if (sscanf(maddr, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx", &addr[0],
87 &addr[1], &addr[2], &addr[3], &addr[4], &addr[5]) != 6) {
88 dev_warn(&pdev->dev,
89 "can't parse mac address, not configuring\n");
90 return -EINVAL;
91 }
92
93 memcpy(mac->mac_addr, addr, sizeof(addr));
94 return 0;
95}
96
97static int pasemi_mac_setup_rx_resources(struct net_device *dev)
98{
99 struct pasemi_mac_rxring *ring;
100 struct pasemi_mac *mac = netdev_priv(dev);
101 int chan_id = mac->dma_rxch;
102
103 ring = kzalloc(sizeof(*ring), GFP_KERNEL);
104
105 if (!ring)
106 goto out_ring;
107
108 spin_lock_init(&ring->lock);
109
110 ring->desc_info = kzalloc(sizeof(struct pasemi_mac_buffer) *
111 RX_RING_SIZE, GFP_KERNEL);
112
113 if (!ring->desc_info)
114 goto out_desc_info;
115
116 /* Allocate descriptors */
117 ring->desc = dma_alloc_coherent(&mac->dma_pdev->dev,
118 RX_RING_SIZE *
119 sizeof(struct pas_dma_xct_descr),
120 &ring->dma, GFP_KERNEL);
121
122 if (!ring->desc)
123 goto out_desc;
124
125 memset(ring->desc, 0, RX_RING_SIZE * sizeof(struct pas_dma_xct_descr));
126
127 ring->buffers = dma_alloc_coherent(&mac->dma_pdev->dev,
128 RX_RING_SIZE * sizeof(u64),
129 &ring->buf_dma, GFP_KERNEL);
130 if (!ring->buffers)
131 goto out_buffers;
132
133 memset(ring->buffers, 0, RX_RING_SIZE * sizeof(u64));
134
135 pci_write_config_dword(mac->dma_pdev, PAS_DMA_RXCHAN_BASEL(chan_id),
136 PAS_DMA_RXCHAN_BASEL_BRBL(ring->dma));
137
138 pci_write_config_dword(mac->dma_pdev, PAS_DMA_RXCHAN_BASEU(chan_id),
139 PAS_DMA_RXCHAN_BASEU_BRBH(ring->dma >> 32) |
140 PAS_DMA_RXCHAN_BASEU_SIZ(RX_RING_SIZE >> 2));
141
142 pci_write_config_dword(mac->dma_pdev, PAS_DMA_RXCHAN_CFG(chan_id),
143 PAS_DMA_RXCHAN_CFG_HBU(1));
144
145 pci_write_config_dword(mac->dma_pdev, PAS_DMA_RXINT_BASEL(mac->dma_if),
146 PAS_DMA_RXINT_BASEL_BRBL(__pa(ring->buffers)));
147
148 pci_write_config_dword(mac->dma_pdev, PAS_DMA_RXINT_BASEU(mac->dma_if),
149 PAS_DMA_RXINT_BASEU_BRBH(__pa(ring->buffers) >> 32) |
150 PAS_DMA_RXINT_BASEU_SIZ(RX_RING_SIZE >> 3));
151
152 ring->next_to_fill = 0;
153 ring->next_to_clean = 0;
154
155 snprintf(ring->irq_name, sizeof(ring->irq_name),
156 "%s rx", dev->name);
157 mac->rx = ring;
158
159 return 0;
160
161out_buffers:
162 dma_free_coherent(&mac->dma_pdev->dev,
163 RX_RING_SIZE * sizeof(struct pas_dma_xct_descr),
164 mac->rx->desc, mac->rx->dma);
165out_desc:
166 kfree(ring->desc_info);
167out_desc_info:
168 kfree(ring);
169out_ring:
170 return -ENOMEM;
171}
172
173
174static int pasemi_mac_setup_tx_resources(struct net_device *dev)
175{
176 struct pasemi_mac *mac = netdev_priv(dev);
177 u32 val;
178 int chan_id = mac->dma_txch;
179 struct pasemi_mac_txring *ring;
180
181 ring = kzalloc(sizeof(*ring), GFP_KERNEL);
182 if (!ring)
183 goto out_ring;
184
185 spin_lock_init(&ring->lock);
186
187 ring->desc_info = kzalloc(sizeof(struct pasemi_mac_buffer) *
188 TX_RING_SIZE, GFP_KERNEL);
189 if (!ring->desc_info)
190 goto out_desc_info;
191
192 /* Allocate descriptors */
193 ring->desc = dma_alloc_coherent(&mac->dma_pdev->dev,
194 TX_RING_SIZE *
195 sizeof(struct pas_dma_xct_descr),
196 &ring->dma, GFP_KERNEL);
197 if (!ring->desc)
198 goto out_desc;
199
200 memset(ring->desc, 0, TX_RING_SIZE * sizeof(struct pas_dma_xct_descr));
201
202 pci_write_config_dword(mac->dma_pdev, PAS_DMA_TXCHAN_BASEL(chan_id),
203 PAS_DMA_TXCHAN_BASEL_BRBL(ring->dma));
204 val = PAS_DMA_TXCHAN_BASEU_BRBH(ring->dma >> 32);
205 val |= PAS_DMA_TXCHAN_BASEU_SIZ(TX_RING_SIZE >> 2);
206
207 pci_write_config_dword(mac->dma_pdev, PAS_DMA_TXCHAN_BASEU(chan_id), val);
208
209 pci_write_config_dword(mac->dma_pdev, PAS_DMA_TXCHAN_CFG(chan_id),
210 PAS_DMA_TXCHAN_CFG_TY_IFACE |
211 PAS_DMA_TXCHAN_CFG_TATTR(mac->dma_if) |
212 PAS_DMA_TXCHAN_CFG_UP |
213 PAS_DMA_TXCHAN_CFG_WT(2));
214
215 ring->next_to_use = 0;
216 ring->next_to_clean = 0;
217
218 snprintf(ring->irq_name, sizeof(ring->irq_name),
219 "%s tx", dev->name);
220 mac->tx = ring;
221
222 return 0;
223
224out_desc:
225 kfree(ring->desc_info);
226out_desc_info:
227 kfree(ring);
228out_ring:
229 return -ENOMEM;
230}
231
232static void pasemi_mac_free_tx_resources(struct net_device *dev)
233{
234 struct pasemi_mac *mac = netdev_priv(dev);
235 unsigned int i;
236 struct pasemi_mac_buffer *info;
237 struct pas_dma_xct_descr *dp;
238
239 for (i = 0; i < TX_RING_SIZE; i++) {
240 info = &TX_DESC_INFO(mac, i);
241 dp = &TX_DESC(mac, i);
242 if (info->dma) {
243 if (info->skb) {
244 pci_unmap_single(mac->dma_pdev,
245 info->dma,
246 info->skb->len,
247 PCI_DMA_TODEVICE);
248 dev_kfree_skb_any(info->skb);
249 }
250 info->dma = 0;
251 info->skb = NULL;
252 dp->mactx = 0;
253 dp->ptr = 0;
254 }
255 }
256
257 dma_free_coherent(&mac->dma_pdev->dev,
258 TX_RING_SIZE * sizeof(struct pas_dma_xct_descr),
259 mac->tx->desc, mac->tx->dma);
260
261 kfree(mac->tx->desc_info);
262 kfree(mac->tx);
263 mac->tx = NULL;
264}
265
266static void pasemi_mac_free_rx_resources(struct net_device *dev)
267{
268 struct pasemi_mac *mac = netdev_priv(dev);
269 unsigned int i;
270 struct pasemi_mac_buffer *info;
271 struct pas_dma_xct_descr *dp;
272
273 for (i = 0; i < RX_RING_SIZE; i++) {
274 info = &RX_DESC_INFO(mac, i);
275 dp = &RX_DESC(mac, i);
Olof Johansson9f05cfe2007-05-08 00:47:37 -0500276 if (info->skb) {
277 if (info->dma) {
Olof Johanssonf5cd7872007-01-31 21:43:54 -0600278 pci_unmap_single(mac->dma_pdev,
279 info->dma,
280 info->skb->len,
281 PCI_DMA_FROMDEVICE);
282 dev_kfree_skb_any(info->skb);
283 }
284 info->dma = 0;
285 info->skb = NULL;
286 dp->macrx = 0;
287 dp->ptr = 0;
288 }
289 }
290
291 dma_free_coherent(&mac->dma_pdev->dev,
292 RX_RING_SIZE * sizeof(struct pas_dma_xct_descr),
293 mac->rx->desc, mac->rx->dma);
294
295 dma_free_coherent(&mac->dma_pdev->dev, RX_RING_SIZE * sizeof(u64),
296 mac->rx->buffers, mac->rx->buf_dma);
297
298 kfree(mac->rx->desc_info);
299 kfree(mac->rx);
300 mac->rx = NULL;
301}
302
303static void pasemi_mac_replenish_rx_ring(struct net_device *dev)
304{
305 struct pasemi_mac *mac = netdev_priv(dev);
306 unsigned int i;
307 int start = mac->rx->next_to_fill;
Olof Johanssoncd4ceb22007-05-08 00:47:45 -0500308 unsigned int limit, count;
Olof Johanssonf5cd7872007-01-31 21:43:54 -0600309
Olof Johanssoncd4ceb22007-05-08 00:47:45 -0500310 limit = (mac->rx->next_to_clean + RX_RING_SIZE -
Olof Johanssonf5cd7872007-01-31 21:43:54 -0600311 mac->rx->next_to_fill) & (RX_RING_SIZE - 1);
312
313 /* Check to see if we're doing first-time setup */
314 if (unlikely(mac->rx->next_to_clean == 0 && mac->rx->next_to_fill == 0))
Olof Johanssoncd4ceb22007-05-08 00:47:45 -0500315 limit = RX_RING_SIZE;
Olof Johanssonf5cd7872007-01-31 21:43:54 -0600316
Olof Johanssoncd4ceb22007-05-08 00:47:45 -0500317 if (limit <= 0)
Olof Johanssonf5cd7872007-01-31 21:43:54 -0600318 return;
319
Olof Johanssoncd4ceb22007-05-08 00:47:45 -0500320 i = start;
321 for (count = limit; count; count--) {
Olof Johanssonf5cd7872007-01-31 21:43:54 -0600322 struct pasemi_mac_buffer *info = &RX_DESC_INFO(mac, i);
323 u64 *buff = &RX_BUFF(mac, i);
324 struct sk_buff *skb;
325 dma_addr_t dma;
326
Olof Johansson9f05cfe2007-05-08 00:47:37 -0500327 /* skb might still be in there for recycle on short receives */
328 if (info->skb)
329 skb = info->skb;
330 else
331 skb = dev_alloc_skb(BUF_SIZE);
Olof Johanssonf5cd7872007-01-31 21:43:54 -0600332
Olof Johansson9f05cfe2007-05-08 00:47:37 -0500333 if (unlikely(!skb))
Olof Johanssonf5cd7872007-01-31 21:43:54 -0600334 break;
Olof Johanssonf5cd7872007-01-31 21:43:54 -0600335
Olof Johanssonf5cd7872007-01-31 21:43:54 -0600336 dma = pci_map_single(mac->dma_pdev, skb->data, skb->len,
337 PCI_DMA_FROMDEVICE);
338
Olof Johanssoncd4ceb22007-05-08 00:47:45 -0500339 if (unlikely(dma_mapping_error(dma))) {
Olof Johanssonf5cd7872007-01-31 21:43:54 -0600340 dev_kfree_skb_irq(info->skb);
Olof Johanssonf5cd7872007-01-31 21:43:54 -0600341 break;
342 }
343
344 info->skb = skb;
345 info->dma = dma;
346 *buff = XCT_RXB_LEN(BUF_SIZE) | XCT_RXB_ADDR(dma);
Olof Johanssoncd4ceb22007-05-08 00:47:45 -0500347 i++;
Olof Johanssonf5cd7872007-01-31 21:43:54 -0600348 }
349
350 wmb();
351
352 pci_write_config_dword(mac->dma_pdev,
353 PAS_DMA_RXCHAN_INCR(mac->dma_rxch),
Olof Johanssoncd4ceb22007-05-08 00:47:45 -0500354 limit - count);
Olof Johanssonf5cd7872007-01-31 21:43:54 -0600355 pci_write_config_dword(mac->dma_pdev,
356 PAS_DMA_RXINT_INCR(mac->dma_if),
Olof Johanssoncd4ceb22007-05-08 00:47:45 -0500357 limit - count);
Olof Johanssonf5cd7872007-01-31 21:43:54 -0600358
Olof Johanssoncd4ceb22007-05-08 00:47:45 -0500359 mac->rx->next_to_fill += limit - count;
Olof Johanssonf5cd7872007-01-31 21:43:54 -0600360}
361
Olof Johansson1b0335ea2007-05-08 00:47:26 -0500362static void pasemi_mac_restart_rx_intr(struct pasemi_mac *mac)
363{
364 unsigned int reg, stat;
365 /* Re-enable packet count interrupts: finally
366 * ack the packet count interrupt we got in rx_intr.
367 */
368
369 pci_read_config_dword(mac->iob_pdev,
370 PAS_IOB_DMA_RXCH_STAT(mac->dma_rxch),
371 &stat);
372
373 reg = PAS_IOB_DMA_RXCH_RESET_PCNT(stat & PAS_IOB_DMA_RXCH_STAT_CNTDEL_M)
374 | PAS_IOB_DMA_RXCH_RESET_PINTC;
375
376 pci_write_config_dword(mac->iob_pdev,
377 PAS_IOB_DMA_RXCH_RESET(mac->dma_rxch),
378 reg);
379}
380
381static void pasemi_mac_restart_tx_intr(struct pasemi_mac *mac)
382{
383 unsigned int reg, stat;
384
385 /* Re-enable packet count interrupts */
386 pci_read_config_dword(mac->iob_pdev,
387 PAS_IOB_DMA_TXCH_STAT(mac->dma_txch), &stat);
388
389 reg = PAS_IOB_DMA_TXCH_RESET_PCNT(stat & PAS_IOB_DMA_TXCH_STAT_CNTDEL_M)
390 | PAS_IOB_DMA_TXCH_RESET_PINTC;
391
392 pci_write_config_dword(mac->iob_pdev,
393 PAS_IOB_DMA_TXCH_RESET(mac->dma_txch), reg);
394}
395
396
Olof Johanssonf5cd7872007-01-31 21:43:54 -0600397static int pasemi_mac_clean_rx(struct pasemi_mac *mac, int limit)
398{
Olof Johanssoncd4ceb22007-05-08 00:47:45 -0500399 unsigned int n;
400 int count;
401 struct pas_dma_xct_descr *dp;
402 struct pasemi_mac_buffer *info;
403 struct sk_buff *skb;
404 unsigned int i, len;
405 u64 macrx;
406 dma_addr_t dma;
Olof Johanssonf5cd7872007-01-31 21:43:54 -0600407
408 spin_lock(&mac->rx->lock);
409
Olof Johanssoncd4ceb22007-05-08 00:47:45 -0500410 n = mac->rx->next_to_clean;
Olof Johanssonf5cd7872007-01-31 21:43:54 -0600411
Olof Johanssoncd4ceb22007-05-08 00:47:45 -0500412 for (count = limit; count; count--) {
Olof Johanssonf5cd7872007-01-31 21:43:54 -0600413
414 rmb();
415
Olof Johanssoncd4ceb22007-05-08 00:47:45 -0500416 dp = &RX_DESC(mac, n);
417 macrx = dp->macrx;
Olof Johanssonf5cd7872007-01-31 21:43:54 -0600418
Olof Johanssoncd4ceb22007-05-08 00:47:45 -0500419 if (!(macrx & XCT_MACRX_O))
Olof Johanssonf5cd7872007-01-31 21:43:54 -0600420 break;
421
Olof Johanssonf5cd7872007-01-31 21:43:54 -0600422
423 info = NULL;
424
425 /* We have to scan for our skb since there's no way
426 * to back-map them from the descriptor, and if we
427 * have several receive channels then they might not
428 * show up in the same order as they were put on the
429 * interface ring.
430 */
431
432 dma = (dp->ptr & XCT_PTR_ADDR_M);
Olof Johanssoncd4ceb22007-05-08 00:47:45 -0500433 for (i = n; i < (n + RX_RING_SIZE); i++) {
434 info = &RX_DESC_INFO(mac, i);
Olof Johanssonf5cd7872007-01-31 21:43:54 -0600435 if (info->dma == dma)
436 break;
437 }
438
Olof Johansson9f05cfe2007-05-08 00:47:37 -0500439 skb = info->skb;
Olof Johansson9f05cfe2007-05-08 00:47:37 -0500440 info->dma = 0;
Olof Johanssonf5cd7872007-01-31 21:43:54 -0600441
Olof Johanssoncd4ceb22007-05-08 00:47:45 -0500442 pci_unmap_single(mac->dma_pdev, dma, skb->len,
443 PCI_DMA_FROMDEVICE);
Olof Johanssonf5cd7872007-01-31 21:43:54 -0600444
Olof Johanssoncd4ceb22007-05-08 00:47:45 -0500445 len = (macrx & XCT_MACRX_LLEN_M) >> XCT_MACRX_LLEN_S;
446
Olof Johansson9f05cfe2007-05-08 00:47:37 -0500447 if (len < 256) {
448 struct sk_buff *new_skb =
449 netdev_alloc_skb(mac->netdev, len + NET_IP_ALIGN);
450 if (new_skb) {
451 skb_reserve(new_skb, NET_IP_ALIGN);
452 memcpy(new_skb->data - NET_IP_ALIGN,
453 skb->data - NET_IP_ALIGN,
454 len + NET_IP_ALIGN);
455 /* save the skb in buffer_info as good */
456 skb = new_skb;
457 }
458 /* else just continue with the old one */
459 } else
460 info->skb = NULL;
Olof Johanssonf5cd7872007-01-31 21:43:54 -0600461
462 skb_put(skb, len);
463
464 skb->protocol = eth_type_trans(skb, mac->netdev);
465
Olof Johanssoncd4ceb22007-05-08 00:47:45 -0500466 if ((macrx & XCT_MACRX_HTY_M) == XCT_MACRX_HTY_IPV4_OK) {
Olof Johanssonf5cd7872007-01-31 21:43:54 -0600467 skb->ip_summed = CHECKSUM_COMPLETE;
Olof Johanssoncd4ceb22007-05-08 00:47:45 -0500468 skb->csum = (macrx & XCT_MACRX_CSUM_M) >>
Olof Johanssonf5cd7872007-01-31 21:43:54 -0600469 XCT_MACRX_CSUM_S;
470 } else
471 skb->ip_summed = CHECKSUM_NONE;
472
473 mac->stats.rx_bytes += len;
474 mac->stats.rx_packets++;
475
476 netif_receive_skb(skb);
477
Olof Johanssonf5cd7872007-01-31 21:43:54 -0600478 dp->ptr = 0;
479 dp->macrx = 0;
Olof Johanssoncd4ceb22007-05-08 00:47:45 -0500480
481 n++;
Olof Johanssonf5cd7872007-01-31 21:43:54 -0600482 }
483
Olof Johanssoncd4ceb22007-05-08 00:47:45 -0500484 mac->rx->next_to_clean += limit - count;
Olof Johanssonf5cd7872007-01-31 21:43:54 -0600485 pasemi_mac_replenish_rx_ring(mac->netdev);
486
487 spin_unlock(&mac->rx->lock);
488
489 return count;
490}
491
492static int pasemi_mac_clean_tx(struct pasemi_mac *mac)
493{
494 int i;
495 struct pasemi_mac_buffer *info;
496 struct pas_dma_xct_descr *dp;
497 int start, count;
498 int flags;
499
500 spin_lock_irqsave(&mac->tx->lock, flags);
501
502 start = mac->tx->next_to_clean;
503 count = 0;
504
505 for (i = start; i < mac->tx->next_to_use; i++) {
506 dp = &TX_DESC(mac, i);
507 if (!dp || (dp->mactx & XCT_MACTX_O))
508 break;
509
510 count++;
511
512 info = &TX_DESC_INFO(mac, i);
513
514 pci_unmap_single(mac->dma_pdev, info->dma,
515 info->skb->len, PCI_DMA_TODEVICE);
516 dev_kfree_skb_irq(info->skb);
517
518 info->skb = NULL;
519 info->dma = 0;
520 dp->mactx = 0;
521 dp->ptr = 0;
522 }
523 mac->tx->next_to_clean += count;
524 spin_unlock_irqrestore(&mac->tx->lock, flags);
525
Olof Johansson0ce68c72007-04-28 15:36:40 -0500526 netif_wake_queue(mac->netdev);
527
Olof Johanssonf5cd7872007-01-31 21:43:54 -0600528 return count;
529}
530
531
532static irqreturn_t pasemi_mac_rx_intr(int irq, void *data)
533{
534 struct net_device *dev = data;
535 struct pasemi_mac *mac = netdev_priv(dev);
536 unsigned int reg;
537
Olof Johansson6dfa7522007-05-08 00:47:32 -0500538 if (!(*mac->rx_status & PAS_STATUS_CAUSE_M))
Olof Johanssonf5cd7872007-01-31 21:43:54 -0600539 return IRQ_NONE;
540
Olof Johansson6dfa7522007-05-08 00:47:32 -0500541 if (*mac->rx_status & PAS_STATUS_ERROR)
542 printk("rx_status reported error\n");
Olof Johanssonf5cd7872007-01-31 21:43:54 -0600543
Olof Johansson6dfa7522007-05-08 00:47:32 -0500544 /* Don't reset packet count so it won't fire again but clear
545 * all others.
546 */
547
548 pci_read_config_dword(mac->dma_pdev, PAS_DMA_RXINT_RCMDSTA(mac->dma_if), &reg);
549
550 reg = 0;
551 if (*mac->rx_status & PAS_STATUS_SOFT)
552 reg |= PAS_IOB_DMA_RXCH_RESET_SINTC;
553 if (*mac->rx_status & PAS_STATUS_ERROR)
554 reg |= PAS_IOB_DMA_RXCH_RESET_DINTC;
Olof Johanssonf5cd7872007-01-31 21:43:54 -0600555 if (*mac->rx_status & PAS_STATUS_TIMER)
556 reg |= PAS_IOB_DMA_RXCH_RESET_TINTC;
557
Olof Johansson6dfa7522007-05-08 00:47:32 -0500558 netif_rx_schedule(dev);
559
Olof Johanssonf5cd7872007-01-31 21:43:54 -0600560 pci_write_config_dword(mac->iob_pdev,
561 PAS_IOB_DMA_RXCH_RESET(mac->dma_rxch), reg);
562
563
564 return IRQ_HANDLED;
565}
566
567static irqreturn_t pasemi_mac_tx_intr(int irq, void *data)
568{
569 struct net_device *dev = data;
570 struct pasemi_mac *mac = netdev_priv(dev);
571 unsigned int reg;
Olof Johanssonf5cd7872007-01-31 21:43:54 -0600572
Olof Johansson6dfa7522007-05-08 00:47:32 -0500573 if (!(*mac->tx_status & PAS_STATUS_CAUSE_M))
Olof Johanssonf5cd7872007-01-31 21:43:54 -0600574 return IRQ_NONE;
575
576 pasemi_mac_clean_tx(mac);
577
Olof Johansson6dfa7522007-05-08 00:47:32 -0500578 reg = PAS_IOB_DMA_TXCH_RESET_PINTC;
579
580 if (*mac->tx_status & PAS_STATUS_SOFT)
581 reg |= PAS_IOB_DMA_TXCH_RESET_SINTC;
582 if (*mac->tx_status & PAS_STATUS_ERROR)
583 reg |= PAS_IOB_DMA_TXCH_RESET_DINTC;
Olof Johanssonf5cd7872007-01-31 21:43:54 -0600584
585 pci_write_config_dword(mac->iob_pdev, PAS_IOB_DMA_TXCH_RESET(mac->dma_txch),
586 reg);
587
Olof Johanssonf5cd7872007-01-31 21:43:54 -0600588 return IRQ_HANDLED;
589}
590
591static int pasemi_mac_open(struct net_device *dev)
592{
593 struct pasemi_mac *mac = netdev_priv(dev);
Olof Johansson771f7402007-05-08 00:47:21 -0500594 int base_irq;
Olof Johanssonf5cd7872007-01-31 21:43:54 -0600595 unsigned int flags;
596 int ret;
597
598 /* enable rx section */
599 pci_write_config_dword(mac->dma_pdev, PAS_DMA_COM_RXCMD,
600 PAS_DMA_COM_RXCMD_EN);
601
602 /* enable tx section */
603 pci_write_config_dword(mac->dma_pdev, PAS_DMA_COM_TXCMD,
604 PAS_DMA_COM_TXCMD_EN);
605
606 flags = PAS_MAC_CFG_TXP_FCE | PAS_MAC_CFG_TXP_FPC(3) |
607 PAS_MAC_CFG_TXP_SL(3) | PAS_MAC_CFG_TXP_COB(0xf) |
608 PAS_MAC_CFG_TXP_TIFT(8) | PAS_MAC_CFG_TXP_TIFG(12);
609
610 pci_write_config_dword(mac->pdev, PAS_MAC_CFG_TXP, flags);
611
612 flags = PAS_MAC_CFG_PCFG_S1 | PAS_MAC_CFG_PCFG_PE |
613 PAS_MAC_CFG_PCFG_PR | PAS_MAC_CFG_PCFG_CE;
614
615 flags |= PAS_MAC_CFG_PCFG_TSR_1G | PAS_MAC_CFG_PCFG_SPD_1G;
616
617 pci_write_config_dword(mac->iob_pdev, PAS_IOB_DMA_RXCH_CFG(mac->dma_rxch),
Olof Johansson6dfa7522007-05-08 00:47:32 -0500618 PAS_IOB_DMA_RXCH_CFG_CNTTH(1));
619
620 pci_write_config_dword(mac->iob_pdev, PAS_IOB_DMA_TXCH_CFG(mac->dma_txch),
621 PAS_IOB_DMA_TXCH_CFG_CNTTH(32));
Olof Johanssonf5cd7872007-01-31 21:43:54 -0600622
Olof Johansson1b0335ea2007-05-08 00:47:26 -0500623 /* Clear out any residual packet count state from firmware */
624 pasemi_mac_restart_rx_intr(mac);
625 pasemi_mac_restart_tx_intr(mac);
626
Olof Johansson6dfa7522007-05-08 00:47:32 -0500627 /* 0xffffff is max value, about 16ms */
Olof Johanssonf5cd7872007-01-31 21:43:54 -0600628 pci_write_config_dword(mac->iob_pdev, PAS_IOB_DMA_COM_TIMEOUTCFG,
Olof Johansson6dfa7522007-05-08 00:47:32 -0500629 PAS_IOB_DMA_COM_TIMEOUTCFG_TCNT(0xffffff));
Olof Johanssonf5cd7872007-01-31 21:43:54 -0600630
631 pci_write_config_dword(mac->pdev, PAS_MAC_CFG_PCFG, flags);
632
633 ret = pasemi_mac_setup_rx_resources(dev);
634 if (ret)
635 goto out_rx_resources;
636
637 ret = pasemi_mac_setup_tx_resources(dev);
638 if (ret)
639 goto out_tx_resources;
640
641 pci_write_config_dword(mac->pdev, PAS_MAC_IPC_CHNL,
642 PAS_MAC_IPC_CHNL_DCHNO(mac->dma_rxch) |
643 PAS_MAC_IPC_CHNL_BCH(mac->dma_rxch));
644
645 /* enable rx if */
646 pci_write_config_dword(mac->dma_pdev,
647 PAS_DMA_RXINT_RCMDSTA(mac->dma_if),
648 PAS_DMA_RXINT_RCMDSTA_EN);
649
650 /* enable rx channel */
651 pci_write_config_dword(mac->dma_pdev,
652 PAS_DMA_RXCHAN_CCMDSTA(mac->dma_rxch),
653 PAS_DMA_RXCHAN_CCMDSTA_EN |
654 PAS_DMA_RXCHAN_CCMDSTA_DU);
655
656 /* enable tx channel */
657 pci_write_config_dword(mac->dma_pdev,
658 PAS_DMA_TXCHAN_TCMDSTA(mac->dma_txch),
659 PAS_DMA_TXCHAN_TCMDSTA_EN);
660
661 pasemi_mac_replenish_rx_ring(dev);
662
663 netif_start_queue(dev);
664 netif_poll_enable(dev);
665
Olof Johansson771f7402007-05-08 00:47:21 -0500666 /* Interrupts are a bit different for our DMA controller: While
667 * it's got one a regular PCI device header, the interrupt there
668 * is really the base of the range it's using. Each tx and rx
669 * channel has it's own interrupt source.
670 */
671
672 base_irq = virq_to_hw(mac->dma_pdev->irq);
673
674 mac->tx_irq = irq_create_mapping(NULL, base_irq + mac->dma_txch);
675 mac->rx_irq = irq_create_mapping(NULL, base_irq + 20 + mac->dma_txch);
676
677 ret = request_irq(mac->tx_irq, &pasemi_mac_tx_intr, IRQF_DISABLED,
Olof Johanssonf5cd7872007-01-31 21:43:54 -0600678 mac->tx->irq_name, dev);
679 if (ret) {
680 dev_err(&mac->pdev->dev, "request_irq of irq %d failed: %d\n",
Olof Johansson771f7402007-05-08 00:47:21 -0500681 base_irq + mac->dma_txch, ret);
Olof Johanssonf5cd7872007-01-31 21:43:54 -0600682 goto out_tx_int;
683 }
684
Olof Johansson771f7402007-05-08 00:47:21 -0500685 ret = request_irq(mac->rx_irq, &pasemi_mac_rx_intr, IRQF_DISABLED,
Olof Johanssonf5cd7872007-01-31 21:43:54 -0600686 mac->rx->irq_name, dev);
687 if (ret) {
688 dev_err(&mac->pdev->dev, "request_irq of irq %d failed: %d\n",
Olof Johansson771f7402007-05-08 00:47:21 -0500689 base_irq + 20 + mac->dma_rxch, ret);
Olof Johanssonf5cd7872007-01-31 21:43:54 -0600690 goto out_rx_int;
691 }
692
693 return 0;
694
695out_rx_int:
Olof Johansson771f7402007-05-08 00:47:21 -0500696 free_irq(mac->tx_irq, dev);
Olof Johanssonf5cd7872007-01-31 21:43:54 -0600697out_tx_int:
698 netif_poll_disable(dev);
699 netif_stop_queue(dev);
700 pasemi_mac_free_tx_resources(dev);
701out_tx_resources:
702 pasemi_mac_free_rx_resources(dev);
703out_rx_resources:
704
705 return ret;
706}
707
708#define MAX_RETRIES 5000
709
710static int pasemi_mac_close(struct net_device *dev)
711{
712 struct pasemi_mac *mac = netdev_priv(dev);
713 unsigned int stat;
714 int retries;
715
716 netif_stop_queue(dev);
717
718 /* Clean out any pending buffers */
719 pasemi_mac_clean_tx(mac);
720 pasemi_mac_clean_rx(mac, RX_RING_SIZE);
721
722 /* Disable interface */
723 pci_write_config_dword(mac->dma_pdev,
724 PAS_DMA_TXCHAN_TCMDSTA(mac->dma_txch),
725 PAS_DMA_TXCHAN_TCMDSTA_ST);
726 pci_write_config_dword(mac->dma_pdev,
727 PAS_DMA_RXINT_RCMDSTA(mac->dma_if),
728 PAS_DMA_RXINT_RCMDSTA_ST);
729 pci_write_config_dword(mac->dma_pdev,
730 PAS_DMA_RXCHAN_CCMDSTA(mac->dma_rxch),
731 PAS_DMA_RXCHAN_CCMDSTA_ST);
732
733 for (retries = 0; retries < MAX_RETRIES; retries++) {
734 pci_read_config_dword(mac->dma_pdev,
735 PAS_DMA_TXCHAN_TCMDSTA(mac->dma_txch),
736 &stat);
Olof Johansson0ce68c72007-04-28 15:36:40 -0500737 if (!(stat & PAS_DMA_TXCHAN_TCMDSTA_ACT))
Olof Johanssonf5cd7872007-01-31 21:43:54 -0600738 break;
739 cond_resched();
740 }
741
Olof Johansson0ce68c72007-04-28 15:36:40 -0500742 if (stat & PAS_DMA_TXCHAN_TCMDSTA_ACT)
Olof Johanssonf5cd7872007-01-31 21:43:54 -0600743 dev_err(&mac->dma_pdev->dev, "Failed to stop tx channel\n");
Olof Johanssonf5cd7872007-01-31 21:43:54 -0600744
745 for (retries = 0; retries < MAX_RETRIES; retries++) {
746 pci_read_config_dword(mac->dma_pdev,
747 PAS_DMA_RXCHAN_CCMDSTA(mac->dma_rxch),
748 &stat);
Olof Johansson0ce68c72007-04-28 15:36:40 -0500749 if (!(stat & PAS_DMA_RXCHAN_CCMDSTA_ACT))
Olof Johanssonf5cd7872007-01-31 21:43:54 -0600750 break;
751 cond_resched();
752 }
753
Olof Johansson0ce68c72007-04-28 15:36:40 -0500754 if (stat & PAS_DMA_RXCHAN_CCMDSTA_ACT)
Olof Johanssonf5cd7872007-01-31 21:43:54 -0600755 dev_err(&mac->dma_pdev->dev, "Failed to stop rx channel\n");
Olof Johanssonf5cd7872007-01-31 21:43:54 -0600756
757 for (retries = 0; retries < MAX_RETRIES; retries++) {
758 pci_read_config_dword(mac->dma_pdev,
759 PAS_DMA_RXINT_RCMDSTA(mac->dma_if),
760 &stat);
Olof Johansson0ce68c72007-04-28 15:36:40 -0500761 if (!(stat & PAS_DMA_RXINT_RCMDSTA_ACT))
Olof Johanssonf5cd7872007-01-31 21:43:54 -0600762 break;
763 cond_resched();
764 }
765
Olof Johansson0ce68c72007-04-28 15:36:40 -0500766 if (stat & PAS_DMA_RXINT_RCMDSTA_ACT)
Olof Johanssonf5cd7872007-01-31 21:43:54 -0600767 dev_err(&mac->dma_pdev->dev, "Failed to stop rx interface\n");
Olof Johanssonf5cd7872007-01-31 21:43:54 -0600768
769 /* Then, disable the channel. This must be done separately from
770 * stopping, since you can't disable when active.
771 */
772
773 pci_write_config_dword(mac->dma_pdev,
774 PAS_DMA_TXCHAN_TCMDSTA(mac->dma_txch), 0);
775 pci_write_config_dword(mac->dma_pdev,
776 PAS_DMA_RXCHAN_CCMDSTA(mac->dma_rxch), 0);
777 pci_write_config_dword(mac->dma_pdev,
778 PAS_DMA_RXINT_RCMDSTA(mac->dma_if), 0);
779
Olof Johansson771f7402007-05-08 00:47:21 -0500780 free_irq(mac->tx_irq, dev);
781 free_irq(mac->rx_irq, dev);
Olof Johanssonf5cd7872007-01-31 21:43:54 -0600782
783 /* Free resources */
784 pasemi_mac_free_rx_resources(dev);
785 pasemi_mac_free_tx_resources(dev);
786
787 return 0;
788}
789
790static int pasemi_mac_start_tx(struct sk_buff *skb, struct net_device *dev)
791{
792 struct pasemi_mac *mac = netdev_priv(dev);
793 struct pasemi_mac_txring *txring;
794 struct pasemi_mac_buffer *info;
795 struct pas_dma_xct_descr *dp;
796 u64 dflags;
797 dma_addr_t map;
798 int flags;
799
800 dflags = XCT_MACTX_O | XCT_MACTX_ST | XCT_MACTX_SS | XCT_MACTX_CRC_PAD;
801
802 if (skb->ip_summed == CHECKSUM_PARTIAL) {
Arnaldo Carvalho de Melod56f90a2007-04-10 20:50:43 -0700803 const unsigned char *nh = skb_network_header(skb);
804
Arnaldo Carvalho de Meloeddc9ec2007-04-20 22:47:35 -0700805 switch (ip_hdr(skb)->protocol) {
Olof Johanssonf5cd7872007-01-31 21:43:54 -0600806 case IPPROTO_TCP:
807 dflags |= XCT_MACTX_CSUM_TCP;
Arnaldo Carvalho de Melocfe1fc72007-03-16 17:26:39 -0300808 dflags |= XCT_MACTX_IPH(skb_network_header_len(skb) >> 2);
Arnaldo Carvalho de Melod56f90a2007-04-10 20:50:43 -0700809 dflags |= XCT_MACTX_IPO(nh - skb->data);
Olof Johanssonf5cd7872007-01-31 21:43:54 -0600810 break;
811 case IPPROTO_UDP:
812 dflags |= XCT_MACTX_CSUM_UDP;
Arnaldo Carvalho de Melocfe1fc72007-03-16 17:26:39 -0300813 dflags |= XCT_MACTX_IPH(skb_network_header_len(skb) >> 2);
Arnaldo Carvalho de Melod56f90a2007-04-10 20:50:43 -0700814 dflags |= XCT_MACTX_IPO(nh - skb->data);
Olof Johanssonf5cd7872007-01-31 21:43:54 -0600815 break;
816 }
817 }
818
819 map = pci_map_single(mac->dma_pdev, skb->data, skb->len, PCI_DMA_TODEVICE);
820
821 if (dma_mapping_error(map))
822 return NETDEV_TX_BUSY;
823
824 txring = mac->tx;
825
826 spin_lock_irqsave(&txring->lock, flags);
827
828 if (txring->next_to_clean - txring->next_to_use == TX_RING_SIZE) {
829 spin_unlock_irqrestore(&txring->lock, flags);
830 pasemi_mac_clean_tx(mac);
831 spin_lock_irqsave(&txring->lock, flags);
832
833 if (txring->next_to_clean - txring->next_to_use ==
834 TX_RING_SIZE) {
835 /* Still no room -- stop the queue and wait for tx
836 * intr when there's room.
837 */
838 netif_stop_queue(dev);
839 goto out_err;
840 }
841 }
842
843
844 dp = &TX_DESC(mac, txring->next_to_use);
845 info = &TX_DESC_INFO(mac, txring->next_to_use);
846
847 dp->mactx = dflags | XCT_MACTX_LLEN(skb->len);
848 dp->ptr = XCT_PTR_LEN(skb->len) | XCT_PTR_ADDR(map);
849 info->dma = map;
850 info->skb = skb;
851
852 txring->next_to_use++;
853 mac->stats.tx_packets++;
854 mac->stats.tx_bytes += skb->len;
855
856 spin_unlock_irqrestore(&txring->lock, flags);
857
858 pci_write_config_dword(mac->dma_pdev,
859 PAS_DMA_TXCHAN_INCR(mac->dma_txch), 1);
860
861 return NETDEV_TX_OK;
862
863out_err:
864 spin_unlock_irqrestore(&txring->lock, flags);
865 pci_unmap_single(mac->dma_pdev, map, skb->len, PCI_DMA_TODEVICE);
866 return NETDEV_TX_BUSY;
867}
868
869static struct net_device_stats *pasemi_mac_get_stats(struct net_device *dev)
870{
871 struct pasemi_mac *mac = netdev_priv(dev);
872
873 return &mac->stats;
874}
875
876static void pasemi_mac_set_rx_mode(struct net_device *dev)
877{
878 struct pasemi_mac *mac = netdev_priv(dev);
879 unsigned int flags;
880
881 pci_read_config_dword(mac->pdev, PAS_MAC_CFG_PCFG, &flags);
882
883 /* Set promiscuous */
884 if (dev->flags & IFF_PROMISC)
885 flags |= PAS_MAC_CFG_PCFG_PR;
886 else
887 flags &= ~PAS_MAC_CFG_PCFG_PR;
888
889 pci_write_config_dword(mac->pdev, PAS_MAC_CFG_PCFG, flags);
890}
891
892
893static int pasemi_mac_poll(struct net_device *dev, int *budget)
894{
895 int pkts, limit = min(*budget, dev->quota);
896 struct pasemi_mac *mac = netdev_priv(dev);
897
898 pkts = pasemi_mac_clean_rx(mac, limit);
899
Olof Johanssoncd4ceb22007-05-08 00:47:45 -0500900 dev->quota -= pkts;
901 *budget -= pkts;
902
Olof Johanssonf5cd7872007-01-31 21:43:54 -0600903 if (pkts < limit) {
904 /* all done, no more packets present */
905 netif_rx_complete(dev);
906
Olof Johansson1b0335ea2007-05-08 00:47:26 -0500907 pasemi_mac_restart_rx_intr(mac);
Olof Johanssonf5cd7872007-01-31 21:43:54 -0600908 return 0;
909 } else {
910 /* used up our quantum, so reschedule */
Olof Johanssonf5cd7872007-01-31 21:43:54 -0600911 return 1;
912 }
913}
914
915static int __devinit
916pasemi_mac_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
917{
918 static int index = 0;
919 struct net_device *dev;
920 struct pasemi_mac *mac;
921 int err;
922
923 err = pci_enable_device(pdev);
924 if (err)
925 return err;
926
927 dev = alloc_etherdev(sizeof(struct pasemi_mac));
928 if (dev == NULL) {
929 dev_err(&pdev->dev,
930 "pasemi_mac: Could not allocate ethernet device.\n");
931 err = -ENOMEM;
932 goto out_disable_device;
933 }
934
935 SET_MODULE_OWNER(dev);
936 pci_set_drvdata(pdev, dev);
937 SET_NETDEV_DEV(dev, &pdev->dev);
938
939 mac = netdev_priv(dev);
940
941 mac->pdev = pdev;
942 mac->netdev = dev;
943 mac->dma_pdev = pci_get_device(PCI_VENDOR_ID_PASEMI, 0xa007, NULL);
944
945 if (!mac->dma_pdev) {
946 dev_err(&pdev->dev, "Can't find DMA Controller\n");
947 err = -ENODEV;
948 goto out_free_netdev;
949 }
950
951 mac->iob_pdev = pci_get_device(PCI_VENDOR_ID_PASEMI, 0xa001, NULL);
952
953 if (!mac->iob_pdev) {
954 dev_err(&pdev->dev, "Can't find I/O Bridge\n");
955 err = -ENODEV;
956 goto out_put_dma_pdev;
957 }
958
959 /* These should come out of the device tree eventually */
960 mac->dma_txch = index;
961 mac->dma_rxch = index;
962
963 /* We probe GMAC before XAUI, but the DMA interfaces are
964 * in XAUI, GMAC order.
965 */
966 if (index < 4)
967 mac->dma_if = index + 2;
968 else
969 mac->dma_if = index - 4;
970 index++;
971
972 switch (pdev->device) {
973 case 0xa005:
974 mac->type = MAC_TYPE_GMAC;
975 break;
976 case 0xa006:
977 mac->type = MAC_TYPE_XAUI;
978 break;
979 default:
980 err = -ENODEV;
981 goto out;
982 }
983
984 /* get mac addr from device tree */
985 if (pasemi_get_mac_addr(mac) || !is_valid_ether_addr(mac->mac_addr)) {
986 err = -ENODEV;
987 goto out;
988 }
989 memcpy(dev->dev_addr, mac->mac_addr, sizeof(mac->mac_addr));
990
991 dev->open = pasemi_mac_open;
992 dev->stop = pasemi_mac_close;
993 dev->hard_start_xmit = pasemi_mac_start_tx;
994 dev->get_stats = pasemi_mac_get_stats;
995 dev->set_multicast_list = pasemi_mac_set_rx_mode;
996 dev->weight = 64;
997 dev->poll = pasemi_mac_poll;
998 dev->features = NETIF_F_HW_CSUM;
999
1000 /* The dma status structure is located in the I/O bridge, and
1001 * is cache coherent.
1002 */
1003 if (!dma_status)
1004 /* XXXOJN This should come from the device tree */
1005 dma_status = __ioremap(0xfd800000, 0x1000, 0);
1006
1007 mac->rx_status = &dma_status->rx_sta[mac->dma_rxch];
1008 mac->tx_status = &dma_status->tx_sta[mac->dma_txch];
1009
1010 err = register_netdev(dev);
1011
1012 if (err) {
1013 dev_err(&mac->pdev->dev, "register_netdev failed with error %d\n",
1014 err);
1015 goto out;
1016 } else
1017 printk(KERN_INFO "%s: PA Semi %s: intf %d, txch %d, rxch %d, "
1018 "hw addr %02x:%02x:%02x:%02x:%02x:%02x\n",
1019 dev->name, mac->type == MAC_TYPE_GMAC ? "GMAC" : "XAUI",
1020 mac->dma_if, mac->dma_txch, mac->dma_rxch,
1021 dev->dev_addr[0], dev->dev_addr[1], dev->dev_addr[2],
1022 dev->dev_addr[3], dev->dev_addr[4], dev->dev_addr[5]);
1023
1024 return err;
1025
1026out:
1027 pci_dev_put(mac->iob_pdev);
1028out_put_dma_pdev:
1029 pci_dev_put(mac->dma_pdev);
1030out_free_netdev:
1031 free_netdev(dev);
1032out_disable_device:
1033 pci_disable_device(pdev);
1034 return err;
1035
1036}
1037
1038static void __devexit pasemi_mac_remove(struct pci_dev *pdev)
1039{
1040 struct net_device *netdev = pci_get_drvdata(pdev);
1041 struct pasemi_mac *mac;
1042
1043 if (!netdev)
1044 return;
1045
1046 mac = netdev_priv(netdev);
1047
1048 unregister_netdev(netdev);
1049
1050 pci_disable_device(pdev);
1051 pci_dev_put(mac->dma_pdev);
1052 pci_dev_put(mac->iob_pdev);
1053
1054 pci_set_drvdata(pdev, NULL);
1055 free_netdev(netdev);
1056}
1057
1058static struct pci_device_id pasemi_mac_pci_tbl[] = {
1059 { PCI_DEVICE(PCI_VENDOR_ID_PASEMI, 0xa005) },
1060 { PCI_DEVICE(PCI_VENDOR_ID_PASEMI, 0xa006) },
1061};
1062
1063MODULE_DEVICE_TABLE(pci, pasemi_mac_pci_tbl);
1064
1065static struct pci_driver pasemi_mac_driver = {
1066 .name = "pasemi_mac",
1067 .id_table = pasemi_mac_pci_tbl,
1068 .probe = pasemi_mac_probe,
1069 .remove = __devexit_p(pasemi_mac_remove),
1070};
1071
1072static void __exit pasemi_mac_cleanup_module(void)
1073{
1074 pci_unregister_driver(&pasemi_mac_driver);
1075 __iounmap(dma_status);
1076 dma_status = NULL;
1077}
1078
1079int pasemi_mac_init_module(void)
1080{
1081 return pci_register_driver(&pasemi_mac_driver);
1082}
1083
1084MODULE_LICENSE("GPL");
1085MODULE_AUTHOR ("Olof Johansson <olof@lixom.net>");
1086MODULE_DESCRIPTION("PA Semi PWRficient Ethernet driver");
1087
1088module_init(pasemi_mac_init_module);
1089module_exit(pasemi_mac_cleanup_module);