Exemplo n.º 1
0
/*
 * Attach all the sub-devices we can find
 */
static void
bha_eisa_attach(device_t parent, device_t self, void *aux)
{
	struct eisa_attach_args *ea = aux;
	struct bha_softc *sc = device_private(self);
	bus_space_tag_t iot = ea->ea_iot;
	bus_space_handle_t ioh, ioh2;
	int port;
	struct bha_probe_data bpd;
	eisa_chipset_tag_t ec = ea->ea_ec;
	eisa_intr_handle_t ih;
	const char *model, *intrstr;

	sc->sc_dev = self;

	if (!strcmp(ea->ea_idstring, "BUS4201"))
		model = EISA_PRODUCT_BUS4201;
	else if (!strcmp(ea->ea_idstring, "BUS4202"))
		model = EISA_PRODUCT_BUS4202;
	else
		model = "unknown model!";
	printf(": %s\n", model);

	if (bus_space_map(iot,
	    EISA_SLOT_ADDR(ea->ea_slot) + BHA_EISA_SLOT_OFFSET, BHA_EISA_IOSIZE,
	    0, &ioh))
		panic("bha_eisa_attach: could not map EISA slot");

	if (bha_eisa_address(iot, ioh, &port) ||
	    bus_space_map(iot, port, BHA_ISA_IOSIZE, 0, &ioh2))
		panic("bha_eisa_attach: could not map ISA address");

	sc->sc_iot = iot;
	sc->sc_ioh = ioh2;
	sc->sc_dmat = ea->ea_dmat;
	if (!bha_probe_inquiry(iot, ioh2, &bpd))
		panic("bha_eisa_attach failed");

	sc->sc_dmaflags = 0;

	if (eisa_intr_map(ec, bpd.sc_irq, &ih)) {
		aprint_error_dev(sc->sc_dev, "couldn't map interrupt (%d)\n",
		    bpd.sc_irq);
		return;
	}
	intrstr = eisa_intr_string(ec, ih);
	sc->sc_ih = eisa_intr_establish(ec, ih, IST_LEVEL, IPL_BIO,
	    bha_intr, sc);
	if (sc->sc_ih == NULL) {
		aprint_error_dev(sc->sc_dev, "couldn't establish interrupt");
		if (intrstr != NULL)
			aprint_error(" at %s", intrstr);
		aprint_error("\n");
		return;
	}
	aprint_normal_dev(sc->sc_dev, "interrupting at %s\n", intrstr);

	bha_attach(sc);
}
Exemplo n.º 2
0
/*
 * Attach all the sub-devices we can find
 */
static void
uha_eisa_attach(struct device *parent, struct device *self, void *aux)
{
	struct eisa_attach_args *ea = aux;
	struct uha_softc *sc = device_private(self);
	bus_space_tag_t iot = ea->ea_iot;
	bus_dma_tag_t dmat = ea->ea_dmat;
	bus_space_handle_t ioh;
	struct uha_probe_data upd;
	eisa_chipset_tag_t ec = ea->ea_ec;
	eisa_intr_handle_t ih;
	const char *model, *intrstr;

	if (!strncmp(ea->ea_idstring, "USC024", 6))
		model = EISA_PRODUCT_USC0240;
	else
		model = "unknown model!";
	printf(": %s\n", model);

	if (bus_space_map(iot, EISA_SLOT_ADDR(ea->ea_slot) +
	    UHA_EISA_SLOT_OFFSET, UHA_EISA_IOSIZE, 0, &ioh))
		panic("uha_eisa_attach: could not map I/O addresses");

	sc->sc_iot = iot;
	sc->sc_ioh = ioh;
	sc->sc_dmat = dmat;
	if (!u24_find(iot, ioh, &upd))
		panic("uha_eisa_attach: u24_find failed!");

	sc->sc_dmaflags = 0;

	if (eisa_intr_map(ec, upd.sc_irq, &ih)) {
		aprint_error_dev(&sc->sc_dev, "couldn't map interrupt (%d)\n",
		    upd.sc_irq);
		return;
	}
	intrstr = eisa_intr_string(ec, ih);
	sc->sc_ih = eisa_intr_establish(ec, ih, IST_LEVEL, IPL_BIO,
	    u24_intr, sc);
	if (sc->sc_ih == NULL) {
		aprint_error_dev(&sc->sc_dev, "couldn't establish interrupt");
		if (intrstr != NULL)
			printf(" at %s", intrstr);
		printf("\n");
		return;
	}
	printf("%s: interrupting at %s\n", device_xname(&sc->sc_dev), intrstr);

	/* Save function pointers for later use. */
	sc->start_mbox = u24_start_mbox;
	sc->poll = u24_poll;
	sc->init = u24_init;

	uha_attach(sc, &upd);
}
Exemplo n.º 3
0
static void
mlx_eisa_attach(device_t parent, device_t self, void *aux)
{
	struct eisa_attach_args *ea;
	bus_space_handle_t ioh;
	eisa_chipset_tag_t ec;
	eisa_intr_handle_t ih;
	struct mlx_softc *mlx;
	bus_space_tag_t iot;
	const char *intrstr;
	int irq, i, icfg;

	ea = aux;
	mlx = device_private(self);
	iot = ea->ea_iot;
	ec = ea->ea_ec;

	if (bus_space_map(iot, EISA_SLOT_ADDR(ea->ea_slot) +
	    MLX_EISA_SLOT_OFFSET, MLX_EISA_IOSIZE, 0, &ioh)) {
		printf("can't map i/o space\n");
		return;
	}

	mlx->mlx_dv = self;
	mlx->mlx_iot = iot;
	mlx->mlx_ioh = ioh;
	mlx->mlx_dmat = ea->ea_dmat;

	/*
	 * Map and establish the interrupt.
	 */
	icfg = bus_space_read_1(iot, ioh, MLX_EISA_CFG03);

	switch (icfg & 0xf0) {
	case 0xa0:
		irq = 11;
		break;
	case 0xc0:
		irq = 12;
		break;
	case 0xe0:
		irq = 14;
		break;
	case 0x80:
		irq = 15;
		break;
	default:
		printf("controller on invalid IRQ\n");
		return;
	}

	if (eisa_intr_map(ec, irq, &ih)) {
		printf("can't map interrupt (%d)\n", irq);
		return;
	}

	intrstr = eisa_intr_string(ec, ih);
	mlx->mlx_ih = eisa_intr_establish(ec, ih,
	    ((icfg & 0x08) != 0 ? IST_LEVEL : IST_EDGE),
	    IPL_BIO, mlx_intr, mlx);
	if (mlx->mlx_ih == NULL) {
		printf("can't establish interrupt");
		if (intrstr != NULL)
			printf(" at %s", intrstr);
		printf("\n");
		return;
	}

	for (i = 0; i < sizeof(mlx_eisa_prod) / sizeof(mlx_eisa_prod[0]); i++)
		if (strcmp(ea->ea_idstring, mlx_eisa_prod[i].mp_idstr) == 0) {
			mlx->mlx_ci.ci_nchan = mlx_eisa_prod[i].mp_nchan;
			break;
		}
	mlx->mlx_ci.ci_iftype = 1;

	mlx->mlx_submit = mlx_v1_submit;
	mlx->mlx_findcomplete = mlx_v1_findcomplete;
	mlx->mlx_intaction = mlx_v1_intaction;
	mlx->mlx_fw_handshake = mlx_v1_fw_handshake;
#ifdef MLX_RESET
	mlx->mlx_reset = mlx_v1_reset;
#endif

	printf(": Mylex RAID\n");
	mlx_init(mlx, intrstr);
}
Exemplo n.º 4
0
static void
ahc_eisa_attach(device_t parent, device_t self, void *aux)
{
	struct ahc_softc *ahc = device_private(self);
	struct eisa_attach_args *ea = aux;
	eisa_chipset_tag_t ec = ea->ea_ec;
	eisa_intr_handle_t ih;
	bus_space_tag_t iot = ea->ea_iot;
	bus_space_handle_t ioh;
	int irq, intrtype;
	const char *intrstr, *intrtypestr;
	u_int biosctrl;
	u_int scsiconf;
	u_int scsiconf1;
	u_char intdef;
#ifdef AHC_DEBUG
	int i;
#endif
	char intrbuf[EISA_INTRSTR_LEN];

	ahc->sc_dev = self;

	if (bus_space_map(iot, EISA_SLOT_ADDR(ea->ea_slot) +
	    AHC_EISA_SLOT_OFFSET, AHC_EISA_IOSIZE, 0, &ioh)) {
		aprint_error_dev(ahc->sc_dev, "could not map I/O addresses");
		return;
	}
	if ((irq = ahc_aic77xx_irq(iot, ioh)) < 0) {
		aprint_error_dev(ahc->sc_dev, "ahc_aic77xx_irq failed!");
		goto free_io;
	}

	if (strcmp(ea->ea_idstring, "ADP7770") == 0) {
		printf(": %s\n", EISA_PRODUCT_ADP7770);
	} else if (strcmp(ea->ea_idstring, "ADP7771") == 0) {
		printf(": %s\n", EISA_PRODUCT_ADP7771);
	} else {
		printf(": Unknown device type %s", ea->ea_idstring);
		goto free_io;
	}

	ahc_set_name(ahc, device_xname(ahc->sc_dev));
	ahc->parent_dmat = ea->ea_dmat;
	ahc->chip = AHC_AIC7770|AHC_EISA;
	ahc->features = AHC_AIC7770_FE;
	ahc->flags = AHC_PAGESCBS;
	ahc->bugs = AHC_TMODE_WIDEODD_BUG;
	ahc->tag = iot;
	ahc->bsh = ioh;
	ahc->channel = 'A';

	if (ahc_softc_init(ahc) != 0)
		goto free_io;

	ahc_intr_enable(ahc, FALSE);

	if (ahc_reset(ahc) != 0)
		goto free_io;

	if (eisa_intr_map(ec, irq, &ih)) {
		aprint_error_dev(ahc->sc_dev, "couldn't map interrupt (%d)\n",
		    irq);
		goto free_io;
	}

	intdef = bus_space_read_1(iot, ioh, INTDEF);

	if (intdef & EDGE_TRIG) {
		intrtype = IST_EDGE;
		intrtypestr = "edge triggered";
	} else {
		intrtype = IST_LEVEL;
		intrtypestr = "level sensitive";
	}
	intrstr = eisa_intr_string(ec, ih, intrbuf, sizeof(intrbuf));
	ahc->ih = eisa_intr_establish(ec, ih,
	    intrtype, IPL_BIO, ahc_intr, ahc);
	if (ahc->ih == NULL) {
		aprint_error_dev(ahc->sc_dev, "couldn't establish %s interrupt",
		    intrtypestr);
		if (intrstr != NULL)
			aprint_error(" at %s", intrstr);
		aprint_error("\n");
		goto free_io;
	}
	if (intrstr != NULL)
		aprint_normal_dev(ahc->sc_dev, "%s interrupting at %s\n",
		       intrtypestr, intrstr);

	/*
	 * Now that we know we own the resources we need, do the
	 * card initialization.
	 *
	 * First, the aic7770 card specific setup.
	 */
	biosctrl = ahc_inb(ahc, HA_274_BIOSCTRL);
	scsiconf = ahc_inb(ahc, SCSICONF);
	scsiconf1 = ahc_inb(ahc, SCSICONF + 1);

#ifdef AHC_DEBUG
	for (i = TARG_SCSIRATE; i <= HA_274_BIOSCTRL; i+=8) {
		printf("0x%x, 0x%x, 0x%x, 0x%x, "
		       "0x%x, 0x%x, 0x%x, 0x%x\n",
		       ahc_inb(ahc, i),
		       ahc_inb(ahc, i+1),
		       ahc_inb(ahc, i+2),
		       ahc_inb(ahc, i+3),
		       ahc_inb(ahc, i+4),
		       ahc_inb(ahc, i+5),
		       ahc_inb(ahc, i+6),
		       ahc_inb(ahc, i+7));
	}
#endif

	/* Get the primary channel information */
	if ((biosctrl & CHANNEL_B_PRIMARY) != 0)
		ahc->flags |= AHC_PRIMARY_CHANNEL;

	if ((biosctrl & BIOSMODE) == BIOSDISABLED) {
		ahc->flags |= AHC_USEDEFAULTS;
	} else if ((ahc->features & AHC_WIDE) != 0) {
		ahc->our_id = scsiconf1 & HWSCSIID;
		if (scsiconf & TERM_ENB)
			ahc->flags |= AHC_TERM_ENB_A;
	} else {
		ahc->our_id = scsiconf & HSCSIID;
		ahc->our_id_b = scsiconf1 & HSCSIID;
		if (scsiconf & TERM_ENB)
			ahc->flags |= AHC_TERM_ENB_A;
		if (scsiconf1 & TERM_ENB)
			ahc->flags |= AHC_TERM_ENB_B;
	}
	if ((ahc_inb(ahc, HA_274_BIOSGLOBAL) & HA_274_EXTENDED_TRANS))
		ahc->flags |= AHC_EXTENDED_TRANS_A|AHC_EXTENDED_TRANS_B;

	/* Attach sub-devices */
	if (ahc_aic77xx_attach(ahc) == 0)
		return; /* succeed */

	/* failed */
	eisa_intr_disestablish(ec, ahc->ih);
free_io:
	bus_space_unmap(iot, ioh, AHC_EISA_IOSIZE);
}
Exemplo n.º 5
0
static void
mlx_eisa_attach(struct device *parent, struct device *self, void *aux)
{
	struct eisa_attach_args *ea;
	bus_space_handle_t ioh;
	eisa_chipset_tag_t ec;
	eisa_intr_handle_t ih;
	struct mlx_softc *mlx;
	bus_space_tag_t iot;
	const char *intrstr;
	int irq, le;
	
	ea = aux;
	mlx = (struct mlx_softc *)self;
	iot = ea->ea_iot;
	ec = ea->ea_ec;
	
	if (bus_space_map(iot, EISA_SLOT_ADDR(ea->ea_slot) +
	    MLX_EISA_SLOT_OFFSET, MLX_EISA_IOSIZE, 0, &ioh)) {
		printf("can't map i/o space\n");
		return;
	}

	mlx->mlx_iot = iot;
	mlx->mlx_ioh = ioh;
	mlx->mlx_dmat = ea->ea_dmat;

	/* 
	 * Map and establish the interrupt.
	 */
	switch (bus_space_read_1(iot, ioh, MLX_EISA_IOCONF1) & 0xf0) {
	case 0xa0:
		irq = 11;
		break;
	case 0xc0:
		irq = 12;
		break;
	case 0xe0:
		irq = 14;
		break;
	case 0x80:
		irq = 15;
		break;
	default:
		printf("controller on invalid IRQ\n");
		return;
	}

	if (eisa_intr_map(ec, irq, &ih)) {
		printf("can't map interrupt (%d)\n", irq);
		return;
	}

	if ((bus_space_read_1(iot, ioh, MLX_EISA_IOCONF1) & 0x08) != 0)
		le = IST_LEVEL;
	else
		le = IST_EDGE;

	intrstr = eisa_intr_string(ec, ih);
	mlx->mlx_ih = eisa_intr_establish(ec, ih, le, IPL_BIO, mlx_intr, mlx);
	if (mlx->mlx_ih == NULL) {
		printf("can't establish interrupt");
		if (intrstr != NULL)
			printf(" at %s", intrstr);
		printf("\n");
		return;
	}

	mlx->mlx_flags = MLXF_EISA;

	mlx->mlx_submit = mlx_v1_submit;
	mlx->mlx_findcomplete = mlx_v1_findcomplete;
	mlx->mlx_intaction = mlx_v1_intaction;
	mlx->mlx_fw_handshake = mlx_v1_fw_handshake;
#ifdef MLX_RESET
	mlx->mlx_reset = mlx_v1_reset;
#endif

	printf(": Mylex RAID\n");
	mlx_init(mlx, intrstr);
}
Exemplo n.º 6
0
static void
dpt_eisa_attach(device_t parent, device_t self, void *aux)
{
	struct eisa_attach_args *ea;
	bus_space_handle_t ioh;
	eisa_chipset_tag_t ec;
	eisa_intr_handle_t ih;
	struct dpt_softc *sc;
	bus_space_tag_t iot;
	const char *intrstr;
	int irq;
	char intrbuf[EISA_INTRSTR_LEN];

	ea = aux;
	sc = device_private(self);
	sc->sc_dev = self;
	iot = ea->ea_iot;
	ec = ea->ea_ec;

	printf(": ");

	if (bus_space_map(iot, EISA_SLOT_ADDR(ea->ea_slot) +
	    DPT_EISA_SLOT_OFFSET, DPT_EISA_IOSIZE, 0, &ioh)) {
		printf("can't map i/o space\n");
		return;
	}

	sc->sc_iot = iot;
	sc->sc_ioh = ioh;
	sc->sc_dmat = ea->ea_dmat;

	/* Map and establish the interrupt. */
	if (dpt_eisa_irq(iot, ioh, &irq)) {
		printf("HBA on invalid IRQ\n");
		return;
	}

	if (eisa_intr_map(ec, irq, &ih)) {
		printf("can't map interrupt (%d)\n", irq);
		return;
	}

	intrstr = eisa_intr_string(ec, ih, intrbuf, sizeof(intrbuf));
	sc->sc_ih = eisa_intr_establish(ec, ih, IST_LEVEL, IPL_BIO,
	    dpt_intr, sc);
	if (sc->sc_ih == NULL) {
		printf("can't establish interrupt");
		if (intrstr != NULL)
			printf(" at %s", intrstr);
		printf("\n");
		return;
	}

	/* Read the EATA configuration. */
	if (dpt_readcfg(sc)) {
		aprint_error_dev(sc->sc_dev, "readcfg failed - see dpt(4)\n");
		return;
	}

	sc->sc_bustype = SI_EISA_BUS;
	sc->sc_isaport =  EISA_SLOT_ADDR(ea->ea_slot) + DPT_EISA_SLOT_OFFSET;
	sc->sc_isairq = irq;

	/* Now attach to the bus-independent code. */
	dpt_init(sc, intrstr);
}
Exemplo n.º 7
0
static void
tlp_eisa_attach(device_t parent, device_t self, void *aux)
{
    static const u_int8_t testpat[] =
    { 0xff, 0, 0x55, 0xaa, 0xff, 0, 0x55, 0xaa };
    struct tulip_eisa_softc *esc = device_private(self);
    struct tulip_softc *sc = &esc->sc_tulip;
    struct eisa_attach_args *ea = aux;
    eisa_chipset_tag_t ec = ea->ea_ec;
    eisa_intr_handle_t ih;
    bus_space_tag_t iot = ea->ea_iot;
    bus_space_handle_t ioh;
    const char *intrstr;
    const struct tulip_eisa_product *tep;
    u_int8_t enaddr[ETHER_ADDR_LEN], tmpbuf[sizeof(testpat)];
    u_int32_t val;
    int irq, i, cnt;
    char intrbuf[EISA_INTRSTR_LEN];

    /*
     * Map the device.
     */
    if (bus_space_map(iot, EISA_SLOT_ADDR(ea->ea_slot),
                      EISA_SLOT_SIZE, 0, &ioh)) {
        printf(": unable to map I/O space\n");
        return;
    }

    sc->sc_dev = self;
    sc->sc_st = iot;
    sc->sc_sh = ioh;

    tep = tlp_eisa_lookup(ea);
    if (tep == NULL) {
        printf("\n");
        panic("tlp_eisa_attach: impossible");
    }
    sc->sc_chip = tep->tep_chip;

    /*
     * DE425's registers are 16 bytes long; the PCI configuration
     * space registers are interleaved in the I/O space.
     */
    sc->sc_regshift = 4;

    /*
     * No power management hooks.
     */
    sc->sc_flags |= TULIPF_ENABLED;

    /*
     * CBIO must map the EISA slot, and I/O access and Bus Mastering
     * must be enabled.
     */
    bus_space_write_4(iot, ioh, DE425_CBIO, EISA_SLOT_ADDR(ea->ea_slot));
    bus_space_write_4(iot, ioh, DE425_CFCS,
                      bus_space_read_4(iot, ioh, DE425_CFCS) |
                      PCI_COMMAND_IO_ENABLE | PCI_COMMAND_MASTER_ENABLE);

    /*
     * Get revision info.
     */
    sc->sc_rev = bus_space_read_4(iot, ioh, DE425_CFRV) & 0xff;

    printf(": %s Ethernet, pass %d.%d\n",
           tep->tep_name, (sc->sc_rev >> 4) & 0xf, sc->sc_rev & 0xf);

    sc->sc_dmat = ea->ea_dmat;

    /*
     * EISA doesn't have a cache line register.
     */
    sc->sc_cacheline = 0;

    /*
     * Find the beginning of the Ethernet Address ROM.
     */
    for (i = 0, cnt = 0; i < sizeof(testpat) && cnt < 32; cnt++) {
        tmpbuf[i] = bus_space_read_1(iot, ioh, DE425_ENETROM);
        if (tmpbuf[i] == testpat[i])
            i++;
        else
            i = 0;
    }

    /*
     * ...and now read the contents of the Ethernet Address ROM.
     */
    sc->sc_srom = malloc(32, M_DEVBUF, M_WAITOK|M_ZERO);
    for (i = 0; i < 32; i++)
        sc->sc_srom[i] = bus_space_read_1(iot, ioh, DE425_ENETROM);

    /*
     * None of the DE425 boards have the new-style SROMs.
     */
    if (tlp_parse_old_srom(sc, enaddr) == 0) {
        aprint_error_dev(self, "unable to decode old-style SROM\n");
        return;
    }

    /*
     * All DE425 boards use the 21040 media switch.
     */
    sc->sc_mediasw = &tlp_21040_mediasw;

    /*
     * Figure out which IRQ we want to use, and determine if it's
     * edge- or level-triggered.
     */
    val = bus_space_read_4(iot, ioh, DE425_CFG0);
    irq = tlp_eisa_irqs[(val >> 1) & 0x03];

    /*
     * Map and establish our interrupt.
     */
    if (eisa_intr_map(ec, irq, &ih)) {
        aprint_error_dev(self, "unable to map interrupt (%u)\n",
                         irq);
        return;
    }
    intrstr = eisa_intr_string(ec, ih, intrbuf, sizeof(intrbuf));
    esc->sc_ih = eisa_intr_establish(ec, ih,
                                     (val & 0x01) ? IST_EDGE : IST_LEVEL, IPL_NET, tlp_intr, sc);
    if (esc->sc_ih == NULL) {
        aprint_error_dev(self, "unable to establish interrupt");
        if (intrstr != NULL)
            aprint_error(" at %s", intrstr);
        aprint_error("\n");
        return;
    }
    if (intrstr != NULL)
        aprint_normal_dev(self, "interrupting at %s\n", intrstr);

    /*
     * Finish off the attach.
     */
    tlp_attach(sc, enaddr);
}