unsigned long tulip_probe1(unsigned long mem_start, int ioaddr, int irq) { static int did_version = 0; /* Already printed version info. */ struct device *dev; struct tulip_private *tp; int i; if (tulip_debug > 0 && did_version++ == 0) printk(version); dev = init_etherdev(0, sizeof(struct tulip_private) + PKT_BUF_SZ*RX_RING_SIZE, &mem_start); printk("%s: DEC 21040 Tulip at %#3x,", dev->name, ioaddr); /* Stop the chip's Tx and Rx processes. */ outl(inl(ioaddr + CSR6) & ~0x2002, ioaddr + CSR6); /* Clear the missed-packet counter. */ inl(ioaddr + CSR8) & 0xffff; /* The station address ROM is read byte serially. The register must be polled, waiting for the value to be read bit serially from the EEPROM. */ outl(0, ioaddr + CSR9); /* Reset the pointer with a dummy write. */ for (i = 0; i < 6; i++) { int value, boguscnt = 100000; do value = inl(ioaddr + CSR9); while (value < 0 && --boguscnt > 0); printk(" %2.2x", dev->dev_addr[i] = value); } printk(", IRQ %d\n", irq); /* We do a request_region() only to register /proc/ioports info. */ request_region(ioaddr, TULIP_TOTAL_SIZE, "DEC Tulip Ethernet"); dev->base_addr = ioaddr; dev->irq = irq; /* Make certain the data structures are quadword aligned. */ dev->priv = (void *)(((int)dev->priv + 7) & ~7); tp = (struct tulip_private *)dev->priv; tp->rx_buffs = (long)dev->priv + sizeof(struct tulip_private); /* The Tulip-specific entries in the device structure. */ dev->open = &tulip_open; dev->hard_start_xmit = &tulip_start_xmit; dev->stop = &tulip_close; dev->get_stats = &tulip_get_stats; #ifdef HAVE_MULTICAST dev->set_multicast_list = &set_multicast_list; #endif #ifdef HAVE_SET_MAC_ADDR dev->set_mac_address = &set_mac_address; #endif return mem_start; }
static void *rtl8150_probe(struct usb_device *udev, unsigned int ifnum, const struct usb_device_id *id) { rtl8150_t *dev; struct net_device *netdev; udev->config[0].bConfigurationValue = 1; if (usb_set_configuration(udev, udev->config[0].bConfigurationValue)) { err("usb_set_configuration() failed"); return NULL; } dev = kmalloc(sizeof(rtl8150_t), GFP_KERNEL); if (!dev) { err("Out of memory"); goto exit; } else memset(dev, 0, sizeof(rtl8150_t)); netdev = init_etherdev(NULL, 0); if (!netdev) { kfree(dev); err("Oh boy, out of memory again?!?"); dev = NULL; goto exit; } init_MUTEX(&dev->sem); dev->udev = udev; dev->netdev = netdev; SET_MODULE_OWNER(netdev); netdev->priv = dev; netdev->open = rtl8150_open; netdev->stop = rtl8150_close; netdev->do_ioctl = rtl8150_ioctl; netdev->watchdog_timeo = RTL8150_TX_TIMEOUT; netdev->tx_timeout = rtl8150_tx_timeout; netdev->hard_start_xmit = rtl8150_start_xmit; netdev->set_multicast_list = rtl8150_set_multicast; netdev->set_mac_address = rtl8150_set_mac_address; netdev->get_stats = rtl8150_netdev_stats; netdev->mtu = RTL8150_MTU; dev->intr_interval = 100; /* 100ms */ if (rtl8150_reset(dev) || !alloc_all_urbs(dev)) { err("couldn't reset the device"); free_all_urbs(dev); unregister_netdev(dev->netdev); kfree(netdev); kfree(dev); dev = NULL; goto exit; } set_ethernet_addr(dev); /* let's not be very nasty :-) */ info("%s: rtl8150 is detected", netdev->name); exit: return dev; }
/* * This is the real probe routine. */ static int isl3893_probe1(struct net_device *dev, int ioaddr) { static unsigned version_printed = 0; u_char ether_address[] = "\x00\x10\x91\x00\xed\xcb"; int i; /* Allocate a new 'dev' if needed. */ if (dev == NULL) { /* * Don't allocate the private data here, it is done later * This makes it easier to free the memory when this driver * is used as a module. */ dev = init_etherdev(0, 0); if (dev == NULL) return -ENOMEM; } if (net_debug && version_printed++ == 0) printk(KERN_DEBUG "%s", version); printk(KERN_INFO "%s: %s found, ", dev->name, cardname ); /* Fill in the 'dev' fields. */ if (dev->base_addr == 0) dev->base_addr = ioaddr; /* Retrieve and print the ethernet address. */ for (i = 0; i < 6; i++) printk(" %2.2x", dev->dev_addr[i] = ether_address[i] ); /* Initialize the device structure. */ if (dev->priv == NULL) { dev->priv = kmalloc(sizeof(struct net_local), GFP_KERNEL); if (dev->priv == NULL) return -ENOMEM; } memset(dev->priv, 0, sizeof(struct net_local)); dev->open = net_open; dev->stop = net_close; dev->get_stats = net_get_stats; dev->hard_start_xmit = net_send_packet; ether_setup(dev); SET_MODULE_OWNER(dev); return 0; }
static int awc_i365_init(struct i365_socket * s) { struct net_device * dev; int i; dev = init_etherdev(0, sizeof(struct awc_private) ); // dev->tx_queue_len = tx_queue_len; ether_setup(dev); dev->hard_start_xmit = &awc_start_xmit; // dev->set_config = &awc_config_misiganes,aga mitte awc_config; dev->get_stats = &awc_get_stats; dev->set_multicast_list = &awc_set_multicast_list; dev->init = &awc_init; dev->open = &awc_open; dev->stop = &awc_close; dev->irq = s->irq; dev->base_addr = s->io; dev->tx_timeout = &awc_tx_timeout; dev->watchdog_timeo = AWC_TX_TIMEOUT; awc_private_init( dev); i=0; while (aironet4500_devices[i] && i < MAX_AWCS-1) i++; if (!aironet4500_devices[i]) { aironet4500_devices[i]=dev; ((struct awc_private *) aironet4500_devices[i]->priv)->card_type = AIRONET4500_365; if (awc_proc_set_fun) awc_proc_set_fun(i); } if (register_netdev(dev) != 0) { printk(KERN_NOTICE "awc_cs: register_netdev() failed\n"); goto failed; } return 0; failed: return -1; }
struct net_device * __init dmfe_probe(void) { struct net_device *dev; int err; DMFE_DBUG(0, "dmfe_probe()",0); #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) dev = init_etherdev(NULL, sizeof(struct board_info)); //ether_setup(dev); #else dev= alloc_etherdev(sizeof(struct board_info)); #endif if(!dev) return ERR_PTR(-ENOMEM); SET_MODULE_OWNER(dev); err = dmfe_probe1(dev); if (err) goto out; #if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0) err = register_netdev(dev); if (err) goto out1; #endif return dev; out1: release_region(dev->base_addr,2); out: #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) kfree(dev); #else free_netdev(dev); #endif return ERR_PTR(err); }
static struct device *via_probe1(int pci_bus, int pci_devfn, struct device *dev, long ioaddr, int irq, int chip_id, int card_idx) { struct netdev_private *np; int i, option = card_idx < MAX_UNITS ? options[card_idx] : 0; dev = init_etherdev(dev, 0); printk(KERN_INFO "%s: %s at 0x%lx, ", dev->name, pci_tbl[chip_id].name, ioaddr); /* Ideally we would be read the EEPROM but access may be locked. */ for (i = 0; i <6; i++) dev->dev_addr[i] = readb(ioaddr + StationAddr + i); for (i = 0; i < 5; i++) printk("%2.2x:", dev->dev_addr[i]); printk("%2.2x, IRQ %d.\n", dev->dev_addr[i], irq); #ifdef VIA_USE_IO request_region(ioaddr, pci_tbl[chip_id].io_size, dev->name); #endif /* Reset the chip to erase previous misconfiguration. */ writew(CmdReset, ioaddr + ChipCmd); dev->base_addr = ioaddr; dev->irq = irq; /* Make certain the descriptor lists are cache-aligned. */ np = (void *)(((long)kmalloc(sizeof(*np), GFP_KERNEL) + 31) & ~31); memset(np, 0, sizeof(*np)); dev->priv = np; np->next_module = root_net_dev; root_net_dev = dev; np->pci_bus = pci_bus; np->pci_devfn = pci_devfn; np->chip_id = chip_id; if (dev->mem_start) option = dev->mem_start; /* The lower four bits are the media type. */ if (option > 0) { if (option & 0x200) np->full_duplex = 1; np->default_port = option & 15; if (np->default_port) np->medialock = 1; } if (card_idx < MAX_UNITS && full_duplex[card_idx] > 0) np->full_duplex = 1; if (np->full_duplex) np->duplex_lock = 1; /* The chip-specific entries in the device structure. */ dev->open = &netdev_open; dev->hard_start_xmit = &start_tx; dev->stop = &netdev_close; dev->get_stats = &get_stats; dev->set_multicast_list = &set_rx_mode; dev->do_ioctl = &mii_ioctl; if (cap_tbl[np->chip_id].flags & CanHaveMII) { int phy, phy_idx = 0; np->phys[0] = 1; /* Standard for this chip. */ for (phy = 1; phy < 32 && phy_idx < 4; phy++) { int mii_status = mdio_read(dev, phy, 1); if (mii_status != 0xffff && mii_status != 0x0000) { np->phys[phy_idx++] = phy; np->advertising = mdio_read(dev, phy, 4); printk(KERN_INFO "%s: MII PHY found at address %d, status " "0x%4.4x advertising %4.4x Link %4.4x.\n", dev->name, phy, mii_status, np->advertising, mdio_read(dev, phy, 5)); } } np->mii_cnt = phy_idx; } return dev; }
__initfunc(int ne3210_probe1(struct device *dev, int ioaddr)) { int i; unsigned long eisa_id; const char *ifmap[] = {"UTP", "?", "BNC", "AUI"}; if (inb_p(ioaddr + NE3210_ID_PORT) == 0xff) return -ENODEV; #if NE3210_DEBUG & NE3210_D_PROBE printk("ne3210-debug: probe at %#x, ID %#8x\n", ioaddr, inl(ioaddr + NE3210_ID_PORT)); printk("ne3210-debug: config regs: %#x %#x\n", inb(ioaddr + NE3210_CFG1), inb(ioaddr + NE3210_CFG2)); #endif /* Check the EISA ID of the card. */ eisa_id = inl(ioaddr + NE3210_ID_PORT); if (eisa_id != NE3210_ID) { return ENODEV; } #if 0 /* Check the vendor ID as well. Not really required. */ if (inb(ioaddr + NE3210_SA_PROM + 0) != NE3210_ADDR0 || inb(ioaddr + NE3210_SA_PROM + 1) != NE3210_ADDR1 || inb(ioaddr + NE3210_SA_PROM + 2) != NE3210_ADDR2 ) { printk("ne3210.c: card not found"); for(i = 0; i < ETHER_ADDR_LEN; i++) printk(" %02x", inb(ioaddr + NE3210_SA_PROM + i)); printk(" (invalid prefix).\n"); return ENODEV; } #endif if (load_8390_module("ne3210.c")) return -ENOSYS; /* We should have a "dev" from Space.c or the static module table. */ if (dev == NULL) { printk("ne3210.c: Passed a NULL device.\n"); dev = init_etherdev(0, 0); } /* Allocate dev->priv and fill in 8390 specific dev fields. */ if (ethdev_init(dev)) { printk ("ne3210.c: unable to allocate memory for dev->priv!\n"); return -ENOMEM; } printk("ne3210.c: NE3210 in EISA slot %d, media: %s, addr:", ioaddr/0x1000, ifmap[inb(ioaddr + NE3210_CFG2) >> 6]); for(i = 0; i < ETHER_ADDR_LEN; i++) printk(" %02x", (dev->dev_addr[i] = inb(ioaddr + NE3210_SA_PROM + i))); printk(".\nne3210.c: "); /* Snarf the interrupt now. CFG file has them all listed as `edge' with share=NO */ if (dev->irq == 0) { unsigned char irq_reg = inb(ioaddr + NE3210_CFG2) >> 3; dev->irq = irq_map[irq_reg & 0x07]; printk("using"); } else {
int mace68k_probe(struct net_device *unused) { int j; static int once=0; struct mace68k_data *mp; unsigned char *addr; struct net_device *dev; unsigned char checksum = 0; /* * There can be only one... */ if (once) return -ENODEV; once = 1; if (macintosh_config->ether_type != MAC_ETHER_MACE) return -ENODEV; printk("MACE ethernet should be present "); dev = init_etherdev(0, PRIV_BYTES); if(dev==NULL) { printk("no free memory.\n"); return -ENOMEM; } mp = (struct mace68k_data *) dev->priv; dev->base_addr = (u32)MACE_BASE; mp->mace = (volatile struct mace *) MACE_BASE; printk("at 0x%p", mp->mace); /* * 16K RX ring and 4K TX ring should do nicely */ mp->rx_ring=(void *)__get_free_pages(GFP_KERNEL, 2); mp->tx_ring=(void *)__get_free_page(GFP_KERNEL); printk("."); if(mp->tx_ring==NULL || mp->rx_ring==NULL) { if(mp->tx_ring) free_page((u32)mp->tx_ring); // if(mp->rx_ring) // __free_pages(mp->rx_ring,2); printk("\nNo memory for ring buffers.\n"); return -ENOMEM; } /* We want the receive data to be uncached. We dont care about the byte reading order */ printk("."); kernel_set_cachemode((void *)mp->rx_ring, 16384, IOMAP_NOCACHE_NONSER); printk("."); /* The transmit buffer needs to be write through */ kernel_set_cachemode((void *)mp->tx_ring, 4096, IOMAP_WRITETHROUGH); printk(" Ok\n"); dev->irq = IRQ_MAC_MACE; printk(KERN_INFO "%s: MACE at", dev->name); /* * The PROM contains 8 bytes which total 0xFF when XOR'd * together. Due to the usual peculiar apple brain damage * the bytes are spaced out in a strange boundary and the * bits are reversed. */ addr = (void *)MACE_PROM; for (j = 0; j < 6; ++j) { u8 v=bitrev(addr[j<<4]); checksum^=v; dev->dev_addr[j] = v; printk("%c%.2x", (j ? ':' : ' '), dev->dev_addr[j]); } for (; j < 8; ++j) { checksum^=bitrev(addr[j<<4]); } if(checksum!=0xFF) { printk(" (invalid checksum)\n"); return -ENODEV; } printk("\n"); memset(&mp->stats, 0, sizeof(mp->stats)); init_timer(&mp->tx_timeout); mp->timeout_active = 0; dev->open = mace68k_open; dev->stop = mace68k_close; dev->hard_start_xmit = mace68k_xmit_start; dev->get_stats = mace68k_stats; dev->set_multicast_list = mace68k_set_multicast; dev->set_mac_address = mace68k_set_address; ether_setup(dev); mp = (struct mace68k_data *) dev->priv; mp->maccc = ENXMT | ENRCV; mp->dma_intr = IRQ_MAC_MACE_DMA; psc_write_word(PSC_ENETWR_CTL, 0x9000); psc_write_word(PSC_ENETRD_CTL, 0x9000); psc_write_word(PSC_ENETWR_CTL, 0x0400); psc_write_word(PSC_ENETRD_CTL, 0x0400); /* apple's driver doesn't seem to do this */ /* except at driver shutdown time... */ #if 0 mace68k_dma_off(dev); #endif return 0; }
static int __init myri_ether_init(struct net_device *dev, struct sbus_dev *sdev, int num) { static unsigned version_printed = 0; struct myri_eth *mp; unsigned char prop_buf[32]; int i; DET(("myri_ether_init(%p,%p,%d):\n", dev, sdev, num)); dev = init_etherdev(0, sizeof(struct myri_eth)); if (version_printed++ == 0) printk(version); printk("%s: MyriCOM MyriNET Ethernet ", dev->name); mp = (struct myri_eth *) dev->priv; mp->myri_sdev = sdev; /* Clean out skb arrays. */ for (i = 0; i < (RX_RING_SIZE + 1); i++) mp->rx_skbs[i] = NULL; for (i = 0; i < TX_RING_SIZE; i++) mp->tx_skbs[i] = NULL; /* First check for EEPROM information. */ i = prom_getproperty(sdev->prom_node, "myrinet-eeprom-info", (char *)&mp->eeprom, sizeof(struct myri_eeprom)); DET(("prom_getprop(myrinet-eeprom-info) returns %d\n", i)); if (i == 0 || i == -1) { /* No eeprom property, must cook up the values ourselves. */ DET(("No EEPROM: ")); mp->eeprom.bus_type = BUS_TYPE_SBUS; mp->eeprom.cpuvers = prom_getintdefault(sdev->prom_node,"cpu_version",0); mp->eeprom.cval = prom_getintdefault(sdev->prom_node,"clock_value",0); mp->eeprom.ramsz = prom_getintdefault(sdev->prom_node,"sram_size",0); DET(("cpuvers[%d] cval[%d] ramsz[%d]\n", mp->eeprom.cpuvers, mp->eeprom.cval, mp->eeprom.ramsz)); if (mp->eeprom.cpuvers == 0) { DET(("EEPROM: cpuvers was zero, setting to %04x\n",CPUVERS_2_3)); mp->eeprom.cpuvers = CPUVERS_2_3; } if (mp->eeprom.cpuvers < CPUVERS_3_0) { DET(("EEPROM: cpuvers < CPUVERS_3_0, clockval set to zero.\n")); mp->eeprom.cval = 0; } if (mp->eeprom.ramsz == 0) { DET(("EEPROM: ramsz == 0, setting to 128k\n")); mp->eeprom.ramsz = (128 * 1024); } i = prom_getproperty(sdev->prom_node, "myrinet-board-id", &prop_buf[0], 10); DET(("EEPROM: prom_getprop(myrinet-board-id) returns %d\n", i)); if ((i != 0) && (i != -1)) memcpy(&mp->eeprom.id[0], &prop_buf[0], 6); else set_boardid_from_idprom(mp, num); i = prom_getproperty(sdev->prom_node, "fpga_version", &mp->eeprom.fvers[0], 32); DET(("EEPROM: prom_getprop(fpga_version) returns %d\n", i)); if (i == 0 || i == -1) memset(&mp->eeprom.fvers[0], 0, 32); if (mp->eeprom.cpuvers == CPUVERS_4_1) { DET(("EEPROM: cpuvers CPUVERS_4_1, ")); if (mp->eeprom.ramsz == (128 * 1024)) { DET(("ramsize 128k, setting to 256k, ")); mp->eeprom.ramsz = (256 * 1024); } if ((mp->eeprom.cval==0x40414041)||(mp->eeprom.cval==0x90449044)){ DET(("changing cval from %08x to %08x ", mp->eeprom.cval, 0x50e450e4)); mp->eeprom.cval = 0x50e450e4; } DET(("\n")); } } #ifdef DEBUG_DETECT dump_eeprom(mp); #endif for (i = 0; i < 6; i++) printk("%2.2x%c", dev->dev_addr[i] = mp->eeprom.id[i], i == 5 ? ' ' : ':'); printk("\n"); determine_reg_space_size(mp); /* Map in the MyriCOM register/localram set. */ if (mp->eeprom.cpuvers < CPUVERS_4_0) { /* XXX Makes no sense, if control reg is non-existant this * XXX driver cannot function at all... maybe pre-4.0 is * XXX only a valid version for PCI cards? Ask feldy... */ DET(("Mapping regs for cpuvers < CPUVERS_4_0\n")); mp->regs = sbus_ioremap(&sdev->resource[0], 0, mp->reg_size, "MyriCOM Regs"); if (!mp->regs) { printk("MyriCOM: Cannot map MyriCOM registers.\n"); return -ENODEV; } mp->lanai = (unsigned short *) (mp->regs + (256 * 1024)); mp->lanai3 = (unsigned int *) mp->lanai; mp->lregs = (unsigned long) &mp->lanai[0x10000]; } else { DET(("Mapping regs for cpuvers >= CPUVERS_4_0\n")); mp->cregs = sbus_ioremap(&sdev->resource[0], 0, PAGE_SIZE, "MyriCOM Control Regs"); mp->lregs = sbus_ioremap(&sdev->resource[0], (256 * 1024), PAGE_SIZE, "MyriCOM LANAI Regs"); mp->lanai = (unsigned short *) sbus_ioremap(&sdev->resource[0], (512 * 1024), mp->eeprom.ramsz, "MyriCOM SRAM"); mp->lanai3 = (unsigned int *) mp->lanai; } DET(("Registers mapped: cregs[%lx] lregs[%lx] lanai[%p] lanai3[%p]\n", mp->cregs, mp->lregs, mp->lanai, mp->lanai3)); if (mp->eeprom.cpuvers >= CPUVERS_4_0) mp->shmem_base = 0xf000; else mp->shmem_base = 0x8000; DET(("Shared memory base is %04x, ", mp->shmem_base)); mp->shmem = (struct myri_shmem *) &mp->lanai[mp->shmem_base]; DET(("shmem mapped at %p\n", mp->shmem)); mp->rqack = &mp->shmem->channel.recvqa; mp->rq = &mp->shmem->channel.recvq; mp->sq = &mp->shmem->channel.sendq; /* Reset the board. */ DET(("Resetting LANAI\n")); myri_reset_off(mp->lregs, mp->cregs); myri_reset_on(mp->cregs); /* Turn IRQ's off. */ myri_disable_irq(mp->lregs, mp->cregs); /* Reset once more. */ myri_reset_on(mp->cregs); /* Get the supported DVMA burst sizes from our SBUS. */ mp->myri_bursts = prom_getintdefault(mp->myri_sdev->bus->prom_node, "burst-sizes", 0x00); if (!sbus_can_burst64(sdev)) mp->myri_bursts &= ~(DMA_BURST64); DET(("MYRI bursts %02x\n", mp->myri_bursts)); /* Encode SBUS interrupt level in second control register. */ i = prom_getint(sdev->prom_node, "interrupts"); if (i == 0) i = 4; DET(("prom_getint(interrupts)==%d, irqlvl set to %04x\n", i, (1 << i))); sbus_writel((1 << i), mp->cregs + MYRICTRL_IRQLVL); mp->dev = dev; dev->open = &myri_open; dev->stop = &myri_close; dev->hard_start_xmit = &myri_start_xmit; dev->tx_timeout = &myri_tx_timeout; dev->watchdog_timeo = 5*HZ; dev->get_stats = &myri_get_stats; dev->set_multicast_list = &myri_set_multicast; dev->irq = sdev->irqs[0]; /* Register interrupt handler now. */ DET(("Requesting MYRIcom IRQ line.\n")); if (request_irq(dev->irq, &myri_interrupt, SA_SHIRQ, "MyriCOM Ethernet", (void *) dev)) { printk("MyriCOM: Cannot register interrupt handler.\n"); return -ENODEV; } DET(("ether_setup()\n")); ether_setup(dev); dev->mtu = MYRINET_MTU; dev->change_mtu = myri_change_mtu; dev->hard_header = myri_header; dev->rebuild_header = myri_rebuild_header; dev->hard_header_len = (ETH_HLEN + MYRI_PAD_LEN); dev->hard_header_cache = myri_header_cache; dev->header_cache_update= myri_header_cache_update; /* Load code onto the LANai. */ DET(("Loading LANAI firmware\n")); myri_load_lanai(mp); #ifdef MODULE dev->ifindex = dev_new_index(); mp->next_module = root_myri_dev; root_myri_dev = mp; #endif return 0; }
/* Search DM910X board ,allocate space and register it */ int dmfe_probe(struct device *dev) { unsigned long pci_iobase; u16 dm9102_count = 0; u8 pci_irqline; static int index = 0; /* For multiple call */ struct dmfe_board_info *db; /* Point a board information structure */ int i; struct pci_dev *net_dev = NULL; DMFE_DBUG(0, "dmfe_probe()", 0); if (!pci_present()) return -ENODEV; index = 0; while ((net_dev = pci_find_class(PCI_CLASS_NETWORK_ETHERNET << 8, net_dev))) { u32 pci_id; u32 dev_rev; u8 pci_cmd; index++; if (pci_read_config_dword(net_dev, PCI_VENDOR_ID, &pci_id) != DMFE_SUCC) continue; if ((pci_id != PCI_DM9102_ID) && (pci_id != PCI_DM9132_ID)) continue; /* read PCI IO base address and IRQ to check */ pci_iobase = net_dev->base_address[0]; pci_irqline = net_dev->irq; pci_iobase &= ~0x7f; /* mask off bit0~6 */ /* Enable Master/IO access, Disable memory access */ pci_read_config_byte(net_dev, PCI_COMMAND, &pci_cmd); pci_cmd |= PCI_COMMAND_IO + PCI_COMMAND_MASTER; pci_cmd &= ~PCI_COMMAND_MEMORY; pci_write_config_byte(net_dev, PCI_COMMAND, pci_cmd); /* Set Latency Timer 80h */ pci_write_config_byte(net_dev, PCI_LATENCY_TIMER, 0x80); /* Read Chip revesion */ pci_read_config_dword(net_dev, PCI_REVISION_ID, &dev_rev); /* IO range check */ if (check_region(pci_iobase, CHK_IO_SIZE(pci_id, dev_rev))) continue; /* Interrupt check */ if (pci_irqline == 0) { printk(KERN_ERR "dmfe: Interrupt wrong : IRQ=%d\n", pci_irqline); continue; } /* Found DM9102 card and PCI resource allocated OK */ dm9102_count++; /* Found a DM9102 card */ /* Init network device */ dev = init_etherdev(dev, 0); /* Allocated board information structure */ db = (void *) (kmalloc(sizeof(*db), GFP_KERNEL | GFP_DMA)); memset(db, 0, sizeof(*db)); dev->priv = db; /* link device and board info */ db->next_dev = dmfe_root_dev; dmfe_root_dev = dev; db->chip_id = pci_id; /* keep Chip vandor/Device ID */ db->ioaddr = pci_iobase; db->chip_revesion = dev_rev; db->net_dev = net_dev; dev->base_addr = pci_iobase; dev->irq = pci_irqline; dev->open = &dmfe_open; dev->hard_start_xmit = &dmfe_start_xmit; dev->stop = &dmfe_stop; dev->get_stats = &dmfe_get_stats; dev->set_multicast_list = &dmfe_set_filter_mode; dev->do_ioctl = &dmfe_do_ioctl; request_region(pci_iobase, CHK_IO_SIZE(pci_id, dev_rev), dev->name); /* read 64 word srom data */ for (i = 0; i < 64; i++) ((u16 *) db->srom)[i] = read_srom_word(pci_iobase, i); /* Set Node address */ for (i = 0; i < 6; i++) dev->dev_addr[i] = db->srom[20 + i]; dev = 0; /* NULL device */ } return dm9102_count ? 0 : -ENODEV; }
static struct device * sis900_mac_probe (struct mac_chip_info * mac, struct pci_dev * pci_dev, struct device * net_dev) { struct sis900_private *sis_priv; long ioaddr = pci_dev->base_address[0] & ~3; int irq = pci_dev->irq; static int did_version = 0; u16 signature; int i; if (did_version++ == 0) printk(KERN_INFO "%s", version); if ((net_dev = init_etherdev(net_dev, 0)) == NULL) return NULL; /* check to see if we have sane EEPROM */ signature = (u16) read_eeprom(ioaddr, EEPROMSignature); if (signature == 0xffff || signature == 0x0000) { printk (KERN_INFO "%s: Error EEPROM read: %x\n", net_dev->name, signature); unregister_netdevice(net_dev); return NULL; } printk(KERN_INFO "%s: %s at %#lx, IRQ %d, ", net_dev->name, mac->name, ioaddr, irq); /* get MAC address from EEPROM */ for (i = 0; i < 3; i++) ((u16 *)(net_dev->dev_addr))[i] = read_eeprom(ioaddr, i+EEPROMMACAddr); for (i = 0; i < 5; i++) printk("%2.2x:", (u8)net_dev->dev_addr[i]); printk("%2.2x.\n", net_dev->dev_addr[i]); if ((net_dev->priv = kmalloc(sizeof(struct sis900_private), GFP_KERNEL)) == NULL) { unregister_netdevice(net_dev); return NULL; } sis_priv = net_dev->priv; memset(sis_priv, 0, sizeof(struct sis900_private)); /* We do a request_region() to register /proc/ioports info. */ request_region(ioaddr, mac->io_size, net_dev->name); net_dev->base_addr = ioaddr; net_dev->irq = irq; sis_priv->pci_dev = pci_dev; sis_priv->mac = mac; /* probe for mii transciver */ if (sis900_mii_probe(net_dev) == 0) { unregister_netdev(net_dev); kfree(sis_priv); release_region(ioaddr, mac->io_size); return NULL; } sis_priv->next_module = root_sis900_dev; root_sis900_dev = net_dev; /* The SiS900-specific entries in the device structure. */ net_dev->open = &sis900_open; net_dev->hard_start_xmit = &sis900_start_xmit; net_dev->stop = &sis900_close; net_dev->get_stats = &sis900_get_stats; net_dev->set_multicast_list = &set_rx_mode; net_dev->do_ioctl = &mii_ioctl; return net_dev; }
int __init mac8390_probe(struct net_device *dev) { static int slots; volatile unsigned short *i; volatile unsigned char *p; int plen; int id; static struct nubus_dev* ndev; /* Find the first card that hasn't already been seen */ while ((ndev = nubus_find_type(NUBUS_CAT_NETWORK, NUBUS_TYPE_ETHERNET, ndev)) != NULL) { /* Have we seen it already? */ if (slots & (1<<ndev->board->slot)) continue; slots |= 1<<ndev->board->slot; /* Is it one of ours? */ if ((id = ns8390_ident(ndev)) != -1) break; } /* Hm. No more cards, then */ if (ndev == NULL) return -ENODEV; dev = init_etherdev(dev, 0); if (!dev) return -ENOMEM; SET_MODULE_OWNER(dev); if (!version_printed) { printk(KERN_INFO "%s", version); version_printed = 1; } /* * Dayna specific init */ if(id==NS8390_DAYNA) { dev->base_addr = (int)(ndev->board->slot_addr+DAYNA_8390_BASE); dev->mem_start = (int)(ndev->board->slot_addr+DAYNA_8390_MEM); dev->mem_end = dev->mem_start+DAYNA_MEMSIZE; /* 8K it seems */ printk(KERN_INFO "%s: daynaport. testing board: ", dev->name); printk("memory - "); i = (void *)dev->mem_start; memset((void *)i,0xAA, DAYNA_MEMSIZE); while(i<(volatile unsigned short *)dev->mem_end) { if(*i!=0xAAAA) goto membad; *i=0x5678; /* make sure we catch byte smearing */ if(*i!=0x5678) goto membad; i+=2; /* Skip a word */ } printk("controller - "); p=(void *)dev->base_addr; plen=0; while(plen<0x3FF00) { if(test_8390(p,0)==0) break; if(test_8390(p,1)==0) break; if(test_8390(p,2)==0) break; if(test_8390(p,3)==0) break; plen++; p++; } if(plen==0x3FF00) goto membad; printk("OK\n"); dev->irq = SLOT2IRQ(ndev->board->slot); if(ns8390_probe1(dev, 0, "dayna", id, -1, ndev)==0) return 0; } /* Cabletron */ if (id==NS8390_CABLETRON) { int memsize = 16<<10; /* fix this */ dev->base_addr=(int)(ndev->board->slot_addr+CABLETRON_8390_BASE); dev->mem_start=(int)(ndev->board->slot_addr+CABLETRON_8390_MEM); dev->mem_end=dev->mem_start+memsize; dev->irq = SLOT2IRQ(ndev->board->slot); /* The base address is unreadable if 0x00 has been written to the command register */ /* Reset the chip by writing E8390_NODMA+E8390_PAGE0+E8390_STOP just to be sure */ i = (void *)dev->base_addr; *i = 0x21; printk(KERN_INFO "%s: cabletron: testing board: ", dev->name); printk("%dK memory - ", memsize>>10); i=(void *)dev->mem_start; while(i<(volatile unsigned short *)(dev->mem_start+memsize)) { *i=0xAAAA; if(*i!=0xAAAA) goto membad; *i=0x5555; if(*i!=0x5555) goto membad; i+=2; /* Skip a word */ } printk("OK\n"); if(ns8390_probe1(dev, 1, "cabletron", id, -1, ndev)==0) return 0; }
static int __init ariadne_probe(void) { struct zorro_dev *z = NULL; struct net_device *dev; struct ariadne_private *priv; int res = -ENODEV; while ((z = zorro_find_device(ZORRO_PROD_VILLAGE_TRONIC_ARIADNE, z))) { unsigned long board = z->resource.start; unsigned long base_addr = board+ARIADNE_LANCE; unsigned long mem_start = board+ARIADNE_RAM; struct resource *r1, *r2; r1 = request_mem_region(base_addr, sizeof(struct Am79C960), "Am79C960"); if (!r1) continue; r2 = request_mem_region(mem_start, ARIADNE_RAM_SIZE, "RAM"); if (!r2) { release_resource(r1); continue; } dev = init_etherdev(NULL, sizeof(struct ariadne_private)); if (dev == NULL) { release_resource(r1); release_resource(r2); return -ENOMEM; } SET_MODULE_OWNER(dev); priv = dev->priv; r1->name = dev->name; r2->name = dev->name; priv->dev = dev; dev->dev_addr[0] = 0x00; dev->dev_addr[1] = 0x60; dev->dev_addr[2] = 0x30; dev->dev_addr[3] = (z->rom.er_SerialNumber>>16) & 0xff; dev->dev_addr[4] = (z->rom.er_SerialNumber>>8) & 0xff; dev->dev_addr[5] = z->rom.er_SerialNumber & 0xff; printk("%s: Ariadne at 0x%08lx, Ethernet Address " "%02x:%02x:%02x:%02x:%02x:%02x\n", dev->name, board, dev->dev_addr[0], dev->dev_addr[1], dev->dev_addr[2], dev->dev_addr[3], dev->dev_addr[4], dev->dev_addr[5]); dev->base_addr = ZTWO_VADDR(base_addr); dev->mem_start = ZTWO_VADDR(mem_start); dev->mem_end = dev->mem_start+ARIADNE_RAM_SIZE; dev->open = &ariadne_open; dev->stop = &ariadne_close; dev->hard_start_xmit = &ariadne_start_xmit; dev->tx_timeout = &ariadne_tx_timeout; dev->watchdog_timeo = 5*HZ; dev->get_stats = &ariadne_get_stats; dev->set_multicast_list = &set_multicast_list; #ifdef MODULE priv->next_module = root_ariadne_dev; root_ariadne_dev = priv; #endif res = 0; } return res; }
int awc4500_isa_probe(struct net_device *dev) { // int cards_found = 0; // static int isa_index; /* Static, for multiple probe calls. */ int isa_irq_line = 0; int isa_ioaddr = 0; // int p; int card = 0; int i=0; if (! io[0] || ! irq[0]) { // printk(" Both irq and io params must be supplied for ISA mode !!!\n"); return -ENODEV; } printk(KERN_WARNING " Aironet ISA Card in non-PNP(ISA) mode sometimes feels bad on interrupt \n"); printk(KERN_WARNING " Use aironet4500_pnp if any problems(i.e. card malfunctioning). \n"); printk(KERN_WARNING " Note that this isa probe is not friendly... must give exact parameters \n"); while (irq[card] != 0) { isa_ioaddr = io[card]; isa_irq_line = irq[card]; request_region(isa_ioaddr, AIRONET4X00_IO_SIZE, "aironet4x00 ioaddr"); if (!dev) { dev = init_etherdev(NULL, 0); if (!dev) { release_region(isa_ioaddr, AIRONET4X00_IO_SIZE); return (card == 0) ? -ENOMEM : 0; } } dev->priv = kmalloc(sizeof(struct awc_private),GFP_KERNEL ); memset(dev->priv,0,sizeof(struct awc_private)); if (!dev->priv) { printk(KERN_CRIT "aironet4x00: could not allocate device private, some unstability may follow\n"); return -1; }; // ether_setup(dev); // dev->tx_queue_len = tx_queue_len; dev->hard_start_xmit = &awc_start_xmit; // dev->set_config = &awc_config_misiganes,aga mitte awc_config; dev->get_stats = &awc_get_stats; // dev->set_multicast_list = &awc_set_multicast_list; dev->change_mtu = awc_change_mtu; dev->init = &awc_init; dev->open = &awc_open; dev->stop = &awc_close; dev->base_addr = isa_ioaddr; dev->irq = isa_irq_line; dev->tx_timeout = &awc_tx_timeout; dev->watchdog_timeo = AWC_TX_TIMEOUT; request_irq(dev->irq,awc_interrupt ,SA_INTERRUPT ,"Aironet 4X00",dev); awc_private_init( dev); if ( awc_init(dev) ) { printk("card not found at irq %x mem %x\n",irq[card],io[card]); if (card==0) return -1; break; } i=0; while (aironet4500_devices[i] && i < MAX_AWCS-1) i++; if (!aironet4500_devices[i]) { aironet4500_devices[i]=dev; ((struct awc_private *) aironet4500_devices[i]->priv)->card_type = AIRONET4500_ISA; if (awc_proc_set_fun) awc_proc_set_fun(i); } card++; } if (card == 0 ) { return -ENODEV; }; return 0; }
int awc4500_pnp_probe(struct net_device *dev) { int isa_index = 0; int isa_irq_line = 0; int isa_ioaddr = 0; int card = 0; int i=0; struct isapnp_dev * pnp_dev ; struct isapnp_logdev *logdev; while (1) { pnp_dev = isapnp_find_device( ISAPNP_VENDOR('A','W','L'), ISAPNP_DEVICE(1), 0); if (!pnp_dev) break; isa_index++; logdev = isapnp_find_logdev(pnp_dev, ISAPNP_VENDOR('A','W','L'), ISAPNP_FUNCTION(1), 0); if (!logdev) { printk("No logical device found on Aironet board \n"); return -ENODEV; } if (isapnp_cfg_begin(logdev->PNP_BUS->PNP_BUS_NUMBER, logdev->PNP_DEV_NUMBER) < 0) { printk("cfg begin failed for csn %x devnum %x \n", logdev->PNP_BUS->PNP_BUS_NUMBER, logdev->PNP_DEV_NUMBER); return -EAGAIN; } isapnp_activate(logdev->PNP_DEV_NUMBER); /* activate device */ isapnp_cfg_end(); isa_irq_line = logdev->irq; isa_ioaddr = logdev->resource[0].start; request_region(isa_ioaddr, AIRONET4X00_IO_SIZE, "aironet4x00 ioaddr"); if (!dev) { dev = init_etherdev(NULL, 0); if (!dev) { release_region(isa_ioaddr, AIRONET4X00_IO_SIZE); isapnp_cfg_begin(logdev->PNP_BUS->PNP_BUS_NUMBER, logdev->PNP_DEV_NUMBER); isapnp_deactivate(logdev->PNP_DEV_NUMBER); isapnp_cfg_end(); return -ENOMEM; } } dev->priv = kmalloc(sizeof(struct awc_private),GFP_KERNEL ); memset(dev->priv,0,sizeof(struct awc_private)); if (!dev->priv) { printk(KERN_CRIT "aironet4x00: could not allocate device private, some unstability may follow\n"); return -1; }; ((struct awc_private *)dev->priv)->bus = logdev; // ether_setup(dev); // dev->tx_queue_len = tx_queue_len; dev->hard_start_xmit = &awc_start_xmit; // dev->set_config = &awc_config_misiganes,aga mitte awc_config; dev->get_stats = &awc_get_stats; // dev->set_multicast_list = &awc_set_multicast_list; dev->change_mtu = awc_change_mtu; dev->init = &awc_init; dev->open = &awc_open; dev->stop = &awc_close; dev->base_addr = isa_ioaddr; dev->irq = isa_irq_line; dev->tx_timeout = &awc_tx_timeout; dev->watchdog_timeo = AWC_TX_TIMEOUT; netif_start_queue (dev); request_irq(dev->irq,awc_interrupt , SA_SHIRQ | SA_INTERRUPT ,"Aironet 4X00",dev); awc_private_init( dev); ((struct awc_private *)dev->priv)->bus = logdev; cli(); if ( awc_init(dev) ) { printk("card not found at irq %x io %lx\n",dev->irq, dev->base_addr); if (card==0) { sti(); return -1; } sti(); break; } udelay(10); sti(); i=0; while (aironet4500_devices[i] && i < MAX_AWCS-1) i++; if (!aironet4500_devices[i] && i < MAX_AWCS-1 ) { aironet4500_devices[i]=dev; ((struct awc_private *) aironet4500_devices[i]->priv)->card_type = AIRONET4500_PNP; if (awc_proc_set_fun) awc_proc_set_fun(i); } else { printk(KERN_CRIT "Out of resources (MAX_AWCS) \n"); return -1; } card++; } if (card == 0) return -ENODEV; return 0; }
static int awc_pci_init(struct net_device * dev, struct pci_dev *pdev, int ioaddr, int cis_addr, int mem_addr, u8 pci_irq_line) { int i, allocd_dev = 0; if (!dev) { dev = init_etherdev(NULL, 0); if (!dev) return -ENOMEM; allocd_dev = 1; } dev->priv = kmalloc(sizeof(struct awc_private),GFP_KERNEL ); if (!dev->priv) { if (allocd_dev) { unregister_netdev(dev); kfree(dev); } return -ENOMEM; } memset(dev->priv,0,sizeof(struct awc_private)); if (!dev->priv) { printk(KERN_CRIT "aironet4x00: could not allocate device private, some unstability may follow\n"); if (allocd_dev) { unregister_netdev(dev); kfree(dev); } return -ENOMEM; }; // ether_setup(dev); // dev->tx_queue_len = tx_queue_len; dev->hard_start_xmit = &awc_start_xmit; // dev->set_config = &awc_config_misiganes,aga mitte awc_config; dev->get_stats = &awc_get_stats; // dev->set_multicast_list = &awc_set_multicast_list; dev->change_mtu = awc_change_mtu; dev->init = &awc_init; dev->open = &awc_open; dev->stop = &awc_close; dev->base_addr = ioaddr; dev->irq = pci_irq_line; dev->tx_timeout = &awc_tx_timeout; dev->watchdog_timeo = AWC_TX_TIMEOUT; i = request_irq(dev->irq,awc_interrupt, SA_SHIRQ | SA_INTERRUPT, dev->name, dev); if (i) { kfree(dev->priv); dev->priv = NULL; if (allocd_dev) { unregister_netdev(dev); kfree(dev); } return i; } awc_private_init( dev); awc_init(dev); i=0; while (aironet4500_devices[i] && i < MAX_AWCS-1) i++; if (!aironet4500_devices[i]) { aironet4500_devices[i]=dev; ((struct awc_private *) aironet4500_devices[i]->priv)->card_type = AIRONET4500_PCI; if (awc_proc_set_fun) awc_proc_set_fun(i); } // if (register_netdev(dev) != 0) { // printk(KERN_NOTICE "awc_cs: register_netdev() failed\n"); // goto failed; // } return 0; // failed: // return -1; }
__initfunc(static int seeq8005_probe1(struct device *dev, int ioaddr)) { static unsigned version_printed = 0; int i,j; unsigned char SA_prom[32]; int old_cfg1; int old_cfg2; int old_stat; int old_dmaar; int old_rear; if (net_debug>1) printk("seeq8005: probing at 0x%x\n",ioaddr); old_stat = inw(SEEQ_STATUS); /* read status register */ if (old_stat == 0xffff) return ENODEV; /* assume that 0xffff == no device */ if ( (old_stat & 0x1800) != 0x1800 ) { /* assume that unused bits are 1, as my manual says */ if (net_debug>1) { printk("seeq8005: reserved stat bits != 0x1800\n"); printk(" == 0x%04x\n",old_stat); } return ENODEV; } old_rear = inw(SEEQ_REA); if (old_rear == 0xffff) { outw(0,SEEQ_REA); if (inw(SEEQ_REA) == 0xffff) { /* assume that 0xffff == no device */ return ENODEV; } } else if ((old_rear & 0xff00) != 0xff00) { /* assume that unused bits are 1 */ if (net_debug>1) { printk("seeq8005: unused rear bits != 0xff00\n"); printk(" == 0x%04x\n",old_rear); } return ENODEV; } old_cfg2 = inw(SEEQ_CFG2); /* read CFG2 register */ old_cfg1 = inw(SEEQ_CFG1); old_dmaar = inw(SEEQ_DMAAR); if (net_debug>4) { printk("seeq8005: stat = 0x%04x\n",old_stat); printk("seeq8005: cfg1 = 0x%04x\n",old_cfg1); printk("seeq8005: cfg2 = 0x%04x\n",old_cfg2); printk("seeq8005: raer = 0x%04x\n",old_rear); printk("seeq8005: dmaar= 0x%04x\n",old_dmaar); } outw( SEEQCMD_FIFO_WRITE | SEEQCMD_SET_ALL_OFF, SEEQ_CMD); /* setup for reading PROM */ outw( 0, SEEQ_DMAAR); /* set starting PROM address */ outw( SEEQCFG1_BUFFER_PROM, SEEQ_CFG1); /* set buffer to look at PROM */ j=0; for(i=0; i <32; i++) { j+= SA_prom[i] = inw(SEEQ_BUFFER) & 0xff; } #if 0 /* untested because I only have the one card */ if ( (j&0xff) != 0 ) { /* checksum appears to be 8bit = 0 */ if (net_debug>1) { /* check this before deciding that we have a card */ printk("seeq8005: prom sum error\n"); } outw( old_stat, SEEQ_STATUS); outw( old_dmaar, SEEQ_DMAAR); outw( old_cfg1, SEEQ_CFG1); return ENODEV; } #endif outw( SEEQCFG2_RESET, SEEQ_CFG2); /* reset the card */ udelay(5); outw( SEEQCMD_SET_ALL_OFF, SEEQ_CMD); if (net_debug) { printk("seeq8005: prom sum = 0x%08x\n",j); for(j=0; j<32; j+=16) { printk("seeq8005: prom %02x: ",j); for(i=0;i<16;i++) { printk("%02x ",SA_prom[j|i]); } printk(" "); for(i=0;i<16;i++) { if ((SA_prom[j|i]>31)&&(SA_prom[j|i]<127)) { printk("%c", SA_prom[j|i]); } else { printk(" "); } } printk("\n"); } } #if 0 /* * testing the packet buffer memory doesn't work yet * but all other buffer accesses do * - fixing is not a priority */ if (net_debug>1) { /* test packet buffer memory */ printk("seeq8005: testing packet buffer ... "); outw( SEEQCFG1_BUFFER_BUFFER, SEEQ_CFG1); outw( SEEQCMD_FIFO_WRITE | SEEQCMD_SET_ALL_OFF, SEEQ_CMD); outw( 0 , SEEQ_DMAAR); for(i=0;i<32768;i++) { outw(0x5a5a, SEEQ_BUFFER); } j=jiffies+HZ; while ( ((inw(SEEQ_STATUS) & SEEQSTAT_FIFO_EMPTY) != SEEQSTAT_FIFO_EMPTY) && time_before(jiffies, j) ) mb(); outw( 0 , SEEQ_DMAAR); while ( ((inw(SEEQ_STATUS) & SEEQSTAT_WINDOW_INT) != SEEQSTAT_WINDOW_INT) && time_before(jiffies, j+HZ)) mb(); if ( (inw(SEEQ_STATUS) & SEEQSTAT_WINDOW_INT) == SEEQSTAT_WINDOW_INT) outw( SEEQCMD_WINDOW_INT_ACK | (inw(SEEQ_STATUS)& SEEQCMD_INT_MASK), SEEQ_CMD); outw( SEEQCMD_FIFO_READ | SEEQCMD_SET_ALL_OFF, SEEQ_CMD); j=0; for(i=0;i<32768;i++) { if (inw(SEEQ_BUFFER) != 0x5a5a) j++; } if (j) { printk("%i\n",j); } else { printk("ok.\n"); } } #endif /* Allocate a new 'dev' if needed. */ if (dev == NULL) dev = init_etherdev(0, sizeof(struct net_local)); if (net_debug && version_printed++ == 0) printk(version); printk("%s: %s found at %#3x, ", dev->name, "seeq8005", ioaddr); /* Fill in the 'dev' fields. */ dev->base_addr = ioaddr; /* Retrieve and print the ethernet address. */ for (i = 0; i < 6; i++) printk(" %2.2x", dev->dev_addr[i] = SA_prom[i+6]); if (dev->irq == 0xff) ; /* Do nothing: a user-level program will set it. */ else if (dev->irq < 2) { /* "Auto-IRQ" */ autoirq_setup(0); outw( SEEQCMD_RX_INT_EN | SEEQCMD_SET_RX_ON | SEEQCMD_SET_RX_OFF, SEEQ_CMD ); dev->irq = autoirq_report(0); if (net_debug >= 2) printk(" autoirq is %d\n", dev->irq); } else if (dev->irq == 2) /* Fixup for users that don't know that IRQ 2 is really IRQ 9, * or don't know which one to set. */ dev->irq = 9; #if 0 { int irqval = request_irq(dev->irq, &seeq8005_interrupt, 0, "seeq8005", dev); if (irqval) { printk ("%s: unable to get IRQ %d (irqval=%d).\n", dev->name, dev->irq, irqval); return EAGAIN; } } #endif /* Grab the region so we can find another board if autoIRQ fails. */ request_region(ioaddr, SEEQ8005_IO_EXTENT,"seeq8005"); /* Initialize the device structure. */ dev->priv = kmalloc(sizeof(struct net_local), GFP_KERNEL); if (dev->priv == NULL) return -ENOMEM; memset(dev->priv, 0, sizeof(struct net_local)); dev->open = seeq8005_open; dev->stop = seeq8005_close; dev->hard_start_xmit = seeq8005_send_packet; dev->get_stats = seeq8005_get_stats; dev->set_multicast_list = &set_multicast_list; /* Fill in the fields of the device structure with ethernet values. */ ether_setup(dev); dev->flags &= ~IFF_MULTICAST; return 0; }
/* Probe for the Etherlink II card at I/O port base IOADDR, returning non-zero on success. If found, set the station address and memory parameters in DEVICE. */ int el2_probe1(struct device *dev, int ioaddr) { int i, iobase_reg, membase_reg, saved_406, wordlength; static unsigned version_printed = 0; unsigned long vendor_id; /* Reset and/or avoid any lurking NE2000 */ if (inb(ioaddr + 0x408) == 0xff) { udelay(1000); return ENODEV; } /* We verify that it's a 3C503 board by checking the first three octets of its ethernet address. */ iobase_reg = inb(ioaddr+0x403); membase_reg = inb(ioaddr+0x404); /* ASIC location registers should be 0 or have only a single bit set. */ if ( (iobase_reg & (iobase_reg - 1)) || (membase_reg & (membase_reg - 1))) { return ENODEV; } saved_406 = inb_p(ioaddr + 0x406); outb_p(ECNTRL_RESET|ECNTRL_THIN, ioaddr + 0x406); /* Reset it... */ outb_p(ECNTRL_THIN, ioaddr + 0x406); /* Map the station addr PROM into the lower I/O ports. We now check for both the old and new 3Com prefix */ outb(ECNTRL_SAPROM|ECNTRL_THIN, ioaddr + 0x406); vendor_id = inb(ioaddr)*0x10000 + inb(ioaddr + 1)*0x100 + inb(ioaddr + 2); if ((vendor_id != OLD_3COM_ID) && (vendor_id != NEW_3COM_ID)) { /* Restore the register we frobbed. */ outb(saved_406, ioaddr + 0x406); return ENODEV; } /* We should have a "dev" from Space.c or the static module table. */ if (dev == NULL) { printk("3c503.c: Passed a NULL device.\n"); dev = init_etherdev(0, 0); } if (ei_debug && version_printed++ == 0) printk("%s", version); dev->base_addr = ioaddr; /* Allocate dev->priv and fill in 8390 specific dev fields. */ if (ethdev_init(dev)) { printk ("3c503: unable to allocate memory for dev->priv.\n"); return -ENOMEM; } printk("%s: 3c503 at i/o base %#3x, node ", dev->name, ioaddr); /* Retrieve and print the ethernet address. */ for (i = 0; i < 6; i++) printk(" %2.2x", dev->dev_addr[i] = inb(ioaddr + i)); /* Map the 8390 back into the window. */ outb(ECNTRL_THIN, ioaddr + 0x406); /* Check for EL2/16 as described in tech. man. */ outb_p(E8390_PAGE0, ioaddr + E8390_CMD); outb_p(0, ioaddr + EN0_DCFG); outb_p(E8390_PAGE2, ioaddr + E8390_CMD); wordlength = inb_p(ioaddr + EN0_DCFG) & ENDCFG_WTS; outb_p(E8390_PAGE0, ioaddr + E8390_CMD); /* Probe for, turn on and clear the board's shared memory. */ if (ei_debug > 2) printk(" memory jumpers %2.2x ", membase_reg); outb(EGACFR_NORM, ioaddr + 0x405); /* Enable RAM */ /* This should be probed for (or set via an ioctl()) at run-time. Right now we use a sleazy hack to pass in the interface number at boot-time via the low bits of the mem_end field. That value is unused, and the low bits would be discarded even if it was used. */ #if defined(EI8390_THICK) || defined(EL2_AUI) ei_status.interface_num = 1; #else ei_status.interface_num = dev->mem_end & 0xf; #endif printk(", using %sternal xcvr.\n", ei_status.interface_num == 0 ? "in" : "ex"); if ((membase_reg & 0xf0) == 0) { dev->mem_start = 0; ei_status.name = "3c503-PIO"; } else { dev->mem_start = ((membase_reg & 0xc0) ? 0xD8000 : 0xC8000) + ((membase_reg & 0xA0) ? 0x4000 : 0); #define EL2_MEMSIZE (EL2_MB1_STOP_PG - EL2_MB1_START_PG)*256 #ifdef EL2MEMTEST /* This has never found an error, but someone might care. Note that it only tests the 2nd 8kB on 16kB 3c503/16 cards between card addr. 0x2000 and 0x3fff. */ { /* Check the card's memory. */ unsigned long mem_base = dev->mem_start; unsigned int test_val = 0xbbadf00d; writel(0xba5eba5e, mem_base); for (i = sizeof(test_val); i < EL2_MEMSIZE; i+=sizeof(test_val)) { writel(test_val, mem_base + i); if (readl(mem_base) != 0xba5eba5e || readl(mem_base + i) != test_val) { printk("3c503: memory failure or memory address conflict.\n"); dev->mem_start = 0; ei_status.name = "3c503-PIO"; break; } test_val += 0x55555555; writel(0, mem_base + i); } } #endif /* EL2MEMTEST */ dev->mem_end = dev->rmem_end = dev->mem_start + EL2_MEMSIZE; if (wordlength) { /* No Tx pages to skip over to get to Rx */ dev->rmem_start = dev->mem_start; ei_status.name = "3c503/16"; } else { dev->rmem_start = TX_PAGES*256 + dev->mem_start; ei_status.name = "3c503"; } } /* Divide up the memory on the card. This is the same regardless of whether shared-mem or PIO is used. For 16 bit cards (16kB RAM), we use the entire 8k of bank1 for an Rx ring. We only use 3k of the bank0 for 2 full size Tx packet slots. For 8 bit cards, (8kB RAM) we use 3kB of bank1 for two Tx slots, and the remaining 5kB for an Rx ring. */ if (wordlength) { ei_status.tx_start_page = EL2_MB0_START_PG; ei_status.rx_start_page = EL2_MB1_START_PG; } else { ei_status.tx_start_page = EL2_MB1_START_PG; ei_status.rx_start_page = EL2_MB1_START_PG + TX_PAGES; } /* Finish setting the board's parameters. */ ei_status.stop_page = EL2_MB1_STOP_PG; ei_status.word16 = wordlength; ei_status.reset_8390 = &el2_reset_8390; ei_status.get_8390_hdr = &el2_get_8390_hdr; ei_status.block_input = &el2_block_input; ei_status.block_output = &el2_block_output; request_region(ioaddr, EL2_IO_EXTENT, ei_status.name); if (dev->irq == 2) dev->irq = 9; else if (dev->irq > 5 && dev->irq != 9) { printk("3c503: configured interrupt %d invalid, will use autoIRQ.\n", dev->irq); dev->irq = 0; } ei_status.saved_irq = dev->irq; dev->start = 0; dev->open = &el2_open; dev->stop = &el2_close; if (dev->mem_start) printk("%s: %s - %dkB RAM, 8kB shared mem window at %#6lx-%#6lx.\n", dev->name, ei_status.name, (wordlength+1)<<3, dev->mem_start, dev->mem_end-1); else { ei_status.tx_start_page = EL2_MB1_START_PG; ei_status.rx_start_page = EL2_MB1_START_PG + TX_PAGES; printk("\n%s: %s, %dkB RAM, using programmed I/O (REJUMPER for SHARED MEMORY).\n", dev->name, ei_status.name, (wordlength+1)<<3); } return 0; }
static void * CDCEther_probe( struct usb_device *usb, unsigned int ifnum, const struct usb_device_id *id) { struct net_device *net; ether_dev_t *ether_dev; int rc; // First we should check the active configuration to see if // any other driver has claimed any of the interfaces. if ( check_for_claimed_interfaces( usb->actconfig ) ) { // Someone has already put there grubby paws on this device. // We don't want it now... return NULL; } // We might be finding a device we can use. // We all go ahead and allocate our storage space. // We need to because we have to start filling in the data that // we are going to need later. if(!(ether_dev = kmalloc(sizeof(ether_dev_t), GFP_KERNEL))) { err("out of memory allocating device structure"); return NULL; } // Zero everything out. memset(ether_dev, 0, sizeof(ether_dev_t)); // Let's see if we can find a configuration we can use. rc = find_valid_configuration( usb, ether_dev ); if (rc) { // Nope we couldn't find one we liked. // This device was not meant for us to control. kfree( ether_dev ); return NULL; } // Now that we FOUND a configuration. let's try to make the // device go into it. if ( usb_set_configuration( usb, ether_dev->bConfigurationValue ) ) { err("usb_set_configuration() failed"); kfree( ether_dev ); return NULL; } // Now set the communication interface up as required. if (usb_set_interface(usb, ether_dev->comm_bInterfaceNumber, ether_dev->comm_bAlternateSetting)) { err("usb_set_interface() failed"); kfree( ether_dev ); return NULL; } // Only turn traffic on right now if we must... if (ether_dev->data_interface_altset_num_without_traffic >= 0) { // We found an alternate setting for the data // interface that allows us to turn off traffic. // We should use it. if (usb_set_interface( usb, ether_dev->data_bInterfaceNumber, ether_dev->data_bAlternateSetting_without_traffic)) { err("usb_set_interface() failed"); kfree( ether_dev ); return NULL; } } else { // We didn't find an alternate setting for the data // interface that would let us turn off traffic. // Oh well, let's go ahead and do what we must... if (usb_set_interface( usb, ether_dev->data_bInterfaceNumber, ether_dev->data_bAlternateSetting_with_traffic)) { err("usb_set_interface() failed"); kfree( ether_dev ); return NULL; } } // Now we need to get a kernel Ethernet interface. net = init_etherdev( NULL, 0 ); if ( !net ) { // Hmm... The kernel is not sharing today... // Fine, we didn't want it anyway... err( "Unable to initialize ethernet device" ); kfree( ether_dev ); return NULL; } // Now that we have an ethernet device, let's set it up // (And I don't mean "set [it] up the bomb".) net->priv = ether_dev; net->open = CDCEther_open; net->stop = CDCEther_close; net->watchdog_timeo = CDC_ETHER_TX_TIMEOUT; net->tx_timeout = CDCEther_tx_timeout; // TX timeout function net->do_ioctl = CDCEther_ioctl; net->hard_start_xmit = CDCEther_start_xmit; net->set_multicast_list = CDCEther_set_multicast; net->get_stats = CDCEther_netdev_stats; net->mtu = ether_dev->wMaxSegmentSize - 14; // We'll keep track of this information for later... ether_dev->usb = usb; ether_dev->net = net; // and don't forget the MAC address. set_ethernet_addr( ether_dev ); // Send a message to syslog about what we are handling log_device_info( ether_dev ); // I claim this interface to be a CDC Ethernet Networking device usb_driver_claim_interface( &CDCEther_driver, &(usb->config[ether_dev->configuration_num].interface[ether_dev->comm_interface]), ether_dev ); // I claim this interface to be a CDC Ethernet Networking device usb_driver_claim_interface( &CDCEther_driver, &(usb->config[ether_dev->configuration_num].interface[ether_dev->data_interface]), ether_dev ); // Does this REALLY do anything??? usb_inc_dev_use( usb ); // TODO - last minute HACK ether_dev->comm_ep_in = 5; // Okay, we are finally done... return NULL; }
static void* ecos_usbeth_probe(struct usb_device* usbdev, unsigned int interface_id) { struct net_device* net; ecos_usbeth* usbeth; int res; unsigned char MAC[6]; unsigned char dummy[1]; int tx_endpoint = -1; int rx_endpoint = -1; const ecos_usbeth_impl* impl; int found_impl = 0; // See if this is the correct driver for this USB peripheral. impl = ecos_usbeth_implementations; while (impl->name != NULL) { if ((usbdev->descriptor.idVendor != impl->vendor) || (usbdev->descriptor.idProduct != impl->id)) { found_impl = 1; break; } impl++; } if (! found_impl) { return (void*) 0; } // For now only support USB-ethernet peripherals consisting of a single // configuration, with a single interface, with two bulk endpoints. if ((1 != usbdev->descriptor.bNumConfigurations) || (1 != usbdev->config[0].bNumInterfaces) || (2 != usbdev->config[0].interface[0].altsetting->bNumEndpoints)) { return (void*) 0; } if ((0 == (usbdev->config[0].interface[0].altsetting->endpoint[0].bEndpointAddress & USB_DIR_IN)) && (0 != (usbdev->config[0].interface[0].altsetting->endpoint[1].bEndpointAddress & USB_DIR_IN))) { tx_endpoint = usbdev->config[0].interface[0].altsetting->endpoint[0].bEndpointAddress; rx_endpoint = usbdev->config[0].interface[0].altsetting->endpoint[1].bEndpointAddress & ~USB_DIR_IN; } if ((0 != (usbdev->config[0].interface[0].altsetting->endpoint[0].bEndpointAddress & USB_DIR_IN)) && (0 == (usbdev->config[0].interface[0].altsetting->endpoint[1].bEndpointAddress & USB_DIR_IN))) { tx_endpoint = usbdev->config[0].interface[0].altsetting->endpoint[1].bEndpointAddress; rx_endpoint = usbdev->config[0].interface[0].altsetting->endpoint[0].bEndpointAddress & ~USB_DIR_IN; } if (-1 == tx_endpoint) { return (void*) 0; } res = usb_set_configuration(usbdev, usbdev->config[0].bConfigurationValue); if (0 != res) { printk("ecos_usbeth: failed to set configuration, %d\n", res); return (void*) 0; } res = usb_control_msg(usbdev, usb_rcvctrlpipe(usbdev, 0), ECOS_USBETH_CONTROL_GET_MAC_ADDRESS, USB_TYPE_CLASS | USB_RECIP_DEVICE | USB_DIR_IN, 0, 0, (void*) MAC, 6, 5 * HZ); if (6 != res) { printk("ecos_usbeth: failed to get MAC address, %d\n", res); return (void*) 0; } res = usb_control_msg(usbdev, usb_sndctrlpipe(usbdev, 0), // pipe ECOS_USBETH_CONTROL_SET_PROMISCUOUS_MODE, // request USB_TYPE_CLASS | USB_RECIP_DEVICE, // requesttype 0, // value 0, // index (void*) dummy, // data 0, // size 5 * HZ); // timeout if (0 != res) { printk("ecos_usbeth: failed to disable promiscous mode, %d\n", res); } usbeth = (ecos_usbeth*) kmalloc(sizeof(ecos_usbeth), GFP_KERNEL); if ((ecos_usbeth*)0 == usbeth) { printk("ecos_usbeth: failed to allocate memory for usbeth data structure\n"); return (void*) 0; } memset(usbeth, 0, sizeof(ecos_usbeth)); net = init_etherdev(0, 0); if ((struct net_device*) 0 == net) { kfree(usbeth); printk("ecos_usbeth: failed to allocate memory for net data structure\n"); return (void*) 0; } usbeth->usb_lock = SPIN_LOCK_UNLOCKED; usbeth->usb_dev = usbdev; FILL_BULK_URB(&(usbeth->tx_urb), usbdev, usb_sndbulkpipe(usbdev, tx_endpoint), usbeth->tx_buffer, ECOS_USBETH_MAXTU, &ecos_usbeth_tx_callback, (void*) usbeth); FILL_BULK_URB(&(usbeth->rx_urb), usbdev, usb_rcvbulkpipe(usbdev, rx_endpoint), usbeth->rx_buffer, ECOS_USBETH_MAXTU, &ecos_usbeth_rx_callback, (void*) usbeth); usbeth->net_dev = net; usbeth->target_promiscuous = 0; net->priv = (void*) usbeth; net->open = &ecos_usbeth_open; net->stop = &ecos_usbeth_close; net->do_ioctl = &ecos_usbeth_ioctl; net->hard_start_xmit = &ecos_usbeth_start_tx; net->set_multicast_list = &ecos_usbeth_set_rx_mode; net->get_stats = &ecos_usbeth_netdev_stats; net->mtu = 1500; // ECOS_USBETH_MAXTU - 2; memcpy(net->dev_addr, MAC, 6); printk("eCos-based USB ethernet peripheral active at %s\n", net->name); MOD_INC_USE_COUNT; return (void*) usbeth; }
/** * @brief This function adds the card. it will probe the * card, allocate the wlan_priv and initialize the device. * * @param card A pointer to card * @return A pointer to wlan_private structure */ wlan_private * wlan_add_card(void *card) { struct net_device *dev = NULL; wlan_private *priv = NULL; ENTER(); if (OS_ACQ_SEMAPHORE_BLOCK(&AddRemoveCardSem)) goto exit_sem_err; /* Allocate an Ethernet device and register it */ #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) if (!(dev = init_etherdev(dev, sizeof(wlan_private)))) { #else if (!(dev = alloc_etherdev(sizeof(wlan_private)))) { #endif PRINTM(MSG, "Init ethernet device failed!\n"); goto exit_add_err; } #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24) /* Allocate device name */ if (dev_alloc_name(dev, "mlan%d") < 0) { PRINTM(ERROR, "Could not allocate device name!\n"); goto err_kmalloc; } #endif priv = (wlan_private *) netdev_priv(dev); /* allocate buffer for wlan_adapter */ if (!(priv->adapter = kmalloc(sizeof(wlan_adapter), GFP_KERNEL))) { PRINTM(MSG, "Allocate buffer for wlan_adapter failed!\n"); goto err_kmalloc; } /* init wlan_adapter */ memset(priv->adapter, 0, sizeof(wlan_adapter)); priv->wlan_dev.netdev = dev; priv->wlan_dev.card = card; ((struct sdio_mmc_card *) card)->priv = priv; wlanpriv = priv; //XXX FB global var a virer ? #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24) SET_MODULE_OWNER(dev); #endif /* Setup the OS Interface to our functions */ #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29) dev->open = wlan_open; dev->hard_start_xmit = wlan_hard_start_xmit; dev->stop = wlan_close; dev->do_ioctl = wlan_do_ioctl; dev->set_mac_address = wlan_set_mac_address; dev->set_multicast_list = wlan_set_multicast_list; dev->tx_timeout = wlan_tx_timeout; dev->get_stats = wlan_get_stats; #else dev->netdev_ops = &wlan_netdev_ops; #endif dev->watchdog_timeo = MRVDRV_DEFAULT_WATCHDOG_TIMEOUT; dev->hard_header_len += sizeof(TxPD); dev->hard_header_len += SDIO_HEADER_LEN; dev->hard_header_len += HEADER_ALIGNMENT; #ifdef WIRELESS_EXT #if WIRELESS_EXT < 21 dev->get_wireless_stats = wlan_get_wireless_stats; #endif dev->wireless_handlers = (struct iw_handler_def *) &wlan_handler_def; #endif #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) dev->features |= NETIF_F_DYNALLOC; #endif dev->flags |= IFF_BROADCAST | IFF_MULTICAST; /* init SW */ if (wlan_init_sw(priv)) { PRINTM(FATAL, "Software Init Failed\n"); goto err_kmalloc; } PRINTM(INFO, "Starting kthread...\n"); priv->MainThread.priv = priv; wlan_create_thread(wlan_service_main_thread, &priv->MainThread, "wlan_main_service"); ConfigureThreadPriority(); #ifdef REASSOCIATION priv->ReassocThread.priv = priv; wlan_create_thread(wlan_reassociation_thread, &priv->ReassocThread, "wlan_reassoc_service"); #endif /* REASSOCIATION */ while ((priv->MainThread.pid == 0) #ifdef REASSOCIATION || (priv->ReassocThread.pid == 0) #endif ) { os_sched_timeout(2); } /* * Register the device. Fill up the private data structure with * relevant information from the card and request for the required * IRQ. */ if (sbi_register_dev(priv) < 0) { PRINTM(FATAL, "Failed to register wlan device!\n"); goto err_registerdev; } SET_NETDEV_DEV(dev, priv->hotplug_device); /* init FW and HW */ if (wlan_init_fw(priv)) { PRINTM(FATAL, "Firmware Init Failed\n"); goto err_init_fw; } #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33) SET_NETDEV_DEVTYPE(dev, &wlan_type); #endif #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) if (register_netdev(dev)) { printk(KERN_ERR "Cannot register network device!\n"); goto err_init_fw; } #endif os_carrier_off(priv); os_stop_queue(priv); PRINTM(INFO, "%s: WLAN 802.11 Adapter revision 0x%02X\n", dev->name, priv->adapter->chip_rev); #ifdef CONFIG_PROC_FS wlan_proc_entry(priv, dev); #ifdef PROC_DEBUG wlan_debug_entry(priv, dev); #endif #endif /* CONFIG_PROC_FS */ OS_REL_SEMAPHORE(&AddRemoveCardSem); LEAVE(); return priv; err_init_fw: sbi_unregister_dev(priv); err_registerdev: priv->adapter->SurpriseRemoved = TRUE; if (priv->MainThread.pid) { /* Stop the thread servicing the interrupts */ wake_up_interruptible(&priv->MainThread.waitQ); #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) wlan_terminate_thread(&priv->MainThread); #endif } #ifdef REASSOCIATION if (priv->ReassocThread.pid) { wake_up_interruptible(&priv->ReassocThread.waitQ); #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) wlan_terminate_thread(&priv->ReassocThread); #endif } #endif /* REASSOCIATION */ /* waiting for main thread quit */ while (priv->MainThread.pid #ifdef REASSOCIATION || priv->ReassocThread.pid #endif ) { os_sched_timeout(2); } err_kmalloc: if (dev->reg_state == NETREG_REGISTERED) unregister_netdev(dev); wlan_free_adapter(priv); priv->wlan_dev.netdev = NULL; #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) free_netdev(dev); #endif ((struct sdio_mmc_card *) card)->priv = NULL; wlanpriv = NULL; exit_add_err: OS_REL_SEMAPHORE(&AddRemoveCardSem); exit_sem_err: LEAVE(); return NULL; } /** * @brief This function removes the card. * * @param card A pointer to card * @return WLAN_STATUS_SUCCESS */ int wlan_remove_card(void *card) { wlan_private *priv = ((struct sdio_mmc_card *) card)->priv; wlan_adapter *Adapter = NULL; struct net_device *dev; union iwreq_data wrqu; ENTER(); if (OS_ACQ_SEMAPHORE_BLOCK(&AddRemoveCardSem)) goto exit_sem_err; if (!priv || !(Adapter = priv->adapter)) goto exit_remove; Adapter->SurpriseRemoved = TRUE; #ifdef REASSOCIATION if (Adapter->ReassocTimerIsSet == TRUE) { wlan_cancel_timer(&Adapter->MrvDrvTimer); Adapter->ReassocTimerIsSet = FALSE; } #endif if (Adapter->MediaConnectStatus == WlanMediaStateConnected) { Adapter->MediaConnectStatus = WlanMediaStateDisconnected; memset(wrqu.ap_addr.sa_data, 0x00, ETH_ALEN); wrqu.ap_addr.sa_family = ARPHRD_ETHER; wireless_send_event(priv->wlan_dev.netdev, SIOCGIWAP, &wrqu, NULL); wlan_clean_txrx(priv); } /* Release all pending commands */ wlan_clear_pending_cmd(priv); dev = priv->wlan_dev.netdev; /* Last reference is our one */ #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,37) PRINTM(INFO, "refcnt = %d\n", atomic_read(&dev->refcnt)); #else PRINTM(INFO, "refcnt = %d\n", netdev_refcnt_read(dev)); #endif PRINTM(INFO, "netdev_finish_unregister: %s\n", dev->name); if (dev->reg_state == NETREG_REGISTERED) unregister_netdev(dev); PRINTM(INFO, "Unregister finish\n"); if (priv->MainThread.pid) { /* Stop the thread servicing the interrupts */ wake_up_interruptible(&priv->MainThread.waitQ); #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) wlan_terminate_thread(&priv->MainThread); #endif } #ifdef REASSOCIATION if (priv->ReassocThread.pid) { wake_up_interruptible(&priv->ReassocThread.waitQ); #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) wlan_terminate_thread(&priv->ReassocThread); #endif } #endif /* REASSOCIATION */ /* waiting for thread quit */ while (priv->MainThread.pid #ifdef REASSOCIATION || priv->ReassocThread.pid #endif ) { os_sched_timeout(1); } wake_up_interruptible(&Adapter->HS_wait_q); if (Adapter->IsDeepSleep == TRUE) { Adapter->IsDeepSleep = FALSE; wake_up_interruptible(&Adapter->ds_awake_q); } #ifdef CONFIG_PROC_FS #ifdef PROC_DEBUG wlan_debug_remove(priv); #endif wlan_proc_remove(priv); #endif PRINTM(INFO, "unregister device\n"); sbi_unregister_dev(priv); PRINTM(INFO, "Free Adapter\n"); wlan_free_adapter(priv); priv->wlan_dev.netdev = NULL; #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) free_netdev(dev); #endif wlanpriv = NULL; exit_remove: OS_REL_SEMAPHORE(&AddRemoveCardSem); exit_sem_err: LEAVE(); return WLAN_STATUS_SUCCESS; }
int mace_probe(struct net_device *unused) { int j; struct mace_data *mp; unsigned char *addr; struct net_device *dev; unsigned char checksum = 0; static int found = 0; if (found || macintosh_config->ether_type != MAC_ETHER_MACE) return -ENODEV; found = 1; /* prevent 'finding' one on every device probe */ dev = init_etherdev(0, PRIV_BYTES); if (!dev) return -ENOMEM; mp = (struct mace_data *) dev->priv; dev->base_addr = (u32)MACE_BASE; mp->mace = (volatile struct mace *) MACE_BASE; dev->irq = IRQ_MAC_MACE; mp->dma_intr = IRQ_MAC_MACE_DMA; /* * The PROM contains 8 bytes which total 0xFF when XOR'd * together. Due to the usual peculiar apple brain damage * the bytes are spaced out in a strange boundary and the * bits are reversed. */ addr = (void *)MACE_PROM; for (j = 0; j < 6; ++j) { u8 v=bitrev(addr[j<<4]); checksum ^= v; dev->dev_addr[j] = v; } for (; j < 8; ++j) { checksum ^= bitrev(addr[j<<4]); } if (checksum != 0xFF) return -ENODEV; memset(&mp->stats, 0, sizeof(mp->stats)); dev->open = mace_open; dev->stop = mace_close; dev->hard_start_xmit = mace_xmit_start; dev->tx_timeout = mace_tx_timeout; dev->watchdog_timeo = TX_TIMEOUT; dev->get_stats = mace_stats; dev->set_multicast_list = mace_set_multicast; dev->set_mac_address = mace_set_address; ether_setup(dev); printk(KERN_INFO "%s: 68K MACE, hardware address %.2X", dev->name, dev->dev_addr[0]); for (j = 1 ; j < 6 ; j++) printk(":%.2X", dev->dev_addr[j]); printk("\n"); return 0; }
static void * usb_hpna_probe( struct usb_device *dev, unsigned int ifnum ) { // struct net_device *net_dev; struct device *net_dev; usb_hpna_t *hpna = &usb_dev_hpna; #ifdef PEGASUS_PRINT_PRODUCT_NAME int dev_index; #endif spinlock_t xxx = { }; #ifdef PEGASUS_PRINT_PRODUCT_NAME /* XXX */ if ( (dev_index = match_product(dev->descriptor.idVendor, dev->descriptor.idProduct)) == -1 ) { return NULL; } printk("USB Ethernet(Pegasus) %s found\n", product_list[dev_index].name); #else if ( dev->descriptor.idVendor != ADMTEK_VENDOR_ID || dev->descriptor.idProduct != ADMTEK_HPNA_PEGASUS ) { return NULL; } printk("USB HPNA Pegasus found\n"); #endif if ( usb_set_configuration(dev, dev->config[0].bConfigurationValue)) { err("usb_set_configuration() failed"); return NULL; } hpna->usb_dev = dev; hpna->rx_pipe = usb_rcvbulkpipe(hpna->usb_dev, 1); hpna->tx_pipe = usb_sndbulkpipe(hpna->usb_dev, 2); hpna->intr_pipe = usb_rcvintpipe(hpna->usb_dev, 0); if ( reset_mac(dev) ) { err("can't reset MAC"); } hpna->present = 1; if(!(hpna->rx_buff=kmalloc(MAX_MTU, GFP_KERNEL))) { err("not enough mem for out buff"); return NULL; } if(!(hpna->tx_buff=kmalloc(MAX_MTU, GFP_KERNEL))) { kfree_s(hpna->rx_buff, MAX_MTU); err("not enough mem for out buff"); return NULL; } net_dev = init_etherdev( 0, 0 ); hpna->net_dev = net_dev; net_dev->priv = hpna; net_dev->open = hpna_open; net_dev->stop = hpna_close; // net_dev->watchdog_timeo = TX_TIMEOUT; // net_dev->tx_timeout = tx_timeout; net_dev->do_ioctl = hpna_ioctl; net_dev->hard_start_xmit = hpna_start_xmit; net_dev->set_multicast_list = set_rx_mode; net_dev->get_stats = hpna_netdev_stats; net_dev->mtu = HPNA_MTU; #if 1 { /* * to support dhcp client daemon(dhcpcd), it needs to get HW address * in probe routine. */ struct usb_device *usb_dev = hpna->usb_dev; __u8 node_id[6]; if ( get_node_id(usb_dev, node_id) ) { printk("USB Pegasus can't get HW address in probe routine.\n"); printk("But Pegasus will re-try in open routine.\n"); goto next; } hpna_set_registers(usb_dev, 0x10, 6, node_id); memcpy(net_dev->dev_addr, node_id, 6); } next: #endif hpna->hpna_lock = xxx; //SPIN_LOCK_UNLOCKED; FILL_BULK_URB( &hpna->rx_urb, hpna->usb_dev, hpna->rx_pipe, hpna->rx_buff, MAX_MTU, hpna_read_irq, net_dev ); FILL_BULK_URB( &hpna->tx_urb, hpna->usb_dev, hpna->tx_pipe, hpna->tx_buff, MAX_MTU, hpna_write_irq, net_dev ); FILL_INT_URB( &hpna->intr_urb, hpna->usb_dev, hpna->intr_pipe, hpna->intr_buff, 8, hpna_irq, net_dev, 250 ); /* list_add( &hpna->list, &hpna_list );*/ return net_dev; }
static int __devinit w840_probe1 (struct pci_dev *pdev, const struct pci_device_id *ent) { struct net_device *dev; struct netdev_private *np; static int find_cnt; int chip_idx = ent->driver_data; int irq = pdev->irq; int i, option = find_cnt < MAX_UNITS ? options[find_cnt] : 0; long ioaddr; if (pci_enable_device(pdev)) return -EIO; pci_set_master(pdev); if(!pci_dma_supported(pdev,0xFFFFffff)) { printk(KERN_WARNING "Winbond-840: Device %s disabled due to DMA limitations.\n", pdev->name); return -EIO; } dev = init_etherdev(NULL, sizeof(*np)); if (!dev) return -ENOMEM; SET_MODULE_OWNER(dev); #ifdef USE_IO_OPS ioaddr = pci_resource_start(pdev, 0); if (!request_region(ioaddr, pci_id_tbl[chip_idx].io_size, dev->name)) goto err_out_netdev; #else ioaddr = pci_resource_start(pdev, 1); if (!request_mem_region(ioaddr, pci_id_tbl[chip_idx].io_size, dev->name)) goto err_out_netdev; ioaddr = (long) ioremap (ioaddr, pci_id_tbl[chip_idx].io_size); if (!ioaddr) goto err_out_iomem; #endif printk(KERN_INFO "%s: %s at 0x%lx, ", dev->name, pci_id_tbl[chip_idx].name, ioaddr); /* Warning: broken for big-endian machines. */ for (i = 0; i < 3; i++) ((u16 *)dev->dev_addr)[i] = le16_to_cpu(eeprom_read(ioaddr, i)); for (i = 0; i < 5; i++) printk("%2.2x:", dev->dev_addr[i]); printk("%2.2x, IRQ %d.\n", dev->dev_addr[i], irq); /* Reset the chip to erase previous misconfiguration. No hold time required! */ writel(0x00000001, ioaddr + PCIBusCfg); dev->base_addr = ioaddr; dev->irq = irq; np = dev->priv; np->chip_id = chip_idx; np->drv_flags = pci_id_tbl[chip_idx].drv_flags; np->pdev = pdev; spin_lock_init(&np->lock); pdev->driver_data = dev; if (dev->mem_start) option = dev->mem_start; /* The lower four bits are the media type. */ if (option > 0) { if (option & 0x200) np->full_duplex = 1; np->default_port = option & 15; if (np->default_port) np->medialock = 1; } if (find_cnt < MAX_UNITS && full_duplex[find_cnt] > 0) np->full_duplex = 1; if (np->full_duplex) np->duplex_lock = 1; /* The chip-specific entries in the device structure. */ dev->open = &netdev_open; dev->hard_start_xmit = &start_tx; dev->stop = &netdev_close; dev->get_stats = &get_stats; dev->set_multicast_list = &set_rx_mode; dev->do_ioctl = &mii_ioctl; dev->tx_timeout = &tx_timeout; dev->watchdog_timeo = TX_TIMEOUT; if (np->drv_flags & CanHaveMII) { int phy, phy_idx = 0; for (phy = 1; phy < 32 && phy_idx < 4; phy++) { int mii_status = mdio_read(dev, phy, 1); if (mii_status != 0xffff && mii_status != 0x0000) { np->phys[phy_idx++] = phy; np->advertising = mdio_read(dev, phy, 4); printk(KERN_INFO "%s: MII PHY found at address %d, status " "0x%4.4x advertising %4.4x.\n", dev->name, phy, mii_status, np->advertising); } } np->mii_cnt = phy_idx; if (phy_idx == 0) { printk(KERN_WARNING "%s: MII PHY not found -- this device may " "not operate correctly.\n", dev->name); } } find_cnt++; return 0; #ifndef USE_IO_OPS err_out_iomem: release_mem_region(pci_resource_start(pdev, 1), pci_id_tbl[chip_idx].io_size); #endif err_out_netdev: unregister_netdev (dev); kfree (dev); return -ENODEV; }
static int __init au1000_probe1(struct net_device *dev, long ioaddr, int irq, int port_num) { static unsigned version_printed = 0; struct au1000_private *aup = NULL; int i, retval = 0; db_dest_t *pDB, *pDBfree; char *pmac, *argptr; char ethaddr[6]; if (!request_region(ioaddr, MAC_IOSIZE, "Au1000 ENET")) { return -ENODEV; } if (version_printed++ == 0) printk(version); if (!dev) { dev = init_etherdev(0, sizeof(struct au1000_private)); } if (!dev) { printk (KERN_ERR "au1000 eth: init_etherdev failed\n"); return -ENODEV; } printk("%s: Au1xxx ethernet found at 0x%lx, irq %d\n", dev->name, ioaddr, irq); /* Initialize our private structure */ if (dev->priv == NULL) { aup = (struct au1000_private *) kmalloc(sizeof(*aup), GFP_KERNEL); if (aup == NULL) { retval = -ENOMEM; goto free_region; } dev->priv = aup; } aup = dev->priv; memset(aup, 0, sizeof(*aup)); /* Allocate the data buffers */ aup->vaddr = (u32)dma_alloc(MAX_BUF_SIZE * (NUM_TX_BUFFS+NUM_RX_BUFFS), &aup->dma_addr); if (!aup->vaddr) { retval = -ENOMEM; goto free_region; } /* aup->mac is the base address of the MAC's registers */ aup->mac = (volatile mac_reg_t *)((unsigned long)ioaddr); /* Setup some variables for quick register address access */ switch (ioaddr) { case AU1000_ETH0_BASE: case AU1500_ETH0_BASE: /* check env variables first */ if (!get_ethernet_addr(ethaddr)) { memcpy(au1000_mac_addr, ethaddr, sizeof(dev->dev_addr)); } else { /* Check command line */ argptr = prom_getcmdline(); if ((pmac = strstr(argptr, "ethaddr=")) == NULL) { printk(KERN_INFO "%s: No mac address found\n", dev->name); /* use the hard coded mac addresses */ } else { str2eaddr(ethaddr, pmac + strlen("ethaddr=")); memcpy(au1000_mac_addr, ethaddr, sizeof(dev->dev_addr)); } } if (ioaddr == AU1000_ETH0_BASE) aup->enable = (volatile u32 *) ((unsigned long)AU1000_MAC0_ENABLE); else aup->enable = (volatile u32 *) ((unsigned long)AU1500_MAC0_ENABLE); memcpy(dev->dev_addr, au1000_mac_addr, sizeof(dev->dev_addr)); setup_hw_rings(aup, MAC0_RX_DMA_ADDR, MAC0_TX_DMA_ADDR); break; case AU1000_ETH1_BASE: case AU1500_ETH1_BASE: if (ioaddr == AU1000_ETH1_BASE) aup->enable = (volatile u32 *) ((unsigned long)AU1000_MAC1_ENABLE); else aup->enable = (volatile u32 *) ((unsigned long)AU1500_MAC1_ENABLE); memcpy(dev->dev_addr, au1000_mac_addr, sizeof(dev->dev_addr)); dev->dev_addr[4] += 0x10; setup_hw_rings(aup, MAC1_RX_DMA_ADDR, MAC1_TX_DMA_ADDR); break; default: printk(KERN_ERR "%s: bad ioaddr\n", dev->name); break; } aup->phy_addr = PHY_ADDRESS; /* bring the device out of reset, otherwise probing the mii * will hang */ *aup->enable = MAC_EN_CLOCK_ENABLE; au_sync_delay(2); *aup->enable = MAC_EN_RESET0 | MAC_EN_RESET1 | MAC_EN_RESET2 | MAC_EN_CLOCK_ENABLE; au_sync_delay(2); if (mii_probe(dev) != 0) { goto free_region; } pDBfree = NULL; /* setup the data buffer descriptors and attach a buffer to each one */ pDB = aup->db; for (i=0; i<(NUM_TX_BUFFS+NUM_RX_BUFFS); i++) { pDB->pnext = pDBfree; pDBfree = pDB; pDB->vaddr = (u32 *)((unsigned)aup->vaddr + MAX_BUF_SIZE*i); pDB->dma_addr = (dma_addr_t)virt_to_bus(pDB->vaddr); pDB++; } aup->pDBfree = pDBfree; for (i=0; i<NUM_RX_DMA; i++) { pDB = GetFreeDB(aup); if (!pDB) goto free_region; aup->rx_dma_ring[i]->buff_stat = (unsigned)pDB->dma_addr; aup->rx_db_inuse[i] = pDB; } for (i=0; i<NUM_TX_DMA; i++) { pDB = GetFreeDB(aup); if (!pDB) goto free_region; aup->tx_dma_ring[i]->buff_stat = (unsigned)pDB->dma_addr; aup->tx_dma_ring[i]->len = 0; aup->tx_db_inuse[i] = pDB; } spin_lock_init(&aup->lock); dev->base_addr = ioaddr; dev->irq = irq; dev->open = au1000_open; dev->hard_start_xmit = au1000_tx; dev->stop = au1000_close; dev->get_stats = au1000_get_stats; dev->set_multicast_list = &set_rx_mode; dev->do_ioctl = &au1000_ioctl; dev->set_config = &au1000_set_config; dev->tx_timeout = au1000_tx_timeout; dev->watchdog_timeo = ETH_TX_TIMEOUT; /* Fill in the fields of the device structure with ethernet values. */ ether_setup(dev); /* * The boot code uses the ethernet controller, so reset it to start * fresh. au1000_init() expects that the device is in reset state. */ reset_mac(dev); return 0; free_region: release_region(ioaddr, MAC_IOSIZE); unregister_netdev(dev); if (aup->vaddr) dma_free((void *)aup->vaddr, MAX_BUF_SIZE * (NUM_TX_BUFFS+NUM_RX_BUFFS)); if (dev->priv != NULL) kfree(dev->priv); printk(KERN_ERR "%s: au1000_probe1 failed. Returns %d\n", dev->name, retval); kfree(dev); return retval; }
int acacia_probe(int port_num) { struct acacia_local *lp = NULL; struct acacia_if_t *bif = NULL; struct net_device *dev = NULL; int i, retval; bif = &acacia_iflist[port_num]; if (port_num == 0) { request_region(bif->iobase, 0x24C, "ACACIA0"); } else if (port_num == 1) { request_region(bif->iobase, 0x24C, "ACACIA1"); } /* Allocate a new 'dev' if needed */ dev = init_etherdev(0, sizeof(struct acacia_local)); bif->dev = dev; if (port_num == 0) { info("RC32438 ethernet0 found at 0x%08x\n", bif->iobase); } else if (port_num == 1) info("RC32438 ethernet1 found at 0x%08x\n", bif->iobase); /* Fill in the 'dev' fields. */ dev->base_addr = bif->iobase; dev->irq = bif->rx_dma_irq; /* just use the rx dma irq */ if ((retval = parse_mac_addr(dev, bif->mac_str))) { err("%s: MAC address parse failed\n", __func__); retval = -EINVAL; goto probe1_err_out; } info("HW Address "); for (i = 0; i < 6; i++) { printk("%2.2x", dev->dev_addr[i]); if (i<5) printk(":"); } printk("\n"); info("Rx IRQ %d, Tx IRQ %d\n", bif->rx_dma_irq, bif->tx_dma_irq); /* Initialize the device structure. */ if (dev->priv == NULL) { lp = (struct acacia_local *)kmalloc(sizeof(*lp), GFP_KERNEL); memset(lp, 0, sizeof(struct acacia_local)); } else { lp = (struct acacia_local *)dev->priv; } dev->priv = lp; lp->rx_irq = bif->rx_dma_irq; lp->tx_irq = bif->tx_dma_irq; lp->ovr_irq = bif->rx_ovr_irq; lp->eth_regs = ioremap_nocache(bif->iobase, sizeof(*lp->eth_regs)); if (!lp->eth_regs) { err("Can't remap eth registers\n"); retval = -ENXIO; goto probe1_err_out; } if (port_num == 0) { lp->rx_dma_regs = ioremap_nocache(DMA0_PhysicalAddress + 2*DMA_CHAN_OFFSET, sizeof(struct DMA_Chan_s)); if (!lp->rx_dma_regs) { err("Can't remap Rx DMA registers\n"); retval = -ENXIO; goto probe1_err_out; } lp->tx_dma_regs = ioremap_nocache(DMA0_PhysicalAddress + 3*DMA_CHAN_OFFSET, sizeof(struct DMA_Chan_s)); if (!lp->tx_dma_regs) { err("Can't remap Tx DMA registers\n"); retval = -ENXIO; goto probe1_err_out; } } else if (port_num == 1) { lp->rx_dma_regs = ioremap_nocache(DMA0_PhysicalAddress + 4*DMA_CHAN_OFFSET, sizeof(struct DMA_Chan_s)); if (!lp->rx_dma_regs) { err("Can't remap Rx DMA registers\n"); retval = -ENXIO; goto probe1_err_out; } lp->tx_dma_regs = ioremap_nocache(DMA0_PhysicalAddress + 5*DMA_CHAN_OFFSET, sizeof(struct DMA_Chan_s)); if (!lp->tx_dma_regs) { err("Can't remap Tx DMA registers\n"); retval = -ENXIO; goto probe1_err_out; } } lp->td_ring = (DMAD_t)kmalloc(TD_RING_SIZE + RD_RING_SIZE, GFP_KERNEL); if (!lp->td_ring) { err("Can't allocate descriptors\n"); retval = -ENOMEM; goto probe1_err_out; } dma_cache_inv((unsigned long)(lp->td_ring), TD_RING_SIZE + RD_RING_SIZE); /* now convert TD_RING pointer to KSEG1 */ lp->td_ring = (DMAD_t )KSEG1ADDR(lp->td_ring); lp->rd_ring = &lp->td_ring[ACACIA_NUM_TDS]; /* allocate receive buffer area */ /* FIXME, maybe we should use skbs */ if ((lp->rba = (u8*)kmalloc(ACACIA_NUM_RDS * ACACIA_RBSIZE, GFP_KERNEL)) == NULL) { err("couldn't allocate receive buffers\n"); retval = -ENOMEM; goto probe1_err_out; } /* get virtual dma address */ dma_cache_inv((unsigned long)(lp->rba), ACACIA_NUM_RDS * ACACIA_RBSIZE); spin_lock_init(&lp->lock); dev->open = acacia_open; dev->stop = acacia_close; dev->hard_start_xmit = acacia_send_packet; dev->get_stats = acacia_get_stats; dev->set_multicast_list = &acacia_multicast_list; dev->tx_timeout = acacia_tx_timeout; dev->watchdog_timeo = ACACIA_TX_TIMEOUT; #ifdef ACACIA_PROC_DEBUG lp->ps = create_proc_read_entry ("net/rc32438", 0, NULL, acacia_read_proc, dev); #endif /* * clear tally counter */ /* Fill in the fields of the device structure with ethernet values. */ ether_setup(dev); return 0; probe1_err_out: acacia_cleanup_module(); err("%s failed. Returns %d\n", __func__, retval); return retval; }
unsigned long lance_probe1(short ioaddr, unsigned long mem_start) { struct device *dev; struct lance_private *lp; int hpJ2405A = 0; int i, reset_val; hpJ2405A = (inb(ioaddr) == 0x08 && inb(ioaddr+1) == 0x00 && inb(ioaddr+2) == 0x09); /* Reset the LANCE. */ reset_val = inw(ioaddr+LANCE_RESET); /* Reset the LANCE */ /* The Un-Reset needed is only needed for the real NE2100, and will confuse the HP board. */ if (!hpJ2405A) outw(reset_val, ioaddr+LANCE_RESET); outw(0x0000, ioaddr+LANCE_ADDR); /* Switch to window 0 */ if (inw(ioaddr+LANCE_DATA) != 0x0004) return mem_start; /* 真正的注册网卡 */ dev = init_etherdev(0, sizeof(struct lance_private) + PKT_BUF_SZ*(RX_RING_SIZE + TX_RING_SIZE), &mem_start); printk("%s: LANCE at %#3x,", dev->name, ioaddr); /* There is a 16 byte station address PROM at the base address. The first six bytes are the station address. */ for (i = 0; i < 6; i++) printk(" %2.2x", dev->dev_addr[i] = inb(ioaddr + i)); dev->base_addr = ioaddr; snarf_region(ioaddr, LANCE_TOTAL_SIZE); /* Make certain the data structures used by the LANCE are aligned. */ dev->priv = (void *)(((int)dev->priv + 7) & ~7); lp = (struct lance_private *)dev->priv; lp->rx_buffs = (long)dev->priv + sizeof(struct lance_private); lp->tx_bounce_buffs = (char (*)[PKT_BUF_SZ]) (lp->rx_buffs + PKT_BUF_SZ*RX_RING_SIZE); #ifndef final_version /* This should never happen. */ if ((int)(lp->rx_ring) & 0x07) { printk(" **ERROR** LANCE Rx and Tx rings not on even boundary.\n"); return mem_start; } #endif outw(88, ioaddr+LANCE_ADDR); lp->old_lance = (inw(ioaddr+LANCE_DATA) != 0x3003); #if defined(notdef) printk(lp->old_lance ? " original LANCE (%04x)" : " PCnet-ISA LANCE (%04x)", inw(ioaddr+LANCE_DATA)); #endif lp->init_block.mode = 0x0003; /* Disable Rx and Tx. */ for (i = 0; i < 6; i++) lp->init_block.phys_addr[i] = dev->dev_addr[i]; lp->init_block.filter[0] = 0x00000000; lp->init_block.filter[1] = 0x00000000; lp->init_block.rx_ring = (int)lp->rx_ring | RX_RING_LEN_BITS; lp->init_block.tx_ring = (int)lp->tx_ring | TX_RING_LEN_BITS; outw(0x0001, ioaddr+LANCE_ADDR); outw((short) (int) &lp->init_block, ioaddr+LANCE_DATA); outw(0x0002, ioaddr+LANCE_ADDR); outw(((int)&lp->init_block) >> 16, ioaddr+LANCE_DATA); outw(0x0000, ioaddr+LANCE_ADDR); if (hpJ2405A) { char dma_tbl[4] = {3, 5, 6, 7}; char irq_tbl[8] = {3, 4, 5, 9, 10, 11, 12, 15}; short reset_val = inw(ioaddr+LANCE_RESET); dev->dma = dma_tbl[(reset_val >> 2) & 3]; dev->irq = irq_tbl[(reset_val >> 4) & 7]; printk(" HP J2405A IRQ %d DMA %d.\n", dev->irq, dev->dma); } else { /* The DMA channel may be passed in on this parameter. */ if (dev->mem_start & 0x07)
/* Initialise a single lance board at the given select code */ static int __init hplance_init(struct net_device *dev, int scode) { /* const char *name = dio_scodetoname(scode); */ static const char name[] = "HP LANCE"; void *va = dio_scodetoviraddr(scode); struct hplance_private *lp; int i; #ifdef MODULE dev = init_etherdev(0, sizeof(struct hplance_private)); if (!dev) return -ENOMEM; #else dev->priv = kmalloc(sizeof(struct hplance_private), GFP_KERNEL); if (dev->priv == NULL) return -ENOMEM; memset(dev->priv, 0, sizeof(struct hplance_private)); #endif SET_MODULE_OWNER(dev); printk("%s: HP LANCE; select code %d, addr", dev->name, scode); /* reset the board */ writeb(0xff,va+DIO_IDOFF); udelay(100); /* ariba! ariba! udelay! udelay! */ /* Fill the dev fields */ dev->base_addr = (unsigned long)va; dev->open = &hplance_open; dev->stop = &hplance_close; dev->hard_start_xmit = &lance_start_xmit; dev->get_stats = &lance_get_stats; dev->set_multicast_list = &lance_set_multicast; dev->dma = 0; for (i=0; i<6; i++) { /* The NVRAM holds our ethernet address, one nibble per byte, * at bytes NVRAMOFF+1,3,5,7,9... */ dev->dev_addr[i] = ((readb(va + HPLANCE_NVRAMOFF + i*4 + 1) & 0xF) << 4) | (readb(va + HPLANCE_NVRAMOFF + i*4 + 3) & 0xF); printk("%c%2.2x", i == 0 ? ' ' : ':', dev->dev_addr[i]); } lp = (struct hplance_private *)dev->priv; lp->lance.name = (char*)name; /* discards const, shut up gcc */ lp->lance.ll = (struct lance_regs *)(va + HPLANCE_REGOFF); lp->lance.init_block = (struct lance_init_block *)(va + HPLANCE_MEMOFF); /* CPU addr */ lp->lance.lance_init_block = 0; /* LANCE addr of same RAM */ lp->lance.busmaster_regval = LE_C3_BSWP; /* we're bigendian */ lp->lance.irq = dio_scodetoipl(scode); lp->lance.writerap = hplance_writerap; lp->lance.writerdp = hplance_writerdp; lp->lance.readrdp = hplance_readrdp; lp->lance.lance_log_rx_bufs = LANCE_LOG_RX_BUFFERS; lp->lance.lance_log_tx_bufs = LANCE_LOG_TX_BUFFERS; lp->lance.rx_ring_mod_mask = RX_RING_MOD_MASK; lp->lance.tx_ring_mod_mask = TX_RING_MOD_MASK; lp->scode = scode; lp->base = va; ether_setup(dev); printk(", irq %d\n", lp->lance.irq); #ifdef MODULE dev->ifindex = dev_new_index(); lp->next_module = root_hplance_dev; root_hplance_dev = lp; #endif /* MODULE */ dio_config_board(scode); /* tell bus scanning code this one's taken */ return 0; }
int __init mac8390_probe(struct net_device * dev) { volatile unsigned short *i; int boards_found = 0; int version_disp = 0; struct nubus_dev * ndev = NULL; struct nubus_dir dir; struct nubus_dirent ent; int offset; enum mac8390_type cardtype; if (probed) return -ENODEV; probed++; /* probably should check for Nubus instead */ if (!MACH_IS_MAC) return -ENODEV; while ((ndev = nubus_find_type(NUBUS_CAT_NETWORK, NUBUS_TYPE_ETHERNET, ndev))) { dev = NULL; if ((cardtype = mac8390_ident(ndev)) == MAC8390_NONE) continue; dev = init_etherdev(dev, 0); if (dev == NULL) { printk(KERN_ERR "Unable to allocate etherdev" "structure!\n"); return -ENOMEM; } if (version_disp == 0) { version_disp = 1; printk(version); } dev->irq = SLOT2IRQ(ndev->board->slot); /* This is getting to be a habit */ dev->base_addr = ndev->board->slot_addr | ((ndev->board->slot&0xf) << 20); /* Get some Nubus info - we will trust the card's idea of where its memory and registers are. */ if (nubus_get_func_dir(ndev, &dir) == -1) { printk(KERN_ERR "%s: Unable to get Nubus functional" " directory for slot %X!\n", dev->name, ndev->board->slot); continue; } /* Get the MAC address */ if ((nubus_find_rsrc(&dir, NUBUS_RESID_MAC_ADDRESS, &ent)) == -1) { printk(KERN_INFO "%s: Couldn't get MAC address!\n", dev->name); continue; } else { nubus_get_rsrc_mem(dev->dev_addr, &ent, 6); /* Some Sonic Sys cards masquerade as Farallon */ if (cardtype == MAC8390_FARALLON && dev->dev_addr[0] == 0x0 && dev->dev_addr[1] == 0x40 && dev->dev_addr[2] == 0x10) { /* This is really Sonic Sys card */ cardtype = MAC8390_SONICSYS; } } if (useresources[cardtype] == 1) { nubus_rewinddir(&dir); if (nubus_find_rsrc(&dir, NUBUS_RESID_MINOR_BASEOS, &ent) == -1) { printk(KERN_ERR "%s: Memory offset resource" " for slot %X not found!\n", dev->name, ndev->board->slot); continue; } nubus_get_rsrc_mem(&offset, &ent, 4); dev->mem_start = dev->base_addr + offset; /* yes, this is how the Apple driver does it */ dev->base_addr = dev->mem_start + 0x10000; nubus_rewinddir(&dir); if (nubus_find_rsrc(&dir, NUBUS_RESID_MINOR_LENGTH, &ent) == -1) { printk(KERN_INFO "%s: Memory length resource" " for slot %X not found" ", probing\n", dev->name, ndev->board->slot); offset = mac8390_memsize(dev->mem_start); } else { nubus_get_rsrc_mem(&offset, &ent, 4); } dev->mem_end = dev->mem_start + offset; } else { switch (cardtype) { case MAC8390_KINETICS: case MAC8390_DAYNA: /* it's the same */ dev->base_addr = (int)(ndev->board->slot_addr + DAYNA_8390_BASE); dev->mem_start = (int)(ndev->board->slot_addr + DAYNA_8390_MEM); dev->mem_end = dev->mem_start + mac8390_memsize(dev->mem_start); break; case MAC8390_CABLETRON: dev->base_addr = (int)(ndev->board->slot_addr + CABLETRON_8390_BASE); dev->mem_start = (int)(ndev->board->slot_addr + CABLETRON_8390_MEM); /* The base address is unreadable if 0x00 * has been written to the command register * Reset the chip by writing E8390_NODMA + * E8390_PAGE0 + E8390_STOP just to be * sure */ i = (void *)dev->base_addr; *i = 0x21; dev->mem_end = dev->mem_start + mac8390_memsize(dev->mem_start); break; default: printk(KERN_ERR "Card type %s is" " unsupported, sorry\n", cardname[cardtype]); return -ENODEV; } } /* Do the nasty 8390 stuff */ if (mac8390_initdev(dev, ndev, cardtype)) continue; boards_found++; } /* We're outta here */ if (boards_found > 0) return 0; else return -ENODEV; }
int fmv18x_probe1(struct device *dev, short ioaddr) { char irqmap[4] = {3, 7, 10, 15}; unsigned int i, irq; /* Resetting the chip doesn't reset the ISA interface, so don't bother. That means we have to be careful with the register values we probe for. */ /* Check I/O address configuration and Fujitsu vendor code */ if (fmv18x_probe_list[inb(ioaddr + FJ_CONFIG0) & 0x07] != ioaddr || inb(ioaddr+FJ_MACADDR ) != 0x00 || inb(ioaddr+FJ_MACADDR+1) != 0x00 || inb(ioaddr+FJ_MACADDR+2) != 0x0e) return -ENODEV; irq = irqmap[(inb(ioaddr + FJ_CONFIG0)>>6) & 0x03]; /* Snarf the interrupt vector now. */ if (request_irq(irq, &net_interrupt, 0, "fmv18x", NULL)) { printk ("FMV-18x found at %#3x, but it's unusable due to a conflict on" "IRQ %d.\n", ioaddr, irq); return EAGAIN; } /* Allocate a new 'dev' if needed. */ if (dev == NULL) dev = init_etherdev(0, sizeof(struct net_local)); /* Grab the region so that we can find another board if the IRQ request fails. */ request_region(ioaddr, FMV18X_IO_EXTENT, "fmv18x"); printk("%s: FMV-18x found at %#3x, IRQ %d, address ", dev->name, ioaddr, irq); dev->base_addr = ioaddr; dev->irq = irq; irq2dev_map[irq] = dev; for(i = 0; i < 6; i++) { unsigned char val = inb(ioaddr + FJ_MACADDR + i); printk("%02x", val); dev->dev_addr[i] = val; } /* "FJ_STATUS0" 12 bit 0x0400 means use regular 100 ohm 10baseT signals, rather than 150 ohm shielded twisted pair compensation. 0x0000 == auto-sense the interface 0x0800 == use TP interface 0x1800 == use coax interface */ { const char *porttype[] = {"auto-sense", "10baseT", "auto-sense", "10base2/5"}; ushort setup_value = inb(ioaddr + FJ_STATUS0); switch( setup_value & 0x07 ){ case 0x01 /* 10base5 */: case 0x02 /* 10base2 */: dev->if_port = 0x18; break; case 0x04 /* 10baseT */: dev->if_port = 0x08; break; default /* auto-sense*/: dev->if_port = 0x00; break; } printk(" %s interface.\n", porttype[(dev->if_port>>3) & 3]); } /* Initialize LAN Controller and LAN Card */ outb(0xda, ioaddr + CONFIG_0); /* Initialize LAN Controller */ outb(0x00, ioaddr + CONFIG_1); /* Stand by mode */ outb(0x00, ioaddr + FJ_CONFIG1); /* Disable IRQ of LAN Card */ outb(0x00, ioaddr + FJ_BUFCNTL); /* Reset ? I'm not sure (TAMIYA) */ /* wait for a while */ udelay(200); /* Set the station address in bank zero. */ outb(0x00, ioaddr + CONFIG_1); for (i = 0; i < 6; i++) outb(dev->dev_addr[i], ioaddr + 8 + i); /* Switch to bank 1 and set the multicast table to accept none. */ outb(0x04, ioaddr + CONFIG_1); for (i = 0; i < 8; i++) outb(0x00, ioaddr + 8 + i); /* Switch to bank 2 and lock our I/O address. */ outb(0x08, ioaddr + CONFIG_1); outb(dev->if_port, ioaddr + MODE13); if (net_debug) printk("%s", version); /* Initialize the device structure. */ dev->priv = kmalloc(sizeof(struct net_local), GFP_KERNEL); if (dev->priv == NULL) return -ENOMEM; memset(dev->priv, 0, sizeof(struct net_local)); dev->open = net_open; dev->stop = net_close; dev->hard_start_xmit = net_send_packet; dev->get_stats = net_get_stats; dev->set_multicast_list = &set_multicast_list; /* Fill in the fields of 'dev' with ethernet-generic values. */ ether_setup(dev); return 0; }