29 #include <linux/module.h>
30 #include <linux/kernel.h>
31 #include <linux/types.h>
32 #include <linux/fcntl.h>
36 #include <linux/string.h>
37 #include <linux/errno.h>
38 #include <linux/netdevice.h>
40 #include <linux/ethtool.h>
43 #include <linux/device.h>
45 #include <linux/bitops.h>
52 #define EI_SHIFT(x) (ei_local->reg_offset[x])
54 #define ei_inb(_p) readb((void __iomem *)_p)
55 #define ei_outb(_v,_p) writeb(_v,(void __iomem *)_p)
56 #define ei_inb_p(_p) readb((void __iomem *)_p)
57 #define ei_outb_p(_v,_p) writeb(_v,(void __iomem *)_p)
62 #define DRV_NAME "etherh"
63 #define DRV_VERSION "1.11"
66 "EtherH/EtherM Driver (c) 2002-2004 Russell King " DRV_VERSION "\n";
97 #define ETHERH500_DATAPORT 0x800
98 #define ETHERH500_NS8390 0x000
99 #define ETHERH500_CTRLPORT 0x800
101 #define ETHERH600_DATAPORT 0x040
102 #define ETHERH600_NS8390 0x800
103 #define ETHERH600_CTRLPORT 0x200
105 #define ETHERH_CP_IE 1
106 #define ETHERH_CP_IF 2
107 #define ETHERH_CP_HEARTBEAT 2
109 #define ETHERH_TX_START_PAGE 1
110 #define ETHERH_STOP_PAGE 127
115 #define ETHERM_DATAPORT 0x200
116 #define ETHERM_NS8390 0x800
117 #define ETHERM_CTRLPORT 0x23c
119 #define ETHERM_TX_START_PAGE 64
120 #define ETHERM_STOP_PAGE 127
124 #define etherh_priv(dev) \
125 ((struct etherh_priv *)(((char *)netdev_priv(dev)) + sizeof(struct ei_device)))
127 static inline void etherh_set_ctrl(
struct etherh_priv *eh,
unsigned char mask)
134 static inline void etherh_clr_ctrl(
struct etherh_priv *eh,
unsigned char mask)
136 unsigned char ctrl = eh->
ctrl & ~mask;
141 static inline unsigned int etherh_get_stat(
struct etherh_priv *eh)
149 static void etherh_irq_enable(
ecard_t *ec,
int irqnr)
156 static void etherh_irq_disable(
ecard_t *ec,
int irqnr)
165 .irqdisable = etherh_irq_disable,
174 struct ei_device *ei_local = netdev_priv(dev);
218 struct ei_device *ei_local = netdev_priv(dev);
231 stat =
readb(addr) & 4;
287 struct ei_device *ei_local = netdev_priv(dev);
313 etherh_block_output (
struct net_device *dev,
int count,
const unsigned char *
buf,
int start_page)
315 struct ei_device *ei_local = netdev_priv(dev);
321 " DMAstat %d irqlock %d\n", dev->
name,
329 if (count & 1 && ei_local->
word16)
337 count = (count + 1) & ~1;
356 writesw (dma_base, buf, count >> 1);
358 writesb (dma_base, buf, count);
381 struct ei_device *ei_local = netdev_priv(dev);
387 " DMAstat %d irqlock %d\n", dev->
name,
406 readsw (dma_base, buf, count >> 1);
408 buf[count - 1] =
readb (dma_base);
410 readsb (dma_base, buf, count);
422 struct ei_device *ei_local = netdev_priv(dev);
427 " DMAstat %d irqlock %d\n", dev->
name,
445 readsw (dma_base, hdr,
sizeof (*hdr) >> 1);
447 readsb (dma_base, hdr,
sizeof (*hdr));
464 struct ei_device *ei_local = netdev_priv(dev);
466 if (!is_valid_ether_addr(dev->
dev_addr)) {
490 if (!etherh_getifstat(dev)) {
518 static void __init etherh_banner(
void)
520 static int version_printed;
545 for (i = 0; i < 6; i++) {
547 if (*s != (i == 5?
')' :
':'))
556 dev_name(&ec->
dev),
cd.d.string);
565 static int __init etherm_addr(
char *addr)
577 addr[3] = 0x10 + (serial >> 24);
578 addr[4] = serial >> 16;
579 addr[5] = serial >> 8;
594 ethtool_cmd_speed_set(cmd,
SPEED_10);
634 static const struct ethtool_ops etherh_ethtool_ops = {
635 .get_settings = etherh_get_settings,
636 .set_settings = etherh_set_settings,
637 .get_drvinfo = etherh_get_drvinfo,
642 .ndo_open = etherh_open,
643 .ndo_stop = etherh_close,
644 .ndo_set_config = etherh_set_config,
652 #ifdef CONFIG_NET_POLL_CONTROLLER
657 static u32 etherh_regoffsets[16];
658 static u32 etherm_regoffsets[16];
701 eh->
id = ec->
cid.product;
734 ei_local = netdev_priv(dev);
795 .name =
"ANT EtherM",
806 .name =
"i3 EtherH 500",
816 .name =
"i3 EtherH 600",
826 .name =
"i3 EtherH 600A",
832 static const struct ecard_id etherh_ids[] = {
841 .probe = etherh_probe,
843 .id_table = etherh_ids,
849 static int __init etherh_init(
void)
853 for (i = 0; i < 16; i++) {
854 etherh_regoffsets[
i] = i << 2;
855 etherm_regoffsets[
i] = i << 5;
861 static void __exit etherh_exit(
void)