Import 2.1.36
[davej-history.git] / drivers / net / seeq8005.c
blob397228647e3882716af3d4039eed89c11b757dfe
1 /* seeq8005.c: A network driver for linux. */
2 /*
3 Based on skeleton.c,
4 Written 1993-94 by Donald Becker.
5 See the skeleton.c file for further copyright information.
7 This software may be used and distributed according to the terms
8 of the GNU Public License, incorporated herein by reference.
10 The author may be reached as hamish@zot.apana.org.au
12 This file is a network device driver for the SEEQ 8005 chipset and
13 the Linux operating system.
17 static const char *version =
18 "seeq8005.c:v1.00 8/07/95 Hamish Coleman (hamish@zot.apana.org.au)\n";
21 Sources:
22 SEEQ 8005 databook
24 Version history:
25 1.00 Public release. cosmetic changes (no warnings now)
26 0.68 Turning per- packet,interrupt debug messages off - testing for release.
27 0.67 timing problems/bad buffer reads seem to be fixed now
28 0.63 *!@$ protocol=eth_type_trans -- now packets flow
29 0.56 Send working
30 0.48 Receive working
33 #include <linux/kernel.h>
34 #include <linux/sched.h>
35 #include <linux/types.h>
36 #include <linux/fcntl.h>
37 #include <linux/interrupt.h>
38 #include <linux/ptrace.h>
39 #include <linux/ioport.h>
40 #include <linux/in.h>
41 #include <linux/malloc.h>
42 #include <linux/string.h>
43 #include <linux/init.h>
44 #include <asm/system.h>
45 #include <asm/bitops.h>
46 #include <asm/io.h>
47 #include <asm/dma.h>
48 #include <linux/errno.h>
50 #include <linux/netdevice.h>
51 #include <linux/etherdevice.h>
52 #include <linux/skbuff.h>
53 #include "seeq8005.h"
55 /* First, a few definitions that the brave might change. */
56 /* A zero-terminated list of I/O addresses to be probed. */
57 static unsigned int seeq8005_portlist[] __initdata =
58 { 0x300, 0x320, 0x340, 0x360, 0};
60 /* use 0 for production, 1 for verification, >2 for debug */
61 #ifndef NET_DEBUG
62 #define NET_DEBUG 1
63 #endif
64 static unsigned int net_debug = NET_DEBUG;
66 /* Information that need to be kept for each board. */
67 struct net_local {
68 struct net_device_stats stats;
69 unsigned short receive_ptr; /* What address in packet memory do we expect a recv_pkt_header? */
70 long open_time; /* Useless example local info. */
73 /* The station (ethernet) address prefix, used for IDing the board. */
74 #define SA_ADDR0 0x00
75 #define SA_ADDR1 0x80
76 #define SA_ADDR2 0x4b
78 /* Index to functions, as function prototypes. */
80 extern int seeq8005_probe(struct device *dev);
82 static int seeq8005_probe1(struct device *dev, int ioaddr);
83 static int seeq8005_open(struct device *dev);
84 static int seeq8005_send_packet(struct sk_buff *skb, struct device *dev);
85 static void seeq8005_interrupt(int irq, void *dev_id, struct pt_regs *regs);
86 static void seeq8005_rx(struct device *dev);
87 static int seeq8005_close(struct device *dev);
88 static struct net_device_stats *seeq8005_get_stats(struct device *dev);
89 static void set_multicast_list(struct device *dev);
91 /* Example routines you must write ;->. */
92 #define tx_done(dev) (inw(SEEQ_STATUS) & SEEQSTAT_TX_ON)
93 static void hardware_send_packet(struct device *dev, char *buf, int length);
94 extern void seeq8005_init(struct device *dev, int startp);
95 static inline void wait_for_buffer(struct device *dev);
98 /* Check for a network adaptor of this type, and return '0' iff one exists.
99 If dev->base_addr == 0, probe all likely locations.
100 If dev->base_addr == 1, always return failure.
101 If dev->base_addr == 2, allocate space for the device and return success
102 (detachable devices only).
104 #ifdef HAVE_DEVLIST
105 /* Support for an alternate probe manager, which will eliminate the
106 boilerplate below. */
107 struct netdev_entry seeq8005_drv =
108 {"seeq8005", seeq8005_probe1, SEEQ8005_IO_EXTENT, seeq8005_portlist};
109 #else
110 __initfunc(int
111 seeq8005_probe(struct device *dev))
113 int i;
114 int base_addr = dev ? dev->base_addr : 0;
116 if (base_addr > 0x1ff) /* Check a single specified location. */
117 return seeq8005_probe1(dev, base_addr);
118 else if (base_addr != 0) /* Don't probe at all. */
119 return ENXIO;
121 for (i = 0; seeq8005_portlist[i]; i++) {
122 int ioaddr = seeq8005_portlist[i];
123 if (check_region(ioaddr, SEEQ8005_IO_EXTENT))
124 continue;
125 if (seeq8005_probe1(dev, ioaddr) == 0)
126 return 0;
129 return ENODEV;
131 #endif
133 /* This is the real probe routine. Linux has a history of friendly device
134 probes on the ISA bus. A good device probes avoids doing writes, and
135 verifies that the correct device exists and functions. */
137 __initfunc(static int seeq8005_probe1(struct device *dev, int ioaddr))
139 static unsigned version_printed = 0;
140 int i,j;
141 unsigned char SA_prom[32];
142 int old_cfg1;
143 int old_cfg2;
144 int old_stat;
145 int old_dmaar;
146 int old_rear;
148 if (net_debug>1)
149 printk("seeq8005: probing at 0x%x\n",ioaddr);
151 old_stat = inw(SEEQ_STATUS); /* read status register */
152 if (old_stat == 0xffff)
153 return ENODEV; /* assume that 0xffff == no device */
154 if ( (old_stat & 0x1800) != 0x1800 ) { /* assume that unused bits are 1, as my manual says */
155 if (net_debug>1) {
156 printk("seeq8005: reserved stat bits != 0x1800\n");
157 printk(" == 0x%04x\n",old_stat);
159 return ENODEV;
162 old_rear = inw(SEEQ_REA);
163 if (old_rear == 0xffff) {
164 outw(0,SEEQ_REA);
165 if (inw(SEEQ_REA) == 0xffff) { /* assume that 0xffff == no device */
166 return ENODEV;
168 } else if ((old_rear & 0xff00) != 0xff00) { /* assume that unused bits are 1 */
169 if (net_debug>1) {
170 printk("seeq8005: unused rear bits != 0xff00\n");
171 printk(" == 0x%04x\n",old_rear);
173 return ENODEV;
176 old_cfg2 = inw(SEEQ_CFG2); /* read CFG2 register */
177 old_cfg1 = inw(SEEQ_CFG1);
178 old_dmaar = inw(SEEQ_DMAAR);
180 if (net_debug>4) {
181 printk("seeq8005: stat = 0x%04x\n",old_stat);
182 printk("seeq8005: cfg1 = 0x%04x\n",old_cfg1);
183 printk("seeq8005: cfg2 = 0x%04x\n",old_cfg2);
184 printk("seeq8005: raer = 0x%04x\n",old_rear);
185 printk("seeq8005: dmaar= 0x%04x\n",old_dmaar);
188 outw( SEEQCMD_FIFO_WRITE | SEEQCMD_SET_ALL_OFF, SEEQ_CMD); /* setup for reading PROM */
189 outw( 0, SEEQ_DMAAR); /* set starting PROM address */
190 outw( SEEQCFG1_BUFFER_PROM, SEEQ_CFG1); /* set buffer to look at PROM */
193 j=0;
194 for(i=0; i <32; i++) {
195 j+= SA_prom[i] = inw(SEEQ_BUFFER) & 0xff;
198 #if 0
199 /* untested because I only have the one card */
200 if ( (j&0xff) != 0 ) { /* checksum appears to be 8bit = 0 */
201 if (net_debug>1) { /* check this before deciding that we have a card */
202 printk("seeq8005: prom sum error\n");
204 outw( old_stat, SEEQ_STATUS);
205 outw( old_dmaar, SEEQ_DMAAR);
206 outw( old_cfg1, SEEQ_CFG1);
207 return ENODEV;
209 #endif
211 outw( SEEQCFG2_RESET, SEEQ_CFG2); /* reset the card */
212 SLOW_DOWN_IO; /* have to wait 4us after a reset - should be fixed */
213 SLOW_DOWN_IO;
214 SLOW_DOWN_IO;
215 SLOW_DOWN_IO;
216 outw( SEEQCMD_SET_ALL_OFF, SEEQ_CMD);
218 if (net_debug) {
219 printk("seeq8005: prom sum = 0x%08x\n",j);
220 for(j=0; j<32; j+=16) {
221 printk("seeq8005: prom %02x: ",j);
222 for(i=0;i<16;i++) {
223 printk("%02x ",SA_prom[j|i]);
225 printk(" ");
226 for(i=0;i<16;i++) {
227 if ((SA_prom[j|i]>31)&&(SA_prom[j|i]<127)) {
228 printk("%c", SA_prom[j|i]);
229 } else {
230 printk(" ");
233 printk("\n");
237 #if 0
239 * testing the packet buffer memory doesn't work yet
240 * but all other buffer accesses do
241 * - fixing is not a priority
243 if (net_debug>1) { /* test packet buffer memory */
244 printk("seeq8005: testing packet buffer ... ");
245 outw( SEEQCFG1_BUFFER_BUFFER, SEEQ_CFG1);
246 outw( SEEQCMD_FIFO_WRITE | SEEQCMD_SET_ALL_OFF, SEEQ_CMD);
247 outw( 0 , SEEQ_DMAAR);
248 for(i=0;i<32768;i++) {
249 outw(0x5a5a, SEEQ_BUFFER);
251 j=jiffies+HZ;
252 while ( ((inw(SEEQ_STATUS) & SEEQSTAT_FIFO_EMPTY) != SEEQSTAT_FIFO_EMPTY) && jiffies < j )
253 mb();
254 outw( 0 , SEEQ_DMAAR);
255 while ( ((inw(SEEQ_STATUS) & SEEQSTAT_WINDOW_INT) != SEEQSTAT_WINDOW_INT) && jiffies < j+HZ)
256 mb();
257 if ( (inw(SEEQ_STATUS) & SEEQSTAT_WINDOW_INT) == SEEQSTAT_WINDOW_INT)
258 outw( SEEQCMD_WINDOW_INT_ACK | (inw(SEEQ_STATUS)& SEEQCMD_INT_MASK), SEEQ_CMD);
259 outw( SEEQCMD_FIFO_READ | SEEQCMD_SET_ALL_OFF, SEEQ_CMD);
260 j=0;
261 for(i=0;i<32768;i++) {
262 if (inw(SEEQ_BUFFER) != 0x5a5a)
263 j++;
265 if (j) {
266 printk("%i\n",j);
267 } else {
268 printk("ok.\n");
271 #endif
273 /* Allocate a new 'dev' if needed. */
274 if (dev == NULL)
275 dev = init_etherdev(0, sizeof(struct net_local));
277 if (net_debug && version_printed++ == 0)
278 printk(version);
280 printk("%s: %s found at %#3x, ", dev->name, "seeq8005", ioaddr);
282 /* Fill in the 'dev' fields. */
283 dev->base_addr = ioaddr;
285 /* Retrieve and print the ethernet address. */
286 for (i = 0; i < 6; i++)
287 printk(" %2.2x", dev->dev_addr[i] = SA_prom[i+6]);
289 if (dev->irq == 0xff)
290 ; /* Do nothing: a user-level program will set it. */
291 else if (dev->irq < 2) { /* "Auto-IRQ" */
292 autoirq_setup(0);
294 outw( SEEQCMD_RX_INT_EN | SEEQCMD_SET_RX_ON | SEEQCMD_SET_RX_OFF, SEEQ_CMD );
296 dev->irq = autoirq_report(0);
298 if (net_debug >= 2)
299 printk(" autoirq is %d\n", dev->irq);
300 } else if (dev->irq == 2)
301 /* Fixup for users that don't know that IRQ 2 is really IRQ 9,
302 * or don't know which one to set.
304 dev->irq = 9;
306 #if 0
308 int irqval = request_irq(dev->irq, &seeq8005_interrupt, 0, "seeq8005", NULL);
309 if (irqval) {
310 printk ("%s: unable to get IRQ %d (irqval=%d).\n", dev->name,
311 dev->irq, irqval);
312 return EAGAIN;
315 #endif
317 /* Grab the region so we can find another board if autoIRQ fails. */
318 request_region(ioaddr, SEEQ8005_IO_EXTENT,"seeq8005");
320 /* Initialize the device structure. */
321 dev->priv = kmalloc(sizeof(struct net_local), GFP_KERNEL);
322 if (dev->priv == NULL)
323 return -ENOMEM;
324 memset(dev->priv, 0, sizeof(struct net_local));
326 dev->open = seeq8005_open;
327 dev->stop = seeq8005_close;
328 dev->hard_start_xmit = seeq8005_send_packet;
329 dev->get_stats = seeq8005_get_stats;
330 dev->set_multicast_list = &set_multicast_list;
332 /* Fill in the fields of the device structure with ethernet values. */
333 ether_setup(dev);
335 dev->flags &= ~IFF_MULTICAST;
337 return 0;
341 /* Open/initialize the board. This is called (in the current kernel)
342 sometime after booting when the 'ifconfig' program is run.
344 This routine should set everything up anew at each open, even
345 registers that "should" only need to be set once at boot, so that
346 there is non-reboot way to recover if something goes wrong.
348 static int
349 seeq8005_open(struct device *dev)
351 struct net_local *lp = (struct net_local *)dev->priv;
354 int irqval = request_irq(dev->irq, &seeq8005_interrupt, 0, "seeq8005", NULL);
355 if (irqval) {
356 printk ("%s: unable to get IRQ %d (irqval=%d).\n", dev->name,
357 dev->irq, irqval);
358 return EAGAIN;
361 irq2dev_map[dev->irq] = dev;
363 /* Reset the hardware here. Don't forget to set the station address. */
364 seeq8005_init(dev, 1);
366 lp->open_time = jiffies;
368 dev->tbusy = 0;
369 dev->interrupt = 0;
370 dev->start = 1;
371 return 0;
374 static int
375 seeq8005_send_packet(struct sk_buff *skb, struct device *dev)
377 int ioaddr = dev->base_addr;
379 if (dev->tbusy) {
380 /* If we get here, some higher level has decided we are broken.
381 There should really be a "kick me" function call instead. */
382 int tickssofar = jiffies - dev->trans_start;
383 if (tickssofar < 5)
384 return 1;
385 printk("%s: transmit timed out, %s?\n", dev->name,
386 tx_done(dev) ? "IRQ conflict" : "network cable problem");
387 /* Try to restart the adaptor. */
388 seeq8005_init(dev, 1);
389 dev->tbusy=0;
390 dev->trans_start = jiffies;
393 /* Block a timer-based transmit from overlapping. This could better be
394 done with atomic_swap(1, dev->tbusy), but set_bit() works as well. */
395 if (set_bit(0, (void*)&dev->tbusy) != 0)
396 printk("%s: Transmitter access conflict.\n", dev->name);
397 else {
398 short length = ETH_ZLEN < skb->len ? skb->len : ETH_ZLEN;
399 unsigned char *buf = skb->data;
401 hardware_send_packet(dev, buf, length);
402 dev->trans_start = jiffies;
404 dev_kfree_skb (skb, FREE_WRITE);
406 /* You might need to clean up and record Tx statistics here. */
408 return 0;
411 /* The typical workload of the driver:
412 Handle the network interface interrupts. */
413 static void
414 seeq8005_interrupt(int irq, void *dev_id, struct pt_regs * regs)
416 struct device *dev = (struct device *)(irq2dev_map[irq]);
417 struct net_local *lp;
418 int ioaddr, status, boguscount = 0;
420 if (dev == NULL) {
421 printk ("net_interrupt(): irq %d for unknown device.\n", irq);
422 return;
425 if (dev->interrupt)
426 printk ("%s: Re-entering the interrupt handler.\n", dev->name);
427 dev->interrupt = 1;
429 ioaddr = dev->base_addr;
430 lp = (struct net_local *)dev->priv;
432 status = inw(SEEQ_STATUS);
433 do {
434 if (net_debug >2) {
435 printk("%s: int, status=0x%04x\n",dev->name,status);
438 if (status & SEEQSTAT_WINDOW_INT) {
439 outw( SEEQCMD_WINDOW_INT_ACK | (status & SEEQCMD_INT_MASK), SEEQ_CMD);
440 if (net_debug) {
441 printk("%s: window int!\n",dev->name);
444 if (status & SEEQSTAT_TX_INT) {
445 outw( SEEQCMD_TX_INT_ACK | (status & SEEQCMD_INT_MASK), SEEQ_CMD);
446 lp->stats.tx_packets++;
447 dev->tbusy = 0;
448 mark_bh(NET_BH); /* Inform upper layers. */
450 if (status & SEEQSTAT_RX_INT) {
451 /* Got a packet(s). */
452 seeq8005_rx(dev);
454 status = inw(SEEQ_STATUS);
455 } while ( (++boguscount < 10) && (status & SEEQSTAT_ANY_INT)) ;
457 if(net_debug>2) {
458 printk("%s: eoi\n",dev->name);
460 dev->interrupt = 0;
461 return;
464 /* We have a good packet(s), get it/them out of the buffers. */
465 static void
466 seeq8005_rx(struct device *dev)
468 struct net_local *lp = (struct net_local *)dev->priv;
469 int boguscount = 10;
470 int pkt_hdr;
471 int ioaddr = dev->base_addr;
473 do {
474 int next_packet;
475 int pkt_len;
476 int i;
477 int status;
479 status = inw(SEEQ_STATUS);
480 outw( lp->receive_ptr, SEEQ_DMAAR);
481 outw(SEEQCMD_FIFO_READ | SEEQCMD_RX_INT_ACK | (status & SEEQCMD_INT_MASK), SEEQ_CMD);
482 wait_for_buffer(dev);
483 next_packet = ntohs(inw(SEEQ_BUFFER));
484 pkt_hdr = inw(SEEQ_BUFFER);
486 if (net_debug>2) {
487 printk("%s: 0x%04x recv next=0x%04x, hdr=0x%04x\n",dev->name,lp->receive_ptr,next_packet,pkt_hdr);
490 if ((next_packet == 0) || ((pkt_hdr & SEEQPKTH_CHAIN)==0)) { /* Read all the frames? */
491 return; /* Done for now */
494 if ((pkt_hdr & SEEQPKTS_DONE)==0)
495 break;
497 if (next_packet < lp->receive_ptr) {
498 pkt_len = (next_packet + 0x10000 - ((DEFAULT_TEA+1)<<8)) - lp->receive_ptr - 4;
499 } else {
500 pkt_len = next_packet - lp->receive_ptr - 4;
503 if (next_packet < ((DEFAULT_TEA+1)<<8)) { /* is the next_packet address sane? */
504 printk("%s: recv packet ring corrupt, resetting board\n",dev->name);
505 seeq8005_init(dev,1);
506 return;
509 lp->receive_ptr = next_packet;
511 if (net_debug>2) {
512 printk("%s: recv len=0x%04x\n",dev->name,pkt_len);
515 if (pkt_hdr & SEEQPKTS_ANY_ERROR) { /* There was an error. */
516 lp->stats.rx_errors++;
517 if (pkt_hdr & SEEQPKTS_SHORT) lp->stats.rx_frame_errors++;
518 if (pkt_hdr & SEEQPKTS_DRIB) lp->stats.rx_frame_errors++;
519 if (pkt_hdr & SEEQPKTS_OVERSIZE) lp->stats.rx_over_errors++;
520 if (pkt_hdr & SEEQPKTS_CRC_ERR) lp->stats.rx_crc_errors++;
521 /* skip over this packet */
522 outw( SEEQCMD_FIFO_WRITE | SEEQCMD_DMA_INT_ACK | (status & SEEQCMD_INT_MASK), SEEQ_CMD);
523 outw( (lp->receive_ptr & 0xff00)>>8, SEEQ_REA);
524 } else {
525 /* Malloc up new buffer. */
526 struct sk_buff *skb;
527 unsigned char *buf;
529 skb = dev_alloc_skb(pkt_len);
530 if (skb == NULL) {
531 printk("%s: Memory squeeze, dropping packet.\n", dev->name);
532 lp->stats.rx_dropped++;
533 break;
535 skb->dev = dev;
536 skb_reserve(skb, 2); /* align data on 16 byte */
537 buf = skb_put(skb,pkt_len);
539 insw(SEEQ_BUFFER, buf, (pkt_len + 1) >> 1);
541 if (net_debug>2) {
542 char * p = buf;
543 printk("%s: recv ",dev->name);
544 for(i=0;i<14;i++) {
545 printk("%02x ",*(p++)&0xff);
547 printk("\n");
550 skb->protocol=eth_type_trans(skb,dev);
551 netif_rx(skb);
552 lp->stats.rx_packets++;
554 } while ((--boguscount) && (pkt_hdr & SEEQPKTH_CHAIN));
556 /* If any worth-while packets have been received, netif_rx()
557 has done a mark_bh(NET_BH) for us and will work on them
558 when we get to the bottom-half routine. */
559 return;
562 /* The inverse routine to net_open(). */
563 static int
564 seeq8005_close(struct device *dev)
566 struct net_local *lp = (struct net_local *)dev->priv;
567 int ioaddr = dev->base_addr;
569 lp->open_time = 0;
571 dev->tbusy = 1;
572 dev->start = 0;
574 /* Flush the Tx and disable Rx here. */
575 outw( SEEQCMD_SET_ALL_OFF, SEEQ_CMD);
577 free_irq(dev->irq, NULL);
579 irq2dev_map[dev->irq] = 0;
581 /* Update the statistics here. */
583 return 0;
587 /* Get the current statistics. This may be called with the card open or
588 closed. */
589 static struct net_device_stats *seeq8005_get_stats(struct device *dev)
591 struct net_local *lp = (struct net_local *)dev->priv;
593 return &lp->stats;
596 /* Set or clear the multicast filter for this adaptor.
597 num_addrs == -1 Promiscuous mode, receive all packets
598 num_addrs == 0 Normal mode, clear multicast list
599 num_addrs > 0 Multicast mode, receive normal and MC packets, and do
600 best-effort filtering.
602 static void
603 set_multicast_list(struct device *dev)
606 * I _could_ do up to 6 addresses here, but won't (yet?)
609 #if 0
610 int ioaddr = dev->base_addr;
612 * hmm, not even sure if my matching works _anyway_ - seem to be receiving
613 * _everything_ . . .
616 if (num_addrs) { /* Enable promiscuous mode */
617 outw( (inw(SEEQ_CFG1) & ~SEEQCFG1_MATCH_MASK)| SEEQCFG1_MATCH_ALL, SEEQ_CFG1);
618 dev->flags|=IFF_PROMISC;
619 } else { /* Disable promiscuous mode, use normal mode */
620 outw( (inw(SEEQ_CFG1) & ~SEEQCFG1_MATCH_MASK)| SEEQCFG1_MATCH_BROAD, SEEQ_CFG1);
622 #endif
625 void seeq8005_init(struct device *dev, int startp)
627 struct net_local *lp = (struct net_local *)dev->priv;
628 int ioaddr = dev->base_addr;
629 int i;
631 outw(SEEQCFG2_RESET, SEEQ_CFG2); /* reset device */
632 SLOW_DOWN_IO; /* have to wait 4us after a reset - should be fixed */
633 SLOW_DOWN_IO;
634 SLOW_DOWN_IO;
635 SLOW_DOWN_IO;
637 outw( SEEQCMD_FIFO_WRITE | SEEQCMD_SET_ALL_OFF, SEEQ_CMD);
638 outw( 0, SEEQ_DMAAR); /* load start address into both low and high byte */
639 /* wait_for_buffer(dev); */ /* I think that you only need a wait for memory buffer */
640 outw( SEEQCFG1_BUFFER_MAC0, SEEQ_CFG1);
642 for(i=0;i<6;i++) { /* set Station address */
643 outb(dev->dev_addr[i], SEEQ_BUFFER);
644 SLOW_DOWN_IO;
647 outw( SEEQCFG1_BUFFER_TEA, SEEQ_CFG1); /* set xmit end area pointer to 16K */
648 outb( DEFAULT_TEA, SEEQ_BUFFER); /* this gives us 16K of send buffer and 48K of recv buffer */
650 lp->receive_ptr = (DEFAULT_TEA+1)<<8; /* so we can find our packet_header */
651 outw( lp->receive_ptr, SEEQ_RPR); /* Receive Pointer Register is set to recv buffer memory */
653 outw( 0x00ff, SEEQ_REA); /* Receive Area End */
655 if (net_debug>4) {
656 printk("%s: SA0 = ",dev->name);
658 outw( SEEQCMD_FIFO_READ | SEEQCMD_SET_ALL_OFF, SEEQ_CMD);
659 outw( 0, SEEQ_DMAAR);
660 outw( SEEQCFG1_BUFFER_MAC0, SEEQ_CFG1);
662 for(i=0;i<6;i++) {
663 printk("%02x ",inb(SEEQ_BUFFER));
665 printk("\n");
668 outw( SEEQCFG1_MAC0_EN | SEEQCFG1_MATCH_BROAD | SEEQCFG1_BUFFER_BUFFER, SEEQ_CFG1);
669 outw( SEEQCFG2_AUTO_REA | SEEQCFG2_CTRLO, SEEQ_CFG2);
670 outw( SEEQCMD_SET_RX_ON | SEEQCMD_TX_INT_EN | SEEQCMD_RX_INT_EN, SEEQ_CMD);
672 if (net_debug>4) {
673 int old_cfg1;
674 old_cfg1 = inw(SEEQ_CFG1);
675 printk("%s: stat = 0x%04x\n",dev->name,inw(SEEQ_STATUS));
676 printk("%s: cfg1 = 0x%04x\n",dev->name,old_cfg1);
677 printk("%s: cfg2 = 0x%04x\n",dev->name,inw(SEEQ_CFG2));
678 printk("%s: raer = 0x%04x\n",dev->name,inw(SEEQ_REA));
679 printk("%s: dmaar= 0x%04x\n",dev->name,inw(SEEQ_DMAAR));
685 static void hardware_send_packet(struct device * dev, char *buf, int length)
687 int ioaddr = dev->base_addr;
688 int status = inw(SEEQ_STATUS);
689 int transmit_ptr = 0;
690 int tmp;
692 if (net_debug>4) {
693 printk("%s: send 0x%04x\n",dev->name,length);
696 /* Set FIFO to writemode and set packet-buffer address */
697 outw( SEEQCMD_FIFO_WRITE | (status & SEEQCMD_INT_MASK), SEEQ_CMD);
698 outw( transmit_ptr, SEEQ_DMAAR);
700 /* output SEEQ Packet header barfage */
701 outw( htons(length + 4), SEEQ_BUFFER);
702 outw( SEEQPKTH_XMIT | SEEQPKTH_DATA_FOLLOWS | SEEQPKTH_XMIT_INT_EN, SEEQ_BUFFER );
704 /* blat the buffer */
705 outsw( SEEQ_BUFFER, buf, (length +1) >> 1);
706 /* paranoia !! */
707 outw( 0, SEEQ_BUFFER);
708 outw( 0, SEEQ_BUFFER);
710 /* set address of start of transmit chain */
711 outw( transmit_ptr, SEEQ_TPR);
713 /* drain FIFO */
714 tmp = jiffies;
715 while ( (((status=inw(SEEQ_STATUS)) & SEEQSTAT_FIFO_EMPTY) == 0) && (jiffies < tmp + HZ))
716 mb();
718 /* doit ! */
719 outw( SEEQCMD_WINDOW_INT_ACK | SEEQCMD_SET_TX_ON | (status & SEEQCMD_INT_MASK), SEEQ_CMD);
725 * wait_for_buffer
727 * This routine waits for the SEEQ chip to assert that the FIFO is ready
728 * by checking for a window interrupt, and then clearing it
730 inline void wait_for_buffer(struct device * dev)
732 int ioaddr = dev->base_addr;
733 int tmp;
734 int status;
736 tmp = jiffies + HZ;
737 while ( ( ((status=inw(SEEQ_STATUS)) & SEEQSTAT_WINDOW_INT) != SEEQSTAT_WINDOW_INT) && jiffies < tmp)
738 mb();
740 if ( (status & SEEQSTAT_WINDOW_INT) == SEEQSTAT_WINDOW_INT)
741 outw( SEEQCMD_WINDOW_INT_ACK | (status & SEEQCMD_INT_MASK), SEEQ_CMD);
746 * Local variables:
747 * compile-command: "gcc -D__KERNEL__ -I/usr/src/linux/net/inet -Wall -Wstrict-prototypes -O6 -m486 -c skeleton.c"
748 * version-control: t
749 * kept-new-versions: 5
750 * tab-width: 4
751 * End: