Example #1
0
void cleanup_module(void)
{
	int this_dev;
	for(this_dev=0; this_dev<MAX_3C523_CARDS; this_dev++) {

		struct net_device *dev = &dev_elmc[this_dev];
		if(dev->priv) {
			/* shutdown interrupts on the card */
			elmc_id_reset586();
			if (dev->irq != 0) {
				/* this should be done by close, but if we failed to
				   initialize properly something may have gotten hosed. */
				free_irq(dev->irq, dev);
				dev->irq = 0;
			}
			if (dev->base_addr != 0) {
				release_region(dev->base_addr, ELMC_IO_EXTENT);
				dev->base_addr = 0;
			}
			irq[this_dev] = 0;
			io[this_dev] = 0;
			unregister_netdev(dev);

			mca_set_adapter_procfn(((struct priv *) (dev->priv))->slot,
			       NULL, NULL);

			kfree(dev->priv);
			dev->priv = NULL;
		}
	}
}
Example #2
0
void cleanup_module(void)
{
	struct IBMLANA_NETDEV *dev;
	ibmlana_priv *priv;
	int z;

	if (MOD_IN_USE) {
		printk("cannot unload, module in use\n");
		return;
	}

	for (z = 0; z < DEVMAX; z++) {
		dev = moddevs + z;
		if (dev->priv != NULL) {
			priv = (ibmlana_priv *) dev->priv;
			/*DeinitBoard(dev); */
			if (dev->irq != 0)
				free_irq(dev->irq, dev);
			dev->irq = 0;
			release_region(dev->base_addr, IBM_LANA_IORANGE);
			unregister_netdev(dev);
#if (LINUX_VERSION_CODE >= 0x20200)
			mca_mark_as_unused(priv->slot);
#endif
			mca_set_adapter_name(priv->slot, "");
			mca_set_adapter_procfn(priv->slot, NULL, NULL);
			kfree(dev->priv);
			dev->priv = NULL;
		}
	}
}
Example #3
0
int init_module(void)
{
	int z;

	startslot = 0;
	for (z = 0; z < DEVMAX; z++) {
		struct net_device *dev = alloc_etherdev(sizeof(ibmlana_priv));
		if (!dev)
			break;
		dev->irq = irq;
		dev->base_addr = io;
		if (ibmlana_probe(dev)) {
			free_netdev(dev);
			break;
		}
		if (register_netdev(dev)) {
			ibmlana_priv *priv = netdev_priv(dev);
			release_region(dev->base_addr, IBM_LANA_IORANGE);
			mca_mark_as_unused(priv->slot);
			mca_set_adapter_name(priv->slot, "");
			mca_set_adapter_procfn(priv->slot, NULL, NULL);
			iounmap(priv->base);
			free_netdev(dev);
			break;
		}
		moddevs[z] = dev;
	}
	return (z > 0) ? 0 : -EIO;
}
Example #4
0
void cleanup_module(void)
{
	int z;
	for (z = 0; z < DEVMAX; z++) {
		struct net_device *dev = moddevs[z];
		if (dev) {
			ibmlana_priv *priv = netdev_priv(dev);
			unregister_netdev(dev);
			/*DeinitBoard(dev); */
			release_region(dev->base_addr, IBM_LANA_IORANGE);
			mca_mark_as_unused(priv->slot);
			mca_set_adapter_name(priv->slot, "");
			mca_set_adapter_procfn(priv->slot, NULL, NULL);
			iounmap(priv->base);
			free_netdev(dev);
		}
	}
}
Example #5
0
void cleanup_module(void)
{
	struct net_device *dev;
	ibmlana_priv *priv;
	int z;

	for (z = 0; z < DEVMAX; z++) {
		dev = moddevs + z;
		if (dev->priv != NULL) {
			priv = (ibmlana_priv *) dev->priv;
			/*DeinitBoard(dev); */
			if (dev->irq != 0)
				free_irq(dev->irq, dev);
			dev->irq = 0;
			release_region(dev->base_addr, IBM_LANA_IORANGE);
			unregister_netdev(dev);
			mca_mark_as_unused(priv->slot);
			mca_set_adapter_name(priv->slot, "");
			mca_set_adapter_procfn(priv->slot, NULL, NULL);
			kfree(dev->priv);
			dev->priv = NULL;
		}
	}
}
Example #6
0
int __init elmc_probe(struct net_device *dev)
{
	static int slot;
	int base_addr = dev->base_addr;
	int irq = dev->irq;
	u_char status = 0;
	u_char revision = 0;
	int i = 0;
	unsigned int size = 0;
	int retval;
	struct priv *pr;

	SET_MODULE_OWNER(dev);
	if (MCA_bus == 0) {
		return -ENODEV;
	}
	/* search through the slots for the 3c523. */
	slot = mca_find_adapter(ELMC_MCA_ID, 0);
	while (slot != -1) {
		status = mca_read_stored_pos(slot, 2);

		dev->irq=irq_table[(status & ELMC_STATUS_IRQ_SELECT) >> 6];
		dev->base_addr=csr_table[(status & ELMC_STATUS_CSR_SELECT) >> 1];
		
		/*
		   If we're trying to match a specified irq or IO address,
		   we'll reject a match unless it's what we're looking for.
		   Also reject it if the card is already in use.
		 */

		if ((irq && irq != dev->irq) || 
		    (base_addr && base_addr != dev->base_addr)) {
			slot = mca_find_adapter(ELMC_MCA_ID, slot + 1);
			continue;
		}
		if (!request_region(dev->base_addr, ELMC_IO_EXTENT, dev->name)) {
			slot = mca_find_adapter(ELMC_MCA_ID, slot + 1);
			continue;
		}

		/* found what we're looking for... */
		break;
	}

	/* we didn't find any 3c523 in the slots we checked for */
	if (slot == MCA_NOTFOUND) {
		retval = ((base_addr || irq) ? -ENXIO : -ENODEV);
		goto err_out;
	}
	mca_set_adapter_name(slot, "3Com 3c523 Etherlink/MC");
	mca_set_adapter_procfn(slot, (MCA_ProcFn) elmc_getinfo, dev);

	/* if we get this far, adapter has been found - carry on */
	printk(KERN_INFO "%s: 3c523 adapter found in slot %d\n", dev->name, slot + 1);

	/* Now we extract configuration info from the card.
	   The 3c523 provides information in two of the POS registers, but
	   the second one is only needed if we want to tell the card what IRQ
	   to use.  I suspect that whoever sets the thing up initially would
	   prefer we don't screw with those things.

	   Note that we read the status info when we found the card...

	   See 3c523.h for more details.
	 */

	/* revision is stored in the first 4 bits of the revision register */
	revision = inb(dev->base_addr + ELMC_REVISION) & 0xf;

	/* according to docs, we read the interrupt and write it back to
	   the IRQ select register, since the POST might not configure the IRQ
	   properly. */
	switch (dev->irq) {
	case 3:
		mca_write_pos(slot, 3, 0x04);
		break;
	case 7:
		mca_write_pos(slot, 3, 0x02);
		break;
	case 9:
		mca_write_pos(slot, 3, 0x08);
		break;
	case 12:
		mca_write_pos(slot, 3, 0x01);
		break;
	}

	pr = dev->priv = kmalloc(sizeof(struct priv), GFP_KERNEL);
	if (dev->priv == NULL) {
		retval = -ENOMEM;
		goto err_out;
	}
	memset(pr, 0, sizeof(struct priv));

	pr->slot = slot;

	printk(KERN_INFO "%s: 3Com 3c523 Rev 0x%x at %#lx\n", dev->name, (int) revision,
	       dev->base_addr);

	/* Determine if we're using the on-board transceiver (i.e. coax) or
	   an external one.  The information is pretty much useless, but I
	   guess it's worth brownie points. */
	dev->if_port = (status & ELMC_STATUS_DISABLE_THIN);

	/* The 3c523 has a 24K chunk of memory.  The first 16K is the
	   shared memory, while the last 8K is for the EtherStart BIOS ROM.
	   Which we don't care much about here.  We'll just tell Linux that
	   we're using 16K.  MCA won't permit address space conflicts caused
	   by not mapping the other 8K. */
	dev->mem_start = shm_table[(status & ELMC_STATUS_MEMORY_SELECT) >> 3];

	/* We're using MCA, so it's a given that the information about memory
	   size is correct.  The Crynwr drivers do something like this. */

	elmc_id_reset586();	/* seems like a good idea before checking it... */

	size = 0x4000;		/* check for 16K mem */
	if (!check586(dev, dev->mem_start, size)) {
		printk(KERN_ERR "%s: memprobe, Can't find memory at 0x%lx!\n", dev->name,
		       dev->mem_start);
		kfree(dev->priv);
		dev->priv = NULL;
		retval = -ENODEV;
		goto err_out;
	}
	dev->mem_end = dev->mem_start + size;	/* set mem_end showed by 'ifconfig' */

	pr->memtop = bus_to_virt(dev->mem_start) + size;
	pr->base = (unsigned long) bus_to_virt(dev->mem_start) + size - 0x01000000;
	alloc586(dev);

	elmc_id_reset586();	/* make sure it doesn't generate spurious ints */

	/* set number of receive-buffs according to memsize */
	pr->num_recv_buffs = NUM_RECV_BUFFS_16;

	/* dump all the assorted information */
	printk(KERN_INFO "%s: IRQ %d, %sternal xcvr, memory %#lx-%#lx.\n", dev->name,
	       dev->irq, dev->if_port ? "ex" : "in", 
	       dev->mem_start, dev->mem_end - 1);

	/* The hardware address for the 3c523 is stored in the first six
	   bytes of the IO address. */
	printk(KERN_INFO "%s: hardware address ", dev->name);
	for (i = 0; i < 6; i++) {
		dev->dev_addr[i] = inb(dev->base_addr + i);
		printk(" %02x", dev->dev_addr[i]);
	}
	printk("\n");

	dev->open = &elmc_open;
	dev->stop = &elmc_close;
	dev->get_stats = &elmc_get_stats;
	dev->hard_start_xmit = &elmc_send_packet;
	dev->tx_timeout = &elmc_timeout;
	dev->watchdog_timeo = HZ;
#ifdef ELMC_MULTICAST
	dev->set_multicast_list = &set_multicast_list;
#else
	dev->set_multicast_list = NULL;
#endif
	dev->ethtool_ops = &netdev_ethtool_ops;
	
	ether_setup(dev);

	/* note that we haven't actually requested the IRQ from the kernel.
	   That gets done in elmc_open().  I'm not sure that's such a good idea,
	   but it works, so I'll go with it. */

#ifndef ELMC_MULTICAST
        dev->flags&=~IFF_MULTICAST;     /* Multicast doesn't work */
#endif

	return 0;
err_out:
	release_region(dev->base_addr, ELMC_IO_EXTENT);
	return retval;
}
Example #7
0
int ibmlana_probe(struct net_device *dev)
{
	int force_detect = 0;
	int slot, z;
	int base = 0, irq = 0, iobase = 0, memlen = 0;
	ibmlana_priv *priv;
	ibmlana_medium medium;

	SET_MODULE_OWNER(dev);

	/* can't work without an MCA bus ;-) */
	if (MCA_bus == 0)
		return -ENODEV;

	/* start address of 1 --> forced detection */
	if (dev->mem_start == 1)
		force_detect = 1;

	/* search through slots */
	if (dev != NULL) {
		base = dev->mem_start;
		irq = dev->irq;
	}
	slot = mca_find_adapter(IBM_LANA_ID, startslot);

	while (slot != -1) {
		/* deduce card addresses */
		getaddrs(slot, &base, &memlen, &iobase, &irq, &medium);

		/* slot already in use ? */
		if (mca_is_adapter_used(slot)) {
			slot = mca_find_adapter(IBM_LANA_ID, slot + 1);
			continue;
		}
		/* were we looking for something different ? */
		if (dev->irq != 0 || dev->mem_start != 0) {
			if (dev->irq != 0 && dev->irq != irq) {
				slot = mca_find_adapter(IBM_LANA_ID, slot + 1);
				continue;
			}
			if (dev->mem_start != 0 && dev->mem_start != base) 
			{
				slot = mca_find_adapter(IBM_LANA_ID, slot + 1);
				continue;
			}
		}
		/* found something that matches */
		break;
	}

	/* nothing found ? */
	if (slot == -1)
		return (base != 0 || irq != 0) ? -ENXIO : -ENODEV;

	/* announce success */
	printk(KERN_INFO "%s: IBM LAN Adapter/A found in slot %d\n", dev->name, slot + 1);

	/* try to obtain I/O range */
	if (!request_region(iobase, IBM_LANA_IORANGE, dev->name)) {
		printk(KERN_ERR "%s: cannot allocate I/O range at %#x!\n", dev->name, iobase);
		startslot = slot + 1;
		return -EBUSY;
	}

	/* make procfs entries */
	mca_set_adapter_name(slot, "IBM LAN Adapter/A");
	mca_set_adapter_procfn(slot, (MCA_ProcFn) ibmlana_getinfo, dev);

	mca_mark_as_used(slot);

	/* allocate structure */
	priv = dev->priv = (ibmlana_priv *) kmalloc(sizeof(ibmlana_priv), GFP_KERNEL);
	if (!priv) {
		release_region(iobase, IBM_LANA_IORANGE);
		return -ENOMEM;
	}
	priv->slot = slot;
	priv->realirq = irq;
	priv->medium = medium;
	spin_lock_init(&priv->lock);
	memset(&priv->stat, 0, sizeof(struct net_device_stats));

	/* set base + irq for this device (irq not allocated so far) */

	dev->irq = 0;
	dev->mem_start = base;
	dev->mem_end = base + memlen;
	dev->base_addr = iobase;

	/* set methods */

	dev->open = ibmlana_open;
	dev->stop = ibmlana_close;
	dev->set_config = ibmlana_config;
	dev->hard_start_xmit = ibmlana_tx;
	dev->do_ioctl = NULL;
	dev->get_stats = ibmlana_stats;
	dev->set_multicast_list = ibmlana_set_multicast_list;
	dev->flags |= IFF_MULTICAST;

	/* generic setup */

	ether_setup(dev);

	/* copy out MAC address */

	for (z = 0; z < sizeof(dev->dev_addr); z++)
		dev->dev_addr[z] = inb(dev->base_addr + MACADDRPROM + z);

	/* print config */

	printk(KERN_INFO "%s: IRQ %d, I/O %#lx, memory %#lx-%#lx, "
	       "MAC address %02x:%02x:%02x:%02x:%02x:%02x.\n",
	       dev->name, priv->realirq, dev->base_addr,
	       dev->mem_start, dev->mem_end - 1,
	       dev->dev_addr[0], dev->dev_addr[1], dev->dev_addr[2],
	       dev->dev_addr[3], dev->dev_addr[4], dev->dev_addr[5]);
	printk(KERN_INFO "%s: %s medium\n", dev->name, MediaNames[priv->medium]);

	/* reset board */

	ResetBoard(dev);

	/* next probe will start at next slot */

	startslot = slot + 1;

	return 0;
}
Example #8
0
static void cleanup_card(struct net_device *dev)
{
	mca_set_adapter_procfn(((struct priv *) (dev->priv))->slot, NULL, NULL);
	release_region(dev->base_addr, ELMC_IO_EXTENT);
}
Example #9
0
static void __exit
eicon_exit(void)
{
#if CONFIG_PCI	
#ifdef CONFIG_ISDN_DRV_EICON_PCI
	card_t *pCard;
	word wCardIndex;
	extern int Divas_major;
	int iTmp = 0;
#endif
#endif
	
        eicon_card *card = cards;
        eicon_card *last;

        while (card) {
#ifdef CONFIG_ISDN_DRV_EICON_ISA
#ifdef CONFIG_MCA
        	if (MCA_bus)
                        {
                        mca_mark_as_unused (card->mca_slot);
                        mca_set_adapter_procfn(card->mca_slot, NULL, NULL);
                        };
#endif /* CONFIG_MCA */
#endif
                unregister_card(card); 
                card = card->next;
        }
        card = cards;
        while (card) {
                last = card;
                card = card->next;
		eicon_freecard(last);
        }

#if CONFIG_PCI	
#ifdef CONFIG_ISDN_DRV_EICON_PCI
	pCard = DivasCards;
	for (wCardIndex = 0; wCardIndex < MAX_CARDS; wCardIndex++)
	{
		if ((pCard->hw) && (pCard->hw->in_use))
		{
			(*pCard->card_reset)(pCard);
			
			UxIsrRemove(pCard->hw, pCard);
			UxCardHandleFree(pCard->hw);

			if(pCard->e_tbl != NULL)
			{
				kfree(pCard->e_tbl);
			}

			if(pCard->hw->card_type == DIA_CARD_TYPE_DIVA_SERVER_B)
			{
				release_region(pCard->hw->io_base,0x20);
				release_region(pCard->hw->reset_base,0x80);
			}

                        // If this is a 4BRI ...
                        if (pCard->hw->card_type == DIA_CARD_TYPE_DIVA_SERVER_Q)
                        {
                                // Skip over the next 3 virtual adapters
                                wCardIndex += 3;

                                // But free their handles
				for (iTmp = 0; iTmp < 3; iTmp++)
				{
					pCard++;
					UxCardHandleFree(pCard->hw);

					if(pCard->e_tbl != NULL)
					{
						kfree(pCard->e_tbl);
					}
				}
                        }
		}
		pCard++;
	}
	unregister_chrdev(Divas_major, "Divas");
#endif
#endif /* CONFIG_PCI */
        printk(KERN_INFO "%s unloaded\n", DRIVERNAME);
}