예제 #1
0
static void mcf8390_block_output(struct net_device *dev, int count,
				 const unsigned char *buf,
				 const int start_page)
{
	struct ei_device *ei_local = netdev_priv(dev);
	u32 addr = dev->base_addr;
	unsigned long dma_start;

	/* Make sure we transfer all bytes if 16bit IO writes */
	if (count & 0x1)
		count++;

	if (ei_local->dmaing) {
		mcf8390_dmaing_err(__func__, dev, ei_local);
		return;
	}

	ei_local->dmaing |= 0x01;
	/* We should already be in page 0, but to be safe... */
	ei_outb(E8390_PAGE0 + E8390_START + E8390_NODMA, addr + NE_CMD);

	ei_outb(ENISR_RDC, addr + NE_EN0_ISR);

	/* Now the normal output. */
	ei_outb(count & 0xff, addr + NE_EN0_RCNTLO);
	ei_outb(count >> 8, addr + NE_EN0_RCNTHI);
	ei_outb(0x00, addr + NE_EN0_RSARLO);
	ei_outb(start_page, addr + NE_EN0_RSARHI);
	ei_outb(E8390_RWRITE + E8390_START, addr + NE_CMD);

	ei_outsw(addr + NE_DATAPORT, buf, count >> 1);

	dma_start = jiffies;
	while ((ei_inb(addr + NE_EN0_ISR) & ENISR_RDC) == 0) {
		if (time_after(jiffies, dma_start + 2 * HZ / 100)) { /* 20ms */
			netdev_warn(dev, "timeout waiting for Tx RDC\n");
			mcf8390_reset_8390(dev);
			__NS8390_init(dev, 1);
			break;
		}
	}

	ei_outb(ENISR_RDC, addr + NE_EN0_ISR);	/* Ack intr */
	ei_local->dmaing &= ~0x01;
}
예제 #2
0
void NS8390_init(struct net_device *dev, int startp)
{
	__NS8390_init(dev, startp);
}
예제 #3
0
static int __devinit hydra_init(struct zorro_dev *z)
{
    struct net_device *dev;
    unsigned long board = ZTWO_VADDR(z->resource.start);
    unsigned long ioaddr = board+HYDRA_NIC_BASE;
    const char name[] = "NE2000";
    int start_page, stop_page;
    int j;
    int err;

    static u32 hydra_offsets[16] = {
        0x00, 0x02, 0x04, 0x06, 0x08, 0x0a, 0x0c, 0x0e,
        0x10, 0x12, 0x14, 0x16, 0x18, 0x1a, 0x1c, 0x1e,
    };

    dev = ____alloc_ei_netdev(0);
    if (!dev)
        return -ENOMEM;

    for(j = 0; j < ETHER_ADDR_LEN; j++)
        dev->dev_addr[j] = *((u8 *)(board + HYDRA_ADDRPROM + 2*j));

    /* We must set the 8390 for word mode. */
    z_writeb(0x4b, ioaddr + NE_EN0_DCFG);
    start_page = NESM_START_PG;
    stop_page = NESM_STOP_PG;

    dev->base_addr = ioaddr;
    dev->irq = IRQ_AMIGA_PORTS;

    /* Install the Interrupt handler */
    if (request_irq(IRQ_AMIGA_PORTS, __ei_interrupt, IRQF_SHARED, "Hydra Ethernet",
                    dev)) {
        free_netdev(dev);
        return -EAGAIN;
    }

    ei_status.name = name;
    ei_status.tx_start_page = start_page;
    ei_status.stop_page = stop_page;
    ei_status.word16 = 1;
    ei_status.bigendian = 1;

    ei_status.rx_start_page = start_page + TX_PAGES;

    ei_status.reset_8390 = hydra_reset_8390;
    ei_status.block_input = hydra_block_input;
    ei_status.block_output = hydra_block_output;
    ei_status.get_8390_hdr = hydra_get_8390_hdr;
    ei_status.reg_offset = hydra_offsets;

    dev->netdev_ops = &hydra_netdev_ops;
    __NS8390_init(dev, 0);

    err = register_netdev(dev);
    if (err) {
        free_irq(IRQ_AMIGA_PORTS, dev);
        free_netdev(dev);
        return err;
    }

    zorro_set_drvdata(z, dev);

    pr_info("%s: Hydra at %pR, address %pM (hydra.c " HYDRA_VERSION ")\n",
            dev->name, &z->resource, dev->dev_addr);

    return 0;
}
예제 #4
0
static int zorro8390_init(struct net_device *dev, unsigned long board,
			  const char *name, void __iomem *ioaddr)
{
	int i;
	int err;
	unsigned char SA_prom[32];
	int start_page, stop_page;
	struct ei_device *ei_local = netdev_priv(dev);
	static u32 zorro8390_offsets[16] = {
		0x00, 0x02, 0x04, 0x06, 0x08, 0x0a, 0x0c, 0x0e,
		0x10, 0x12, 0x14, 0x16, 0x18, 0x1a, 0x1c, 0x1e,
	};

	/* Reset card. Who knows what dain-bramaged state it was left in. */
	{
		unsigned long reset_start_time = jiffies;

		z_writeb(z_readb(ioaddr + NE_RESET), ioaddr + NE_RESET);

		while ((z_readb(ioaddr + NE_EN0_ISR) & ENISR_RESET) == 0)
			if (time_after(jiffies,
				       reset_start_time + 2 * HZ / 100)) {
				netdev_warn(dev, "not found (no reset ack)\n");
				return -ENODEV;
			}

		z_writeb(0xff, ioaddr + NE_EN0_ISR);	/* Ack all intr. */
	}

	/* Read the 16 bytes of station address PROM.
	 * We must first initialize registers,
	 * similar to NS8390_init(eifdev, 0).
	 * We can't reliably read the SAPROM address without this.
	 * (I learned the hard way!).
	 */
	{
		static const struct {
			u32 value;
			u32 offset;
		} program_seq[] = {
			{E8390_NODMA + E8390_PAGE0 + E8390_STOP, NE_CMD},
						/* Select page 0 */
			{0x48,	NE_EN0_DCFG},	/* 0x48: Set byte-wide access */
			{0x00,	NE_EN0_RCNTLO},	/* Clear the count regs */
			{0x00,	NE_EN0_RCNTHI},
			{0x00,	NE_EN0_IMR},	/* Mask completion irq */
			{0xFF,	NE_EN0_ISR},
			{E8390_RXOFF, NE_EN0_RXCR}, /* 0x20 Set to monitor */
			{E8390_TXOFF, NE_EN0_TXCR}, /* 0x02 and loopback mode */
			{32,	NE_EN0_RCNTLO},
			{0x00,	NE_EN0_RCNTHI},
			{0x00,	NE_EN0_RSARLO},	/* DMA starting at 0x0000 */
			{0x00,	NE_EN0_RSARHI},
			{E8390_RREAD + E8390_START, NE_CMD},
		};
		for (i = 0; i < ARRAY_SIZE(program_seq); i++)
			z_writeb(program_seq[i].value,
				 ioaddr + program_seq[i].offset);
	}
	for (i = 0; i < 16; i++) {
		SA_prom[i] = z_readb(ioaddr + NE_DATAPORT);
		(void)z_readb(ioaddr + NE_DATAPORT);
	}

	/* We must set the 8390 for word mode. */
	z_writeb(0x49, ioaddr + NE_EN0_DCFG);
	start_page = NESM_START_PG;
	stop_page = NESM_STOP_PG;

	dev->base_addr = (unsigned long)ioaddr;
	dev->irq = IRQ_AMIGA_PORTS;

	/* Install the Interrupt handler */
	i = request_irq(IRQ_AMIGA_PORTS, __ei_interrupt,
			IRQF_SHARED, DRV_NAME, dev);
	if (i)
		return i;

	for (i = 0; i < ETH_ALEN; i++)
		dev->dev_addr[i] = SA_prom[i];

	pr_debug("Found ethernet address: %pM\n", dev->dev_addr);

	ei_status.name = name;
	ei_status.tx_start_page = start_page;
	ei_status.stop_page = stop_page;
	ei_status.word16 = 1;

	ei_status.rx_start_page = start_page + TX_PAGES;

	ei_status.reset_8390 = zorro8390_reset_8390;
	ei_status.block_input = zorro8390_block_input;
	ei_status.block_output = zorro8390_block_output;
	ei_status.get_8390_hdr = zorro8390_get_8390_hdr;
	ei_status.reg_offset = zorro8390_offsets;

	dev->netdev_ops = &zorro8390_netdev_ops;
	__NS8390_init(dev, 0);

	ei_local->msg_enable = zorro8390_msg_enable;

	err = register_netdev(dev);
	if (err) {
		free_irq(IRQ_AMIGA_PORTS, dev);
		return err;
	}

	netdev_info(dev, "%s at 0x%08lx, Ethernet Address %pM\n",
		    name, board, dev->dev_addr);

	return 0;
}
예제 #5
0
static int mcf8390_init(struct net_device *dev)
{
	static u32 offsets[] = {
		0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
		0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
	};
	struct ei_device *ei_local = netdev_priv(dev);
	unsigned char SA_prom[32];
	u32 addr = dev->base_addr;
	int start_page, stop_page;
	int i, ret;

	mcf8390_reset_8390(dev);

	/*
	 * Read the 16 bytes of station address PROM.
	 * We must first initialize registers,
	 * similar to NS8390_init(eifdev, 0).
	 * We can't reliably read the SAPROM address without this.
	 * (I learned the hard way!).
	 */
	{
		static const struct {
			u32 value;
			u32 offset;
		} program_seq[] = {
			{E8390_NODMA + E8390_PAGE0 + E8390_STOP, NE_CMD},
						/* Select page 0 */
			{0x48,	NE_EN0_DCFG},	/* 0x48: Set byte-wide access */
			{0x00,	NE_EN0_RCNTLO},	/* Clear the count regs */
			{0x00,	NE_EN0_RCNTHI},
			{0x00,	NE_EN0_IMR},	/* Mask completion irq */
			{0xFF,	NE_EN0_ISR},
			{E8390_RXOFF, NE_EN0_RXCR}, /* 0x20 Set to monitor */
			{E8390_TXOFF, NE_EN0_TXCR}, /* 0x02 and loopback mode */
			{32,	NE_EN0_RCNTLO},
			{0x00,	NE_EN0_RCNTHI},
			{0x00,	NE_EN0_RSARLO},	/* DMA starting at 0x0000 */
			{0x00,	NE_EN0_RSARHI},
			{E8390_RREAD + E8390_START, NE_CMD},
		};
		for (i = 0; i < ARRAY_SIZE(program_seq); i++) {
			ei_outb(program_seq[i].value,
				 addr + program_seq[i].offset);
		}
	}

	for (i = 0; i < 16; i++) {
		SA_prom[i] = ei_inb(addr + NE_DATAPORT);
		ei_inb(addr + NE_DATAPORT);
	}

	/* We must set the 8390 for word mode. */
	ei_outb(0x49, addr + NE_EN0_DCFG);
	start_page = NESM_START_PG;
	stop_page = NESM_STOP_PG;

	/* Install the Interrupt handler */
	ret = request_irq(dev->irq, __ei_interrupt, 0, dev->name, dev);
	if (ret)
		return ret;

	for (i = 0; i < ETH_ALEN; i++)
		dev->dev_addr[i] = SA_prom[i];

	netdev_dbg(dev, "Found ethernet address: %pM\n", dev->dev_addr);

	ei_local->name = "mcf8390";
	ei_local->tx_start_page = start_page;
	ei_local->stop_page = stop_page;
	ei_local->word16 = 1;
	ei_local->rx_start_page = start_page + TX_PAGES;
	ei_local->reset_8390 = mcf8390_reset_8390;
	ei_local->block_input = mcf8390_block_input;
	ei_local->block_output = mcf8390_block_output;
	ei_local->get_8390_hdr = mcf8390_get_8390_hdr;
	ei_local->reg_offset = offsets;

	dev->netdev_ops = &mcf8390_netdev_ops;
	__NS8390_init(dev, 0);
	ret = register_netdev(dev);
	if (ret) {
		free_irq(dev->irq, dev);
		return ret;
	}

	netdev_info(dev, "addr=0x%08x irq=%d, Ethernet Address %pM\n",
		addr, dev->irq, dev->dev_addr);
	return 0;
}
예제 #6
0
static int __init mac8390_initdev(struct net_device * dev, struct nubus_dev * ndev,
                                  enum mac8390_type type)
{
    static u32 fwrd4_offsets[16]= {
        0,      4,      8,      12,
        16,     20,     24,     28,
        32,     36,     40,     44,
        48,     52,     56,     60
    };
    static u32 back4_offsets[16]= {
        60,     56,     52,     48,
        44,     40,     36,     32,
        28,     24,     20,     16,
        12,     8,      4,      0
    };
    static u32 fwrd2_offsets[16]= {
        0,      2,      4,      6,
        8,     10,     12,     14,
        16,    18,     20,     22,
        24,    26,     28,     30
    };

    int access_bitmode = 0;

    /* Now fill in our stuff */
    dev->netdev_ops = &mac8390_netdev_ops;

    /* GAR, ei_status is actually a macro even though it looks global */
    ei_status.name = cardname[type];
    ei_status.word16 = word16[type];

    /* Cabletron's TX/RX buffers are backwards */
    if (type == MAC8390_CABLETRON) {
        ei_status.tx_start_page = CABLETRON_TX_START_PG;
        ei_status.rx_start_page = CABLETRON_RX_START_PG;
        ei_status.stop_page = CABLETRON_RX_STOP_PG;
        ei_status.rmem_start = dev->mem_start;
        ei_status.rmem_end = dev->mem_start + CABLETRON_RX_STOP_PG*256;
    } else {
        ei_status.tx_start_page = WD_START_PG;
        ei_status.rx_start_page = WD_START_PG + TX_PAGES;
        ei_status.stop_page = (dev->mem_end - dev->mem_start)/256;
        ei_status.rmem_start = dev->mem_start + TX_PAGES*256;
        ei_status.rmem_end = dev->mem_end;
    }

    /* Fill in model-specific information and functions */
    switch(type) {
    case MAC8390_FARALLON:
    case MAC8390_APPLE:
        switch(mac8390_testio(dev->mem_start)) {
        case ACCESS_UNKNOWN:
            printk("Don't know how to access card memory!\n");
            return -ENODEV;
            break;

        case ACCESS_16:
            /* 16 bit card, register map is reversed */
            ei_status.reset_8390 = &mac8390_no_reset;
            ei_status.block_input = &slow_sane_block_input;
            ei_status.block_output = &slow_sane_block_output;
            ei_status.get_8390_hdr = &slow_sane_get_8390_hdr;
            ei_status.reg_offset = back4_offsets;
            break;

        case ACCESS_32:
            /* 32 bit card, register map is reversed */
            ei_status.reset_8390 = &mac8390_no_reset;
            ei_status.block_input = &sane_block_input;
            ei_status.block_output = &sane_block_output;
            ei_status.get_8390_hdr = &sane_get_8390_hdr;
            ei_status.reg_offset = back4_offsets;
            access_bitmode = 1;
            break;
        }
        break;

    case MAC8390_ASANTE:
        /* Some Asante cards pass the 32 bit test
         * but overwrite system memory when run at 32 bit.
         * so we run them all at 16 bit.
         */
        ei_status.reset_8390 = &mac8390_no_reset;
        ei_status.block_input = &slow_sane_block_input;
        ei_status.block_output = &slow_sane_block_output;
        ei_status.get_8390_hdr = &slow_sane_get_8390_hdr;
        ei_status.reg_offset = back4_offsets;
        break;

    case MAC8390_CABLETRON:
        /* 16 bit card, register map is short forward */
        ei_status.reset_8390 = &mac8390_no_reset;
        ei_status.block_input = &slow_sane_block_input;
        ei_status.block_output = &slow_sane_block_output;
        ei_status.get_8390_hdr = &slow_sane_get_8390_hdr;
        ei_status.reg_offset = fwrd2_offsets;
        break;

    case MAC8390_DAYNA:
    case MAC8390_KINETICS:
        /* 16 bit memory, register map is forward */
        /* dayna and similar */
        ei_status.reset_8390 = &mac8390_no_reset;
        ei_status.block_input = &dayna_block_input;
        ei_status.block_output = &dayna_block_output;
        ei_status.get_8390_hdr = &dayna_get_8390_hdr;
        ei_status.reg_offset = fwrd4_offsets;
        break;

    case MAC8390_INTERLAN:
        /* 16 bit memory, register map is forward */
        ei_status.reset_8390 = &interlan_reset;
        ei_status.block_input = &slow_sane_block_input;
        ei_status.block_output = &slow_sane_block_output;
        ei_status.get_8390_hdr = &slow_sane_get_8390_hdr;
        ei_status.reg_offset = fwrd4_offsets;
        break;

    default:
        printk(KERN_ERR "Card type %s is unsupported, sorry\n", ndev->board->name);
        return -ENODEV;
    }

    __NS8390_init(dev, 0);

    /* Good, done, now spit out some messages */
    printk(KERN_INFO "%s: %s in slot %X (type %s)\n",
           dev->name, ndev->board->name, ndev->board->slot, cardname[type]);
    printk(KERN_INFO "MAC ");
    {
        int i;
        for (i = 0; i < 6; i++) {
            printk("%2.2x", dev->dev_addr[i]);
            if (i < 5)
                printk(":");
        }
    }
    printk(" IRQ %d, %d KB shared memory at %#lx,  %d-bit access.\n",
           dev->irq, (int)((dev->mem_end - dev->mem_start)/0x1000) * 4,
           dev->mem_start, access_bitmode?32:16);
    return 0;
}