39 #define DE600_SLOW_DOWN udelay(delay_time)
41 #include <linux/module.h>
42 #include <linux/kernel.h>
43 #include <linux/types.h>
44 #include <linux/fcntl.h>
45 #include <linux/string.h>
49 #include <linux/errno.h>
53 #include <linux/netdevice.h>
61 static bool check_lost =
true;
65 static unsigned int delay_time = 10;
74 static volatile int rx_page;
78 static volatile int tx_fifo_in;
79 static volatile int tx_fifo_out;
80 static volatile int free_tx_pages =
TX_PAGES;
102 return ((
unsigned char)
inb(
STATUS_PORT) & (
unsigned char)0xf0) | lo;
123 ret = adapter_init(dev);
124 spin_unlock_irqrestore(&de600_lock, flags);
132 static int de600_close(
struct net_device *dev)
144 static inline void trigger_interrupt(
struct net_device *dev)
167 if (free_tx_pages <= 0) {
169 if (tickssofar <
HZ/20)
172 printk(
KERN_WARNING "%s: transmit timed out (%d), %s?\n", dev->
name, tickssofar,
"network cable problem");
175 if (adapter_init(dev)) {
176 spin_unlock_irqrestore(&de600_lock, flags);
179 spin_unlock_irqrestore(&de600_lock, flags);
183 pr_debug(
"de600_start_xmit:len=%d, page %d/%d\n", skb->
len, tx_fifo_in, free_tx_pages);
191 tx_fifo_in = (tx_fifo_in + 1) %
TX_PAGES;
198 if (was_down || (de600_read_byte(
READ_DATA, dev) != 0xde)) {
199 if (adapter_init(dev)) {
200 spin_unlock_irqrestore(&de600_lock, flags);
214 netif_start_queue(dev);
221 netif_start_queue(dev);
223 netif_stop_queue(dev);
226 spin_unlock_irqrestore(&de600_lock, flags);
243 spin_lock(&de600_lock);
246 irq_status = de600_read_status(dev);
249 pr_debug(
"de600_interrupt (%02X)\n", irq_status);
253 else if (!(irq_status &
RX_BUSY))
258 retrig = de600_tx_intr(dev, irq_status);
262 irq_status = de600_read_status(dev);
263 }
while ( (irq_status & RX_GOOD) || ((++boguscount < 100) && retrig) );
273 trigger_interrupt(dev);
274 spin_unlock(&de600_lock);
278 static int de600_tx_intr(
struct net_device *dev,
int irq_status)
291 tx_fifo_out = (tx_fifo_out + 1) %
TX_PAGES;
293 dev->
stats.tx_packets++;
294 netif_wake_queue(dev);
298 if ((free_tx_pages <
TX_PAGES) || (irq_status & TX_FAILED16)) {
312 static void de600_rx_intr(
struct net_device *dev)
321 size = de600_read_byte(
RX_LEN, dev);
322 size += (de600_read_byte(
RX_LEN, dev) << 8);
330 if ((size < 32) || (size > 1535)) {
337 skb = netdev_alloc_skb(dev, size + 2);
339 printk(
"%s: Couldn't allocate a sk_buff of size %d.\n", dev->
name, size);
351 for (i = size; i > 0; --
i, ++
buffer)
352 *buffer = de600_read_byte(
READ_DATA, dev);
359 dev->
stats.rx_packets++;
369 .ndo_open = de600_open,
370 .ndo_stop = de600_close,
371 .ndo_start_xmit = de600_start_xmit,
384 dev = alloc_etherdev(0);
403 (
void)de600_read_status(dev);
406 if (de600_read_status(dev) & 0xf0) {
432 printk(
" not identified in the printer port\n");
457 static int adapter_init(
struct net_device *dev)
470 if ((de600_read_byte(
READ_DATA, dev) != 0xde) ||
471 (de600_read_byte(
READ_DATA, dev) != 0x15)) {
473 printk(
"Something has happened to the DE-600! Please check it and do a new ifconfig!\n");
478 netif_stop_queue(dev);
504 netif_start_queue(dev);
511 static int __init de600_init(
void)
513 de600_dev = de600_probe();
514 if (IS_ERR(de600_dev))
515 return PTR_ERR(de600_dev);
519 static void __exit de600_exit(
void)