27 #include <linux/kernel.h>
28 #include <linux/module.h>
32 #include <linux/netdevice.h>
40 #define VERSION "arcnet: RIM I (entirely mem-mapped) support\n"
50 static int arcrimi_reset(
struct net_device *
dev,
int really_reset);
59 #define BUFFER_SIZE (512)
60 #define MIRROR_SIZE (BUFFER_SIZE*4)
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() readb(_STATUS)
77 #define ACOMMAND(cmd) writeb((cmd),_COMMAND)
78 #define AINTMASK(msk) writeb((msk),_INTMASK)
79 #define SETCONF() writeb(lp->config,_CONFIG)
90 BUGLVL(D_NORMAL)
printk(
"E-mail me if you actually test the RIM I driver, please!\n");
92 BUGLVL(D_NORMAL)
printk(
"Given: node %02Xh, shmem %lXh, irq %d\n",
96 BUGLVL(D_NORMAL)
printk(
"No autoprobe for RIM I; you "
97 "must specify the shmem and irq!\n");
101 BUGLVL(D_NORMAL)
printk(
"You need to specify your card's station "
112 BUGLVL(D_NORMAL)
printk(
"Card memory already allocated\n");
115 return arcrimi_found(dev);
118 static int check_mirror(
unsigned long addr,
size_t size)
128 if (
readb(p) == TESTvalue)
145 struct arcnet_local *
lp;
146 unsigned long first_mirror, last_mirror, shmem;
154 BUGMSG(D_NORMAL,
"Can't ioremap\n");
162 BUGMSG(D_NORMAL,
"Can't get IRQ %d!\n", dev->
irq);
177 if (
readb(p) == TESTvalue &&
182 first_mirror = shmem - mirror_size;
183 while (check_mirror(first_mirror, mirror_size) == 1)
184 first_mirror -= mirror_size;
185 first_mirror += mirror_size;
187 last_mirror = shmem + mirror_size;
188 while (check_mirror(last_mirror, mirror_size) == 1)
189 last_mirror += mirror_size;
190 last_mirror -= mirror_size;
197 lp = netdev_priv(dev);
198 lp->card_name =
"RIM I";
199 lp->hw.command = arcrimi_command;
200 lp->hw.status = arcrimi_status;
201 lp->hw.intmask = arcrimi_setmask;
202 lp->hw.reset = arcrimi_reset;
204 lp->hw.copy_to_card = arcrimi_copy_to_card;
205 lp->hw.copy_from_card = arcrimi_copy_from_card;
218 BUGMSG(D_NORMAL,
"Card memory already allocated\n");
223 if (!lp->mem_start) {
224 BUGMSG(D_NORMAL,
"Can't remap device memory!\n");
225 goto err_release_mem;
231 BUGMSG(D_NORMAL,
"ARCnet RIM I: station %02Xh found at IRQ %d, "
232 "ShMem %lXh (%ld*%d bytes).\n",
261 static int arcrimi_reset(
struct net_device *dev,
int really_reset)
263 struct arcnet_local *lp = netdev_priv(dev);
264 void __iomem *ioaddr = lp->mem_start + 0x800;
269 writeb(TESTvalue, ioaddr - 0x800);
284 struct arcnet_local *lp = netdev_priv(dev);
285 void __iomem *ioaddr = lp->mem_start + 0x800;
290 static int arcrimi_status(
struct net_device *dev)
292 struct arcnet_local *lp = netdev_priv(dev);
293 void __iomem *ioaddr = lp->mem_start + 0x800;
300 struct arcnet_local *lp = netdev_priv(dev);
301 void __iomem *ioaddr = lp->mem_start + 0x800;
306 static void arcrimi_copy_to_card(
struct net_device *dev,
int bufnum,
int offset,
309 struct arcnet_local *lp = netdev_priv(dev);
315 static void arcrimi_copy_from_card(
struct net_device *dev,
int bufnum,
int offset,
316 void *buf,
int count)
318 struct arcnet_local *lp = netdev_priv(dev);
319 void __iomem *memaddr = lp->mem_start + 0x800 + bufnum * 512 +
offset;
336 static int __init arc_rimi_init(
void)
344 if (node && node != 0xff)
352 if (arcrimi_probe(dev)) {
361 static void __exit arc_rimi_exit(
void)
364 struct arcnet_local *lp = netdev_priv(dev);
374 static int __init arcrimi_setup(
char *
s)
382 printk(
"arcrimi: Too many arguments.\n");
391 snprintf(device,
sizeof(device),
"%s", s);
394 __setup(
"arcrimi=", arcrimi_setup);