Esempio n. 1
0
static int
ex_isa_attach(device_t dev)
{
    struct ex_softc *	sc = device_get_softc(dev);
    int			error = 0;
    u_int16_t		temp;

    sc->dev = dev;
    sc->ioport_rid = 0;
    sc->irq_rid = 0;

    if ((error = ex_alloc_resources(dev)) != 0) {
        device_printf(dev, "ex_alloc_resources() failed!\n");
        goto bad;
    }

    /*
     * Fill in several fields of the softc structure:
     *	- I/O base address.
     *	- Hardware Ethernet address.
     *	- IRQ number (if not supplied in config file, read it from EEPROM).
     *	- Connector type.
     */
    sc->iobase = rman_get_start(sc->ioport);
    sc->irq_no = rman_get_start(sc->irq);

    ex_get_address(sc->iobase, sc->arpcom.ac_enaddr);

    temp = eeprom_read(sc->iobase, EE_W0);
    device_printf(sc->dev, "%s config, %s bus, ",
                  (temp & EE_W0_PNP) ? "PnP" : "Manual",
                  (temp & EE_W0_BUS16) ? "16-bit" : "8-bit");

    temp = eeprom_read(sc->iobase, EE_W6);
    printf("board id 0x%03x, stepping 0x%01x\n",
           (temp & EE_W6_BOARD_MASK) >> EE_W6_BOARD_SHIFT,
           temp & EE_W6_STEP_MASK);

    if ((error = ex_attach(dev)) != 0) {
        device_printf(dev, "ex_attach() failed!\n");
        goto bad;
    }

    error = bus_setup_intr(dev, sc->irq, INTR_TYPE_NET,
                           ex_intr, (void *)sc, &sc->ih);
    if (error) {
        device_printf(dev, "bus_setup_intr() failed!\n");
        goto bad;
    }

    return(0);
bad:
    ex_release_resources(dev);
    return (error);
}
static int
ex_pccard_attach(device_t dev)
{
	struct ex_softc *	sc = device_get_softc(dev);
	int			error = 0;
	u_char			ether_addr[ETHER_ADDR_LEN];

	sc->dev = dev;
	sc->ioport_rid = 0;
	sc->irq_rid = 0;

	if ((error = ex_alloc_resources(dev)) != 0) {
		device_printf(dev, "ex_alloc_resources() failed!\n");
		goto bad;
	}

	/*
	 * Fill in several fields of the softc structure:
	 *	- Hardware Ethernet address.
	 *	- IRQ number.
	 */
	sc->irq_no = rman_get_start(sc->irq);

	/* Try to get the ethernet address from the chip, then the CIS */
	ex_get_address(sc, ether_addr);
	if (!ex_pccard_enet_ok(ether_addr))
		pccard_get_ether(dev, ether_addr);
	if (!ex_pccard_enet_ok(ether_addr))
		ex_pccard_get_silicom_mac(dev, ether_addr);
	if (!ex_pccard_enet_ok(ether_addr)) {
		device_printf(dev, "No NIC address found.\n");
		error = ENXIO;
		goto bad;
	}
	bcopy(ether_addr, sc->enaddr, ETHER_ADDR_LEN);

	if ((error = ex_attach(dev)) != 0) {
		device_printf(dev, "ex_attach() failed!\n");
		goto bad;
	}

	return(0);
bad:
	ex_release_resources(dev);
	return (error);
}
Esempio n. 3
0
static int
ex_isa_probe(device_t dev)
{
    u_int		iobase;
    u_int		irq;
    char *		irq2ee;
    u_char *	ee2irq;
    u_char 		enaddr[6];
    int		tmp;
    int		error;

    /* Check isapnp ids */
    error = ISA_PNP_PROBE(device_get_parent(dev), dev, ex_ids);

    /* If the card had a PnP ID that didn't match any we know about */
    if (error == ENXIO) {
        return(error);
    }

    /* If we had some other problem. */
    if (!(error == 0 || error == ENOENT)) {
        return(error);
    }

    iobase = bus_get_resource_start(dev, SYS_RES_IOPORT, 0);
    if (!iobase) {
        printf("ex: no iobase?\n");
        return(ENXIO);
    }

    if (!look_for_card(iobase)) {
        printf("ex: no card found at 0x%03x\n", iobase);
        return(ENXIO);
    }

    if (bootverbose)
        printf("ex: ex_isa_probe() found card at 0x%03x\n", iobase);

    /*
     * Reset the card.
     */
    outb(iobase + CMD_REG, Reset_CMD);
    DELAY(800);

    ex_get_address(iobase, enaddr);

    /* work out which set of irq <-> internal tables to use */
    if (ex_card_type(enaddr) == CARD_TYPE_EX_10_PLUS) {
        irq2ee = plus_irq2eemap;
        ee2irq = plus_ee2irqmap;
    } else {
        irq2ee = irq2eemap;
        ee2irq = ee2irqmap;
    }

    tmp = eeprom_read(iobase, EE_W1) & EE_W1_INT_SEL;
    irq = bus_get_resource_start(dev, SYS_RES_IRQ, 0);

    if (irq > 0) {
        /* This will happen if board is in PnP mode. */
        if (ee2irq[tmp] != irq) {
            printf("ex: WARNING: board's EEPROM is configured"
                   " for IRQ %d, using %d\n",
                   ee2irq[tmp], irq);
        }
    } else {
        irq = ee2irq[tmp];
        bus_set_resource(dev, SYS_RES_IRQ, 0, irq, 1);
    }

    if (irq == 0) {
        printf("ex: invalid IRQ.\n");
        return(ENXIO);
    }

    return(0);
}
Esempio n. 4
0
/*
 * Non-destructive identify.
 */
static void
ex_isa_identify (driver_t *driver, device_t parent)
{
    device_t	child;
    u_int32_t	ioport;
    u_char 		enaddr[6];
    u_int		irq;
    int		tmp;
    const char *	desc;

    if (bootverbose)
        printf("ex_isa_identify()\n");

    for (ioport = 0x200; ioport < 0x3a0; ioport += 0x10) {

        /* No board found at address */
        if (!look_for_card(ioport)) {
            continue;
        }

        if (bootverbose)
            printf("ex: Found card at 0x%03x!\n", ioport);

        /* Board in PnP mode */
        if (eeprom_read(ioport, EE_W0) & EE_W0_PNP) {
            /* Reset the card. */
            outb(ioport + CMD_REG, Reset_CMD);
            DELAY(500);
            if (bootverbose)
                printf("ex: card at 0x%03x in PnP mode!\n", ioport);
            continue;
        }

        bzero(enaddr, sizeof(enaddr));

        /* Reset the card. */
        outb(ioport + CMD_REG, Reset_CMD);
        DELAY(400);

        ex_get_address(ioport, enaddr);
        tmp = eeprom_read(ioport, EE_W1) & EE_W1_INT_SEL;

        /* work out which set of irq <-> internal tables to use */
        if (ex_card_type(enaddr) == CARD_TYPE_EX_10_PLUS) {
            irq  = plus_ee2irqmap[tmp];
            desc = "Intel Pro/10+";
        } else {
            irq = ee2irqmap[tmp];
            desc = "Intel Pro/10";
        }

        child = BUS_ADD_CHILD(parent, ISA_ORDER_SPECULATIVE, "ex", -1);
        device_set_desc_copy(child, desc);
        device_set_driver(child, driver);
        bus_set_resource(child, SYS_RES_IRQ, 0, irq, 1);
        bus_set_resource(child, SYS_RES_IOPORT, 0, ioport, EX_IOSIZE);

        if (bootverbose)
            printf("ex: Adding board at 0x%03x, irq %d\n", ioport, irq);
    }

    return;
}
Esempio n. 5
0
static int
ex_isa_probe(device_t dev)
{
	bus_addr_t	iobase;
	u_int		irq;
	char *		irq2ee;
	u_char *	ee2irq;
	u_char 		enaddr[6];
	int		tmp;
	int		error;
	struct ex_softc *sc = device_get_softc(dev);

	/* Check isapnp ids */
	error = ISA_PNP_PROBE(device_get_parent(dev), dev, ex_ids);

	/* If the card had a PnP ID that didn't match any we know about */
	if (error == ENXIO)
		return(error);

	/* If we had some other problem. */
	if (!(error == 0 || error == ENOENT))
		return(error);

	error = ex_alloc_resources(dev);
	if (error != 0)
		goto bad;
	iobase = bus_get_resource_start(dev, SYS_RES_IOPORT, 0);
	if (!ex_look_for_card(sc)) {
		if (bootverbose)
			printf("ex: no card found at 0x%03lx.\n", (unsigned long)iobase);
		error = ENXIO;
		goto bad;
	}
	if (bootverbose)
		printf("ex: ex_isa_probe() found card at 0x%03lx\n", (unsigned long)iobase);

	/*
	 * Reset the card.
	 */
	CSR_WRITE_1(sc, CMD_REG, Reset_CMD);
	DELAY(800);

	ex_get_address(sc, enaddr);

	/* work out which set of irq <-> internal tables to use */
	if (ex_card_type(enaddr) == CARD_TYPE_EX_10_PLUS) {
		irq2ee = plus_irq2eemap;
		ee2irq = plus_ee2irqmap;
	} else {
		irq2ee = irq2eemap;
		ee2irq = ee2irqmap;
	}

	tmp = ex_eeprom_read(sc, EE_W1) & EE_W1_INT_SEL;
	irq = bus_get_resource_start(dev, SYS_RES_IRQ, 0);
	if (irq > 0) {
		/* This will happen if board is in PnP mode. */
		if (ee2irq[tmp] != irq) {
			device_printf(dev,
			    "WARNING: IRQ mismatch: EEPROM %d, using %d\n",
				ee2irq[tmp], irq);
		}
	} else {
		irq = ee2irq[tmp];
		bus_set_resource(dev, SYS_RES_IRQ, 0, irq, 1);
	}

	if (irq == 0) {
		printf("ex: invalid IRQ.\n");
		error = ENXIO;
	}

bad:;
	ex_release_resources(dev);
	return (error);
}
Esempio n. 6
0
/*
 * Non-destructive identify.
 */
static void
ex_isa_identify(driver_t *driver, device_t parent)
{
	device_t	child;
	bus_addr_t	ioport;
	u_char 		enaddr[6];
	u_int		irq;
	int		tmp;
	const char *	desc;
	struct ex_softc sc;
	int		rid;

	if (bootverbose)
		printf("ex_isa_identify()\n");

	for (ioport = 0x200; ioport < 0x3a0; ioport += 0x10) {
		rid = 0;
		sc.ioport = bus_alloc_resource(parent, SYS_RES_IOPORT, &rid,
		    ioport, ioport, 0x10, RF_ACTIVE);
		if (sc.ioport == NULL)
			continue;

		/* No board found at address */
		if (!ex_look_for_card(&sc)) {
			bus_release_resource(parent, SYS_RES_IOPORT, rid,
			    sc.ioport);
			continue;
		}

		if (bootverbose)
			printf("ex: Found card at 0x%03lx!\n", (unsigned long)ioport);

		/* Board in PnP mode */
		if (ex_eeprom_read(&sc, EE_W0) & EE_W0_PNP) {
			/* Reset the card. */
			CSR_WRITE_1(&sc, CMD_REG, Reset_CMD);
			DELAY(500);
			if (bootverbose)
				printf("ex: card at 0x%03lx in PnP mode!\n", (unsigned long)ioport);
			bus_release_resource(parent, SYS_RES_IOPORT, rid,
			    sc.ioport);
			continue;
		}

		bzero(enaddr, sizeof(enaddr));

		/* Reset the card. */
		CSR_WRITE_1(&sc, CMD_REG, Reset_CMD);
		DELAY(400);

		ex_get_address(&sc, enaddr);
		tmp = ex_eeprom_read(&sc, EE_W1) & EE_W1_INT_SEL;

		/* work out which set of irq <-> internal tables to use */
		if (ex_card_type(enaddr) == CARD_TYPE_EX_10_PLUS) {
			irq  = plus_ee2irqmap[tmp];
			desc = "Intel Pro/10+";
		} else {
			irq = ee2irqmap[tmp];
			desc = "Intel Pro/10";
		}

		bus_release_resource(parent, SYS_RES_IOPORT, rid, sc.ioport);
		child = BUS_ADD_CHILD(parent, ISA_ORDER_SPECULATIVE, "ex", -1);
		device_set_desc_copy(child, desc);
		device_set_driver(child, driver);
		bus_set_resource(child, SYS_RES_IRQ, 0, irq, 1);
		bus_set_resource(child, SYS_RES_IOPORT, 0, ioport, EX_IOSIZE);
		if (bootverbose)
			printf("ex: Adding board at 0x%03lx, irq %d\n",
			   (unsigned long)ioport, irq);
	}

	return;
}