28 #include <linux/kernel.h>
29 #include <linux/module.h>
33 #include <linux/netdevice.h>
41 #define VERSION "arcnet: COM90xx IO-mapped mode support (by David Woodhouse et el.)\n"
50 static int com90io_reset(
struct net_device *
dev,
int really_reset);
60 #define ARCNET_TOTAL_SIZE 16
63 #define _INTMASK (ioaddr+0)
64 #define _STATUS (ioaddr+0)
65 #define _COMMAND (ioaddr+1)
66 #define _RESET (ioaddr+8)
67 #define _MEMDATA (ioaddr+12)
68 #define _ADDR_HI (ioaddr+15)
69 #define _ADDR_LO (ioaddr+14)
70 #define _CONFIG (ioaddr+2)
76 #define ASTATUS() inb(_STATUS)
77 #define ACOMMAND(cmd) outb((cmd),_COMMAND)
78 #define AINTMASK(msk) outb((msk),_INTMASK)
79 #define SETCONF() outb((lp->config),_CONFIG)
88 #undef ONE_AT_A_TIME_TX
89 #undef ONE_AT_A_TIME_RX
101 #ifdef ONE_AT_A_TIME_TX
123 #ifdef ONE_AT_A_TIME_RX
124 *(dest++) = get_buffer_byte(dev, offset++);
130 static void put_whole_buffer(
struct net_device *dev,
unsigned offset,
unsigned length,
char *dest)
138 #ifdef ONE_AT_A_TIME_TX
139 put_buffer_byte(dev, offset++, *(dest++));
152 unsigned long airqmask;
158 BUGMSG(D_NORMAL,
"No autoprobe for IO mapped cards; you "
159 "must specify the base address!\n");
163 BUGMSG(D_INIT_REASONS,
"IO request_region %x-%x failed.\n",
168 BUGMSG(D_INIT_REASONS,
"IO address %x empty\n", ioaddr);
176 if ((
status & 0x9D) != (NORXflag | RECONflag | TXFREEflag | RESETflag)) {
177 BUGMSG(D_INIT_REASONS,
"Status invalid (%Xh).\n",
status);
180 BUGMSG(D_INIT_REASONS,
"Status after reset: %X\n",
status);
182 ACOMMAND(CFLAGScmd | RESETclear | CONFIGclear);
184 BUGMSG(D_INIT_REASONS,
"Status after reset acknowledged: %X\n",
status);
189 BUGMSG(D_INIT_REASONS,
"Eternal reset (status=%Xh)\n",
status);
200 BUGMSG(D_INIT_REASONS,
"Signature byte not found"
201 " (%Xh instead).\n",
status);
217 if ((
int)dev->
irq <= 0) {
218 BUGMSG(D_INIT_REASONS,
"Autoprobe IRQ failed\n");
223 return com90io_found(dev);
236 struct arcnet_local *
lp;
242 BUGMSG(D_NORMAL,
"Can't get IRQ %d!\n", dev->
irq);
251 lp = netdev_priv(dev);
252 lp->card_name =
"COM90xx I/O";
253 lp->hw.command = com90io_command;
254 lp->hw.status = com90io_status;
255 lp->hw.intmask = com90io_setmask;
256 lp->hw.reset = com90io_reset;
258 lp->hw.copy_to_card = com90io_copy_to_card;
259 lp->hw.copy_from_card = com90io_copy_from_card;
261 lp->config = (0x16 | IOMAPflag) & ~ENABLE16flag;
266 dev->
dev_addr[0] = get_buffer_byte(dev, 1);
276 BUGMSG(D_NORMAL,
"COM90IO: station %02Xh found at %03lXh, IRQ %d.\n",
291 static int com90io_reset(
struct net_device *dev,
int really_reset)
293 struct arcnet_local *lp = netdev_priv(dev);
304 lp->config = (0x1C | IOMAPflag) & ~ENABLE16flag;
311 if (get_buffer_byte(dev, 0) != TESTvalue) {
312 BUGMSG(D_NORMAL,
"reset failed: TESTvalue not present.\n");
331 static int com90io_status(
struct net_device *dev)
346 static void com90io_copy_to_card(
struct net_device *dev,
int bufnum,
int offset,
349 TIME(
"put_whole_buffer", count, put_whole_buffer(dev, bufnum * 512 + offset, count, buf));
353 static void com90io_copy_from_card(
struct net_device *dev,
int bufnum,
int offset,
354 void *buf,
int count)
356 TIME(
"get_whole_buffer", count, get_whole_buffer(dev, bufnum * 512 + offset, count, buf));
369 static int __init com90io_setup(
char *
s)
377 printk(
"com90io: Too many arguments.\n");
384 snprintf(device,
sizeof(device),
"%s", s);
387 __setup(
"com90io=", com90io_setup);
392 static int __init com90io_init(
void)
406 err = com90io_probe(dev);
417 static void __exit com90io_exit(
void)