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.
6
7	This software may be used and distributed according to the terms
8	of the GNU General Public License, incorporated herein by reference.
9
10	The author may be reached as hamish@zot.apana.org.au
11
12	This file is a network device driver for the SEEQ 8005 chipset and
13	the Linux operating system.
14
15*/
16
17static const char version[] =
18	"seeq8005.c:v1.00 8/07/95 Hamish Coleman (hamish@zot.apana.org.au)\n";
19
20/*
21  Sources:
22  	SEEQ 8005 databook
23
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
31*/
32
33#include <linux/module.h>
34#include <linux/kernel.h>
35#include <linux/types.h>
36#include <linux/fcntl.h>
37#include <linux/interrupt.h>
38#include <linux/ioport.h>
39#include <linux/in.h>
40#include <linux/string.h>
41#include <linux/init.h>
42#include <linux/delay.h>
43#include <linux/errno.h>
44#include <linux/netdevice.h>
45#include <linux/etherdevice.h>
46#include <linux/skbuff.h>
47#include <linux/bitops.h>
48#include <linux/jiffies.h>
49
50#include <asm/system.h>
51#include <asm/io.h>
52#include <asm/dma.h>
53
54#include "seeq8005.h"
55
56/* First, a few definitions that the brave might change. */
57/* A zero-terminated list of I/O addresses to be probed. */
58static unsigned int seeq8005_portlist[] __initdata =
59   { 0x300, 0x320, 0x340, 0x360, 0};
60
61/* use 0 for production, 1 for verification, >2 for debug */
62#ifndef NET_DEBUG
63#define NET_DEBUG 1
64#endif
65static unsigned int net_debug = NET_DEBUG;
66
67/* Information that need to be kept for each board. */
68struct net_local {
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. */
71};
72
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
77
78/* Index to functions, as function prototypes. */
79
80static int seeq8005_probe1(struct net_device *dev, int ioaddr);
81static int seeq8005_open(struct net_device *dev);
82static void seeq8005_timeout(struct net_device *dev);
83static netdev_tx_t seeq8005_send_packet(struct sk_buff *skb,
84					struct net_device *dev);
85static irqreturn_t seeq8005_interrupt(int irq, void *dev_id);
86static void seeq8005_rx(struct net_device *dev);
87static int seeq8005_close(struct net_device *dev);
88static void set_multicast_list(struct net_device *dev);
89
90/* Example routines you must write ;->. */
91#define tx_done(dev)	(inw(SEEQ_STATUS) & SEEQSTAT_TX_ON)
92static void hardware_send_packet(struct net_device *dev, char *buf, int length);
93extern void seeq8005_init(struct net_device *dev, int startp);
94static inline void wait_for_buffer(struct net_device *dev);
95
96
97/* Check for a network adaptor of this type, and return '0' iff one exists.
98   If dev->base_addr == 0, probe all likely locations.
99   If dev->base_addr == 1, always return failure.
100   */
101
102static int io = 0x320;
103static int irq = 10;
104
105struct net_device * __init seeq8005_probe(int unit)
106{
107	struct net_device *dev = alloc_etherdev(sizeof(struct net_local));
108	unsigned *port;
109	int err = 0;
110
111	if (!dev)
112		return ERR_PTR(-ENODEV);
113
114	if (unit >= 0) {
115		sprintf(dev->name, "eth%d", unit);
116		netdev_boot_setup_check(dev);
117		io = dev->base_addr;
118		irq = dev->irq;
119	}
120
121	if (io > 0x1ff) {	/* Check a single specified location. */
122		err = seeq8005_probe1(dev, io);
123	} else if (io != 0) {	/* Don't probe at all. */
124		err = -ENXIO;
125	} else {
126		for (port = seeq8005_portlist; *port; port++) {
127			if (seeq8005_probe1(dev, *port) == 0)
128				break;
129		}
130		if (!*port)
131			err = -ENODEV;
132	}
133	if (err)
134		goto out;
135	err = register_netdev(dev);
136	if (err)
137		goto out1;
138	return dev;
139out1:
140	release_region(dev->base_addr, SEEQ8005_IO_EXTENT);
141out:
142	free_netdev(dev);
143	return ERR_PTR(err);
144}
145
146static const struct net_device_ops seeq8005_netdev_ops = {
147	.ndo_open		= seeq8005_open,
148	.ndo_stop		= seeq8005_close,
149	.ndo_start_xmit 	= seeq8005_send_packet,
150	.ndo_tx_timeout		= seeq8005_timeout,
151	.ndo_set_multicast_list = set_multicast_list,
152	.ndo_change_mtu		= eth_change_mtu,
153	.ndo_set_mac_address 	= eth_mac_addr,
154	.ndo_validate_addr	= eth_validate_addr,
155};
156
157/* This is the real probe routine.  Linux has a history of friendly device
158   probes on the ISA bus.  A good device probes avoids doing writes, and
159   verifies that the correct device exists and functions.  */
160
161static int __init seeq8005_probe1(struct net_device *dev, int ioaddr)
162{
163	static unsigned version_printed;
164	int i,j;
165	unsigned char SA_prom[32];
166	int old_cfg1;
167	int old_cfg2;
168	int old_stat;
169	int old_dmaar;
170	int old_rear;
171	int retval;
172
173	if (!request_region(ioaddr, SEEQ8005_IO_EXTENT, "seeq8005"))
174		return -ENODEV;
175
176	if (net_debug>1)
177		printk("seeq8005: probing at 0x%x\n",ioaddr);
178
179	old_stat = inw(SEEQ_STATUS);					/* read status register */
180	if (old_stat == 0xffff) {
181		retval = -ENODEV;
182		goto out;						/* assume that 0xffff == no device */
183	}
184	if ( (old_stat & 0x1800) != 0x1800 ) {				/* assume that unused bits are 1, as my manual says */
185		if (net_debug>1) {
186			printk("seeq8005: reserved stat bits != 0x1800\n");
187			printk("          == 0x%04x\n",old_stat);
188		}
189	 	retval = -ENODEV;
190		goto out;
191	}
192
193	old_rear = inw(SEEQ_REA);
194	if (old_rear == 0xffff) {
195		outw(0,SEEQ_REA);
196		if (inw(SEEQ_REA) == 0xffff) {				/* assume that 0xffff == no device */
197			retval = -ENODEV;
198			goto out;
199		}
200	} else if ((old_rear & 0xff00) != 0xff00) {			/* assume that unused bits are 1 */
201		if (net_debug>1) {
202			printk("seeq8005: unused rear bits != 0xff00\n");
203			printk("          == 0x%04x\n",old_rear);
204		}
205		retval = -ENODEV;
206		goto out;
207	}
208
209	old_cfg2 = inw(SEEQ_CFG2);					/* read CFG2 register */
210	old_cfg1 = inw(SEEQ_CFG1);
211	old_dmaar = inw(SEEQ_DMAAR);
212
213	if (net_debug>4) {
214		printk("seeq8005: stat = 0x%04x\n",old_stat);
215		printk("seeq8005: cfg1 = 0x%04x\n",old_cfg1);
216		printk("seeq8005: cfg2 = 0x%04x\n",old_cfg2);
217		printk("seeq8005: raer = 0x%04x\n",old_rear);
218		printk("seeq8005: dmaar= 0x%04x\n",old_dmaar);
219	}
220
221	outw( SEEQCMD_FIFO_WRITE | SEEQCMD_SET_ALL_OFF, SEEQ_CMD);	/* setup for reading PROM */
222	outw( 0, SEEQ_DMAAR);						/* set starting PROM address */
223	outw( SEEQCFG1_BUFFER_PROM, SEEQ_CFG1);				/* set buffer to look at PROM */
224
225
226	j=0;
227	for(i=0; i <32; i++) {
228		j+= SA_prom[i] = inw(SEEQ_BUFFER) & 0xff;
229	}
230
231
232	outw( SEEQCFG2_RESET, SEEQ_CFG2);				/* reset the card */
233	udelay(5);
234	outw( SEEQCMD_SET_ALL_OFF, SEEQ_CMD);
235
236	if (net_debug) {
237		printk("seeq8005: prom sum = 0x%08x\n",j);
238		for(j=0; j<32; j+=16) {
239			printk("seeq8005: prom %02x: ",j);
240			for(i=0;i<16;i++) {
241				printk("%02x ",SA_prom[j|i]);
242			}
243			printk(" ");
244			for(i=0;i<16;i++) {
245				if ((SA_prom[j|i]>31)&&(SA_prom[j|i]<127)) {
246					printk("%c", SA_prom[j|i]);
247				} else {
248					printk(" ");
249				}
250			}
251			printk("\n");
252		}
253	}
254
255
256	if (net_debug  &&  version_printed++ == 0)
257		printk(version);
258
259	printk("%s: %s found at %#3x, ", dev->name, "seeq8005", ioaddr);
260
261	/* Fill in the 'dev' fields. */
262	dev->base_addr = ioaddr;
263	dev->irq = irq;
264
265	/* Retrieve and print the ethernet address. */
266	for (i = 0; i < 6; i++)
267		dev->dev_addr[i] = SA_prom[i+6];
268	printk("%pM", dev->dev_addr);
269
270	if (dev->irq == 0xff)
271		;			/* Do nothing: a user-level program will set it. */
272	else if (dev->irq < 2) {	/* "Auto-IRQ" */
273		unsigned long cookie = probe_irq_on();
274
275		outw( SEEQCMD_RX_INT_EN | SEEQCMD_SET_RX_ON | SEEQCMD_SET_RX_OFF, SEEQ_CMD );
276
277		dev->irq = probe_irq_off(cookie);
278
279		if (net_debug >= 2)
280			printk(" autoirq is %d\n", dev->irq);
281	} else if (dev->irq == 2)
282	  /* Fixup for users that don't know that IRQ 2 is really IRQ 9,
283	   * or don't know which one to set.
284	   */
285	  dev->irq = 9;
286
287	dev->netdev_ops = &seeq8005_netdev_ops;
288	dev->watchdog_timeo	= HZ/20;
289	dev->flags &= ~IFF_MULTICAST;
290
291	return 0;
292out:
293	release_region(ioaddr, SEEQ8005_IO_EXTENT);
294	return retval;
295}
296
297
298/* Open/initialize the board.  This is called (in the current kernel)
299   sometime after booting when the 'ifconfig' program is run.
300
301   This routine should set everything up anew at each open, even
302   registers that "should" only need to be set once at boot, so that
303   there is non-reboot way to recover if something goes wrong.
304   */
305static int seeq8005_open(struct net_device *dev)
306{
307	struct net_local *lp = netdev_priv(dev);
308
309	{
310		 int irqval = request_irq(dev->irq, seeq8005_interrupt, 0, "seeq8005", dev);
311		 if (irqval) {
312			 printk ("%s: unable to get IRQ %d (irqval=%d).\n", dev->name,
313					 dev->irq, irqval);
314			 return -EAGAIN;
315		 }
316	}
317
318	/* Reset the hardware here.  Don't forget to set the station address. */
319	seeq8005_init(dev, 1);
320
321	lp->open_time = jiffies;
322
323	netif_start_queue(dev);
324	return 0;
325}
326
327static void seeq8005_timeout(struct net_device *dev)
328{
329	int ioaddr = dev->base_addr;
330	printk(KERN_WARNING "%s: transmit timed out, %s?\n", dev->name,
331		   tx_done(dev) ? "IRQ conflict" : "network cable problem");
332	/* Try to restart the adaptor. */
333	seeq8005_init(dev, 1);
334	dev->trans_start = jiffies; /* prevent tx timeout */
335	netif_wake_queue(dev);
336}
337
338static netdev_tx_t seeq8005_send_packet(struct sk_buff *skb,
339					struct net_device *dev)
340{
341	short length = skb->len;
342	unsigned char *buf;
343
344	if (length < ETH_ZLEN) {
345		if (skb_padto(skb, ETH_ZLEN))
346			return NETDEV_TX_OK;
347		length = ETH_ZLEN;
348	}
349	buf = skb->data;
350
351	/* Block a timer-based transmit from overlapping */
352	netif_stop_queue(dev);
353
354	hardware_send_packet(dev, buf, length);
355	dev->stats.tx_bytes += length;
356	dev_kfree_skb (skb);
357	/* You might need to clean up and record Tx statistics here. */
358
359	return NETDEV_TX_OK;
360}
361
362/*
363 * wait_for_buffer
364 *
365 * This routine waits for the SEEQ chip to assert that the FIFO is ready
366 * by checking for a window interrupt, and then clearing it. This has to
367 * occur in the interrupt handler!
368 */
369inline void wait_for_buffer(struct net_device * dev)
370{
371	int ioaddr = dev->base_addr;
372	unsigned long tmp;
373	int status;
374
375	tmp = jiffies + HZ;
376	while ( ( ((status=inw(SEEQ_STATUS)) & SEEQSTAT_WINDOW_INT) != SEEQSTAT_WINDOW_INT) && time_before(jiffies, tmp))
377		cpu_relax();
378
379	if ( (status & SEEQSTAT_WINDOW_INT) == SEEQSTAT_WINDOW_INT)
380		outw( SEEQCMD_WINDOW_INT_ACK | (status & SEEQCMD_INT_MASK), SEEQ_CMD);
381}
382
383/* The typical workload of the driver:
384   Handle the network interface interrupts. */
385static irqreturn_t seeq8005_interrupt(int irq, void *dev_id)
386{
387	struct net_device *dev = dev_id;
388	struct net_local *lp;
389	int ioaddr, status, boguscount = 0;
390	int handled = 0;
391
392	ioaddr = dev->base_addr;
393	lp = netdev_priv(dev);
394
395	status = inw(SEEQ_STATUS);
396	do {
397		if (net_debug >2) {
398			printk("%s: int, status=0x%04x\n",dev->name,status);
399		}
400
401		if (status & SEEQSTAT_WINDOW_INT) {
402			handled = 1;
403			outw( SEEQCMD_WINDOW_INT_ACK | (status & SEEQCMD_INT_MASK), SEEQ_CMD);
404			if (net_debug) {
405				printk("%s: window int!\n",dev->name);
406			}
407		}
408		if (status & SEEQSTAT_TX_INT) {
409			handled = 1;
410			outw( SEEQCMD_TX_INT_ACK | (status & SEEQCMD_INT_MASK), SEEQ_CMD);
411			dev->stats.tx_packets++;
412			netif_wake_queue(dev);	/* Inform upper layers. */
413		}
414		if (status & SEEQSTAT_RX_INT) {
415			handled = 1;
416			/* Got a packet(s). */
417			seeq8005_rx(dev);
418		}
419		status = inw(SEEQ_STATUS);
420	} while ( (++boguscount < 10) && (status & SEEQSTAT_ANY_INT)) ;
421
422	if(net_debug>2) {
423		printk("%s: eoi\n",dev->name);
424	}
425	return IRQ_RETVAL(handled);
426}
427
428/* We have a good packet(s), get it/them out of the buffers. */
429static void seeq8005_rx(struct net_device *dev)
430{
431	struct net_local *lp = netdev_priv(dev);
432	int boguscount = 10;
433	int pkt_hdr;
434	int ioaddr = dev->base_addr;
435
436	do {
437		int next_packet;
438		int pkt_len;
439		int i;
440		int status;
441
442		status = inw(SEEQ_STATUS);
443	  	outw( lp->receive_ptr, SEEQ_DMAAR);
444		outw(SEEQCMD_FIFO_READ | SEEQCMD_RX_INT_ACK | (status & SEEQCMD_INT_MASK), SEEQ_CMD);
445	  	wait_for_buffer(dev);
446	  	next_packet = ntohs(inw(SEEQ_BUFFER));
447	  	pkt_hdr = inw(SEEQ_BUFFER);
448
449		if (net_debug>2) {
450			printk("%s: 0x%04x recv next=0x%04x, hdr=0x%04x\n",dev->name,lp->receive_ptr,next_packet,pkt_hdr);
451		}
452
453		if ((next_packet == 0) || ((pkt_hdr & SEEQPKTH_CHAIN)==0)) {	/* Read all the frames? */
454			return;							/* Done for now */
455		}
456
457		if ((pkt_hdr & SEEQPKTS_DONE)==0)
458			break;
459
460		if (next_packet < lp->receive_ptr) {
461			pkt_len = (next_packet + 0x10000 - ((DEFAULT_TEA+1)<<8)) - lp->receive_ptr - 4;
462		} else {
463			pkt_len = next_packet - lp->receive_ptr - 4;
464		}
465
466		if (next_packet < ((DEFAULT_TEA+1)<<8)) {			/* is the next_packet address sane? */
467			printk("%s: recv packet ring corrupt, resetting board\n",dev->name);
468			seeq8005_init(dev,1);
469			return;
470		}
471
472		lp->receive_ptr = next_packet;
473
474		if (net_debug>2) {
475			printk("%s: recv len=0x%04x\n",dev->name,pkt_len);
476		}
477
478		if (pkt_hdr & SEEQPKTS_ANY_ERROR) {				/* There was an error. */
479			dev->stats.rx_errors++;
480			if (pkt_hdr & SEEQPKTS_SHORT) dev->stats.rx_frame_errors++;
481			if (pkt_hdr & SEEQPKTS_DRIB) dev->stats.rx_frame_errors++;
482			if (pkt_hdr & SEEQPKTS_OVERSIZE) dev->stats.rx_over_errors++;
483			if (pkt_hdr & SEEQPKTS_CRC_ERR) dev->stats.rx_crc_errors++;
484			/* skip over this packet */
485			outw( SEEQCMD_FIFO_WRITE | SEEQCMD_DMA_INT_ACK | (status & SEEQCMD_INT_MASK), SEEQ_CMD);
486			outw( (lp->receive_ptr & 0xff00)>>8, SEEQ_REA);
487		} else {
488			/* Malloc up new buffer. */
489			struct sk_buff *skb;
490			unsigned char *buf;
491
492			skb = dev_alloc_skb(pkt_len);
493			if (skb == NULL) {
494				printk("%s: Memory squeeze, dropping packet.\n", dev->name);
495				dev->stats.rx_dropped++;
496				break;
497			}
498			skb_reserve(skb, 2);	/* align data on 16 byte */
499			buf = skb_put(skb,pkt_len);
500
501			insw(SEEQ_BUFFER, buf, (pkt_len + 1) >> 1);
502
503			if (net_debug>2) {
504				char * p = buf;
505				printk("%s: recv ",dev->name);
506				for(i=0;i<14;i++) {
507					printk("%02x ",*(p++)&0xff);
508				}
509				printk("\n");
510			}
511
512			skb->protocol=eth_type_trans(skb,dev);
513			netif_rx(skb);
514			dev->stats.rx_packets++;
515			dev->stats.rx_bytes += pkt_len;
516		}
517	} while ((--boguscount) && (pkt_hdr & SEEQPKTH_CHAIN));
518
519	/* If any worth-while packets have been received, netif_rx()
520	   has done a mark_bh(NET_BH) for us and will work on them
521	   when we get to the bottom-half routine. */
522}
523
524/* The inverse routine to net_open(). */
525static int seeq8005_close(struct net_device *dev)
526{
527	struct net_local *lp = netdev_priv(dev);
528	int ioaddr = dev->base_addr;
529
530	lp->open_time = 0;
531
532	netif_stop_queue(dev);
533
534	/* Flush the Tx and disable Rx here. */
535	outw( SEEQCMD_SET_ALL_OFF, SEEQ_CMD);
536
537	free_irq(dev->irq, dev);
538
539	/* Update the statistics here. */
540
541	return 0;
542
543}
544
545/* Set or clear the multicast filter for this adaptor.
546   num_addrs == -1	Promiscuous mode, receive all packets
547   num_addrs == 0	Normal mode, clear multicast list
548   num_addrs > 0	Multicast mode, receive normal and MC packets, and do
549			best-effort filtering.
550 */
551static void set_multicast_list(struct net_device *dev)
552{
553/*
554 * I _could_ do up to 6 addresses here, but won't (yet?)
555 */
556
557}
558
559void seeq8005_init(struct net_device *dev, int startp)
560{
561	struct net_local *lp = netdev_priv(dev);
562	int ioaddr = dev->base_addr;
563	int i;
564
565	outw(SEEQCFG2_RESET, SEEQ_CFG2);	/* reset device */
566	udelay(5);
567
568	outw( SEEQCMD_FIFO_WRITE | SEEQCMD_SET_ALL_OFF, SEEQ_CMD);
569	outw( 0, SEEQ_DMAAR);			/* load start address into both low and high byte */
570/*	wait_for_buffer(dev); */		/* I think that you only need a wait for memory buffer */
571	outw( SEEQCFG1_BUFFER_MAC0, SEEQ_CFG1);
572
573	for(i=0;i<6;i++) {			/* set Station address */
574		outb(dev->dev_addr[i], SEEQ_BUFFER);
575		udelay(2);
576	}
577
578	outw( SEEQCFG1_BUFFER_TEA, SEEQ_CFG1);	/* set xmit end area pointer to 16K */
579	outb( DEFAULT_TEA, SEEQ_BUFFER);	/* this gives us 16K of send buffer and 48K of recv buffer */
580
581	lp->receive_ptr = (DEFAULT_TEA+1)<<8;	/* so we can find our packet_header */
582	outw( lp->receive_ptr, SEEQ_RPR);	/* Receive Pointer Register is set to recv buffer memory */
583
584	outw( 0x00ff, SEEQ_REA);		/* Receive Area End */
585
586	if (net_debug>4) {
587		printk("%s: SA0 = ",dev->name);
588
589		outw( SEEQCMD_FIFO_READ | SEEQCMD_SET_ALL_OFF, SEEQ_CMD);
590		outw( 0, SEEQ_DMAAR);
591		outw( SEEQCFG1_BUFFER_MAC0, SEEQ_CFG1);
592
593		for(i=0;i<6;i++) {
594			printk("%02x ",inb(SEEQ_BUFFER));
595		}
596		printk("\n");
597	}
598
599	outw( SEEQCFG1_MAC0_EN | SEEQCFG1_MATCH_BROAD | SEEQCFG1_BUFFER_BUFFER, SEEQ_CFG1);
600	outw( SEEQCFG2_AUTO_REA | SEEQCFG2_CTRLO, SEEQ_CFG2);
601	outw( SEEQCMD_SET_RX_ON | SEEQCMD_TX_INT_EN | SEEQCMD_RX_INT_EN, SEEQ_CMD);
602
603	if (net_debug>4) {
604		int old_cfg1;
605		old_cfg1 = inw(SEEQ_CFG1);
606		printk("%s: stat = 0x%04x\n",dev->name,inw(SEEQ_STATUS));
607		printk("%s: cfg1 = 0x%04x\n",dev->name,old_cfg1);
608		printk("%s: cfg2 = 0x%04x\n",dev->name,inw(SEEQ_CFG2));
609		printk("%s: raer = 0x%04x\n",dev->name,inw(SEEQ_REA));
610		printk("%s: dmaar= 0x%04x\n",dev->name,inw(SEEQ_DMAAR));
611
612	}
613}
614
615
616static void hardware_send_packet(struct net_device * dev, char *buf, int length)
617{
618	int ioaddr = dev->base_addr;
619	int status = inw(SEEQ_STATUS);
620	int transmit_ptr = 0;
621	unsigned long tmp;
622
623	if (net_debug>4) {
624		printk("%s: send 0x%04x\n",dev->name,length);
625	}
626
627	/* Set FIFO to writemode and set packet-buffer address */
628	outw( SEEQCMD_FIFO_WRITE | (status & SEEQCMD_INT_MASK), SEEQ_CMD);
629	outw( transmit_ptr, SEEQ_DMAAR);
630
631	/* output SEEQ Packet header barfage */
632	outw( htons(length + 4), SEEQ_BUFFER);
633	outw( SEEQPKTH_XMIT | SEEQPKTH_DATA_FOLLOWS | SEEQPKTH_XMIT_INT_EN, SEEQ_BUFFER );
634
635	/* blat the buffer */
636	outsw( SEEQ_BUFFER, buf, (length +1) >> 1);
637	/* paranoia !! */
638	outw( 0, SEEQ_BUFFER);
639	outw( 0, SEEQ_BUFFER);
640
641	/* set address of start of transmit chain */
642	outw( transmit_ptr, SEEQ_TPR);
643
644	/* drain FIFO */
645	tmp = jiffies;
646	while ( (((status=inw(SEEQ_STATUS)) & SEEQSTAT_FIFO_EMPTY) == 0) && time_before(jiffies, tmp + HZ))
647		mb();
648
649	/* doit ! */
650	outw( SEEQCMD_WINDOW_INT_ACK | SEEQCMD_SET_TX_ON | (status & SEEQCMD_INT_MASK), SEEQ_CMD);
651
652}
653
654
655#ifdef MODULE
656
657static struct net_device *dev_seeq;
658MODULE_LICENSE("GPL");
659module_param(io, int, 0);
660module_param(irq, int, 0);
661MODULE_PARM_DESC(io, "SEEQ 8005 I/O base address");
662MODULE_PARM_DESC(irq, "SEEQ 8005 IRQ number");
663
664int __init init_module(void)
665{
666	dev_seeq = seeq8005_probe(-1);
667	if (IS_ERR(dev_seeq))
668		return PTR_ERR(dev_seeq);
669	return 0;
670}
671
672void __exit cleanup_module(void)
673{
674	unregister_netdev(dev_seeq);
675	release_region(dev_seeq->base_addr, SEEQ8005_IO_EXTENT);
676	free_netdev(dev_seeq);
677}
678
679#endif /* MODULE */
680