Exemple #1
0
static void getaddrs(int slot, int *base, int *memlen, int *iobase,
		     int *irq, ibmlana_medium * medium)
{
	u_char pos0, pos1;

	pos0 = mca_read_stored_pos(slot, 2);
	pos1 = mca_read_stored_pos(slot, 3);

	*base = 0xc0000 + ((pos1 & 0xf0) << 9);
	*memlen = (pos1 & 0x01) ? 0x8000 : 0x4000;
	*iobase = (pos0 & 0xe0) << 7;
	switch (pos0 & 0x06) {
	case 0:
		*irq = 5;
		break;
	case 2:
		*irq = 15;
		break;
	case 4:
		*irq = 10;
		break;
	case 6:
		*irq = 11;
		break;
	}
	*medium = (pos0 & 0x18) >> 3;
}
Exemple #2
0
int probe_sb(struct address_info *hw_config)
{
#ifdef CONFIG_MCA
	/* MCA code added by ZP Gu ([email protected]) */
	if (MCA_bus) {               /* no multiple REPLY card probing */
		int slot;
		u8 pos2, pos3, pos4;

		slot = mca_find_adapter( 0x5138, 0 );
		if( slot == MCA_NOTFOUND ) 
		{
			slot = mca_find_adapter( 0x5137, 0 );

			if (slot != MCA_NOTFOUND)
				mca_set_adapter_name( slot, "REPLY SB16 & SCSI Adapter" );
		}
		else
		{
			mca_set_adapter_name( slot, "REPLY SB16 Adapter" );
		}

		if (slot != MCA_NOTFOUND) 
		{
			mca_mark_as_used(slot);
			pos2 = mca_read_stored_pos( slot, 2 );
			pos3 = mca_read_stored_pos( slot, 3 );
			pos4 = mca_read_stored_pos( slot, 4 );

			if (pos2 & 0x4) 
			{
				/* enabled? */
				static unsigned short irq[] = { 0, 5, 7, 10 };
				/*
				static unsigned short midiaddr[] = {0, 0x330, 0, 0x300 };
       				*/

				hw_config->io_base = 0x220 + 0x20 * (pos2 >> 6);
				hw_config->irq = irq[(pos4 >> 5) & 0x3];
				hw_config->dma = pos3 & 0xf;
				/* Reply ADF wrong on High DMA, pos[1] should start w/ 00 */
				hw_config->dma2 = (pos3 >> 4) & 0x3;
				if (hw_config->dma2 == 0)
					hw_config->dma2 = hw_config->dma;
				else
					hw_config->dma2 += 4;
				/*
					hw_config->driver_use_2 = midiaddr[(pos2 >> 3) & 0x3];
				*/
	
				printk("SB: Reply MCA SB at slot=%d \
iobase=0x%x irq=%d lo_dma=%d hi_dma=%d\n",
						slot+1,
				        	hw_config->io_base, hw_config->irq,
	        				hw_config->dma, hw_config->dma2);
			}
			else
			{
				printk ("Reply SB Base I/O address disabled\n");
			}
		}
static int __init mc32_probe1(struct net_device *dev, int slot)
{
    static unsigned version_printed;
    int i, err;
    u8 POS;
    u32 base;
    struct mc32_local *lp = netdev_priv(dev);
    static u16 mca_io_bases[]= {
        0x7280,0x7290,
        0x7680,0x7690,
        0x7A80,0x7A90,
        0x7E80,0x7E90
    };
    static u32 mca_mem_bases[]= {
        0x00C0000,
        0x00C4000,
        0x00C8000,
        0x00CC000,
        0x00D0000,
        0x00D4000,
        0x00D8000,
        0x00DC000
    };
    static char *failures[]= {
        "Processor instruction",
        "Processor data bus",
        "Processor data bus",
        "Processor data bus",
        "Adapter bus",
        "ROM checksum",
        "Base RAM",
        "Extended RAM",
        "82586 internal loopback",
        "82586 initialisation failure",
        "Adapter list configuration error"
    };

    /* Time to play MCA games */

    if (mc32_debug  &&  version_printed++ == 0)
        printk(KERN_DEBUG "%s", version);

    printk(KERN_INFO "%s: %s found in slot %d:", dev->name, cardname, slot);

    POS = mca_read_stored_pos(slot, 2);

    if(!(POS&1))
    {
        printk(" disabled.\n");
        return -ENODEV;
    }

    /* Fill in the 'dev' fields. */
    dev->base_addr = mca_io_bases[(POS>>1)&7];
    dev->mem_start = mca_mem_bases[(POS>>4)&7];

    POS = mca_read_stored_pos(slot, 4);
    if(!(POS&1))
    {
        printk("memory window disabled.\n");
        return -ENODEV;
    }

    POS = mca_read_stored_pos(slot, 5);

    i=(POS>>4)&3;
    if(i==3)
    {
        printk("invalid memory window.\n");
        return -ENODEV;
    }

    i*=16384;
    i+=16384;

    dev->mem_end=dev->mem_start + i;

    dev->irq = ((POS>>2)&3)+9;

    if(!request_region(dev->base_addr, MC32_IO_EXTENT, cardname))
    {
        printk("io 0x%3lX, which is busy.\n", dev->base_addr);
        return -EBUSY;
    }

    printk("io 0x%3lX irq %d mem 0x%lX (%dK)\n",
           dev->base_addr, dev->irq, dev->mem_start, i/1024);


    /* We ought to set the cache line size here.. */


    /*
     *	Go PROM browsing
     */

    /* Retrieve and print the ethernet address. */
    for (i = 0; i < 6; i++)
    {
        mca_write_pos(slot, 6, i+12);
        mca_write_pos(slot, 7, 0);

        dev->dev_addr[i] = mca_read_pos(slot,3);
    }

    printk("%s: Address %pM", dev->name, dev->dev_addr);

    mca_write_pos(slot, 6, 0);
    mca_write_pos(slot, 7, 0);

    POS = mca_read_stored_pos(slot, 4);

    if(POS&2)
        printk(" : BNC port selected.\n");
    else
        printk(" : AUI port selected.\n");

    POS=inb(dev->base_addr+HOST_CTRL);
    POS|=HOST_CTRL_ATTN|HOST_CTRL_RESET;
    POS&=~HOST_CTRL_INTE;
    outb(POS, dev->base_addr+HOST_CTRL);
    /* Reset adapter */
    udelay(100);
    /* Reset off */
    POS&=~(HOST_CTRL_ATTN|HOST_CTRL_RESET);
    outb(POS, dev->base_addr+HOST_CTRL);

    udelay(300);

    /*
     *	Grab the IRQ
     */

    err = request_irq(dev->irq, &mc32_interrupt, IRQF_SHARED | IRQF_SAMPLE_RANDOM, DRV_NAME, dev);
    if (err) {
        release_region(dev->base_addr, MC32_IO_EXTENT);
        printk(KERN_ERR "%s: unable to get IRQ %d.\n", DRV_NAME, dev->irq);
        goto err_exit_ports;
    }

    memset(lp, 0, sizeof(struct mc32_local));
    lp->slot = slot;

    i=0;

    base = inb(dev->base_addr);

    while(base == 0xFF)
    {
        i++;
        if(i == 1000)
        {
            printk(KERN_ERR "%s: failed to boot adapter.\n", dev->name);
            err = -ENODEV;
            goto err_exit_irq;
        }
        udelay(1000);
        if(inb(dev->base_addr+2)&(1<<5))
            base = inb(dev->base_addr);
    }

    if(base>0)
    {
        if(base < 0x0C)
            printk(KERN_ERR "%s: %s%s.\n", dev->name, failures[base-1],
                   base<0x0A?" test failure":"");
        else
            printk(KERN_ERR "%s: unknown failure %d.\n", dev->name, base);
        err = -ENODEV;
        goto err_exit_irq;
    }

    base=0;
    for(i=0; i<4; i++)
    {
        int n=0;

        while(!(inb(dev->base_addr+2)&(1<<5)))
        {
            n++;
            udelay(50);
            if(n>100)
            {
                printk(KERN_ERR "%s: mailbox read fail (%d).\n", dev->name, i);
                err = -ENODEV;
                goto err_exit_irq;
            }
        }

        base|=(inb(dev->base_addr)<<(8*i));
    }

    lp->exec_box=isa_bus_to_virt(dev->mem_start+base);

    base=lp->exec_box->data[1]<<16|lp->exec_box->data[0];

    lp->base = dev->mem_start+base;

    lp->rx_box=isa_bus_to_virt(lp->base + lp->exec_box->data[2]);
    lp->tx_box=isa_bus_to_virt(lp->base + lp->exec_box->data[3]);

    lp->stats = isa_bus_to_virt(lp->base + lp->exec_box->data[5]);

    /*
     *	Descriptor chains (card relative)
     */

    lp->tx_chain 		= lp->exec_box->data[8];   /* Transmit list start offset */
    lp->rx_chain 		= lp->exec_box->data[10];  /* Receive list start offset */
    lp->tx_len 		= lp->exec_box->data[9];   /* Transmit list count */
    lp->rx_len 		= lp->exec_box->data[11];  /* Receive list count */

    init_MUTEX_LOCKED(&lp->cmd_mutex);
    init_completion(&lp->execution_cmd);
    init_completion(&lp->xceiver_cmd);

    printk("%s: Firmware Rev %d. %d RX buffers, %d TX buffers. Base of 0x%08X.\n",
           dev->name, lp->exec_box->data[12], lp->rx_len, lp->tx_len, lp->base);

    dev->open		= mc32_open;
    dev->stop		= mc32_close;
    dev->hard_start_xmit	= mc32_send_packet;
    dev->get_stats		= mc32_get_stats;
    dev->set_multicast_list = mc32_set_multicast_list;
    dev->tx_timeout		= mc32_timeout;
    dev->watchdog_timeo	= HZ*5;	/* Board does all the work */
    dev->ethtool_ops	= &netdev_ethtool_ops;

    return 0;

err_exit_irq:
    free_irq(dev->irq, dev);
err_exit_ports:
    release_region(dev->base_addr, MC32_IO_EXTENT);
    return err;
}
Exemple #4
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;
}