static int __init com20020_init(void) { struct net_device *dev; struct arcnet_local *lp; dev = alloc_arcdev(device); if (!dev) return -ENOMEM; if (node && node != 0xff) dev->dev_addr[0] = node; lp = dev->priv; lp->backplane = backplane; lp->clockp = clockp & 7; lp->clockm = clockm & 3; lp->timeout = timeout & 3; lp->hw.owner = THIS_MODULE; dev->base_addr = io; dev->irq = irq; if (dev->irq == 2) dev->irq = 9; if (com20020isa_probe(dev)) { free_netdev(dev); return -EIO; } my_dev = dev; return 0; }
static int com20020_probe(struct pcmcia_device *p_dev) { com20020_dev_t *info; struct net_device *dev; struct arcnet_local *lp; DEBUG(0, "com20020_attach()\n"); /* Create new network device */ info = kmalloc(sizeof(struct com20020_dev_t), GFP_KERNEL); if (!info) goto fail_alloc_info; dev = alloc_arcdev(""); if (!dev) goto fail_alloc_dev; memset(info, 0, sizeof(struct com20020_dev_t)); lp = dev->priv; lp->timeout = timeout; lp->backplane = backplane; lp->clockp = clockp; lp->clockm = clockm & 3; lp->hw.owner = THIS_MODULE; /* fill in our module parameters as defaults */ dev->dev_addr[0] = node; p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_8; p_dev->io.NumPorts1 = 16; p_dev->io.IOAddrLines = 16; p_dev->irq.Attributes = IRQ_TYPE_EXCLUSIVE; p_dev->irq.IRQInfo1 = IRQ_LEVEL_ID; p_dev->conf.Attributes = CONF_ENABLE_IRQ; p_dev->conf.IntType = INT_MEMORY_AND_IO; p_dev->conf.Present = PRESENT_OPTION; p_dev->irq.Instance = info->dev = dev; p_dev->priv = info; return com20020_config(p_dev); fail_alloc_dev: kfree(info); fail_alloc_info: return -ENOMEM; } /* com20020_attach */
static int com20020_probe(struct pcmcia_device *p_dev) { com20020_dev_t *info; struct net_device *dev; struct arcnet_local *lp; dev_dbg(&p_dev->dev, "com20020_attach()\n"); /* Create new network device */ info = kzalloc(sizeof(struct com20020_dev_t), GFP_KERNEL); if (!info) goto fail_alloc_info; dev = alloc_arcdev(""); if (!dev) goto fail_alloc_dev; lp = netdev_priv(dev); lp->timeout = timeout; lp->backplane = backplane; lp->clockp = clockp; lp->clockm = clockm & 3; lp->hw.owner = THIS_MODULE; /* fill in our module parameters as defaults */ dev->dev_addr[0] = node; p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_8; p_dev->io.NumPorts1 = 16; p_dev->io.IOAddrLines = 16; p_dev->conf.Attributes = CONF_ENABLE_IRQ; p_dev->conf.IntType = INT_MEMORY_AND_IO; info->dev = dev; p_dev->priv = info; return com20020_config(p_dev); fail_alloc_dev: kfree(info); fail_alloc_info: return -ENOMEM; } /* com20020_attach */
static int __init arc_rimi_init(void) { struct net_device *dev; dev = alloc_arcdev(device); if (!dev) return -ENOMEM; if (node && node != 0xff) dev->dev_addr[0] = node; dev->mem_start = io; dev->irq = irq; if (dev->irq == 2) dev->irq = 9; if (arcrimi_probe(dev)) { free_netdev(dev); return -EIO; } my_dev = dev; return 0; }
static int __init com90io_init(void) { struct net_device *dev; int err; dev = alloc_arcdev(device); if (!dev) return -ENOMEM; dev->base_addr = io; dev->irq = irq; if (dev->irq == 2) dev->irq = 9; err = com90io_probe(dev); if (err) { free_netdev(dev); return err; } my_dev = dev; return 0; }
static int __devinit com20020pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) { struct net_device *dev; struct arcnet_local *lp; int ioaddr, err; if (pci_enable_device(pdev)) return -EIO; dev = alloc_arcdev(device); if (!dev) return -ENOMEM; lp = dev->priv; pci_set_drvdata(pdev, dev); // SOHARD needs PCI base addr 4 if (pdev->vendor==0x10B5) { BUGMSG(D_NORMAL, "SOHARD\n"); ioaddr = pci_resource_start(pdev, 4); } else { BUGMSG(D_NORMAL, "Contemporary Controls\n"); ioaddr = pci_resource_start(pdev, 2); } if (!request_region(ioaddr, ARCNET_TOTAL_SIZE, "com20020-pci")) { BUGMSG(D_INIT, "IO region %xh-%xh already allocated.\n", ioaddr, ioaddr + ARCNET_TOTAL_SIZE - 1); err = -EBUSY; goto out_dev; } // Dummy access after Reset // ARCNET controller needs this access to detect bustype outb(0x00,ioaddr+1); inb(ioaddr+1); dev->base_addr = ioaddr; dev->irq = pdev->irq; dev->dev_addr[0] = node; lp->card_name = "PCI COM20020"; lp->card_flags = id->driver_data; lp->backplane = backplane; lp->clockp = clockp & 7; lp->clockm = clockm & 3; lp->timeout = timeout; lp->hw.owner = THIS_MODULE; if (ASTATUS() == 0xFF) { BUGMSG(D_NORMAL, "IO address %Xh was reported by PCI BIOS, " "but seems empty!\n", ioaddr); err = -EIO; goto out_port; } if (com20020_check(dev)) { err = -EIO; goto out_port; } if ((err = com20020_found(dev, IRQF_SHARED)) != 0) goto out_port; return 0; out_port: release_region(ioaddr, ARCNET_TOTAL_SIZE); out_dev: free_netdev(dev); return err; }
static int __init com90xx_found(int ioaddr, int airq, u_long shmem, void __iomem *p) { struct net_device *dev = NULL; struct arcnet_local *lp; u_long first_mirror, last_mirror; int mirror_size; dev = alloc_arcdev(device); if (!dev) { BUGMSG2(D_NORMAL, "com90xx: Can't allocate device!\n"); iounmap(p); release_mem_region(shmem, MIRROR_SIZE); return -ENOMEM; } lp = netdev_priv(dev); mirror_size = MIRROR_SIZE; if (readb(p) == TESTvalue && check_mirror(shmem - MIRROR_SIZE, MIRROR_SIZE) == 0 && check_mirror(shmem - 2 * MIRROR_SIZE, MIRROR_SIZE) == 1) mirror_size = 2 * MIRROR_SIZE; first_mirror = shmem - mirror_size; while (check_mirror(first_mirror, mirror_size) == 1) first_mirror -= mirror_size; first_mirror += mirror_size; last_mirror = shmem + mirror_size; while (check_mirror(last_mirror, mirror_size) == 1) last_mirror += mirror_size; last_mirror -= mirror_size; dev->mem_start = first_mirror; dev->mem_end = last_mirror + MIRROR_SIZE - 1; iounmap(p); release_mem_region(shmem, MIRROR_SIZE); if (!request_mem_region(dev->mem_start, dev->mem_end - dev->mem_start + 1, "arcnet (90xx)")) goto err_free_dev; if (request_irq(airq, arcnet_interrupt, 0, "arcnet (90xx)", dev)) { BUGMSG(D_NORMAL, "Can't get IRQ %d!\n", airq); goto err_release_mem; } dev->irq = airq; lp->card_name = "COM90xx"; lp->hw.command = com90xx_command; lp->hw.status = com90xx_status; lp->hw.intmask = com90xx_setmask; lp->hw.reset = com90xx_reset; lp->hw.owner = THIS_MODULE; lp->hw.copy_to_card = com90xx_copy_to_card; lp->hw.copy_from_card = com90xx_copy_from_card; lp->mem_start = ioremap(dev->mem_start, dev->mem_end - dev->mem_start + 1); if (!lp->mem_start) { BUGMSG(D_NORMAL, "Can't remap device memory!\n"); goto err_free_irq; } dev->dev_addr[0] = readb(lp->mem_start + 1); dev->base_addr = ioaddr; BUGMSG(D_NORMAL, "COM90xx station %02Xh found at %03lXh, IRQ %d, " "ShMem %lXh (%ld*%xh).\n", dev->dev_addr[0], dev->base_addr, dev->irq, dev->mem_start, (dev->mem_end - dev->mem_start + 1) / mirror_size, mirror_size); if (register_netdev(dev)) goto err_unmap; cards[numcards++] = dev; return 0; err_unmap: iounmap(lp->mem_start); err_free_irq: free_irq(dev->irq, dev); err_release_mem: release_mem_region(dev->mem_start, dev->mem_end - dev->mem_start + 1); err_free_dev: free_netdev(dev); return -EIO; }
/* Set up the struct net_device associated with this card. Called after * probing succeeds. */ static int __init com90xx_found(int ioaddr, int airq, u_long shmem, void __iomem *p) { struct net_device *dev = NULL; struct arcnet_local *lp; u_long first_mirror, last_mirror; int mirror_size; /* allocate struct net_device */ dev = alloc_arcdev(device); if (!dev) { BUGMSG2(D_NORMAL, "com90xx: Can't allocate device!\n"); iounmap(p); release_mem_region(shmem, MIRROR_SIZE); return -ENOMEM; } lp = netdev_priv(dev); /* find the real shared memory start/end points, including mirrors */ /* guess the actual size of one "memory mirror" - the number of * bytes between copies of the shared memory. On most cards, it's * 2k (or there are no mirrors at all) but on some, it's 4k. */ mirror_size = MIRROR_SIZE; if (readb(p) == TESTvalue && check_mirror(shmem - MIRROR_SIZE, MIRROR_SIZE) == 0 && check_mirror(shmem - 2 * MIRROR_SIZE, MIRROR_SIZE) == 1) mirror_size = 2 * MIRROR_SIZE; first_mirror = shmem - mirror_size; while (check_mirror(first_mirror, mirror_size) == 1) first_mirror -= mirror_size; first_mirror += mirror_size; last_mirror = shmem + mirror_size; while (check_mirror(last_mirror, mirror_size) == 1) last_mirror += mirror_size; last_mirror -= mirror_size; dev->mem_start = first_mirror; dev->mem_end = last_mirror + MIRROR_SIZE - 1; iounmap(p); release_mem_region(shmem, MIRROR_SIZE); if (!request_mem_region(dev->mem_start, dev->mem_end - dev->mem_start + 1, "arcnet (90xx)")) goto err_free_dev; /* reserve the irq */ if (request_irq(airq, arcnet_interrupt, 0, "arcnet (90xx)", dev)) { BUGMSG(D_NORMAL, "Can't get IRQ %d!\n", airq); goto err_release_mem; } dev->irq = airq; /* Initialize the rest of the device structure. */ lp->card_name = "COM90xx"; lp->hw.command = com90xx_command; lp->hw.status = com90xx_status; lp->hw.intmask = com90xx_setmask; lp->hw.reset = com90xx_reset; lp->hw.owner = THIS_MODULE; lp->hw.copy_to_card = com90xx_copy_to_card; lp->hw.copy_from_card = com90xx_copy_from_card; lp->mem_start = ioremap(dev->mem_start, dev->mem_end - dev->mem_start + 1); if (!lp->mem_start) { BUGMSG(D_NORMAL, "Can't remap device memory!\n"); goto err_free_irq; } /* get and check the station ID from offset 1 in shmem */ dev->dev_addr[0] = readb(lp->mem_start + 1); dev->base_addr = ioaddr; BUGMSG(D_NORMAL, "COM90xx station %02Xh found at %03lXh, IRQ %d, " "ShMem %lXh (%ld*%xh).\n", dev->dev_addr[0], dev->base_addr, dev->irq, dev->mem_start, (dev->mem_end - dev->mem_start + 1) / mirror_size, mirror_size); if (register_netdev(dev)) goto err_unmap; cards[numcards++] = dev; return 0; err_unmap: iounmap(lp->mem_start); err_free_irq: free_irq(dev->irq, dev); err_release_mem: release_mem_region(dev->mem_start, dev->mem_end - dev->mem_start + 1); err_free_dev: free_netdev(dev); return -EIO; }