| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* | 
|  | 2 | *  linux/drivers/acorn/net/etherh.c | 
|  | 3 | * | 
|  | 4 | *  Copyright (C) 2000-2002 Russell King | 
|  | 5 | * | 
|  | 6 | * This program is free software; you can redistribute it and/or modify | 
|  | 7 | * it under the terms of the GNU General Public License version 2 as | 
|  | 8 | * published by the Free Software Foundation. | 
|  | 9 | * | 
|  | 10 | * NS8390 I-cubed EtherH and ANT EtherM specific driver | 
|  | 11 | * Thanks to I-Cubed for information on their cards. | 
|  | 12 | * EtherM conversion (C) 1999 Chris Kemp and Tim Watterton | 
|  | 13 | * EtherM integration (C) 2000 Aleph One Ltd (Tak-Shing Chan) | 
|  | 14 | * EtherM integration re-engineered by Russell King. | 
|  | 15 | * | 
|  | 16 | * Changelog: | 
|  | 17 | *  08-12-1996	RMK	1.00	Created | 
|  | 18 | *		RMK	1.03	Added support for EtherLan500 cards | 
|  | 19 | *  23-11-1997	RMK	1.04	Added media autodetection | 
|  | 20 | *  16-04-1998	RMK	1.05	Improved media autodetection | 
|  | 21 | *  10-02-2000	RMK	1.06	Updated for 2.3.43 | 
|  | 22 | *  13-05-2000	RMK	1.07	Updated for 2.3.99-pre8 | 
|  | 23 | *  12-10-1999  CK/TEW		EtherM driver first release | 
|  | 24 | *  21-12-2000	TTC		EtherH/EtherM integration | 
|  | 25 | *  25-12-2000	RMK	1.08	Clean integration of EtherM into this driver. | 
|  | 26 | *  03-01-2002	RMK	1.09	Always enable IRQs if we're in the nic slot. | 
|  | 27 | */ | 
|  | 28 |  | 
|  | 29 | #include <linux/module.h> | 
|  | 30 | #include <linux/kernel.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | #include <linux/types.h> | 
|  | 32 | #include <linux/fcntl.h> | 
|  | 33 | #include <linux/interrupt.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | #include <linux/ioport.h> | 
|  | 35 | #include <linux/in.h> | 
|  | 36 | #include <linux/slab.h> | 
|  | 37 | #include <linux/string.h> | 
|  | 38 | #include <linux/errno.h> | 
|  | 39 | #include <linux/netdevice.h> | 
|  | 40 | #include <linux/etherdevice.h> | 
|  | 41 | #include <linux/ethtool.h> | 
|  | 42 | #include <linux/skbuff.h> | 
|  | 43 | #include <linux/delay.h> | 
|  | 44 | #include <linux/device.h> | 
|  | 45 | #include <linux/init.h> | 
|  | 46 | #include <linux/bitops.h> | 
| Marcelo Feitoza Parisi | ff5688a | 2006-01-09 18:37:15 -0800 | [diff] [blame] | 47 | #include <linux/jiffies.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 |  | 
|  | 49 | #include <asm/system.h> | 
|  | 50 | #include <asm/ecard.h> | 
|  | 51 | #include <asm/io.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 |  | 
| Al Viro | 6c3561b | 2006-10-10 00:19:36 +0100 | [diff] [blame] | 53 | #define EI_SHIFT(x)	(ei_local->reg_offset[x]) | 
|  | 54 |  | 
| Al Viro | b936889 | 2006-10-10 00:19:36 +0100 | [diff] [blame] | 55 | #define ei_inb(_p)	 readb((void __iomem *)_p) | 
|  | 56 | #define ei_outb(_v,_p)	 writeb(_v,(void __iomem *)_p) | 
|  | 57 | #define ei_inb_p(_p)	 readb((void __iomem *)_p) | 
|  | 58 | #define ei_outb_p(_v,_p) writeb(_v,(void __iomem *)_p) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 |  | 
|  | 60 | #define NET_DEBUG  0 | 
|  | 61 | #define DEBUG_INIT 2 | 
|  | 62 |  | 
|  | 63 | #define DRV_NAME	"etherh" | 
|  | 64 | #define DRV_VERSION	"1.11" | 
|  | 65 |  | 
| Al Viro | 6c3561b | 2006-10-10 00:19:36 +0100 | [diff] [blame] | 66 | static char version[] __initdata = | 
|  | 67 | "EtherH/EtherM Driver (c) 2002-2004 Russell King " DRV_VERSION "\n"; | 
|  | 68 |  | 
|  | 69 | #include "../lib8390.c" | 
|  | 70 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 71 | static unsigned int net_debug = NET_DEBUG; | 
|  | 72 |  | 
|  | 73 | struct etherh_priv { | 
|  | 74 | void __iomem	*ioc_fast; | 
|  | 75 | void __iomem	*memc; | 
|  | 76 | void __iomem	*dma_base; | 
|  | 77 | unsigned int	id; | 
|  | 78 | void __iomem	*ctrl_port; | 
|  | 79 | unsigned char	ctrl; | 
|  | 80 | u32		supported; | 
|  | 81 | }; | 
|  | 82 |  | 
|  | 83 | struct etherh_data { | 
|  | 84 | unsigned long	ns8390_offset; | 
|  | 85 | unsigned long	dataport_offset; | 
|  | 86 | unsigned long	ctrlport_offset; | 
|  | 87 | int		ctrl_ioc; | 
|  | 88 | const char	name[16]; | 
|  | 89 | u32		supported; | 
|  | 90 | unsigned char	tx_start_page; | 
|  | 91 | unsigned char	stop_page; | 
|  | 92 | }; | 
|  | 93 |  | 
|  | 94 | MODULE_AUTHOR("Russell King"); | 
|  | 95 | MODULE_DESCRIPTION("EtherH/EtherM driver"); | 
|  | 96 | MODULE_LICENSE("GPL"); | 
|  | 97 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 98 | #define ETHERH500_DATAPORT	0x800	/* MEMC */ | 
|  | 99 | #define ETHERH500_NS8390	0x000	/* MEMC */ | 
|  | 100 | #define ETHERH500_CTRLPORT	0x800	/* IOC  */ | 
|  | 101 |  | 
|  | 102 | #define ETHERH600_DATAPORT	0x040	/* MEMC */ | 
|  | 103 | #define ETHERH600_NS8390	0x800	/* MEMC */ | 
|  | 104 | #define ETHERH600_CTRLPORT	0x200	/* MEMC */ | 
|  | 105 |  | 
|  | 106 | #define ETHERH_CP_IE		1 | 
|  | 107 | #define ETHERH_CP_IF		2 | 
|  | 108 | #define ETHERH_CP_HEARTBEAT	2 | 
|  | 109 |  | 
|  | 110 | #define ETHERH_TX_START_PAGE	1 | 
|  | 111 | #define ETHERH_STOP_PAGE	127 | 
|  | 112 |  | 
|  | 113 | /* | 
|  | 114 | * These came from CK/TEW | 
|  | 115 | */ | 
|  | 116 | #define ETHERM_DATAPORT		0x200	/* MEMC */ | 
|  | 117 | #define ETHERM_NS8390		0x800	/* MEMC */ | 
|  | 118 | #define ETHERM_CTRLPORT		0x23c	/* MEMC */ | 
|  | 119 |  | 
|  | 120 | #define ETHERM_TX_START_PAGE	64 | 
|  | 121 | #define ETHERM_STOP_PAGE	127 | 
|  | 122 |  | 
|  | 123 | /* ------------------------------------------------------------------------ */ | 
|  | 124 |  | 
|  | 125 | #define etherh_priv(dev) \ | 
|  | 126 | ((struct etherh_priv *)(((char *)netdev_priv(dev)) + sizeof(struct ei_device))) | 
|  | 127 |  | 
|  | 128 | static inline void etherh_set_ctrl(struct etherh_priv *eh, unsigned char mask) | 
|  | 129 | { | 
|  | 130 | unsigned char ctrl = eh->ctrl | mask; | 
|  | 131 | eh->ctrl = ctrl; | 
|  | 132 | writeb(ctrl, eh->ctrl_port); | 
|  | 133 | } | 
|  | 134 |  | 
|  | 135 | static inline void etherh_clr_ctrl(struct etherh_priv *eh, unsigned char mask) | 
|  | 136 | { | 
|  | 137 | unsigned char ctrl = eh->ctrl & ~mask; | 
|  | 138 | eh->ctrl = ctrl; | 
|  | 139 | writeb(ctrl, eh->ctrl_port); | 
|  | 140 | } | 
|  | 141 |  | 
|  | 142 | static inline unsigned int etherh_get_stat(struct etherh_priv *eh) | 
|  | 143 | { | 
|  | 144 | return readb(eh->ctrl_port); | 
|  | 145 | } | 
|  | 146 |  | 
|  | 147 |  | 
|  | 148 |  | 
|  | 149 |  | 
|  | 150 | static void etherh_irq_enable(ecard_t *ec, int irqnr) | 
|  | 151 | { | 
|  | 152 | struct etherh_priv *eh = ec->irq_data; | 
|  | 153 |  | 
|  | 154 | etherh_set_ctrl(eh, ETHERH_CP_IE); | 
|  | 155 | } | 
|  | 156 |  | 
|  | 157 | static void etherh_irq_disable(ecard_t *ec, int irqnr) | 
|  | 158 | { | 
|  | 159 | struct etherh_priv *eh = ec->irq_data; | 
|  | 160 |  | 
|  | 161 | etherh_clr_ctrl(eh, ETHERH_CP_IE); | 
|  | 162 | } | 
|  | 163 |  | 
|  | 164 | static expansioncard_ops_t etherh_ops = { | 
|  | 165 | .irqenable	= etherh_irq_enable, | 
|  | 166 | .irqdisable	= etherh_irq_disable, | 
|  | 167 | }; | 
|  | 168 |  | 
|  | 169 |  | 
|  | 170 |  | 
|  | 171 |  | 
|  | 172 | static void | 
|  | 173 | etherh_setif(struct net_device *dev) | 
|  | 174 | { | 
|  | 175 | struct ei_device *ei_local = netdev_priv(dev); | 
|  | 176 | unsigned long flags; | 
|  | 177 | void __iomem *addr; | 
|  | 178 |  | 
|  | 179 | local_irq_save(flags); | 
|  | 180 |  | 
|  | 181 | /* set the interface type */ | 
|  | 182 | switch (etherh_priv(dev)->id) { | 
|  | 183 | case PROD_I3_ETHERLAN600: | 
|  | 184 | case PROD_I3_ETHERLAN600A: | 
| Al Viro | b936889 | 2006-10-10 00:19:36 +0100 | [diff] [blame] | 185 | addr = (void __iomem *)dev->base_addr + EN0_RCNTHI; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 186 |  | 
|  | 187 | switch (dev->if_port) { | 
|  | 188 | case IF_PORT_10BASE2: | 
|  | 189 | writeb((readb(addr) & 0xf8) | 1, addr); | 
|  | 190 | break; | 
|  | 191 | case IF_PORT_10BASET: | 
|  | 192 | writeb((readb(addr) & 0xf8), addr); | 
|  | 193 | break; | 
|  | 194 | } | 
|  | 195 | break; | 
|  | 196 |  | 
|  | 197 | case PROD_I3_ETHERLAN500: | 
|  | 198 | switch (dev->if_port) { | 
|  | 199 | case IF_PORT_10BASE2: | 
|  | 200 | etherh_clr_ctrl(etherh_priv(dev), ETHERH_CP_IF); | 
|  | 201 | break; | 
|  | 202 |  | 
|  | 203 | case IF_PORT_10BASET: | 
|  | 204 | etherh_set_ctrl(etherh_priv(dev), ETHERH_CP_IF); | 
|  | 205 | break; | 
|  | 206 | } | 
|  | 207 | break; | 
|  | 208 |  | 
|  | 209 | default: | 
|  | 210 | break; | 
|  | 211 | } | 
|  | 212 |  | 
|  | 213 | local_irq_restore(flags); | 
|  | 214 | } | 
|  | 215 |  | 
|  | 216 | static int | 
|  | 217 | etherh_getifstat(struct net_device *dev) | 
|  | 218 | { | 
|  | 219 | struct ei_device *ei_local = netdev_priv(dev); | 
|  | 220 | void __iomem *addr; | 
|  | 221 | int stat = 0; | 
|  | 222 |  | 
|  | 223 | switch (etherh_priv(dev)->id) { | 
|  | 224 | case PROD_I3_ETHERLAN600: | 
|  | 225 | case PROD_I3_ETHERLAN600A: | 
| Al Viro | b936889 | 2006-10-10 00:19:36 +0100 | [diff] [blame] | 226 | addr = (void __iomem *)dev->base_addr + EN0_RCNTHI; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 227 | switch (dev->if_port) { | 
|  | 228 | case IF_PORT_10BASE2: | 
|  | 229 | stat = 1; | 
|  | 230 | break; | 
|  | 231 | case IF_PORT_10BASET: | 
|  | 232 | stat = readb(addr) & 4; | 
|  | 233 | break; | 
|  | 234 | } | 
|  | 235 | break; | 
|  | 236 |  | 
|  | 237 | case PROD_I3_ETHERLAN500: | 
|  | 238 | switch (dev->if_port) { | 
|  | 239 | case IF_PORT_10BASE2: | 
|  | 240 | stat = 1; | 
|  | 241 | break; | 
|  | 242 | case IF_PORT_10BASET: | 
|  | 243 | stat = etherh_get_stat(etherh_priv(dev)) & ETHERH_CP_HEARTBEAT; | 
|  | 244 | break; | 
|  | 245 | } | 
|  | 246 | break; | 
|  | 247 |  | 
|  | 248 | default: | 
|  | 249 | stat = 0; | 
|  | 250 | break; | 
|  | 251 | } | 
|  | 252 |  | 
|  | 253 | return stat != 0; | 
|  | 254 | } | 
|  | 255 |  | 
|  | 256 | /* | 
|  | 257 | * Configure the interface.  Note that we ignore the other | 
|  | 258 | * parts of ifmap, since its mostly meaningless for this driver. | 
|  | 259 | */ | 
|  | 260 | static int etherh_set_config(struct net_device *dev, struct ifmap *map) | 
|  | 261 | { | 
|  | 262 | switch (map->port) { | 
|  | 263 | case IF_PORT_10BASE2: | 
|  | 264 | case IF_PORT_10BASET: | 
|  | 265 | /* | 
|  | 266 | * If the user explicitly sets the interface | 
|  | 267 | * media type, turn off automedia detection. | 
|  | 268 | */ | 
|  | 269 | dev->flags &= ~IFF_AUTOMEDIA; | 
|  | 270 | dev->if_port = map->port; | 
|  | 271 | break; | 
|  | 272 |  | 
|  | 273 | default: | 
|  | 274 | return -EINVAL; | 
|  | 275 | } | 
|  | 276 |  | 
|  | 277 | etherh_setif(dev); | 
|  | 278 |  | 
|  | 279 | return 0; | 
|  | 280 | } | 
|  | 281 |  | 
|  | 282 | /* | 
|  | 283 | * Reset the 8390 (hard reset).  Note that we can't actually do this. | 
|  | 284 | */ | 
|  | 285 | static void | 
|  | 286 | etherh_reset(struct net_device *dev) | 
|  | 287 | { | 
|  | 288 | struct ei_device *ei_local = netdev_priv(dev); | 
| Al Viro | b936889 | 2006-10-10 00:19:36 +0100 | [diff] [blame] | 289 | void __iomem *addr = (void __iomem *)dev->base_addr; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 290 |  | 
|  | 291 | writeb(E8390_NODMA+E8390_PAGE0+E8390_STOP, addr); | 
|  | 292 |  | 
|  | 293 | /* | 
|  | 294 | * See if we need to change the interface type. | 
|  | 295 | * Note that we use 'interface_num' as a flag | 
|  | 296 | * to indicate that we need to change the media. | 
|  | 297 | */ | 
|  | 298 | if (dev->flags & IFF_AUTOMEDIA && ei_local->interface_num) { | 
|  | 299 | ei_local->interface_num = 0; | 
|  | 300 |  | 
|  | 301 | if (dev->if_port == IF_PORT_10BASET) | 
|  | 302 | dev->if_port = IF_PORT_10BASE2; | 
|  | 303 | else | 
|  | 304 | dev->if_port = IF_PORT_10BASET; | 
|  | 305 |  | 
|  | 306 | etherh_setif(dev); | 
|  | 307 | } | 
|  | 308 | } | 
|  | 309 |  | 
|  | 310 | /* | 
|  | 311 | * Write a block of data out to the 8390 | 
|  | 312 | */ | 
|  | 313 | static void | 
|  | 314 | etherh_block_output (struct net_device *dev, int count, const unsigned char *buf, int start_page) | 
|  | 315 | { | 
|  | 316 | struct ei_device *ei_local = netdev_priv(dev); | 
|  | 317 | unsigned long dma_start; | 
|  | 318 | void __iomem *dma_base, *addr; | 
|  | 319 |  | 
|  | 320 | if (ei_local->dmaing) { | 
|  | 321 | printk(KERN_ERR "%s: DMAing conflict in etherh_block_input: " | 
|  | 322 | " DMAstat %d irqlock %d\n", dev->name, | 
|  | 323 | ei_local->dmaing, ei_local->irqlock); | 
|  | 324 | return; | 
|  | 325 | } | 
|  | 326 |  | 
|  | 327 | /* | 
|  | 328 | * Make sure we have a round number of bytes if we're in word mode. | 
|  | 329 | */ | 
|  | 330 | if (count & 1 && ei_local->word16) | 
|  | 331 | count++; | 
|  | 332 |  | 
|  | 333 | ei_local->dmaing = 1; | 
|  | 334 |  | 
| Al Viro | b936889 | 2006-10-10 00:19:36 +0100 | [diff] [blame] | 335 | addr = (void __iomem *)dev->base_addr; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 336 | dma_base = etherh_priv(dev)->dma_base; | 
|  | 337 |  | 
|  | 338 | count = (count + 1) & ~1; | 
|  | 339 | writeb (E8390_NODMA | E8390_PAGE0 | E8390_START, addr + E8390_CMD); | 
|  | 340 |  | 
|  | 341 | writeb (0x42, addr + EN0_RCNTLO); | 
|  | 342 | writeb (0x00, addr + EN0_RCNTHI); | 
|  | 343 | writeb (0x42, addr + EN0_RSARLO); | 
|  | 344 | writeb (0x00, addr + EN0_RSARHI); | 
|  | 345 | writeb (E8390_RREAD | E8390_START, addr + E8390_CMD); | 
|  | 346 |  | 
|  | 347 | udelay (1); | 
|  | 348 |  | 
|  | 349 | writeb (ENISR_RDC, addr + EN0_ISR); | 
|  | 350 | writeb (count, addr + EN0_RCNTLO); | 
|  | 351 | writeb (count >> 8, addr + EN0_RCNTHI); | 
|  | 352 | writeb (0, addr + EN0_RSARLO); | 
|  | 353 | writeb (start_page, addr + EN0_RSARHI); | 
|  | 354 | writeb (E8390_RWRITE | E8390_START, addr + E8390_CMD); | 
|  | 355 |  | 
|  | 356 | if (ei_local->word16) | 
|  | 357 | writesw (dma_base, buf, count >> 1); | 
|  | 358 | else | 
|  | 359 | writesb (dma_base, buf, count); | 
|  | 360 |  | 
|  | 361 | dma_start = jiffies; | 
|  | 362 |  | 
|  | 363 | while ((readb (addr + EN0_ISR) & ENISR_RDC) == 0) | 
| Marcelo Feitoza Parisi | ff5688a | 2006-01-09 18:37:15 -0800 | [diff] [blame] | 364 | if (time_after(jiffies, dma_start + 2*HZ/100)) { /* 20ms */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 365 | printk(KERN_ERR "%s: timeout waiting for TX RDC\n", | 
|  | 366 | dev->name); | 
|  | 367 | etherh_reset (dev); | 
| Al Viro | 6c3561b | 2006-10-10 00:19:36 +0100 | [diff] [blame] | 368 | __NS8390_init (dev, 1); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 369 | break; | 
|  | 370 | } | 
|  | 371 |  | 
|  | 372 | writeb (ENISR_RDC, addr + EN0_ISR); | 
|  | 373 | ei_local->dmaing = 0; | 
|  | 374 | } | 
|  | 375 |  | 
|  | 376 | /* | 
|  | 377 | * Read a block of data from the 8390 | 
|  | 378 | */ | 
|  | 379 | static void | 
|  | 380 | etherh_block_input (struct net_device *dev, int count, struct sk_buff *skb, int ring_offset) | 
|  | 381 | { | 
|  | 382 | struct ei_device *ei_local = netdev_priv(dev); | 
|  | 383 | unsigned char *buf; | 
|  | 384 | void __iomem *dma_base, *addr; | 
|  | 385 |  | 
|  | 386 | if (ei_local->dmaing) { | 
|  | 387 | printk(KERN_ERR "%s: DMAing conflict in etherh_block_input: " | 
|  | 388 | " DMAstat %d irqlock %d\n", dev->name, | 
|  | 389 | ei_local->dmaing, ei_local->irqlock); | 
|  | 390 | return; | 
|  | 391 | } | 
|  | 392 |  | 
|  | 393 | ei_local->dmaing = 1; | 
|  | 394 |  | 
| Al Viro | b936889 | 2006-10-10 00:19:36 +0100 | [diff] [blame] | 395 | addr = (void __iomem *)dev->base_addr; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 396 | dma_base = etherh_priv(dev)->dma_base; | 
|  | 397 |  | 
|  | 398 | buf = skb->data; | 
|  | 399 | writeb (E8390_NODMA | E8390_PAGE0 | E8390_START, addr + E8390_CMD); | 
|  | 400 | writeb (count, addr + EN0_RCNTLO); | 
|  | 401 | writeb (count >> 8, addr + EN0_RCNTHI); | 
|  | 402 | writeb (ring_offset, addr + EN0_RSARLO); | 
|  | 403 | writeb (ring_offset >> 8, addr + EN0_RSARHI); | 
|  | 404 | writeb (E8390_RREAD | E8390_START, addr + E8390_CMD); | 
|  | 405 |  | 
|  | 406 | if (ei_local->word16) { | 
|  | 407 | readsw (dma_base, buf, count >> 1); | 
|  | 408 | if (count & 1) | 
|  | 409 | buf[count - 1] = readb (dma_base); | 
|  | 410 | } else | 
|  | 411 | readsb (dma_base, buf, count); | 
|  | 412 |  | 
|  | 413 | writeb (ENISR_RDC, addr + EN0_ISR); | 
|  | 414 | ei_local->dmaing = 0; | 
|  | 415 | } | 
|  | 416 |  | 
|  | 417 | /* | 
|  | 418 | * Read a header from the 8390 | 
|  | 419 | */ | 
|  | 420 | static void | 
|  | 421 | etherh_get_header (struct net_device *dev, struct e8390_pkt_hdr *hdr, int ring_page) | 
|  | 422 | { | 
|  | 423 | struct ei_device *ei_local = netdev_priv(dev); | 
|  | 424 | void __iomem *dma_base, *addr; | 
|  | 425 |  | 
|  | 426 | if (ei_local->dmaing) { | 
|  | 427 | printk(KERN_ERR "%s: DMAing conflict in etherh_get_header: " | 
|  | 428 | " DMAstat %d irqlock %d\n", dev->name, | 
|  | 429 | ei_local->dmaing, ei_local->irqlock); | 
|  | 430 | return; | 
|  | 431 | } | 
|  | 432 |  | 
|  | 433 | ei_local->dmaing = 1; | 
|  | 434 |  | 
| Al Viro | b936889 | 2006-10-10 00:19:36 +0100 | [diff] [blame] | 435 | addr = (void __iomem *)dev->base_addr; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 436 | dma_base = etherh_priv(dev)->dma_base; | 
|  | 437 |  | 
|  | 438 | writeb (E8390_NODMA | E8390_PAGE0 | E8390_START, addr + E8390_CMD); | 
|  | 439 | writeb (sizeof (*hdr), addr + EN0_RCNTLO); | 
|  | 440 | writeb (0, addr + EN0_RCNTHI); | 
|  | 441 | writeb (0, addr + EN0_RSARLO); | 
|  | 442 | writeb (ring_page, addr + EN0_RSARHI); | 
|  | 443 | writeb (E8390_RREAD | E8390_START, addr + E8390_CMD); | 
|  | 444 |  | 
|  | 445 | if (ei_local->word16) | 
|  | 446 | readsw (dma_base, hdr, sizeof (*hdr) >> 1); | 
|  | 447 | else | 
|  | 448 | readsb (dma_base, hdr, sizeof (*hdr)); | 
|  | 449 |  | 
|  | 450 | writeb (ENISR_RDC, addr + EN0_ISR); | 
|  | 451 | ei_local->dmaing = 0; | 
|  | 452 | } | 
|  | 453 |  | 
|  | 454 | /* | 
|  | 455 | * Open/initialize the board.  This is called (in the current kernel) | 
|  | 456 | * sometime after booting when the 'ifconfig' program is run. | 
|  | 457 | * | 
|  | 458 | * This routine should set everything up anew at each open, even | 
|  | 459 | * registers that "should" only need to be set once at boot, so that | 
|  | 460 | * there is non-reboot way to recover if something goes wrong. | 
|  | 461 | */ | 
|  | 462 | static int | 
|  | 463 | etherh_open(struct net_device *dev) | 
|  | 464 | { | 
|  | 465 | struct ei_device *ei_local = netdev_priv(dev); | 
|  | 466 |  | 
|  | 467 | if (!is_valid_ether_addr(dev->dev_addr)) { | 
|  | 468 | printk(KERN_WARNING "%s: invalid ethernet MAC address\n", | 
|  | 469 | dev->name); | 
|  | 470 | return -EINVAL; | 
|  | 471 | } | 
|  | 472 |  | 
| Al Viro | 6c3561b | 2006-10-10 00:19:36 +0100 | [diff] [blame] | 473 | if (request_irq(dev->irq, __ei_interrupt, 0, dev->name, dev)) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 474 | return -EAGAIN; | 
|  | 475 |  | 
|  | 476 | /* | 
|  | 477 | * Make sure that we aren't going to change the | 
|  | 478 | * media type on the next reset - we are about to | 
|  | 479 | * do automedia manually now. | 
|  | 480 | */ | 
|  | 481 | ei_local->interface_num = 0; | 
|  | 482 |  | 
|  | 483 | /* | 
|  | 484 | * If we are doing automedia detection, do it now. | 
|  | 485 | * This is more reliable than the 8390's detection. | 
|  | 486 | */ | 
|  | 487 | if (dev->flags & IFF_AUTOMEDIA) { | 
|  | 488 | dev->if_port = IF_PORT_10BASET; | 
|  | 489 | etherh_setif(dev); | 
|  | 490 | mdelay(1); | 
|  | 491 | if (!etherh_getifstat(dev)) { | 
|  | 492 | dev->if_port = IF_PORT_10BASE2; | 
|  | 493 | etherh_setif(dev); | 
|  | 494 | } | 
|  | 495 | } else | 
|  | 496 | etherh_setif(dev); | 
|  | 497 |  | 
|  | 498 | etherh_reset(dev); | 
| Al Viro | 6c3561b | 2006-10-10 00:19:36 +0100 | [diff] [blame] | 499 | __ei_open(dev); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 500 |  | 
|  | 501 | return 0; | 
|  | 502 | } | 
|  | 503 |  | 
|  | 504 | /* | 
|  | 505 | * The inverse routine to etherh_open(). | 
|  | 506 | */ | 
|  | 507 | static int | 
|  | 508 | etherh_close(struct net_device *dev) | 
|  | 509 | { | 
| Al Viro | 6c3561b | 2006-10-10 00:19:36 +0100 | [diff] [blame] | 510 | __ei_close (dev); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 511 | free_irq (dev->irq, dev); | 
|  | 512 | return 0; | 
|  | 513 | } | 
|  | 514 |  | 
|  | 515 | /* | 
|  | 516 | * Initialisation | 
|  | 517 | */ | 
|  | 518 |  | 
|  | 519 | static void __init etherh_banner(void) | 
|  | 520 | { | 
|  | 521 | static int version_printed; | 
|  | 522 |  | 
|  | 523 | if (net_debug && version_printed++ == 0) | 
|  | 524 | printk(KERN_INFO "%s", version); | 
|  | 525 | } | 
|  | 526 |  | 
|  | 527 | /* | 
|  | 528 | * Read the ethernet address string from the on board rom. | 
|  | 529 | * This is an ascii string... | 
|  | 530 | */ | 
|  | 531 | static int __init etherh_addr(char *addr, struct expansion_card *ec) | 
|  | 532 | { | 
|  | 533 | struct in_chunk_dir cd; | 
|  | 534 | char *s; | 
|  | 535 |  | 
|  | 536 | if (!ecard_readchunk(&cd, ec, 0xf5, 0)) { | 
|  | 537 | printk(KERN_ERR "%s: unable to read podule description string\n", | 
| Kay Sievers | 3f97870 | 2008-05-30 17:42:11 +0200 | [diff] [blame] | 538 | dev_name(&ec->dev)); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 539 | goto no_addr; | 
|  | 540 | } | 
|  | 541 |  | 
|  | 542 | s = strchr(cd.d.string, '('); | 
|  | 543 | if (s) { | 
|  | 544 | int i; | 
|  | 545 |  | 
|  | 546 | for (i = 0; i < 6; i++) { | 
|  | 547 | addr[i] = simple_strtoul(s + 1, &s, 0x10); | 
|  | 548 | if (*s != (i == 5? ')' : ':')) | 
|  | 549 | break; | 
|  | 550 | } | 
|  | 551 |  | 
|  | 552 | if (i == 6) | 
|  | 553 | return 0; | 
|  | 554 | } | 
|  | 555 |  | 
|  | 556 | printk(KERN_ERR "%s: unable to parse MAC address: %s\n", | 
| Kay Sievers | 3f97870 | 2008-05-30 17:42:11 +0200 | [diff] [blame] | 557 | dev_name(&ec->dev), cd.d.string); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 558 |  | 
|  | 559 | no_addr: | 
|  | 560 | return -ENODEV; | 
|  | 561 | } | 
|  | 562 |  | 
|  | 563 | /* | 
|  | 564 | * Create an ethernet address from the system serial number. | 
|  | 565 | */ | 
|  | 566 | static int __init etherm_addr(char *addr) | 
|  | 567 | { | 
|  | 568 | unsigned int serial; | 
|  | 569 |  | 
|  | 570 | if (system_serial_low == 0 && system_serial_high == 0) | 
|  | 571 | return -ENODEV; | 
|  | 572 |  | 
|  | 573 | serial = system_serial_low | system_serial_high; | 
|  | 574 |  | 
|  | 575 | addr[0] = 0; | 
|  | 576 | addr[1] = 0; | 
|  | 577 | addr[2] = 0xa4; | 
|  | 578 | addr[3] = 0x10 + (serial >> 24); | 
|  | 579 | addr[4] = serial >> 16; | 
|  | 580 | addr[5] = serial >> 8; | 
|  | 581 | return 0; | 
|  | 582 | } | 
|  | 583 |  | 
|  | 584 | static void etherh_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) | 
|  | 585 | { | 
|  | 586 | strlcpy(info->driver, DRV_NAME, sizeof(info->driver)); | 
|  | 587 | strlcpy(info->version, DRV_VERSION, sizeof(info->version)); | 
| Kay Sievers | 3f97870 | 2008-05-30 17:42:11 +0200 | [diff] [blame] | 588 | strlcpy(info->bus_info, dev_name(dev->dev.parent), | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 589 | sizeof(info->bus_info)); | 
|  | 590 | } | 
|  | 591 |  | 
|  | 592 | static int etherh_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) | 
|  | 593 | { | 
|  | 594 | cmd->supported	= etherh_priv(dev)->supported; | 
|  | 595 | cmd->speed	= SPEED_10; | 
|  | 596 | cmd->duplex	= DUPLEX_HALF; | 
|  | 597 | cmd->port	= dev->if_port == IF_PORT_10BASET ? PORT_TP : PORT_BNC; | 
|  | 598 | cmd->autoneg	= dev->flags & IFF_AUTOMEDIA ? AUTONEG_ENABLE : AUTONEG_DISABLE; | 
|  | 599 | return 0; | 
|  | 600 | } | 
|  | 601 |  | 
|  | 602 | static int etherh_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) | 
|  | 603 | { | 
|  | 604 | switch (cmd->autoneg) { | 
|  | 605 | case AUTONEG_ENABLE: | 
|  | 606 | dev->flags |= IFF_AUTOMEDIA; | 
|  | 607 | break; | 
|  | 608 |  | 
|  | 609 | case AUTONEG_DISABLE: | 
|  | 610 | switch (cmd->port) { | 
|  | 611 | case PORT_TP: | 
|  | 612 | dev->if_port = IF_PORT_10BASET; | 
|  | 613 | break; | 
|  | 614 |  | 
|  | 615 | case PORT_BNC: | 
|  | 616 | dev->if_port = IF_PORT_10BASE2; | 
|  | 617 | break; | 
|  | 618 |  | 
|  | 619 | default: | 
|  | 620 | return -EINVAL; | 
|  | 621 | } | 
|  | 622 | dev->flags &= ~IFF_AUTOMEDIA; | 
|  | 623 | break; | 
|  | 624 |  | 
|  | 625 | default: | 
|  | 626 | return -EINVAL; | 
|  | 627 | } | 
|  | 628 |  | 
|  | 629 | etherh_setif(dev); | 
|  | 630 |  | 
|  | 631 | return 0; | 
|  | 632 | } | 
|  | 633 |  | 
| Jeff Garzik | 7282d49 | 2006-09-13 14:30:00 -0400 | [diff] [blame] | 634 | static const struct ethtool_ops etherh_ethtool_ops = { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 635 | .get_settings	= etherh_get_settings, | 
|  | 636 | .set_settings	= etherh_set_settings, | 
|  | 637 | .get_drvinfo	= etherh_get_drvinfo, | 
|  | 638 | }; | 
|  | 639 |  | 
| Stephen Hemminger | b9a9b4b | 2008-12-02 14:52:25 -0800 | [diff] [blame] | 640 | static const struct net_device_ops etherh_netdev_ops = { | 
|  | 641 | .ndo_open		= etherh_open, | 
|  | 642 | .ndo_stop		= etherh_close, | 
|  | 643 | .ndo_set_config		= etherh_set_config, | 
| Russell King | 8cfd9e9 | 2009-02-22 12:36:55 +0000 | [diff] [blame] | 644 | .ndo_start_xmit		= __ei_start_xmit, | 
|  | 645 | .ndo_tx_timeout		= __ei_tx_timeout, | 
|  | 646 | .ndo_get_stats		= __ei_get_stats, | 
|  | 647 | .ndo_set_multicast_list = __ei_set_multicast_list, | 
| Stephen Hemminger | b9a9b4b | 2008-12-02 14:52:25 -0800 | [diff] [blame] | 648 | .ndo_validate_addr	= eth_validate_addr, | 
| Russell King | a71558d | 2009-01-27 22:32:29 +0000 | [diff] [blame] | 649 | .ndo_set_mac_address	= eth_mac_addr, | 
| Stephen Hemminger | b9a9b4b | 2008-12-02 14:52:25 -0800 | [diff] [blame] | 650 | .ndo_change_mtu		= eth_change_mtu, | 
|  | 651 | #ifdef CONFIG_NET_POLL_CONTROLLER | 
| Russell King | 8cfd9e9 | 2009-02-22 12:36:55 +0000 | [diff] [blame] | 652 | .ndo_poll_controller	= __ei_poll, | 
| Stephen Hemminger | b9a9b4b | 2008-12-02 14:52:25 -0800 | [diff] [blame] | 653 | #endif | 
|  | 654 | }; | 
|  | 655 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 656 | static u32 etherh_regoffsets[16]; | 
|  | 657 | static u32 etherm_regoffsets[16]; | 
|  | 658 |  | 
|  | 659 | static int __init | 
|  | 660 | etherh_probe(struct expansion_card *ec, const struct ecard_id *id) | 
|  | 661 | { | 
|  | 662 | const struct etherh_data *data = id->data; | 
|  | 663 | struct ei_device *ei_local; | 
|  | 664 | struct net_device *dev; | 
|  | 665 | struct etherh_priv *eh; | 
| Russell King | 36149f0 | 2008-04-19 15:12:23 +0100 | [diff] [blame] | 666 | int ret; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 667 |  | 
|  | 668 | etherh_banner(); | 
|  | 669 |  | 
|  | 670 | ret = ecard_request_resources(ec); | 
|  | 671 | if (ret) | 
|  | 672 | goto out; | 
|  | 673 |  | 
| Al Viro | 6c3561b | 2006-10-10 00:19:36 +0100 | [diff] [blame] | 674 | dev = ____alloc_ei_netdev(sizeof(struct etherh_priv)); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 675 | if (!dev) { | 
|  | 676 | ret = -ENOMEM; | 
|  | 677 | goto release; | 
|  | 678 | } | 
|  | 679 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 680 | SET_NETDEV_DEV(dev, &ec->dev); | 
|  | 681 |  | 
| Stephen Hemminger | b9a9b4b | 2008-12-02 14:52:25 -0800 | [diff] [blame] | 682 | dev->netdev_ops		= ðerh_netdev_ops; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 683 | dev->irq		= ec->irq; | 
|  | 684 | dev->ethtool_ops	= ðerh_ethtool_ops; | 
|  | 685 |  | 
|  | 686 | if (data->supported & SUPPORTED_Autoneg) | 
|  | 687 | dev->flags |= IFF_AUTOMEDIA; | 
|  | 688 | if (data->supported & SUPPORTED_TP) { | 
|  | 689 | dev->flags |= IFF_PORTSEL; | 
|  | 690 | dev->if_port = IF_PORT_10BASET; | 
|  | 691 | } else if (data->supported & SUPPORTED_BNC) { | 
|  | 692 | dev->flags |= IFF_PORTSEL; | 
|  | 693 | dev->if_port = IF_PORT_10BASE2; | 
|  | 694 | } else | 
|  | 695 | dev->if_port = IF_PORT_UNKNOWN; | 
|  | 696 |  | 
|  | 697 | eh = etherh_priv(dev); | 
|  | 698 | eh->supported		= data->supported; | 
|  | 699 | eh->ctrl		= 0; | 
|  | 700 | eh->id			= ec->cid.product; | 
| Russell King | 10bdaaa | 2007-05-10 18:40:51 +0100 | [diff] [blame] | 701 | eh->memc		= ecardm_iomap(ec, ECARD_RES_MEMC, 0, PAGE_SIZE); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 702 | if (!eh->memc) { | 
|  | 703 | ret = -ENOMEM; | 
|  | 704 | goto free; | 
|  | 705 | } | 
|  | 706 |  | 
|  | 707 | eh->ctrl_port = eh->memc; | 
|  | 708 | if (data->ctrl_ioc) { | 
| Russell King | 10bdaaa | 2007-05-10 18:40:51 +0100 | [diff] [blame] | 709 | eh->ioc_fast = ecardm_iomap(ec, ECARD_RES_IOCFAST, 0, PAGE_SIZE); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 710 | if (!eh->ioc_fast) { | 
|  | 711 | ret = -ENOMEM; | 
|  | 712 | goto free; | 
|  | 713 | } | 
|  | 714 | eh->ctrl_port = eh->ioc_fast; | 
|  | 715 | } | 
|  | 716 |  | 
| Nicolas Pitre | c7e7887 | 2005-06-29 18:10:54 +0100 | [diff] [blame] | 717 | dev->base_addr = (unsigned long)eh->memc + data->ns8390_offset; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 718 | eh->dma_base = eh->memc + data->dataport_offset; | 
|  | 719 | eh->ctrl_port += data->ctrlport_offset; | 
|  | 720 |  | 
|  | 721 | /* | 
|  | 722 | * IRQ and control port handling - only for non-NIC slot cards. | 
|  | 723 | */ | 
|  | 724 | if (ec->slot_no != 8) { | 
| Russell King | c7b87f3 | 2007-05-10 16:46:13 +0100 | [diff] [blame] | 725 | ecard_setirq(ec, ðerh_ops, eh); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 726 | } else { | 
|  | 727 | /* | 
|  | 728 | * If we're in the NIC slot, make sure the IRQ is enabled | 
|  | 729 | */ | 
|  | 730 | etherh_set_ctrl(eh, ETHERH_CP_IE); | 
|  | 731 | } | 
|  | 732 |  | 
|  | 733 | ei_local = netdev_priv(dev); | 
|  | 734 | spin_lock_init(&ei_local->page_lock); | 
|  | 735 |  | 
|  | 736 | if (ec->cid.product == PROD_ANT_ETHERM) { | 
|  | 737 | etherm_addr(dev->dev_addr); | 
|  | 738 | ei_local->reg_offset = etherm_regoffsets; | 
|  | 739 | } else { | 
|  | 740 | etherh_addr(dev->dev_addr, ec); | 
|  | 741 | ei_local->reg_offset = etherh_regoffsets; | 
|  | 742 | } | 
|  | 743 |  | 
|  | 744 | ei_local->name          = dev->name; | 
|  | 745 | ei_local->word16        = 1; | 
|  | 746 | ei_local->tx_start_page = data->tx_start_page; | 
|  | 747 | ei_local->rx_start_page = ei_local->tx_start_page + TX_PAGES; | 
|  | 748 | ei_local->stop_page     = data->stop_page; | 
|  | 749 | ei_local->reset_8390    = etherh_reset; | 
|  | 750 | ei_local->block_input   = etherh_block_input; | 
|  | 751 | ei_local->block_output  = etherh_block_output; | 
|  | 752 | ei_local->get_8390_hdr  = etherh_get_header; | 
|  | 753 | ei_local->interface_num = 0; | 
|  | 754 |  | 
|  | 755 | etherh_reset(dev); | 
| Al Viro | 6c3561b | 2006-10-10 00:19:36 +0100 | [diff] [blame] | 756 | __NS8390_init(dev, 0); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 757 |  | 
|  | 758 | ret = register_netdev(dev); | 
|  | 759 | if (ret) | 
|  | 760 | goto free; | 
|  | 761 |  | 
| Johannes Berg | e174961 | 2008-10-27 15:59:26 -0700 | [diff] [blame] | 762 | printk(KERN_INFO "%s: %s in slot %d, %pM\n", | 
|  | 763 | dev->name, data->name, ec->slot_no, dev->dev_addr); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 764 |  | 
|  | 765 | ecard_set_drvdata(ec, dev); | 
|  | 766 |  | 
|  | 767 | return 0; | 
|  | 768 |  | 
|  | 769 | free: | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 770 | free_netdev(dev); | 
|  | 771 | release: | 
|  | 772 | ecard_release_resources(ec); | 
|  | 773 | out: | 
|  | 774 | return ret; | 
|  | 775 | } | 
|  | 776 |  | 
|  | 777 | static void __devexit etherh_remove(struct expansion_card *ec) | 
|  | 778 | { | 
|  | 779 | struct net_device *dev = ecard_get_drvdata(ec); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 780 |  | 
|  | 781 | ecard_set_drvdata(ec, NULL); | 
|  | 782 |  | 
|  | 783 | unregister_netdev(dev); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 784 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 785 | free_netdev(dev); | 
|  | 786 |  | 
|  | 787 | ecard_release_resources(ec); | 
|  | 788 | } | 
|  | 789 |  | 
|  | 790 | static struct etherh_data etherm_data = { | 
|  | 791 | .ns8390_offset		= ETHERM_NS8390, | 
|  | 792 | .dataport_offset	= ETHERM_NS8390 + ETHERM_DATAPORT, | 
|  | 793 | .ctrlport_offset	= ETHERM_NS8390 + ETHERM_CTRLPORT, | 
|  | 794 | .name			= "ANT EtherM", | 
|  | 795 | .supported		= SUPPORTED_10baseT_Half, | 
|  | 796 | .tx_start_page		= ETHERM_TX_START_PAGE, | 
|  | 797 | .stop_page		= ETHERM_STOP_PAGE, | 
|  | 798 | }; | 
|  | 799 |  | 
|  | 800 | static struct etherh_data etherlan500_data = { | 
|  | 801 | .ns8390_offset		= ETHERH500_NS8390, | 
|  | 802 | .dataport_offset	= ETHERH500_NS8390 + ETHERH500_DATAPORT, | 
|  | 803 | .ctrlport_offset	= ETHERH500_CTRLPORT, | 
|  | 804 | .ctrl_ioc		= 1, | 
|  | 805 | .name			= "i3 EtherH 500", | 
|  | 806 | .supported		= SUPPORTED_10baseT_Half, | 
|  | 807 | .tx_start_page		= ETHERH_TX_START_PAGE, | 
|  | 808 | .stop_page		= ETHERH_STOP_PAGE, | 
|  | 809 | }; | 
|  | 810 |  | 
|  | 811 | static struct etherh_data etherlan600_data = { | 
|  | 812 | .ns8390_offset		= ETHERH600_NS8390, | 
|  | 813 | .dataport_offset	= ETHERH600_NS8390 + ETHERH600_DATAPORT, | 
|  | 814 | .ctrlport_offset	= ETHERH600_NS8390 + ETHERH600_CTRLPORT, | 
|  | 815 | .name			= "i3 EtherH 600", | 
|  | 816 | .supported		= SUPPORTED_10baseT_Half | SUPPORTED_TP | SUPPORTED_BNC | SUPPORTED_Autoneg, | 
|  | 817 | .tx_start_page		= ETHERH_TX_START_PAGE, | 
|  | 818 | .stop_page		= ETHERH_STOP_PAGE, | 
|  | 819 | }; | 
|  | 820 |  | 
|  | 821 | static struct etherh_data etherlan600a_data = { | 
|  | 822 | .ns8390_offset		= ETHERH600_NS8390, | 
|  | 823 | .dataport_offset	= ETHERH600_NS8390 + ETHERH600_DATAPORT, | 
|  | 824 | .ctrlport_offset	= ETHERH600_NS8390 + ETHERH600_CTRLPORT, | 
|  | 825 | .name			= "i3 EtherH 600A", | 
|  | 826 | .supported		= SUPPORTED_10baseT_Half | SUPPORTED_TP | SUPPORTED_BNC | SUPPORTED_Autoneg, | 
|  | 827 | .tx_start_page		= ETHERH_TX_START_PAGE, | 
|  | 828 | .stop_page		= ETHERH_STOP_PAGE, | 
|  | 829 | }; | 
|  | 830 |  | 
|  | 831 | static const struct ecard_id etherh_ids[] = { | 
|  | 832 | { MANU_ANT, PROD_ANT_ETHERM,      ðerm_data       }, | 
|  | 833 | { MANU_I3,  PROD_I3_ETHERLAN500,  ðerlan500_data  }, | 
|  | 834 | { MANU_I3,  PROD_I3_ETHERLAN600,  ðerlan600_data  }, | 
|  | 835 | { MANU_I3,  PROD_I3_ETHERLAN600A, ðerlan600a_data }, | 
|  | 836 | { 0xffff,   0xffff } | 
|  | 837 | }; | 
|  | 838 |  | 
|  | 839 | static struct ecard_driver etherh_driver = { | 
|  | 840 | .probe		= etherh_probe, | 
|  | 841 | .remove		= __devexit_p(etherh_remove), | 
|  | 842 | .id_table	= etherh_ids, | 
|  | 843 | .drv = { | 
|  | 844 | .name	= DRV_NAME, | 
|  | 845 | }, | 
|  | 846 | }; | 
|  | 847 |  | 
|  | 848 | static int __init etherh_init(void) | 
|  | 849 | { | 
|  | 850 | int i; | 
|  | 851 |  | 
|  | 852 | for (i = 0; i < 16; i++) { | 
|  | 853 | etherh_regoffsets[i] = i << 2; | 
|  | 854 | etherm_regoffsets[i] = i << 5; | 
|  | 855 | } | 
|  | 856 |  | 
|  | 857 | return ecard_register_driver(ðerh_driver); | 
|  | 858 | } | 
|  | 859 |  | 
|  | 860 | static void __exit etherh_exit(void) | 
|  | 861 | { | 
|  | 862 | ecard_remove_driver(ðerh_driver); | 
|  | 863 | } | 
|  | 864 |  | 
|  | 865 | module_init(etherh_init); | 
|  | 866 | module_exit(etherh_exit); |