Beispiel #1
0
void
com_isa_attach(struct device *parent, struct device *self, void *aux)
{
	struct com_softc *sc = (struct com_softc *)self;
	struct isa_attach_args *ia = aux;
	bus_space_handle_t ioh;
	bus_space_tag_t iot;
	int iobase, irq;

	sc->sc_hwflags = 0;
	sc->sc_swflags = 0;

	iobase = ia->ia_iobase;
	iot = ia->ia_iot;

#ifdef KGBD
	if ((iobase != comconsaddr) &&
	    (iobase != com_kgdb_addr)) {
#else
	if (iobase != comconsaddr) {
#endif
		if (bus_space_map(iot, iobase, COM_NPORTS, 0, &ioh))
			panic("com_isa_attach: mapping failed");
	} else {
#ifdef KGDB
		if (iobase == comconsaddr)
			ioh = comconsioh;
		else
			ioh = com_kgdb_ioh;
#else
		ioh = comconsioh;
#endif
	}

	sc->sc_iot = iot;
	sc->sc_ioh = ioh;
	sc->sc_iobase = iobase;
	sc->sc_frequency = COM_FREQ;

	com_attach_subr(sc);

	irq = ia->ia_irq;
	if (irq != IRQUNK) {
#ifdef KGDB     
		if (iobase == com_kgdb_addr) {
			sc->sc_ih = isa_intr_establish(ia->ia_ic, irq,
				IST_EDGE, IPL_HIGH, kgdbintr, sc,
				sc->sc_dev.dv_xname);
		} else {
			sc->sc_ih = isa_intr_establish(ia->ia_ic, irq,
				IST_EDGE, IPL_TTY, comintr, sc,
				sc->sc_dev.dv_xname);
		}
#else   
		sc->sc_ih = isa_intr_establish(ia->ia_ic, irq,
			IST_EDGE, IPL_TTY, comintr, sc,
			sc->sc_dev.dv_xname);
#endif /* KGDB */
	}
}
Beispiel #2
0
void *
pci_intr_establish(pci_chipset_tag_t pc, pci_intr_handle_t ih, int level,
    int (*func)(void *), void *arg, const char *what)
{
	void *ret;
	int bus, dev;
	int l = ih.line & APIC_INT_LINE_MASK;

	pci_decompose_tag(pc, ih.tag, &bus, &dev, NULL);
#if NACPIPRT > 0
	acpiprt_route_interrupt(bus, dev, ih.pin);
#endif

#if NIOAPIC > 0
	if (l != -1 && ih.line & APIC_INT_VIA_APIC)
		return (apic_intr_establish(ih.line, IST_LEVEL, level, func, 
		    arg, what));
#endif
	if (l == 0 || l >= ICU_LEN || l == 2)
		panic("pci_intr_establish: bogus handle 0x%x", l);

	ret = isa_intr_establish(NULL, l, IST_LEVEL, level, func, arg, what);
#if NPCIBIOS > 0
	if (ret)
		pci_intr_route_link(pc, &ih);
#endif
	return (ret);
}
Beispiel #3
0
void
fmv_isa_attach(device_t parent, device_t self, void *aux)
{
	struct fmv_isa_softc *isc = device_private(self);
	struct mb86960_softc *sc = &isc->sc_mb86960;
	struct isa_attach_args *ia = aux;
	bus_space_tag_t iot = ia->ia_iot;
	bus_space_handle_t ioh;

	sc->sc_dev = self;

	/* Map i/o space. */
	if (bus_space_map(iot, ia->ia_io[0].ir_addr, FMV_NPORTS, 0, &ioh)) {
		aprint_error(": can't map i/o space\n");
		return;
	}

	sc->sc_bst = iot;
	sc->sc_bsh = ioh;

	fmv_attach(sc);

	/* Establish the interrupt handler. */
	isc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq[0].ir_irq,
	    IST_EDGE, IPL_NET, mb86960_intr, sc);
	if (isc->sc_ih == NULL)
		aprint_error_dev(sc->sc_dev,
		    "couldn't establish interrupt handler\n");
}
Beispiel #4
0
void
tpm_attach(struct device *parent, struct device *self, void *aux)
{
	struct tpm_softc *sc = (struct tpm_softc *)self;
	struct isa_attach_args *ia = aux;
	bus_addr_t iobase;
	bus_size_t size;
	int rv;

	if (tpm_legacy_probe(ia->ia_iot, ia->ia_iobase)) {
		sc->sc_bt = ia->ia_iot;
		iobase = ia->ia_iobase;
		size = ia->ia_iosize;
		sc->sc_batm = ia->ia_iot;
		sc->sc_init = tpm_legacy_init;
		sc->sc_start = tpm_legacy_start;
		sc->sc_read = tpm_legacy_read;
		sc->sc_write = tpm_legacy_write;
		sc->sc_end = tpm_legacy_end;
	} else {
		sc->sc_bt = ia->ia_memt;
		iobase = ia->ia_maddr;
		size = TPM_SIZE;
		sc->sc_init = tpm_tis12_init;
		sc->sc_start = tpm_tis12_start;
		sc->sc_read = tpm_tis12_read;
		sc->sc_write = tpm_tis12_write;
		sc->sc_end = tpm_tis12_end;
	}

	if (bus_space_map(sc->sc_bt, iobase, size, 0, &sc->sc_bh)) {
		printf(": cannot map registers\n");
		return;
	}

	if ((rv = (sc->sc_init)(sc, ia->ia_irq, sc->sc_dev.dv_xname))) {
		bus_space_unmap(sc->sc_bt, sc->sc_bh, size);
		return;
	}

	/*
	 * Only setup interrupt handler when we have a vector and the
	 * chip is TIS 1.2 compliant.
	 */
	if (sc->sc_init == tpm_tis12_init && ia->ia_irq != IRQUNK &&
	    (sc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq, IST_EDGE,
	    IPL_TTY, tpm_intr, sc, sc->sc_dev.dv_xname)) == NULL) {
		bus_space_unmap(sc->sc_bt, sc->sc_bh, TPM_SIZE);
		printf("%s: cannot establish interrupt\n",
		    sc->sc_dev.dv_xname);
		return;
	}

#ifdef __FreeBSD__
	sc->sc_suspend = 0;
#else
	sc->sc_suspend = PWR_RESUME;
	sc->sc_powerhook = powerhook_establish(tpm_powerhook, sc);
#endif
}
Beispiel #5
0
static void
pckbc_acpi_intr_establish(struct pckbc_softc *sc, pckbc_slot_t slot)
{
	struct pckbc_acpi_softc *psc;
	isa_chipset_tag_t ic = NULL;
	void *rv = NULL;
	int irq = 0, ist = 0; /* XXX: gcc */
	int i;

	/*
	 * Note we're always called with sc == first.
	 */
	for (i = 0; i < pckbc_cd.cd_ndevs; i++) {
		psc = device_lookup_private(&pckbc_cd, i);
		if (psc && psc->sc_slot == slot) {
			irq = psc->sc_irq;
			ist = psc->sc_ist;
			ic = psc->sc_ic;
			break;
		}
	}
	if (i < pckbc_cd.cd_ndevs)
		rv = isa_intr_establish(ic, irq, ist, IPL_TTY, pckbcintr, sc);
	if (rv == NULL) {
		aprint_error_dev(sc->sc_dv,
		    "unable to establish interrupt for %s slot\n",
		    pckbc_slot_names[slot]);
	} else {
		aprint_normal_dev(sc->sc_dv, "using irq %d for %s slot\n",
		    irq, pckbc_slot_names[slot]);
	}
}
static void
slhci_isa_attach(device_t parent, device_t self, void *aux)
{
	struct slhci_isa_softc *isc = device_private(self);
	struct slhci_softc *sc = &isc->sc;
	struct isa_attach_args *ia = aux;
	bus_space_tag_t iot = ia->ia_iot;
	bus_space_handle_t ioh;

	sc->sc_dev = self;
	sc->sc_bus.hci_private = sc;

	printf("\n"); /* XXX still needed? */

	/* Map I/O space */
	if (bus_space_map(iot, ia->ia_io[0].ir_addr, SL11_PORTSIZE, 0, &ioh)) {
		printf("%s: can't map I/O space\n", SC_NAME(sc));
		return;
	}

	/* Initialize sc XXX power value unconfirmed */
	slhci_preinit(sc, NULL, iot, ioh, 30, SL11_IDX_DATA);

	/* Establish the interrupt handler */
	isc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq[0].ir_irq,
					IST_EDGE, IPL_USB, slhci_intr, sc);
	if (isc->sc_ih == NULL) {
		printf("%s: can't establish interrupt\n", SC_NAME(sc));
		return;
	}

	/* Attach SL811HS/T */
	if (slhci_attach(sc))
		printf("%s: slhci_attach failed\n", SC_NAME(sc));
}
Beispiel #7
0
void
cy_isa_attach(device_t parent, device_t self, void *aux)
{
    struct cy_softc *sc = device_private(self);
    struct isa_attach_args *ia = aux;

    sc->sc_dev = self;
    sc->sc_memt = ia->ia_memt;
    sc->sc_bustype = CY_BUSTYPE_ISA;

    printf(": Cyclades-Y multiport serial\n");

    if (bus_space_map(ia->ia_memt, ia->ia_iomem[0].ir_addr, CY_MEMSIZE, 0,
                      &sc->sc_bsh) != 0) {
        aprint_error_dev(sc->sc_dev,
                         "unable to map device registers\n");
        return;
    }

    if (cy_find(sc) == 0) {
        aprint_error_dev(sc->sc_dev, "unable to find CD1400s\n");
        return;
    }

    cy_attach(sc);

    sc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq[0].ir_irq,
                                   IST_EDGE, IPL_TTY, cy_intr, sc);
    if (sc->sc_ih == NULL)
        aprint_error_dev(sc->sc_dev, "unable to establish interrupt\n");
}
Beispiel #8
0
void
mmsattach(struct device *parent, struct device *self, void *aux)
{
	struct mms_softc *sc = (void *)self;
	struct isa_attach_args *ia = aux;
	bus_space_tag_t iot = ia->ia_iot;
	bus_space_handle_t ioh;
	struct wsmousedev_attach_args a;

	printf("\n");

	if (bus_space_map(iot, ia->ia_iobase, MMS_NPORTS, 0, &ioh)) {
		printf("%s: can't map i/o space\n", sc->sc_dev.dv_xname);
		return;
	}

	/* Other initialization was done by mmsprobe. */
	sc->sc_iot = iot;
	sc->sc_ioh = ioh;
	sc->sc_enabled = 0;

	sc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq, IST_PULSE,
	    IPL_TTY, mmsintr, sc, sc->sc_dev.dv_xname);

	a.accessops = &mms_accessops;
	a.accesscookie = sc;

	/*
	 * Attach the wsmouse, saving a handle to it.
	 * Note that we don't need to check this pointer against NULL
	 * here or in psmintr, because if this fails lms_enable() will
	 * never be called, so lmsintr() will never be called.
	 */
	sc->sc_wsmousedev = config_found(self, &a, wsmousedevprint);
}
Beispiel #9
0
void
wdc_isa_attach(struct device *parent, struct device *self, void *aux)
{
	struct wdc_isa_softc *sc = (void *)self;
	struct isa_attach_args *ia = aux;

	printf("\n");

	sc->wdc_channel.cmd_iot = ia->ia_iot;
	sc->wdc_channel.ctl_iot = ia->ia_iot;
	sc->sc_ic = ia->ia_ic;
	sc->sc_isa = parent;

	if (bus_space_map(sc->wdc_channel.cmd_iot, ia->ia_iobase,
	    WDC_ISA_REG_NPORTS, 0, &sc->wdc_channel.cmd_ioh) ||
	    bus_space_map(sc->wdc_channel.ctl_iot,
	      ia->ia_iobase + WDC_ISA_AUXREG_OFFSET, WDC_ISA_AUXREG_NPORTS,
	      0, &sc->wdc_channel.ctl_ioh)) {
		printf("%s: couldn't map registers\n",
		    sc->sc_wdcdev.sc_dev.dv_xname);
	}
	sc->wdc_channel.data32iot = sc->wdc_channel.cmd_iot;
	sc->wdc_channel.data32ioh = sc->wdc_channel.cmd_ioh;

	sc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq, IST_EDGE,
	    IPL_BIO, wdcintr, &sc->wdc_channel, sc->sc_wdcdev.sc_dev.dv_xname);

	if (ia->ia_drq != DRQUNK) {
#if NISADMA > 0
		sc->sc_drq = ia->ia_drq;

		sc->sc_wdcdev.cap |= WDC_CAPABILITY_DMA;
		sc->sc_wdcdev.dma_arg = sc;
		sc->sc_wdcdev.dma_init = wdc_isa_dma_init;
		sc->sc_wdcdev.dma_start = wdc_isa_dma_start;
		sc->sc_wdcdev.dma_finish = wdc_isa_dma_finish;
		wdc_isa_dma_setup(sc);
#else	/* NISADMA > 0 */
		printf("%s: ignoring drq, isa dma not supported",
		    sc->sc_wdcdev.sc_dev.dv_xname);
#endif	/* NISADMA > 0 */
	}
	sc->sc_wdcdev.cap |= WDC_CAPABILITY_DATA16 | WDC_CAPABILITY_PREATA;
	if (sc->sc_wdcdev.sc_dev.dv_cfdata->cf_flags & WDC_OPTIONS_32)
		sc->sc_wdcdev.cap |= WDC_CAPABILITY_DATA32;
	sc->sc_wdcdev.PIO_cap = 0;
	sc->wdc_chanptr = &sc->wdc_channel;
	sc->sc_wdcdev.channels = &sc->wdc_chanptr;
	sc->sc_wdcdev.nchannels = 1;
	sc->wdc_channel.channel = 0;
	sc->wdc_channel.wdc = &sc->sc_wdcdev;
	sc->wdc_channel.ch_queue = wdc_alloc_queue();
	if (sc->wdc_channel.ch_queue == NULL) {
		printf("%s: cannot allocate channel queue",
		    sc->sc_wdcdev.sc_dev.dv_xname);
		return;
	}
	wdcattach(&sc->wdc_channel);
	wdc_print_current_modes(&sc->wdc_channel);
}
Beispiel #10
0
void
sbattach(struct sbdsp_softc *sc)
{
	struct audio_attach_args arg;
#if NMIDI > 0
	struct midi_hw_if *mhw = &sb_midi_hw_if;
#endif

	sc->sc_ih = isa_intr_establish(sc->sc_ic, sc->sc_irq,
	    IST_EDGE, IPL_AUDIO | IPL_MPSAFE,
	    sbdsp_intr, sc, sc->sc_dev.dv_xname);

	sbdsp_attach(sc);

#if NMIDI > 0
	sc->sc_hasmpu = 0;
	if (ISSB16CLASS(sc) && sc->sc_mpu_sc.iobase != 0) {
		sc->sc_mpu_sc.iot = sc->sc_iot;
		if (mpu_find(&sc->sc_mpu_sc)) {
			sc->sc_hasmpu = 1;
			mhw = &sb_mpu401_hw_if;
		}
	}
	midi_attach_mi(mhw, sc, &sc->sc_dev);
#endif

	audio_attach_mi(&sb_hw_if, sc, &sc->sc_dev);

	arg.type = AUDIODEV_TYPE_OPL;
	arg.hwif = 0;
	arg.hdl = 0;
	(void)config_found(&sc->sc_dev, &arg, audioprint);
}
Beispiel #11
0
void
fdcattach(struct device *parent, struct device *self, void *aux)
{
	struct fdc_softc *fdc = (void *)self;
	bus_space_tag_t iot;
	bus_space_handle_t ioh;
	bus_space_handle_t ioh_ctl;
	struct isa_attach_args *ia = aux;
	struct fdc_attach_args fa;
	int type;

	iot = ia->ia_iot;

	/* Re-map the I/O space. */
	if (bus_space_map(iot, ia->ia_iobase, FDC_NPORT, 0, &ioh) ||
	    bus_space_map(iot, ia->ia_iobase + FDCTL_OFFSET,
			  FDCTL_NPORT, 0, &ioh_ctl))
		panic("fdcattach: couldn't map I/O ports");

	fdc->sc_iot = iot;
	fdc->sc_ioh = ioh;
	fdc->sc_ioh_ctl = ioh_ctl;

	fdc->sc_drq = ia->ia_drq;
	fdc->sc_state = DEVIDLE;
	TAILQ_INIT(&fdc->sc_link.fdlink.sc_drives);	/* XXX */

	printf("\n");

	fdc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq, IST_EDGE,
	    IPL_BIO, fdcintr, fdc, fdc->sc_dev.dv_xname);

#if defined(__i386__) || defined(__amd64__)
	/*
	 * The NVRAM info only tells us about the first two disks on the
	 * `primary' floppy controller.
	 */
	if (fdc->sc_dev.dv_unit == 0)
		type = mc146818_read(NULL, NVRAM_DISKETTE); /* XXX softc */
	else
#endif
		type = -1;

	timeout_set(&fdc->fdcpseudointr_to, fdcpseudointr, fdc);

	/* physical limit: four drives per controller. */
	for (fa.fa_drive = 0; fa.fa_drive < 4; fa.fa_drive++) {
		fa.fa_flags = 0;
		fa.fa_type = 0;
#if NFD > 0
		if (type >= 0 && fa.fa_drive < 2)
			fa.fa_deftype = fd_nvtotype(fdc->sc_dev.dv_xname,
			    type, fa.fa_drive);
		else
#endif
			fa.fa_deftype = NULL;		/* unknown */
		(void)config_found(self, (void *)&fa, fddprint);
	}
}
Beispiel #12
0
static void
tpm_isa_attach(device_t parent, device_t self, void *aux)
{
	struct tpm_softc *sc = device_private(self);
	struct isa_attach_args *ia = aux;
	bus_addr_t iobase;
	bus_size_t size;
	int rv;

	sc->sc_dev = self;

	if (tpm_legacy_probe(ia->ia_iot, ia->ia_io[0].ir_addr)) {
		sc->sc_bt = ia->ia_iot;
		iobase = (unsigned int)ia->ia_io[0].ir_addr;
		size = ia->ia_io[0].ir_size;
		sc->sc_batm = ia->ia_iot;
		sc->sc_init = tpm_legacy_init;
		sc->sc_start = tpm_legacy_start;
		sc->sc_read = tpm_legacy_read;
		sc->sc_write = tpm_legacy_write;
		sc->sc_end = tpm_legacy_end;
	} else {
		sc->sc_bt = ia->ia_memt;
		iobase = (unsigned int)ia->ia_iomem[0].ir_addr;
		size = TPM_SIZE;
		sc->sc_init = tpm_tis12_init;
		sc->sc_start = tpm_tis12_start;
		sc->sc_read = tpm_tis12_read;
		sc->sc_write = tpm_tis12_write;
		sc->sc_end = tpm_tis12_end;
	}

	if (bus_space_map(sc->sc_bt, iobase, size, 0, &sc->sc_bh)) {
		aprint_error_dev(sc->sc_dev, "cannot map registers\n");
		return;
	}

	if ((rv = (*sc->sc_init)(sc, ia->ia_irq[0].ir_irq,
	    device_xname(sc->sc_dev))) != 0) {
		bus_space_unmap(sc->sc_bt, sc->sc_bh, size);
		return;
	}

	/*
	 * Only setup interrupt handler when we have a vector and the
	 * chip is TIS 1.2 compliant.
	 */
	if (sc->sc_init == tpm_tis12_init &&
	    ia->ia_irq[0].ir_irq != ISA_UNKNOWN_IRQ &&
	    (sc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq[0].ir_irq,
	    IST_EDGE, IPL_TTY, tpm_intr, sc)) == NULL) {
		bus_space_unmap(sc->sc_bt, sc->sc_bh, TPM_SIZE);
		aprint_error_dev(sc->sc_dev, "cannot establish interrupt\n");
		return;
	}

	if (!pmf_device_register(sc->sc_dev, tpm_suspend, tpm_resume))
		aprint_error_dev(sc->sc_dev, "Cannot set power mgmt handler\n");
}
Beispiel #13
0
void
cecattach(struct device *parent, struct device *self, void *aux)
{
	struct cec_softc *sc = (struct cec_softc *)self;
	struct isa_attach_args *ia = aux;
	struct gpibdev_attach_args ga;
	bus_size_t maxsize;

	printf("\n");

	DPRINTF(DBG_CONFIG, ("cecattach: called\n"));

	sc->sc_iot = ia->ia_iot;
	sc->sc_ic = ia->ia_ic;

	if (bus_space_map(sc->sc_iot, ia->ia_io[0].ir_addr, CEC_IOSIZE,
	    0, &sc->sc_ioh) != 0) {
		printf("%s: unable to map I/O space\n", sc->sc_dev.dv_xname);
		return;
	}

	if (ia->ia_ndrq > 0) {
		sc->sc_flags |= CECF_USEDMA;
		sc->sc_drq = ia->ia_drq[0].ir_drq;

		(void) isa_drq_alloc(sc->sc_ic, sc->sc_drq);
		maxsize = isa_dmamaxsize(sc->sc_ic, sc->sc_drq);
		if (isa_dmamap_create(sc->sc_ic, sc->sc_drq,
		    maxsize, BUS_DMA_NOWAIT | BUS_DMA_ALLOCNOW)) {
			printf("%s: unable to create map for drq %d\n",
			    sc->sc_dev.dv_xname, sc->sc_drq);
			sc->sc_flags &= ~CECF_USEDMA;
		}
	}

	sc->sc_myaddr = 15;		/* XXX */

	cecreset(sc);
	(void) nec7210_setaddress(sc, sc->sc_myaddr, -1);

	sc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq[0].ir_irq,
	    IST_EDGE, IPL_BIO, cecintr, sc);
	if (sc->sc_ih == NULL) {
		printf("%s: couldn't establish interrupt\n",
		    sc->sc_dev.dv_xname);
		return;
	}

	callout_init(&sc->sc_timeout_ch);

	/* attach MI GPIB bus */
	cec_ic.cookie = (void *)sc;
	ga.ga_ic = &cec_ic;
	ga.ga_address = sc->sc_myaddr;
	sc->sc_gpib =
	    (struct gpib_softc *)config_found(self, &ga, gpibdevprint);
}
Beispiel #14
0
void
com_isa_attach(device_t parent, device_t self, void *aux)
{
	struct com_isa_softc *isc = device_private(self);
	struct com_softc *sc = &isc->sc_com;
	int iobase, irq;
	bus_space_tag_t iot;
	bus_space_handle_t ioh;
	struct isa_attach_args *ia = aux;
#ifdef COM_HAYESP
	int	hayesp_ports[] = { 0x140, 0x180, 0x280, 0x300, 0 };
	int	*hayespp;
#endif

	/*
	 * We're living on an isa.
	 */
	iobase = ia->ia_io[0].ir_addr;
	iot = ia->ia_iot;

	if (!com_is_console(iot, iobase, &ioh) &&
	    bus_space_map(iot, iobase, COM_NPORTS, 0, &ioh)) {
		printf(": can't map i/o space\n");
		return;
	}

	sc->sc_dev = self;

	COM_INIT_REGS(sc->sc_regs, iot, ioh, iobase);

	sc->sc_frequency = COM_FREQ;
	irq = ia->ia_irq[0].ir_irq;

#ifdef COM_HAYESP
	for (hayespp = hayesp_ports; *hayespp != 0; hayespp++) {
		bus_space_handle_t	hayespioh;
#define	HAYESP_NPORTS	8
		if (bus_space_map(iot, *hayespp, HAYESP_NPORTS, 0, &hayespioh))
			continue;
		if (com_isa_isHAYESP(hayespioh, sc)) {
			break;
		}
		bus_space_unmap(iot, hayespioh, HAYESP_NPORTS);
	}
#endif

	com_attach_subr(sc);

	if (!pmf_device_register1(self, com_isa_suspend, com_isa_resume,
	    com_cleanup))
		aprint_error_dev(self, "couldn't establish power handler\n");

	isc->sc_ic = ia->ia_ic;
	isc->sc_irq = irq;
	isc->sc_ih = isa_intr_establish(ia->ia_ic, irq, IST_EDGE, IPL_SERIAL,
	    comintr, sc);
}
Beispiel #15
0
void *
mca_intr_establish(mca_chipset_tag_t mc, mca_intr_handle_t ih,
    int level, int (*func)(void *), void *arg)
{
	if (ih == 0 || ih >= NUM_LEGACY_IRQS || ih == 2)
		panic("mca_intr_establish: bogus handle 0x%x", ih);

	/* MCA interrupts are always level-triggered */
	return isa_intr_establish(NULL, ih, IST_LEVEL, level, func, arg);
}
Beispiel #16
0
/*
 * Attach hardware to driver, attach hardware driver to audio
 * pseudo-device driver .
 */
void
wssattach(struct wss_softc *sc)
{
	struct ad1848_softc *ac;
#if 0 /* loses on CS423X chips */
	int version;
#endif

	ac = &sc->sc_ad1848.sc_ad1848;

	ad1848_init_locks(ac, IPL_AUDIO);

	madattach(sc);

	sc->sc_ad1848.sc_ih = isa_intr_establish(sc->wss_ic, sc->wss_irq,
	    IST_EDGE, IPL_AUDIO, wss_intr, &sc->sc_ad1848);

	ad1848_isa_attach(&sc->sc_ad1848);

#if 0 /* loses on CS423X chips */
	version = bus_space_read_1(sc->sc_iot, sc->sc_ioh, WSS_STATUS)
	    & WSS_VERSMASK;
	printf(" (vers %d)", version);
#endif

	switch(sc->mad_chip_type) {
	case MAD_82C928:
		printf(", 82C928");
		break;
	case MAD_OTI601D:
		printf(", OTI-601D");
		break;
	case MAD_82C929:
		printf(", 82C929");
		break;
	case MAD_82C931:
		printf(", 82C931");
		break;
	default:
		break;
	}
	printf("\n");

	ac->parent = sc;

	audio_attach_mi(&wss_hw_if, &sc->sc_ad1848, ac->sc_dev);

	if (sc->mad_chip_type != MAD_NONE) {
		struct audio_attach_args arg;
		arg.type = AUDIODEV_TYPE_OPL;
		arg.hwif = 0;
		arg.hdl = 0;
		(void)config_found(ac->sc_dev, &arg, audioprint);
	}
}
Beispiel #17
0
void
adv_isa_attach(device_t parent, device_t self, void *aux)
{
	struct isa_attach_args *ia = aux;
	ASC_SOFTC *sc = device_private(self);
	bus_space_tag_t iot = ia->ia_iot;
	bus_space_handle_t ioh;
	isa_chipset_tag_t ic = ia->ia_ic;
	int error;

	printf("\n");

	sc->sc_dev = self;
	sc->sc_flags = 0x0;

	if (bus_space_map(iot, ia->ia_io[0].ir_addr, ASC_IOADR_GAP, 0, &ioh)) {
		aprint_error_dev(sc->sc_dev, "can't map i/o space\n");
		return;
	}

	sc->sc_iot = iot;
	sc->sc_ioh = ioh;
	sc->sc_dmat = ia->ia_dmat;
	sc->bus_type = ASC_IS_ISA;
	sc->chip_version = ASC_GET_CHIP_VER_NO(iot, ioh);
	/*
	 * Memo:
	 * for EISA cards:
	 * sc->chip_version = (ASC_CHIP_MIN_VER_EISA - 1) + ea->ea_pid[1];
	 */

	/*
	 * Initialize the board
	 */
	if (adv_init(sc)) {
		aprint_error_dev(sc->sc_dev, "adv_init failed\n");
		return;
	}

	if ((error = isa_dmacascade(ic, ia->ia_drq[0].ir_drq)) != 0) {
		aprint_error_dev(sc->sc_dev,
		    "unable to cascade DRQ, error = %d\n", error);
		return;
	}

	sc->sc_ih = isa_intr_establish(ic, ia->ia_irq[0].ir_irq, IST_EDGE,
	    IPL_BIO, adv_intr, sc);
	if (sc->sc_ih == NULL) {
		aprint_error_dev(sc->sc_dev, "couldn't establish interrupt\n");
		return;
	}

	adv_attach(sc);
}
Beispiel #18
0
static bool
com_isa_resume(device_t self PMF_FN_ARGS)
{
	struct com_isa_softc *isc = device_private(self);
	struct com_softc *sc = &isc->sc_com;

	isc->sc_ih = isa_intr_establish(isc->sc_ic, isc->sc_irq, IST_EDGE,
	    IPL_SERIAL, comintr, sc);

	return com_resume(self PMF_FN_CALL);
}
Beispiel #19
0
/*
 * Attach all the sub-devices we can find
 */
void
uha_isa_attach(struct device *parent, struct device *self, void *aux)
{
	struct isa_attach_args *ia = aux;
	struct uha_softc *sc = (void *)self;
	bus_space_tag_t iot = ia->ia_iot;
	bus_dma_tag_t dmat = ia->ia_dmat;
	bus_space_handle_t ioh;
	struct uha_probe_data upd;
	isa_chipset_tag_t ic = ia->ia_ic;
	int error;

	printf("\n");

	if (bus_space_map(iot, ia->ia_io[0].ir_addr, UHA_ISA_IOSIZE, 0, &ioh)) {
		aprint_error_dev(&sc->sc_dev, "can't map i/o space\n");
		return;
	}

	sc->sc_iot = iot;
	sc->sc_ioh = ioh;
	sc->sc_dmat = dmat;
	if (!u14_find(iot, ioh, &upd)) {
		aprint_error_dev(&sc->sc_dev, "u14_find failed\n");
		return;
	}

	if (upd.sc_drq != -1) {
		sc->sc_dmaflags = 0;
		if ((error = isa_dmacascade(ic, upd.sc_drq)) != 0) {
			aprint_error_dev(&sc->sc_dev, "unable to cascade DRQ, error = %d\n", error);
			return;
		}
	} else {
		/*
		 * We have a VLB controller, and can do 32-bit DMA.
		 */
		sc->sc_dmaflags = ISABUS_DMA_32BIT;
	}

	sc->sc_ih = isa_intr_establish(ic, upd.sc_irq, IST_EDGE, IPL_BIO,
	    u14_intr, sc);
	if (sc->sc_ih == NULL) {
		aprint_error_dev(&sc->sc_dev, "couldn't establish interrupt\n");
		return;
	}

	/* Save function pointers for later use. */
	sc->start_mbox = u14_start_mbox;
	sc->poll = u14_poll;
	sc->init = u14_init;

	uha_attach(sc, &upd);
}
Beispiel #20
0
static void
spic_acpi_attach(device_t parent, device_t self, void *aux)
{
	struct spic_acpi_softc *sc = device_private(self);
	struct acpi_attach_args *aa = aux;
	struct acpi_io *io;
	struct acpi_irq *irq;
	struct acpi_resources res;

	ACPI_STATUS rv;

	aprint_naive(": Sony Programmable I/O Controller\n");
	aprint_normal(": Sony Programmable I/O Controller\n");

	sc->sc_spic.sc_dev = self;
	sc->sc_node = aa->aa_node;

	/* Parse our resources. */
	rv = acpi_resource_parse(self, sc->sc_node->ad_handle,
	    "_CRS", &res, &acpi_resource_parse_ops_default);
	if (ACPI_FAILURE(rv))
		return;

	sc->sc_spic.sc_iot = aa->aa_iot;
	io = acpi_res_io(&res, 0);
	if (io == NULL) {
		aprint_error_dev(self, "unable to find io resource\n");
		goto out;
	}
	if (bus_space_map(sc->sc_spic.sc_iot, io->ar_base, io->ar_length,
	    0, &sc->sc_spic.sc_ioh) != 0) {
		aprint_error_dev(self, "unable to map data register\n");
		goto out;
	}
	irq = acpi_res_irq(&res, 0);
	if (irq == NULL) {
		aprint_error_dev(self, "unable to find irq resource\n");
		/* XXX unmap */
		goto out;
	}
#if 0
	sc->sc_ih = isa_intr_establish(NULL, irq->ar_irq,
	    IST_EDGE, IPL_TTY, spic_intr, sc);
#endif

	if (!pmf_device_register(self, spic_suspend, spic_resume))
		aprint_error_dev(self, "couldn't establish power handler\n");
	else
		pmf_class_input_register(self);

	spic_attach(&sc->sc_spic);
 out:
	acpi_resource_cleanup(&res);
}
Beispiel #21
0
static bool
com_isa_resume(device_t self, const pmf_qual_t *qual)
{
	struct com_isa_softc *isc = device_private(self);
	struct com_softc *sc = &isc->sc_com;

	isc->sc_ih = isa_intr_establish(isc->sc_ic, isc->sc_irq, IST_EDGE,
	    IPL_SERIAL, comintr, sc);

	return com_resume(self, qual);
}
Beispiel #22
0
void
le_isapnp_attach(struct device *parent, struct device *self, void *aux)
{
	struct le_softc *lesc = (void *)self;
	struct isa_attach_args *ia = aux;
	struct am7990_softc *sc = &lesc->sc_am7990;
	bus_space_tag_t iot = lesc->sc_iot;
	bus_space_handle_t ioh = lesc->sc_ioh;
	int i;

	lesc->sc_iot = iot = ia->ia_iot;
	lesc->sc_ioh = ioh = ia->ipa_io[0].h;
	lesc->sc_rap = NE2100_RAP;
	lesc->sc_rdp = NE2100_RDP;
	lesc->sc_card = NE2100;

	/*
	 * Extract the physical MAC address from the ROM.
	 */
	for (i = 0; i < sizeof(sc->sc_arpcom.ac_enaddr); i++)
		sc->sc_arpcom.ac_enaddr[i] = bus_space_read_1(iot, ioh, i);

	sc->sc_mem = malloc(16384, M_DEVBUF, M_NOWAIT);
	if (sc->sc_mem == 0) {
		printf(": couldn't allocate memory for card\n");
		return;
	}

	sc->sc_conf3 = 0;
	sc->sc_addr = kvtop(sc->sc_mem);
	sc->sc_memsize = 16384;

	sc->sc_copytodesc = am7990_copytobuf_contig;
	sc->sc_copyfromdesc = am7990_copyfrombuf_contig;
	sc->sc_copytobuf = am7990_copytobuf_contig;
	sc->sc_copyfrombuf = am7990_copyfrombuf_contig;
	sc->sc_zerobuf = am7990_zerobuf_contig;

	sc->sc_rdcsr = le_isa_rdcsr;
	sc->sc_wrcsr = le_isa_wrcsr;
	sc->sc_hwreset = NULL;
	sc->sc_hwinit = NULL;

	am7990_config(sc);

#if NISADMA > 0
	if (ia->ia_drq != DRQUNK)
		isadma_cascade(ia->ia_drq);
#endif

	lesc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq, IST_EDGE,
	    IPL_NET, le_isa_intredge, sc, sc->sc_dev.dv_xname);
}
Beispiel #23
0
void
mcdattach(struct device *parent, struct device *self, void *aux)
{
	struct mcd_softc *sc = (void *)self;
	struct isa_attach_args *ia = aux;
	bus_space_tag_t iot = ia->ia_iot;
	bus_space_handle_t ioh;
	struct mcd_mbox mbx;

	/* Map i/o space */
	if (bus_space_map(iot, ia->ia_io[0].ir_addr, MCD_NPORT, 0, &ioh)) {
		printf(": can't map i/o space\n");
		return;
	}

	mutex_init(&sc->sc_lock, MUTEX_DEFAULT, IPL_NONE);

	sc->sc_iot = iot;
	sc->sc_ioh = ioh;

	sc->probe = 0;
	sc->debug = 0;

	if (!mcd_find(iot, ioh, sc)) {
		printf(": mcd_find failed\n");
		return;
	}

	bufq_alloc(&sc->buf_queue, "disksort", BUFQ_SORT_RAWBLOCK);
	callout_init(&sc->sc_pintr_ch, 0);

	/*
	 * Initialize and attach the disk structure.
	 */
	disk_init(&sc->sc_dk, device_xname(&sc->sc_dev), &mcddkdriver);
	disk_attach(&sc->sc_dk);

	printf(": model %s\n", sc->type != 0 ? sc->type : "unknown");

	(void) mcd_setlock(sc, MCD_LK_UNLOCK);

	mbx.cmd.opcode = MCD_CMDCONFIGDRIVE;
	mbx.cmd.length = sizeof(mbx.cmd.data.config) - 1;
	mbx.cmd.data.config.subcommand = MCD_CF_IRQENABLE;
	mbx.cmd.data.config.data1 = 0x01;
	mbx.res.length = 0;
	(void) mcd_send(sc, &mbx, 0);

	mcd_soft_reset(sc);

	sc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq[0].ir_irq,
	    IST_EDGE, IPL_BIO, mcdintr, sc);
}
void *
pciide_machdep_compat_intr_establish(struct device *dev,
    struct pci_attach_args *pa, int chan, int (*func)(void *), void *arg)
{
	int irq;
	void *cookie;

	irq = PCIIDE_COMPAT_IRQ(chan);
	cookie = isa_intr_establish(NULL, irq, IST_EDGE, IPL_BIO, func, arg,
	    dev->dv_xname);

	return (cookie);
}
Beispiel #25
0
/*
 * mpu_acpi_attach: autoconf(9) attach routine
 */
static void
mpu_acpi_attach(device_t parent, device_t self, void *aux)
{
	struct mpu_acpi_softc *asc = device_private(self);
	struct mpu_softc *sc = &asc->sc_mpu;
	struct acpi_attach_args *aa = aux;
	struct acpi_resources res;
	struct acpi_io *io;
	struct acpi_irq *irq;
	ACPI_STATUS rv;

	/* parse resources */
	rv = acpi_resource_parse(self, aa->aa_node->ad_handle, "_CRS",
	    &res, &acpi_resource_parse_ops_default);
	if (ACPI_FAILURE(rv))
		return;

	/* find our i/o registers */
	io = acpi_res_io(&res, 0);
	if (io == NULL) {
		aprint_error_dev(self,
		    "unable to find i/o register resource\n");
		goto out;
	}

	/* find our IRQ */
	irq = acpi_res_irq(&res, 0);
	if (irq == NULL) {
		aprint_error_dev(self, "unable to find irq resource\n");
		goto out;
	}

	sc->iot = aa->aa_iot;
	if (bus_space_map(sc->iot, io->ar_base, io->ar_length, 0, &sc->ioh)) {
		aprint_error_dev(self, "can't map i/o space\n");
		goto out;
	}

	sc->model = "Roland MPU-401 MIDI UART";
	sc->sc_dev = self;
	sc->lock = &asc->sc_lock;
	mutex_init(&asc->sc_lock, MUTEX_DEFAULT, IPL_AUDIO);
	mpu_attach(sc);

	sc->arg = isa_intr_establish(aa->aa_ic, irq->ar_irq,
	    (irq->ar_type == ACPI_EDGE_SENSITIVE) ? IST_EDGE : IST_LEVEL,
	    IPL_AUDIO, mpu_intr, sc);

 out:
	acpi_resource_cleanup(&res);
}
Beispiel #26
0
void *
depca_isa_intr_establish(struct depca_softc *parent, struct lance_softc *child)
{
	struct depca_isa_softc *isc = (void *) parent;
	void *rv;

	rv = isa_intr_establish(isc->sc_ic, isc->sc_irq, IST_EDGE,
	    IPL_NET, depca_intredge, child);
	if (rv == NULL)
		printf("%s: unable to establish interrupt\n",
		    parent->sc_dev.dv_xname);

	return (rv);
}
Beispiel #27
0
void
an_isapnp_attach(struct device *parent, struct device *self, void *aux)
{
	struct an_softc *sc = (void *)self;
	struct isa_attach_args *ia = aux;

	sc->sc_iot = ia->ia_iot;
	sc->sc_ioh = ia->ipa_io[0].h;

	sc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq, IST_EDGE,
	    IPL_NET, an_intr, sc, sc->sc_dev.dv_xname);

	an_attach(sc);
}
Beispiel #28
0
static void
opms_isa_attach(device_t parent, device_t self, void *aux)
{
	struct opms_softc *sc = device_private(self);
	struct isa_attach_args *ia = aux;

	sc->sc_dev = self;

	aprint_normal("\n");

	isa_intr_establish(ia->ia_ic, ia->ia_irq[0].ir_irq, IST_EDGE, IPL_TTY,
	    pcintr, sc);
	opms_common_attach(sc, ia->ia_iot, pccons_isa_conf);
}
Beispiel #29
0
void
astattach(device_t parent, device_t self, void *aux)
{
	struct ast_softc *sc = device_private(self);
	struct isa_attach_args *ia = aux;
	struct commulti_attach_args ca;
	bus_space_tag_t iot = ia->ia_iot;
	int i, iobase;
	device_t slave;

	printf("\n");

	sc->sc_iot = ia->ia_iot;
	sc->sc_iobase = ia->ia_io[0].ir_addr;

	for (i = 0; i < NSLAVES; i++) {
		iobase = sc->sc_iobase + i * COM_NPORTS;
		if (!com_is_console(iot, iobase, &sc->sc_slaveioh[i]) &&
		    bus_space_map(iot, iobase, COM_NPORTS, 0,
			&sc->sc_slaveioh[i])) {
			aprint_error_dev(self,
			    "can't map i/o space for slave %d\n", i);
			return;
		}
	}

	/*
	 * Enable the master interrupt.
	 */
	bus_space_write_1(iot, sc->sc_slaveioh[3], com_scratch, 0x80);

	for (i = 0; i < NSLAVES; i++) {
		ca.ca_slave = i;
		ca.ca_iot = sc->sc_iot;
		ca.ca_ioh = sc->sc_slaveioh[i];
		ca.ca_iobase = sc->sc_iobase + i * COM_NPORTS;
		ca.ca_noien = 1;

		slave = config_found(self, &ca, commultiprint);
		if (slave != NULL) {
			sc->sc_alive |= 1 << i;
			sc->sc_slaves[i] = device_private(slave);
		}
	}

	sc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq[0].ir_irq,
	    IST_EDGE, IPL_SERIAL, astintr, sc);
}
Beispiel #30
0
void
ioat66attach(device_t parent, device_t self, void *aux)
{
	struct ioat66_softc *sc = device_private(self);
	struct isa_attach_args *ia = aux;
	struct commulti_attach_args ca;
	bus_space_tag_t iot = ia->ia_iot;
	int i, iobase, irq;

	printf("\n");

	sc->sc_iot = ia->ia_iot;
	sc->sc_iobase = ia->ia_io[0].ir_addr;
	irq = ia->ia_irq[0].ir_irq;

	for (i = 0; i < NSLAVES; i++) {
		iobase = ioatbases[i];
		if (!com_is_console(iot, iobase, &sc->sc_slaveioh[i]) &&
		    bus_space_map(iot, iobase, COM_NPORTS, 0,
			&sc->sc_slaveioh[i])) {
			aprint_error_dev(self,
			    "can't map i/o space for slave %d\n", i);
			return;
		}
	}

	if(bus_space_map(iot, IOAT66SHARED, 1, 0, &sc->sc_intmasq)) {
		aprint_error_dev(self, "can't map shared interrupt mask\n");
		return;
	}

	for (i = 0; i < NSLAVES; i++) {

		ca.ca_slave = i;
		ca.ca_iot = sc->sc_iot;
		ca.ca_ioh = sc->sc_slaveioh[i];
		ca.ca_iobase = ioatbases[i];
		ca.ca_noien = 0;

		sc->sc_slaves[i] = config_found(self, &ca, commultiprint);
		if (sc->sc_slaves[i] != NULL)
			sc->sc_alive |= 1 << i;
	}

	sc->sc_ih = isa_intr_establish(ia->ia_ic, irq, IST_EDGE,
	    IPL_SERIAL, ioat66intr, sc);
}