28 #include <linux/module.h>
29 #include <linux/kernel.h>
30 #include <linux/types.h>
32 #include <linux/errno.h>
34 #include <linux/netdevice.h>
42 #define VERSION "arcnet: COM20020 chipset support (by David Woodhouse et al.)\n"
44 static char *clockrates[] =
45 {
"10 Mb/s",
"Reserved",
"5 Mb/s",
46 "2.5 Mb/s",
"1.25Mb/s",
"625 Kb/s",
"312.5 Kb/s",
47 "156.25 Kb/s",
"Reserved",
"Reserved",
"Reserved"};
52 static int com20020_reset(
struct net_device *
dev,
int really_reset);
53 static void com20020_copy_to_card(
struct net_device *
dev,
int bufnum,
55 static void com20020_copy_from_card(
struct net_device *
dev,
int bufnum,
58 static void com20020_close(
struct net_device *);
60 static void com20020_copy_from_card(
struct net_device *
dev,
int bufnum,
74 static void com20020_copy_to_card(
struct net_device *dev,
int bufnum,
75 int offset,
void *buf,
int count)
92 struct arcnet_local *
lp = netdev_priv(dev);
97 lp->setup = lp->clockm ? 0 : (lp->clockp << 1);
98 lp->setup2 = (lp->clockm << 4) | 8;
102 lp->setup = lp->setup |
P1MODE;
117 lp->config = 0x21 | (lp->timeout << 3) | (lp->backplane << 2);
124 if ((
status & 0x99) != (NORXflag | TXFREEflag | RESETflag)) {
125 BUGMSG(D_NORMAL,
"status invalid (%Xh).\n",
status);
128 BUGMSG(D_INIT_REASONS,
"status after reset: %X\n",
status);
134 ACOMMAND(CFLAGScmd | RESETclear | CONFIGclear);
137 BUGMSG(D_INIT_REASONS,
"status after reset acknowledged: %X\n",
145 BUGMSG(D_NORMAL,
"Signature byte not found (%02Xh != D1h).\n",
157 .ndo_set_rx_mode = com20020_set_mc_list,
165 struct arcnet_local *
lp;
170 lp = netdev_priv(dev);
173 lp->hw.command = com20020_command;
174 lp->hw.status = com20020_status;
175 lp->hw.intmask = com20020_setmask;
176 lp->hw.reset = com20020_reset;
177 lp->hw.copy_to_card = com20020_copy_to_card;
178 lp->hw.copy_from_card = com20020_copy_from_card;
179 lp->hw.close = com20020_close;
187 if (lp->card_flags & ARC_CAN_10MBIT)
197 lp->config = 0x20 | (lp->timeout << 3) | (lp->backplane << 2) | 1;
204 "arcnet (COM20020)", dev)) {
205 BUGMSG(D_NORMAL,
"Can't get IRQ %d!\n", dev->
irq);
211 BUGMSG(D_NORMAL,
"%s: station %02Xh found at %03lXh, IRQ %d.\n",
215 BUGMSG(D_NORMAL,
"Using backplane mode.\n");
217 if (lp->timeout != 3)
218 BUGMSG(D_NORMAL,
"Using extended timeout value of %d.\n", lp->timeout);
220 BUGMSG(D_NORMAL,
"Using CKP %d - data rate %s.\n",
222 clockrates[3 - ((lp->setup2 & 0xF0) >> 4) + ((lp->setup & 0x0F) >> 1)]);
240 static int com20020_reset(
struct net_device *dev,
int really_reset)
242 struct arcnet_local *
lp = netdev_priv(dev);
246 BUGMSG(D_DEBUG,
"%s: %d: %s: dev: %p, lp: %p, dev->name: %s\n",
247 __FILE__,__LINE__,__func__,dev,lp,dev->
name);
248 BUGMSG(
D_INIT,
"Resetting %s (status=%02Xh)\n",
251 BUGMSG(D_DEBUG,
"%s: %d: %s\n",__FILE__,__LINE__,__func__);
252 lp->config =
TXENcfg | (lp->timeout << 3) | (lp->backplane << 2);
255 BUGMSG(D_DEBUG,
"%s: %d: %s\n",__FILE__,__LINE__,__func__);
263 BUGMSG(D_DEBUG,
"%s: %d: %s\n",__FILE__,__LINE__,__func__);
264 ACOMMAND(CFLAGScmd | RESETclear | CONFIGclear);
267 BUGMSG(D_DEBUG,
"%s: %d: %s\n",__FILE__,__LINE__,__func__);
269 com20020_copy_from_card(dev, 0, 0, &inbyte, 1);
270 BUGMSG(D_DEBUG,
"%s: %d: %s\n",__FILE__,__LINE__,__func__);
271 if (inbyte != TESTvalue) {
272 BUGMSG(D_DEBUG,
"%s: %d: %s\n",__FILE__,__LINE__,__func__);
273 BUGMSG(D_NORMAL,
"reset failed: TESTvalue not present.\n");
278 BUGMSG(D_DEBUG,
"%s: %d: %s\n",__FILE__,__LINE__,__func__);
288 BUGMSG(D_DURING,
"Setting mask to %x at %x\n",mask,ioaddr);
293 static void com20020_command(
struct net_device *dev,
int cmd)
300 static int com20020_status(
struct net_device *dev)
307 static void com20020_close(
struct net_device *dev)
309 struct arcnet_local *lp = netdev_priv(dev);
324 static void com20020_set_mc_list(
struct net_device *dev)
326 struct arcnet_local *lp = netdev_priv(dev);
331 BUGMSG(D_NORMAL,
"Setting promiscuous flag...\n");
339 BUGMSG(D_NORMAL,
"Resetting promiscuous flag...\n");
346 #if defined(CONFIG_ARCNET_COM20020_PCI_MODULE) || \
347 defined(CONFIG_ARCNET_COM20020_ISA_MODULE) || \
348 defined(CONFIG_ARCNET_COM20020_CS_MODULE)
358 static int __init com20020_module_init(
void)
364 static
void __exit com20020_module_exit(
void)