28 #define DRV_NAME "ne2k-pci"
29 #define DRV_VERSION "1.03"
30 #define DRV_RELDATE "9/22/2003"
47 #include <linux/module.h>
48 #include <linux/kernel.h>
49 #include <linux/errno.h>
50 #include <linux/pci.h>
53 #include <linux/ethtool.h>
54 #include <linux/netdevice.h>
59 #include <asm/uaccess.h>
66 " D. Becker/P. Gortmaker\n";
68 #if defined(__powerpc__)
69 #define inl_le(addr) le32_to_cpu(inl(addr))
70 #define inw_le(addr) le16_to_cpu(inw(addr))
73 #define PFX DRV_NAME ": "
96 #define ne2k_flags reg0
124 {
"Winbond 89C940", 0},
125 {
"Compex RL2000", 0},
127 {
"NetVin NV5000SC", 0},
130 {
"Winbond W89C940F", 0},
133 {
"Winbond W89C940(misprogrammed)", 0},
157 #define NE_BASE (dev->base_addr)
159 #define NE_DATAPORT 0x10
160 #define NE_RESET 0x1f
161 #define NE_IO_EXTENT 0x20
163 #define NESM_START_PG 0x40
164 #define NESM_STOP_PG 0x80
176 const unsigned char *
buf,
const int start_page);
177 static const struct ethtool_ops ne2k_pci_ethtool_ops;
204 .ndo_open = ne2k_pci_open,
205 .ndo_stop = ne2k_pci_close,
213 #ifdef CONFIG_NET_POLL_CONTROLLER
214 .ndo_poll_controller = ei_poll,
223 unsigned char SA_prom[32];
224 int start_page, stop_page;
226 static unsigned int fnd_cnt;
228 int flags = pci_clone_list[chip_idx].flags;
232 static int printed_version;
233 if (!printed_version++)
247 dev_err(&pdev->
dev,
"no I/O resource at PCI BAR #0\n");
252 dev_err(&pdev->
dev,
"I/O resource 0x%x @ 0x%lx busy\n",
259 goto err_out_free_res;
265 regd =
inb(ioaddr + 0x0d);
266 outb(0xff, ioaddr + 0x0d);
271 outb(regd, ioaddr + 0x0d);
272 goto err_out_free_res;
277 dev = alloc_ei_netdev();
279 dev_err(&pdev->
dev,
"cannot allocate ethernet device\n");
280 goto err_out_free_res;
288 unsigned long reset_start_time =
jiffies;
297 if (jiffies - reset_start_time > 2) {
299 "Card failure (no reset ack).\n");
300 goto err_out_free_netdev;
311 struct {
unsigned char value,
offset; } program_seq[] = {
334 for (i = 0; i < 4 ; i++)
337 for(i = 0; i < 32 ; i++)
349 pci_set_drvdata(pdev, dev);
351 ei_status.name = pci_clone_list[chip_idx].name;
362 #ifdef PACKETBUF_MEMSIZE
367 ei_status.reset_8390 = &ne2k_pci_reset_8390;
368 ei_status.block_input = &ne2k_pci_block_input;
369 ei_status.block_output = &ne2k_pci_block_output;
370 ei_status.get_8390_hdr = &ne2k_pci_get_8390_hdr;
381 goto err_out_free_netdev;
383 printk(
"%s: %s found at %#lx, IRQ %d, %pM.\n",
384 dev->
name, pci_clone_list[chip_idx].name, ioaddr, dev->
irq,
393 pci_set_drvdata (pdev,
NULL);
401 static inline int set_realtek_fdx(
struct net_device *dev)
406 outb(0xC0, ioaddr + 0x01);
407 outb(0x40, ioaddr + 0x06);
408 outb(0x00, ioaddr + 0x01);
413 static inline int set_holtek_fdx(
struct net_device *dev)
417 outb(
inb(ioaddr + 0x20) | 0x80, ioaddr + 0x20);
421 static int ne2k_pci_set_fdx(
struct net_device *dev)
424 return set_realtek_fdx(dev);
426 return set_holtek_fdx(dev);
431 static int ne2k_pci_open(
struct net_device *dev)
438 ne2k_pci_set_fdx(dev);
444 static int ne2k_pci_close(
struct net_device *dev)
453 static void ne2k_pci_reset_8390(
struct net_device *dev)
455 unsigned long reset_start_time =
jiffies;
457 if (
debug > 1)
printk(
"%s: Resetting the 8390 t=%ld...",
467 if (jiffies - reset_start_time > 2) {
468 printk(
"%s: ne2k_pci_reset_8390() did not complete.\n", dev->
name);
485 printk(
"%s: DMAing conflict in ne2k_pci_get_8390_hdr "
486 "[DMAstat:%d][irqlock:%d].\n",
523 printk(
"%s: DMAing conflict in ne2k_pci_block_input "
524 "[DMAstat:%d][irqlock:%d].\n",
529 if (
ei_status.ne2k_flags & ONLY_32BIT_IO)
530 count = (count + 3) & 0xFFFC;
562 static void ne2k_pci_block_output(
struct net_device *dev,
int count,
563 const unsigned char *buf,
const int start_page)
570 if (
ei_status.ne2k_flags & ONLY_32BIT_IO)
571 count = (count + 3) & 0xFFFC;
578 printk(
"%s: DMAing conflict in ne2k_pci_block_output."
579 "[DMAstat:%d][irqlock:%d]\n",
587 #ifdef NE8390_RW_BUGFIX
624 if (jiffies - dma_start > 2) {
626 ne2k_pci_reset_8390(dev);
635 static void ne2k_pci_get_drvinfo(
struct net_device *dev,
646 static const struct ethtool_ops ne2k_pci_ethtool_ops = {
647 .get_drvinfo = ne2k_pci_get_drvinfo,
650 static void __devexit ne2k_pci_remove_one (
struct pci_dev *pdev)
652 struct net_device *dev = pci_get_drvdata(pdev);
659 pci_set_drvdata(pdev,
NULL);
665 struct net_device *dev = pci_get_drvdata (pdev);
675 static int ne2k_pci_resume (
struct pci_dev *pdev)
677 struct net_device *dev = pci_get_drvdata (pdev);
698 .probe = ne2k_pci_init_one,
700 .id_table = ne2k_pci_tbl,
702 .suspend = ne2k_pci_suspend,
703 .resume = ne2k_pci_resume,
709 static int __init ne2k_pci_init(
void)
715 return pci_register_driver(&ne2k_driver);
719 static void __exit ne2k_pci_cleanup(
void)