Esempio n. 1
0
static int
dpt_eisa_probe (device_t dev)
{
	const char *	desc;
	u_int32_t	io_base;
	dpt_conf_t *	conf;

	desc = dpt_eisa_match(eisa_get_id(dev));
	if (!desc)
		return (ENXIO);
	device_set_desc(dev, desc);

	io_base = (eisa_get_slot(dev) * EISA_SLOT_SIZE) +
		DPT_EISA_SLOT_OFFSET +
		DPT_EISA_EATA_REG_OFFSET;

	conf = dpt_pio_get_conf(io_base);
	if (!conf) {
		printf("dpt: dpt_pio_get_conf() failed.\n");
		return (ENXIO);
	}

	eisa_add_iospace(dev, io_base, DPT_EISA_IOSIZE, RESVADDR_NONE);
	eisa_add_intr(dev, conf->IRQ,
		      (conf->IRQ_TR ? EISA_TRIGGER_LEVEL : EISA_TRIGGER_EDGE));

	return 0;
}
Esempio n. 2
0
static int
adv_eisa_probe(device_t dev)
{
	const char *desc;
	u_int32_t iobase;
	u_int8_t irq;

	desc = adv_eisa_match(eisa_get_id(dev));
	if (!desc)
		return (ENXIO);
	device_set_desc(dev, desc);

	iobase = (eisa_get_slot(dev) * EISA_SLOT_SIZE) + ADV_EISA_SLOT_OFFSET;

	eisa_add_iospace(dev, iobase, ADV_EISA_IOSIZE, RESVADDR_NONE);
	irq = inb(iobase + ADV_EISA_IRQ_BURST_LEN_REG);
	irq &= ADV_EISA_IRQ_MASK;
	switch (irq) {
	case 0:
	case 1:
	case 2:
	case 4:
	case 5:
	    break;
	default:
	    printf("adv at slot %d: illegal "
		   "irq setting %d\n", eisa_get_slot(dev),
		   irq);
	    return ENXIO;
	}
	eisa_add_intr(dev, irq + 10, EISA_TRIGGER_LEVEL);

	return 0;
}
Esempio n. 3
0
static int
aic7770_attach(device_t dev)
{
	struct	 aic7770_identity *entry;
	struct	 ahc_softc *ahc;
	char	*name;
	int	 error;

	entry = aic7770_find_device(eisa_get_id(dev));
	if (entry == NULL)
		return (ENXIO);

	/*
	 * Allocate a softc for this card and
	 * set it up for attachment by our
	 * common detect routine.
	 */
	name = malloc(strlen(device_get_nameunit(dev)) + 1, M_DEVBUF, M_NOWAIT);
	if (name == NULL)
		return (ENOMEM);
	strcpy(name, device_get_nameunit(dev));
	ahc = ahc_alloc(dev, name);
	if (ahc == NULL)
		return (ENOMEM);

	ahc_set_unit(ahc, device_get_unit(dev));

	/* Allocate a dmatag for our SCB DMA maps */
	/* XXX Should be a child of the PCI bus dma tag */
	error = aic_dma_tag_create(ahc, /*parent*/bus_get_dma_tag(dev),
				   /*alignment*/1, /*boundary*/0,
				   /*lowaddr*/BUS_SPACE_MAXADDR_32BIT,
				   /*highaddr*/BUS_SPACE_MAXADDR,
				   /*filter*/NULL, /*filterarg*/NULL,
				   /*maxsize*/BUS_SPACE_MAXSIZE_32BIT,
				   /*nsegments*/AHC_NSEG,
				   /*maxsegsz*/AHC_MAXTRANSFER_SIZE,
				   /*flags*/0,
				   &ahc->parent_dmat);

	if (error != 0) {
		printf("ahc_eisa_attach: Could not allocate DMA tag "
		       "- error %d\n", error);
		ahc_free(ahc);
		return (ENOMEM);
	}
	ahc->dev_softc = dev;
	error = aic7770_config(ahc, entry, /*unused ioport arg*/0);
	if (error != 0) {
		ahc_free(ahc);
		return (error);
	}

	ahc_attach(ahc);
	return (0);
}
Esempio n. 4
0
static int
ahbprobe(device_t dev)      
{       
	const char *desc;
	u_int32_t iobase;
	u_int32_t irq;
	u_int8_t  intdef;      
	int shared;
                
	desc = ahbmatch(eisa_get_id(dev));
	if (!desc)
	    return (ENXIO);
	device_set_desc(dev, desc);

	iobase = (eisa_get_slot(dev) * EISA_SLOT_SIZE) +
	    AHB_EISA_SLOT_OFFSET;
                        
	eisa_add_iospace(dev, iobase, AHB_EISA_IOSIZE, RESVADDR_NONE);
		
	intdef = inb(INTDEF + iobase);
	switch (intdef & 0x7) {
	case INT9:  
	    irq = 9;
	    break;
	case INT10: 
	    irq = 10;
	    break;
	case INT11:
	    irq = 11;
	    break;
	case INT12:
	    irq = 12; 
	    break;
	case INT14:
	    irq = 14;
	    break;
	case INT15:
	    irq = 15;
	    break;
	default:
	    printf("Adaptec 174X at slot %d: illegal "
		   "irq setting %d\n", eisa_get_slot(dev),
		   (intdef & 0x7));
	    irq = 0;
	    break;
	}               
	if (irq == 0)
	    return ENXIO;

	shared = (inb(INTDEF + iobase) & INTLEVEL) ?
		 EISA_TRIGGER_LEVEL : EISA_TRIGGER_EDGE;

	eisa_add_intr(dev, irq, shared);

	return 0;   
}
Esempio n. 5
0
static void
eisa_probe_nomatch(device_t dev, device_t child)
{
	u_int32_t	eisa_id = eisa_get_id(child);
	u_int8_t	slot = eisa_get_slot(child);

	device_printf(dev, "%c%c%c%03x%01x (0x%08x) at slot %d (no driver attached)\n",
	    EISA_MFCTR_CHAR0(eisa_id), EISA_MFCTR_CHAR1(eisa_id),
	    EISA_MFCTR_CHAR2(eisa_id), EISA_PRODUCT_ID(eisa_id),
	    EISA_REVISION_ID(eisa_id), eisa_id, slot);
	return;
}
Esempio n. 6
0
static int
mainboard_probe(device_t dev)
{
	char *idstring;
	eisa_id_t id = eisa_get_id(dev);

	if (eisa_get_slot(dev) != 0)
		return (ENXIO);

	idstring = (char *)malloc(8 + sizeof(" (System Board)") + 1,
	    M_DEVBUF, M_NOWAIT);
	if (idstring == NULL)
		panic("Eisa probe unable to malloc");
	sprintf(idstring, "%c%c%c%03x%01x (System Board)",
	    EISA_MFCTR_CHAR0(id), EISA_MFCTR_CHAR1(id), EISA_MFCTR_CHAR2(id),
	    EISA_PRODUCT_ID(id), EISA_REVISION_ID(id));
	device_set_desc(dev, idstring);

	return (0);
}
Esempio n. 7
0
static int
ida_eisa_probe(device_t dev)
{
    struct ida_board	*board;
    u_int32_t		io_base;
    u_int			irq = 0;

    board = ida_eisa_match(eisa_get_id(dev));
    if (board == NULL)
        return (ENXIO);
    device_set_desc(dev, board->desc);

    io_base = (eisa_get_slot(dev) * EISA_SLOT_SIZE);

    switch (IDA_EISA_IRQ_MASK & (inb(IDA_EISA_IRQ_REG + io_base))) {
    case IDA_EISA_IRQ_15:
        irq = 15;
        break;
    case IDA_EISA_IRQ_14:
        irq = 14;
        break;
    case IDA_EISA_IRQ_11:
        irq = 11;
        break;
    case IDA_EISA_IRQ_10:
        irq = 10;
        break;
    default:
        device_printf(dev, "slot %d, illegal irq setting.\n",
                      eisa_get_slot(dev));
        return (ENXIO);
    }

    eisa_add_iospace(dev, (io_base + IDA_EISA_IOPORT_START),
                     IDA_EISA_IOPORT_LEN, RESVADDR_NONE);

    eisa_add_intr(dev, irq, EISA_TRIGGER_LEVEL);		/* XXX ??? */

    return (0);
}
Esempio n. 8
0
static int
vx_eisa_probe(device_t dev)
{
	const char *desc;
	u_long iobase;
	u_long port;

	desc = vx_match(eisa_get_id(dev));
	if (!desc)
		return (ENXIO);
	device_set_desc(dev, desc);

	port = eisa_get_slot(dev) * EISA_SLOT_SIZE;
	iobase = port + VX_EISA_SLOT_OFFSET;

	eisa_add_iospace(dev, iobase, VX_EISA_IOSIZE, RESVADDR_NONE);
	eisa_add_iospace(dev, port, VX_IOSIZE, RESVADDR_NONE);

	/* Set irq */
	eisa_add_intr(dev, inw(iobase + VX_RESOURCE_CONFIG) >> 12,
	    EISA_TRIGGER_EDGE);

	return (0);
}
Esempio n. 9
0
static int
bt_eisa_probe(device_t dev)
{
	const char *desc;
	u_long iobase;
	struct bt_probe_info info;
	u_long port;
	u_long iosize;
	u_int  ioconf;
	int    result;
	int    shared;

	desc = bt_match(eisa_get_id(dev));
	if (!desc)
		return (ENXIO);
	device_set_desc(dev, desc);

	iobase = (eisa_get_slot(dev) * EISA_SLOT_SIZE); 
	if (eisa_get_id(dev) == EISA_DEVICE_ID_AMI_4801) {
		u_int ioconf1;

		iobase += AMI_EISA_SLOT_OFFSET;
		iosize = AMI_EISA_IOSIZE;
		ioconf1 = inb(iobase + AMI_EISA_IOCONF1);
		/* Determine "ISA" I/O port */
		switch (ioconf1 & AMI_PORTADDR) {
		case AMI_PORT_330:
			port = 0x330;
			break;
		case AMI_PORT_334:
			port = 0x334;
			break;
		case AMI_PORT_230:
			port = 0x230;
			break;
		case AMI_PORT_234:
			port = 0x234;
			break;
		case AMI_PORT_134:
			port = 0x134;
			break;
		case AMI_PORT_130:
			port = 0x130;
			break;
		default:
			/* Disabled */
			printf("bt: AMI EISA Adapter at "
			       "slot %d has a disabled I/O "
			       "port.  Cannot attach.\n",
			       eisa_get_slot(dev));
			return (ENXIO);
		}
		shared = (inb(iobase + AMI_EISA_IOCONF1) & AMI_IRQ_LEVEL) ?
				EISA_TRIGGER_LEVEL : EISA_TRIGGER_EDGE;
	} else {
		iobase += BT_EISA_SLOT_OFFSET;
		iosize = BT_EISA_IOSIZE;

		ioconf = inb(iobase + EISA_IOCONF);
		/* Determine "ISA" I/O port */
		switch (ioconf & PORTADDR) {
		case PORT_330:
			port = 0x330;
			break;
		case PORT_334:
			port = 0x334;
			break;
		case PORT_230:
			port = 0x230;
			break;
		case PORT_234:
			port = 0x234;
			break;
		case PORT_130:
			port = 0x130;
			break;
		case PORT_134:
			port = 0x134;
			break;
		default:
			/* Disabled */
			printf("bt: Buslogic EISA Adapter at "
			       "slot %d has a disabled I/O "
			       "port.  Cannot attach.\n",
			       eisa_get_slot(dev));
			return (ENXIO);
		}
		shared = (inb(iobase + EISA_IRQ_TYPE) & LEVEL) ?
				EISA_TRIGGER_LEVEL : EISA_TRIGGER_EDGE;
	}
	bt_mark_probed_iop(port);

	/* Tell parent where our resources are going to be */
	eisa_add_iospace(dev, iobase, iosize, RESVADDR_NONE);
	eisa_add_iospace(dev, port, BT_IOSIZE, RESVADDR_NONE);

	/* And allocate them */
	bt_eisa_alloc_resources(dev);

	if (bt_port_probe(dev, &info) != 0) {
		printf("bt_eisa_probe: Probe failed for "
		       "card at slot 0x%x\n", eisa_get_slot(dev));
		result = ENXIO;
	} else {
		eisa_add_intr(dev, info.irq, shared);
		result = 0;
	}
	bt_eisa_release_resources(dev);

	return (result);
}
Esempio n. 10
0
static int
adv_eisa_attach(device_t dev)
{
	struct adv_softc *adv;
	struct adv_softc *adv_b;
	struct resource *io;
	struct resource *irq;
	int rid, error;
	void *ih;

	adv_b = NULL;

	rid = 0;
	io = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid,
				0, ~0, 1, RF_ACTIVE);
	if (!io) {
		device_printf(dev, "No I/O space?!\n");
		return ENOMEM;
	}

	rid = 0;
	irq = bus_alloc_resource(dev, SYS_RES_IRQ, &rid,
				 0, ~0, 1, RF_SHAREABLE | RF_ACTIVE);
	if (!irq) {
		device_printf(dev, "No irq?!\n");
		bus_release_resource(dev, SYS_RES_IOPORT, 0, io);
		return ENOMEM;

	}

	switch (eisa_get_id(dev) & ~0xF) {
	case EISA_DEVICE_ID_ADVANSYS_750:
		adv_b = adv_alloc(dev, rman_get_bustag(io),
				  rman_get_bushandle(io) + ADV_EISA_OFFSET_CHAN2);
		if (adv_b == NULL)
			goto bad;
		
		/*
		 * Allocate a parent dmatag for all tags created
		 * by the MI portions of the advansys driver
		 */
		/* XXX Should be a child of the PCI bus dma tag */
		error = bus_dma_tag_create(/*parent*/NULL, /*alignment*/1,
					   /*boundary*/0,
					   /*lowaddr*/ADV_EISA_MAX_DMA_ADDR,
					   /*highaddr*/BUS_SPACE_MAXADDR,
					   /*filter*/NULL, /*filterarg*/NULL,
					   /*maxsize*/BUS_SPACE_MAXSIZE_32BIT,
					   /*nsegments*/~0,
					   /*maxsegsz*/ADV_EISA_MAX_DMA_COUNT,
					   /*flags*/0,
					   &adv_b->parent_dmat);
 
		if (error != 0) {
			printf("%s: Could not allocate DMA tag - error %d\n",
			       adv_name(adv_b), error);
			adv_free(adv_b);
			goto bad;
		}

		adv_b->init_level++;

		/* FALLTHROUGH */
	case EISA_DEVICE_ID_ADVANSYS_740:
		adv = adv_alloc(dev, rman_get_bustag(io),
				rman_get_bushandle(io) + ADV_EISA_OFFSET_CHAN1);
		if (adv == NULL) {
			if (adv_b != NULL)
				adv_free(adv_b);
			goto bad;
		}

		/*
		 * Allocate a parent dmatag for all tags created
		 * by the MI portions of the advansys driver
		 */
		/* XXX Should be a child of the PCI bus dma tag */
		error = bus_dma_tag_create(/*parent*/NULL, /*alignment*/1,
					   /*boundary*/0,
					   /*lowaddr*/ADV_EISA_MAX_DMA_ADDR,
					   /*highaddr*/BUS_SPACE_MAXADDR,
					   /*filter*/NULL, /*filterarg*/NULL,
					   /*maxsize*/BUS_SPACE_MAXSIZE_32BIT,
					   /*nsegments*/~0,
					   /*maxsegsz*/ADV_EISA_MAX_DMA_COUNT,
					   /*flags*/0,
					   &adv->parent_dmat);
 
		if (error != 0) {
			printf("%s: Could not allocate DMA tag - error %d\n",
			       adv_name(adv), error);
			adv_free(adv);
			goto bad;
		}

		adv->init_level++;
		break;
	default: 
		printf("adveisaattach: Unknown device type!\n");
		goto bad;
		break;
	}

	if (overrun_buf == NULL) {
		/* Need to allocate our overrun buffer */
		if (bus_dma_tag_create(adv->parent_dmat,
				       /*alignment*/8,
				       /*boundary*/0,
				       ADV_EISA_MAX_DMA_ADDR,
				       BUS_SPACE_MAXADDR,
				       /*filter*/NULL,
				       /*filterarg*/NULL,
				       ADV_OVERRUN_BSIZE,
				       /*nsegments*/1,
				       BUS_SPACE_MAXSIZE_32BIT,
				       /*flags*/0,
				       &overrun_dmat) != 0) {
			adv_free(adv);
			goto bad;
       		}
		if (bus_dmamem_alloc(overrun_dmat,
				     (void **)&overrun_buf,
				     BUS_DMA_NOWAIT,
				     &overrun_dmamap) != 0) {
			bus_dma_tag_destroy(overrun_dmat);
			adv_free(adv);
			goto bad;
		}
		/* And permanently map it in */  
		bus_dmamap_load(overrun_dmat, overrun_dmamap,
				overrun_buf, ADV_OVERRUN_BSIZE,
				adv_map, &overrun_physbase,
				/*flags*/0);
	}
	
	/*
	 * Now that we know we own the resources we need, do the 
	 * card initialization.
	 */

	/*
	 * Stop the chip.
	 */
	ADV_OUTB(adv, ADV_CHIP_CTRL, ADV_CC_HALT);
	ADV_OUTW(adv, ADV_CHIP_STATUS, 0);

	adv->chip_version = EISA_REVISION_ID(eisa_get_id(dev))
			  + ADV_CHIP_MIN_VER_EISA - 1;

	if (adv_init(adv) != 0) {
		adv_free(adv);
		if (adv_b != NULL)
			adv_free(adv_b);
		return(-1);
	}

	adv->max_dma_count = ADV_EISA_MAX_DMA_COUNT;
	adv->max_dma_addr = ADV_EISA_MAX_DMA_ADDR;

	if (adv_b != NULL) {
		/*
		 * Stop the chip.
		 */
		ADV_OUTB(adv_b, ADV_CHIP_CTRL, ADV_CC_HALT);
		ADV_OUTW(adv_b, ADV_CHIP_STATUS, 0);

		adv_b->chip_version = EISA_REVISION_ID(eisa_get_id(dev))
				    + ADV_CHIP_MIN_VER_EISA - 1;

		if (adv_init(adv_b) != 0) {
			adv_free(adv_b);
		} else {
			adv_b->max_dma_count = ADV_EISA_MAX_DMA_COUNT;
			adv_b->max_dma_addr = ADV_EISA_MAX_DMA_ADDR;
		}
	}

	/*
	 * Enable our interrupt handler.
	 */
	bus_setup_intr(dev, irq, INTR_TYPE_CAM|INTR_ENTROPY, adv_intr, adv, &ih);

	/* Attach sub-devices - always succeeds */
	adv_attach(adv);
	if (adv_b != NULL)
		adv_attach(adv_b);

	return 0;

 bad:
	bus_release_resource(dev, SYS_RES_IOPORT, 0, io);
	bus_release_resource(dev, SYS_RES_IRQ, 0, irq);
	return -1;
}
Esempio n. 11
0
static int
ep_eisa_probe(device_t dev)
{
	const char *desc;
	u_long iobase;
	u_short conf;
	u_long port;
	int irq;
	int int_trig;

	desc = ep_match(eisa_get_id(dev));
	if (!desc)
		return (ENXIO);
	device_set_desc(dev, desc);

	port = (eisa_get_slot(dev) * EISA_SLOT_SIZE);
	iobase = port + EP_EISA_SLOT_OFFSET;

	/* We must be in EISA configuration mode */
	if ((inw(iobase + EP_W0_ADDRESS_CFG) & 0x1f) != 0x1f)
		return (ENXIO);

	eisa_add_iospace(dev, iobase, EP_EISA_IOSIZE, RESVADDR_NONE);
	eisa_add_iospace(dev, port, EP_IOSIZE, RESVADDR_NONE);

	conf = inw(iobase + EISA_IOCONF);
	/* Determine our IRQ */
	switch (conf & IRQ_CHANNEL) {
	case INT_3:
		irq = 3;
		break;
	case INT_5:
		irq = 5;
		break;
	case INT_7:
		irq = 7;
		break;
	case INT_9:
		irq = 9;
		break;
	case INT_10:
		irq = 10;
		break;
	case INT_11:
		irq = 11;
		break;
	case INT_12:
		irq = 12;
		break;
	case INT_15:
		irq = 15;
		break;
	default:
		/* Disabled */
		printf("ep: 3COM Network Adapter at "
		    "slot %d has its IRQ disabled. "
		    "Probe failed.\n",
		    eisa_get_slot(dev));
		return (ENXIO);
	}

	switch (eisa_get_id(dev)) {
	case EISA_DEVICE_ID_3COM_3C579_BNC:
	case EISA_DEVICE_ID_3COM_3C579_TP:
		int_trig = EISA_TRIGGER_LEVEL;
		break;
	default:
		int_trig = EISA_TRIGGER_EDGE;
		break;
	}

	eisa_add_intr(dev, irq, int_trig);

	return (0);
}
Esempio n. 12
0
static int
ep_eisa_attach(device_t dev)
{
	struct ep_softc *sc = device_get_softc(dev);
	struct resource *eisa_io = NULL;
	uint32_t eisa_iobase;
	int irq;
	int error = 0;
	int rid;

	rid = 1;
	eisa_io = bus_alloc_resource_any(dev, SYS_RES_IOPORT, &rid, RF_ACTIVE);
	if (!eisa_io) {
		device_printf(dev, "No I/O space?!\n");
		error = ENXIO;
		goto bad;
	}
	eisa_iobase = rman_get_start(eisa_io);

	/* Reset and Enable the card */
	outb(eisa_iobase + EP_W0_CONFIG_CTRL, W0_P4_CMD_RESET_ADAPTER);
	DELAY(1000);		/* we must wait at least 1 ms */
	outb(eisa_iobase + EP_W0_CONFIG_CTRL, W0_P4_CMD_ENABLE_ADAPTER);
	/* Now the registers are availible through the lower ioport */

	if ((error = ep_alloc(dev))) {
		device_printf(dev, "ep_alloc() failed! (%d)\n", error);
		goto bad;
	}
	switch (eisa_get_id(dev)) {
	case EISA_DEVICE_ID_3COM_3C579_BNC:
	case EISA_DEVICE_ID_3COM_3C579_TP:
		sc->stat = F_ACCESS_32_BITS;
		break;
	}

	ep_get_media(sc);

	irq = rman_get_start(sc->irq);
	if (irq == 9)
		irq = 2;

	GO_WINDOW(sc, 0);
	SET_IRQ(sc, irq);

	if ((error = ep_attach(sc))) {
		device_printf(dev, "ep_attach() failed! (%d)\n", error);
		goto bad;
	}
	if ((error = bus_setup_intr(dev, sc->irq, INTR_TYPE_NET | INTR_MPSAFE, 
	    NULL, ep_intr, sc, &sc->ep_intrhand))) {
		device_printf(dev, "bus_setup_intr() failed! (%d)\n", error);
		goto bad;
	}
	return (0);

bad:
	if (eisa_io)
		bus_release_resource(dev, SYS_RES_IOPORT, 0, eisa_io);

	ep_free(dev);
	return (error);
}
Esempio n. 13
0
static int
ida_eisa_attach(device_t dev)
{
    struct ida_softc	*ida;
    struct ida_board	*board;
    int			error;
    int			rid;

    ida = device_get_softc(dev);
    ida->dev = dev;

    board = ida_eisa_match(eisa_get_id(dev));
    ida->cmd = *board->accessor;
    ida->flags = board->flags;
    mtx_init(&ida->lock, "ida", NULL, MTX_DEF);
    callout_init_mtx(&ida->ch, &ida->lock, 0);

    ida->regs_res_type = SYS_RES_IOPORT;
    ida->regs_res_id = 0;
    ida->regs = bus_alloc_resource_any(dev, ida->regs_res_type,
                                       &ida->regs_res_id, RF_ACTIVE);
    if (ida->regs == NULL) {
        device_printf(dev, "can't allocate register resources\n");
        return (ENOMEM);
    }

    error = bus_dma_tag_create(
                /* parent	*/	bus_get_dma_tag(dev),
                /* alignment	*/	0,
                /* boundary	*/	0,
                /* lowaddr	*/	BUS_SPACE_MAXADDR_32BIT,
                /* highaddr	*/	BUS_SPACE_MAXADDR,
                /* filter	*/	NULL,
                /* filterarg	*/	NULL,
                /* maxsize	*/	MAXBSIZE,
                /* nsegments	*/	IDA_NSEG,
                /* maxsegsize	*/	BUS_SPACE_MAXSIZE_32BIT,
                /* flags	*/	BUS_DMA_ALLOCNOW,
                /* lockfunc	*/	NULL,
                /* lockarg	*/	NULL,
                &ida->parent_dmat);

    if (error != 0) {
        device_printf(dev, "can't allocate DMA tag\n");
        ida_free(ida);
        return (ENOMEM);
    }

    rid = 0;
    ida->irq_res_type = SYS_RES_IRQ;
    ida->irq = bus_alloc_resource_any(dev, ida->irq_res_type, &rid,
                                      RF_ACTIVE | RF_SHAREABLE);
    if (ida->irq == NULL) {
        ida_free(ida);
        return (ENOMEM);
    }

    error = bus_setup_intr(dev, ida->irq, INTR_TYPE_BIO | INTR_ENTROPY | INTR_MPSAFE,
                           NULL, ida_intr, ida, &ida->ih);
    if (error) {
        device_printf(dev, "can't setup interrupt\n");
        ida_free(ida);
        return (ENOMEM);
    }

    error = ida_init(ida);
    if (error) {
        ida_free(ida);
        return (error);
    }

    return (0);
}
Esempio n. 14
0
static int
aic7770_probe(device_t dev)
{
	struct	 aic7770_identity *entry;
	struct	 resource *regs;
	uint32_t iobase;
	bus_space_handle_t bsh;
	bus_space_tag_t	tag;
	u_int	 irq;
	u_int	 intdef;
	u_int	 hcntrl;
	int	 shared;
	int	 rid;
	int	 error;

	entry = aic7770_find_device(eisa_get_id(dev));
	if (entry == NULL)
		return (ENXIO);
	device_set_desc(dev, entry->name);

	iobase = (eisa_get_slot(dev) * EISA_SLOT_SIZE) + AHC_EISA_SLOT_OFFSET;

	eisa_add_iospace(dev, iobase, AHC_EISA_IOSIZE, RESVADDR_NONE);

	rid = 0;
	regs = bus_alloc_resource_any(dev, SYS_RES_IOPORT, &rid, RF_ACTIVE);
	if (regs == NULL) {
		device_printf(dev, "Unable to map I/O space?!\n");
		return ENOMEM;
	}

	tag = rman_get_bustag(regs);
	bsh = rman_get_bushandle(regs);
	error = 0;

	/* Pause the card preseving the IRQ type */
	hcntrl = bus_space_read_1(tag, bsh, HCNTRL) & IRQMS;
	bus_space_write_1(tag, bsh, HCNTRL, hcntrl | PAUSE);
	while ((bus_space_read_1(tag, bsh, HCNTRL) & PAUSE) == 0)
		;

	/* Make sure we have a valid interrupt vector */
	intdef = bus_space_read_1(tag, bsh, INTDEF);
	shared = (intdef & EDGE_TRIG) ? EISA_TRIGGER_EDGE : EISA_TRIGGER_LEVEL;
	irq = intdef & VECTOR;
	switch (irq) {
	case 9: 
	case 10:
	case 11:
	case 12:
	case 14:
	case 15:
		break;
	default:
		printf("aic7770 at slot %d: illegal irq setting %d\n",
		       eisa_get_slot(dev), intdef);
		error = ENXIO;
	}

	if (error == 0)
		eisa_add_intr(dev, irq, shared);

	bus_release_resource(dev, SYS_RES_IOPORT, rid, regs);
	return (error);
}