Example #1
0
static int
aic_pccard_attach(device_t dev)
{
	struct aic_pccard_softc *sc = device_get_softc(dev);
	struct aic_softc *aic = &sc->sc_aic;
	int error;

	if (aic_pccard_alloc_resources(dev))
		return (ENXIO);
	if (aic_probe(aic)) {
		aic_pccard_release_resources(dev);
		return (ENXIO);
	}

	device_set_desc(dev, "Adaptec 6260/6360 SCSI controller");

	error = aic_attach(aic);
	if (error) {
		device_printf(dev, "attach failed\n");
		aic_pccard_release_resources(dev);
		return (error);
	}

	error = bus_setup_intr(dev, sc->sc_irq, 0, aic_intr,
			       aic, &sc->sc_ih, NULL);
	if (error) {
		device_printf(dev, "failed to register interrupt handler\n");
		aic_pccard_release_resources(dev);
		return (error);
	}
	return (0);
}
Example #2
0
static int
aic_pccard_attach(device_t dev)
{
	struct aic_pccard_softc *sc = device_get_softc(dev);
	struct aic_softc *aic = &sc->sc_aic;
	int error;

	if (aic_pccard_alloc_resources(dev))
		return (ENXIO);
	if (aic_probe(aic)) {
		aic_pccard_release_resources(dev);
		return (ENXIO);
	}

	error = aic_attach(aic);
	if (error) {
		device_printf(dev, "attach failed\n");
		aic_pccard_release_resources(dev);
		return (error);
	}

	error = bus_setup_intr(dev, sc->sc_irq, INTR_TYPE_CAM | INTR_ENTROPY |
	    INTR_MPSAFE, NULL, aic_intr, aic, &sc->sc_ih);
	if (error) {
		device_printf(dev, "failed to register interrupt handler\n");
		aic_pccard_release_resources(dev);
		return (error);
	}
	return (0);
}
Example #3
0
static int
aic_pccard_attach(device_t dev)
{
	struct aic_pccard_softc *sc = device_get_softc(dev);
	struct aic_softc *aic = &sc->sc_aic;
	int error;

	error = aic_pccard_alloc_resources(dev);
	if (error) {
		device_printf(dev, "resource allocation failed\n");
		return (error);
	}

	error = aic_attach(aic);
	if (error) {
		device_printf(dev, "attach failed\n");
		aic_pccard_release_resources(dev);
		return (error);
	}

	error = bus_setup_intr(dev, sc->sc_irq, INTR_TYPE_CAM, aic_intr,
	    aic, &sc->sc_ih);
	if (error) {
		device_printf(dev, "failed to register interrupt handler\n");
		aic_pccard_release_resources(dev);
		return (error);
	}
	return (0);
}
Example #4
0
static int
aic_pccard_alloc_resources(device_t dev)
{
	struct aic_pccard_softc *sc = device_get_softc(dev);
	int rid;

	sc->sc_port = sc->sc_irq = NULL;

	rid = 0;
	sc->sc_port = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid,
	    0ul, ~0ul, AIC_PCCARD_PORTSIZE, RF_ACTIVE);
	if (!sc->sc_port)
		return (ENOMEM);

	rid = 0;
	sc->sc_irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, RF_ACTIVE);
	if (!sc->sc_irq) {
		aic_pccard_release_resources(dev);
		return (ENOMEM);
	}

	sc->sc_aic.dev = dev;
	sc->sc_aic.unit = device_get_unit(dev);
	sc->sc_aic.tag = rman_get_bustag(sc->sc_port);
	sc->sc_aic.bsh = rman_get_bushandle(sc->sc_port);
	return (0);
}
Example #5
0
static int
aic_pccard_alloc_resources(device_t dev)
{
	struct aic_pccard_softc *sc = device_get_softc(dev);
	int rid;

	sc->sc_port = sc->sc_irq = NULL;

	rid = 0;
	sc->sc_port = bus_alloc_resource_anywhere(dev, SYS_RES_IOPORT, &rid,
	    AIC_PCCARD_PORTSIZE, RF_ACTIVE);
	if (!sc->sc_port)
		return (ENOMEM);

	rid = 0;
	sc->sc_irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, RF_ACTIVE);
	if (!sc->sc_irq) {
		aic_pccard_release_resources(dev);
		return (ENOMEM);
	}

	sc->sc_aic.dev = dev;
	sc->sc_aic.res = sc->sc_port;
	mtx_init(&sc->sc_aic.lock, "aic", NULL, MTX_DEF);
	return (0);
}
Example #6
0
static int
aic_pccard_probe(device_t dev)
{
	struct aic_pccard_softc *sc = device_get_softc(dev);
	struct aic_softc *aic = &sc->sc_aic;

	if (aic_pccard_alloc_resources(dev))
		return (ENXIO);
	if (aic_probe(aic)) {
		aic_pccard_release_resources(dev);
		return (ENXIO);
	}
	aic_pccard_release_resources(dev);

	device_set_desc(dev, "Adaptec 6260/6360 SCSI controller");
	return (0);
}
Example #7
0
static int
aic_pccard_detach(device_t dev)
{
	struct aic_pccard_softc *sc = device_get_softc(dev);
	struct aic_softc *aic = &sc->sc_aic;
	int error;

	error = bus_teardown_intr(dev, sc->sc_irq, sc->sc_ih);
	if (error) {
		device_printf(dev, "failed to unregister interrupt handler\n");
	}

	error = aic_detach(aic);
	if (error) {
		device_printf(dev, "detach failed\n");
		return (error);
	}

	aic_pccard_release_resources(dev);
	return (0);
}