Пример #1
0
static void
joy_isapnp_attach(device_t parent, device_t self, void *aux)
{
	struct joy_softc *sc = device_private(self);
	struct isapnp_attach_args *ipa = aux;
	bus_space_handle_t ioh;

	aprint_normal("\n");

	if (isapnp_config(ipa->ipa_iot, ipa->ipa_memt, ipa)) {
		aprint_error_dev(self, "error in region allocation\n");
		return;
	}

	if (ipa->ipa_io[0].length == 8) {
		if (bus_space_subregion(ipa->ipa_iot, ipa->ipa_io[0].h, 1, 1,
		    &ioh) < 0) {
			aprint_error_dev(self, "error in region allocation\n");
			return;
		}
	} else
		ioh = ipa->ipa_io[0].h;

	sc->sc_iot = ipa->ipa_iot;
	sc->sc_ioh = ioh;
	sc->sc_dev = self;

	aprint_normal_dev(self, "%s %s\n", ipa->ipa_devident,
	    ipa->ipa_devclass);

	joyattach(sc);
}
Пример #2
0
/*
 * Attach hardware to driver, attach hardware driver to audio
 * pseudo-device driver.
 */
void
ym_isapnp_attach(struct device *parent, struct device *self, void *aux)
{
    struct ym_softc *sc;
    struct ad1848_softc *ac;
    struct isapnp_attach_args *ipa;

    sc = device_private(self);
    ac = &sc->sc_ad1848.sc_ad1848;
    ipa = aux;
    printf("\n");

    if (isapnp_config(ipa->ipa_iot, ipa->ipa_memt, ipa)) {
        aprint_error_dev(self, "error in region allocation\n");
        return;
    }

    sc->sc_iot = ipa->ipa_iot;
    sc->sc_ic = ipa->ipa_ic;
    sc->sc_ioh = ipa->ipa_io[1].h;

    sc->ym_irq = ipa->ipa_irq[0].num;
    sc->ym_playdrq = ipa->ipa_drq[0].num;
    sc->ym_recdrq = ipa->ipa_drq[1].num;

    sc->sc_sb_ioh = ipa->ipa_io[0].h;
    sc->sc_opl_ioh = ipa->ipa_io[2].h;
#if NMPU_YM > 0
    sc->sc_mpu_ioh = ipa->ipa_io[3].h;
#endif
    sc->sc_controlioh = ipa->ipa_io[4].h;

    ac->sc_iot = sc->sc_iot;
    if (bus_space_subregion(sc->sc_iot, sc->sc_ioh, WSS_CODEC, AD1848_NPORT,
                            &ac->sc_ioh)) {
        aprint_error_dev(self, "bus_space_subregion failed\n");
        return;
    }
    ac->mode = 2;
    ac->MCE_bit = MODE_CHANGE_ENABLE;

    sc->sc_ad1848.sc_ic  = sc->sc_ic;

    printf("%s: %s %s", device_xname(self), ipa->ipa_devident,
           ipa->ipa_devclass);

    ym_attach(sc);
}
Пример #3
0
void
pcic_isapnp_attach(struct device *parent, struct device *self,
    void *aux)
{
	struct pcic_softc *sc = device_private(self);
	struct pcic_isa_softc *isc = device_private(self);
	struct isapnp_attach_args *ipa = aux;
	isa_chipset_tag_t ic = ipa->ipa_ic;
	bus_space_tag_t iot = ipa->ipa_iot;
	bus_space_tag_t memt = ipa->ipa_memt;
	bus_space_handle_t ioh;
	bus_space_handle_t memh;
	bus_addr_t maddr;
	int msize;
	int tmp1;

	printf("\n");

	if (isapnp_config(iot, memt, ipa)) {
		aprint_error_dev(&sc->dev, "error in region allocation\n");
		return;
	}

	printf("%s: %s %s", device_xname(&sc->dev), ipa->ipa_devident,
	    ipa->ipa_devclass);

	/* sanity check that we get at least one hunk of IO space.. */
	if (ipa->ipa_nio < 1) {
		aprint_error_dev(&sc->dev, "failed to get one chunk of i/o space\n");
		return;
	}

	/* Find i/o space. */
	ioh = ipa->ipa_io[0].h;

	/* sanity check to make sure we have a real PCIC there.. */
	bus_space_write_1(iot, ioh, PCIC_REG_INDEX, C0SA + PCIC_IDENT);
	tmp1 = bus_space_read_1(iot, ioh, PCIC_REG_DATA);
	printf("(ident 0x%x", tmp1);
	if (pcic_ident_ok(tmp1)) {
	  	printf(" OK)");
	} else {
	        printf(" Not OK)\n");
		return;
	}

	msize =  0x4000;
	if (isa_mem_alloc (memt, msize, msize, 0, 0,
			   &maddr, &memh)) {
		printf(": can't alloc mem space\n");
		return;
	}
	printf(": using iomem 0x%lx iosiz 0x%x", maddr, msize);
	sc->membase = maddr;
	sc->subregionmask = (1 << (msize / PCIC_MEM_PAGESIZE)) - 1;

	isc->sc_ic = ic;
	sc->pct = (pcmcia_chipset_tag_t) & pcic_isa_functions;

	sc->iot = iot;
	sc->ioh = ioh;
	sc->memt = memt;
	sc->memh = memh;

	/*
	 * allocate an irq.  it will be used by both controllers.  I could
	 * use two different interrupts, but interrupts are relatively
	 * scarce, shareable, and for PCIC controllers, very infrequent.
	 */

	if (ipa->ipa_nirq > 0)
		sc->irq = ipa->ipa_irq[0].num;
	else
		sc->irq = -1;

	printf("\n");

	pcic_attach(sc);
	pcic_isa_bus_width_probe(sc, iot, ioh, ipa->ipa_io[0].base,
	    ipa->ipa_io[0].length);
	pcic_attach_sockets(sc);
	config_interrupts(self, pcic_isa_config_interrupts);
}
Пример #4
0
static void
wdc_isapnp_attach(device_t parent, device_t self, void *aux)
{
	struct wdc_isapnp_softc *sc = device_private(self);
	struct wdc_regs *wdr;
	struct isapnp_attach_args *ipa = aux;
	int i;

	if (ipa->ipa_nio != 2 ||
	    ipa->ipa_nmem != 0 ||
	    ipa->ipa_nmem32 != 0 ||
	    ipa->ipa_nirq != 1 ||
	    ipa->ipa_ndrq > 1) {
		aprint_error(": unexpected configuration\n");
		return;
	}

	if (isapnp_config(ipa->ipa_iot, ipa->ipa_memt, ipa)) {
		aprint_error(": couldn't map registers\n");
		return;
	}

	aprint_normal(": %s %s\n", ipa->ipa_devident, ipa->ipa_devclass);

	sc->sc_wdcdev.sc_atac.atac_dev = self;
	sc->sc_wdcdev.regs = wdr = &sc->wdc_regs;
	wdr->cmd_iot = ipa->ipa_iot;
	wdr->ctl_iot = ipa->ipa_iot;
	/*
	 * An IDE controller can feed us the regions in any order. Pass
	 * them along with the 8-byte region in sc_ad.ioh, and the other
	 * (2 byte) region in auxioh.
	 */
	if (ipa->ipa_io[0].length == 8) {
		wdr->cmd_baseioh = ipa->ipa_io[0].h;
		wdr->ctl_ioh = ipa->ipa_io[1].h;
	} else {
		wdr->cmd_baseioh = ipa->ipa_io[1].h;
		wdr->ctl_ioh = ipa->ipa_io[0].h;
	}

	for (i = 0; i < WDC_NREG; i++) {
		if (bus_space_subregion(wdr->cmd_iot,
		    wdr->cmd_baseioh, i, i == 0 ? 4 : 1,
		    &wdr->cmd_iohs[i]) != 0) {
			aprint_error(": couldn't subregion registers\n");
			return;
		}
	}
	wdr->data32iot = wdr->cmd_iot;
	wdr->data32ioh = wdr->cmd_iohs[0];

	sc->sc_ic = ipa->ipa_ic;
	sc->sc_ih = isa_intr_establish(ipa->ipa_ic, ipa->ipa_irq[0].num,
	    ipa->ipa_irq[0].type, IPL_BIO, wdcintr, &sc->ata_channel);

#ifdef notyet
	if (ipa->ipa_ndrq > 0) {
		sc->sc_drq = ipa->ipa_drq[0].num;

		sc->sc_wdcdev.sc_atac.atac_cap |= ATAC_CAP_DMA;
		sc->sc_wdcdev.dma_start = &wdc_isapnp_dma_start;
		sc->sc_wdcdev.dma_finish = &wdc_isapnp_dma_finish;
		wdc_isapnp_dma_setup(sc);
	}
#endif
	sc->sc_wdcdev.sc_atac.atac_cap |= ATAC_CAP_DATA16 | ATAC_CAP_DATA32;
	sc->sc_wdcdev.sc_atac.atac_pio_cap = 0;
	sc->wdc_chanlist[0] = &sc->ata_channel;
	sc->sc_wdcdev.sc_atac.atac_channels = sc->wdc_chanlist;
	sc->sc_wdcdev.sc_atac.atac_nchannels = 1;
	sc->ata_channel.ch_channel = 0;
	sc->ata_channel.ch_atac = &sc->sc_wdcdev.sc_atac;
	sc->ata_channel.ch_queue = &sc->wdc_chqueue;
	sc->ata_channel.ch_ndrive = 2;

	wdc_init_shadow_regs(&sc->ata_channel);

	wdcattach(&sc->ata_channel);
}
Пример #5
0
/*
 * Attach hardware to driver, attach hardware driver to audio
 * pseudo-device driver.
 */
void
wss_isapnp_attach(device_t parent, device_t self, void *aux)
{
	struct wss_softc *sc;
	struct ad1848_softc *ac;
	struct isapnp_attach_args *ipa;
	int variant;

	sc = device_private(self);
	ac = &sc->sc_ad1848.sc_ad1848;
	ac->sc_dev = self;
	ipa = aux;
	printf("\n");

	if (!isapnp_devmatch(aux, &isapnp_wss_devinfo, &variant)) {
		aprint_error_dev(self, "match failed?\n");
		return;
	}

	if (isapnp_config(ipa->ipa_iot, ipa->ipa_memt, ipa)) {
		aprint_error_dev(self, "error in region allocation\n");
		return;
	}

	switch (variant) {
	case 1:
		/* We have to put the chip into `WSS mode'. */
		{
			bus_space_tag_t iot;
			bus_space_handle_t ioh;

			iot = ipa->ipa_iot;
			ioh = ipa->ipa_io[0].h;

			while (bus_space_read_1(iot, ioh,
			    SBP_DSP_WSTAT) & SB_DSP_BUSY);
			bus_space_write_1(iot, ioh, SBP_DSP_WRITE, 0x09);
			while (bus_space_read_1(iot, ioh,
			    SBP_DSP_WSTAT) & SB_DSP_BUSY);
			bus_space_write_1(iot, ioh, SBP_DSP_WRITE, 0x00);
			while (bus_space_read_1(iot, ioh,
			    SBP_DSP_WSTAT) & SB_DSP_BUSY);

			delay(1000);
		}

		sc->sc_iot = ipa->ipa_iot;
		sc->sc_ioh = ipa->ipa_io[2].h;
		break;

	default:
		sc->sc_iot = ipa->ipa_iot;
		sc->sc_ioh = ipa->ipa_io[0].h;
		break;
	}

	sc->mad_chip_type = MAD_NONE;

	/* Set up AD1848 I/O handle. */
	ac->sc_iot = sc->sc_iot;
	ac->sc_ioh = sc->sc_ioh;

	sc->sc_ad1848.sc_ic = ipa->ipa_ic;

	sc->wss_ic = ipa->ipa_ic;
	sc->wss_irq = ipa->ipa_irq[0].num;
	sc->wss_playdrq = ipa->ipa_drq[0].num;
	sc->wss_recdrq =
	    ipa->ipa_ndrq > 1 ? ipa->ipa_drq[1].num : ipa->ipa_drq[0].num;

	if (!ad1848_isa_probe(&sc->sc_ad1848)) {
		aprint_error_dev(self, "ad1848_probe failed\n");
		return;
	}

	aprint_error_dev(self, "%s %s", ipa->ipa_devident,
	    ipa->ipa_devclass);

	ac->mode = 2;

	wssattach(sc);

	/* set up OPL I/O handle for ISAPNP boards w/o MAD */
	if (ipa->ipa_nio > 1 && sc->mad_chip_type == MAD_NONE) {
		struct audio_attach_args arg;

		sc->sc_opl_ioh = ipa->ipa_io[1].h;

		arg.type = AUDIODEV_TYPE_OPL;
		arg.hwif = 0;
		arg.hdl = 0;
		(void)config_found(self, &arg, audioprint);
	}
}
Пример #6
0
static void
isic_isapnp_attach(device_t parent, device_t self, void *aux)
{
  	static const char *ISACversion[] = {
  		"2085 Version A1/A2 or 2086/2186 Version 1.1",
		"2085 Version B1",
		"2085 Version B2",
		"2085 Version V2.3 (B3)",
		"Unknown Version"
	};

	static const char *HSCXversion[] = {
		"82525 Version A1",
		"Unknown (0x01)",
		"82525 Version A2",
		"Unknown (0x03)",
		"82525 Version A3",
		"82525 or 21525 Version 2.1",
		"Unknown Version"
	};

	struct isic_softc *sc = device_private(self);
	struct isapnp_attach_args *ipa = aux;
	const struct isic_isapnp_card_desc *desc = isic_isapnp_descriptions;
	int i;

	sc->sc_dev = self;
	if (isapnp_config(ipa->ipa_iot, ipa->ipa_memt, ipa)) {
		aprint_error_dev(sc->sc_dev, "error in region allocation\n");
		return;
	}

	for (i = 0; i < NUM_DESCRIPTIONS; i++, desc++)
		if (strcmp(ipa->ipa_devlogic, desc->devlogic) == 0)
			break;
	if (i >= NUM_DESCRIPTIONS)
		panic("could not identify isic PnP device");

	/* setup parameters */
	sc->sc_cardtyp = desc->card_type;
	sc->sc_irq = ipa->ipa_irq[0].num;
	desc->allocmaps(ipa, sc);

	/* announce card name */
	printf(": %s\n", desc->name);

	/* establish interrupt handler */
	if (isa_intr_establish(ipa->ipa_ic, ipa->ipa_irq[0].num,
	    ipa->ipa_irq[0].type, IPL_NET, isicintr, sc) == NULL)
		aprint_error_dev(sc->sc_dev,
		    "couldn't establish interrupt handler\n");

	/* init card */
	desc->attach(sc);

	/* announce chip versions */
	sc->sc_isac_version = 0;
	sc->sc_isac_version = ((ISAC_READ(I_RBCH)) >> 5) & 0x03;

	switch (sc->sc_isac_version) {
		case ISAC_VA:
		case ISAC_VB1:
                case ISAC_VB2:
		case ISAC_VB3:
			break;

		default:
			aprint_error(ISIC_FMT
			    "Error, ISAC version %d unknown!\n",
			    ISIC_PARM, sc->sc_isac_version);
			return;
			break;
	}

	sc->sc_hscx_version = HSCX_READ(0, H_VSTR) & 0xf;

	switch (sc->sc_hscx_version) {
		case HSCX_VA1:
		case HSCX_VA2:
		case HSCX_VA3:
		case HSCX_V21:
			break;

		default:
			aprint_error(ISIC_FMT
			    "Error, HSCX version %d unknown!\n",
			    ISIC_PARM, sc->sc_hscx_version);
			return;
			break;
	};

        sc->sc_intr_valid = ISIC_INTR_DISABLED;

	/* HSCX setup */

	isic_bchannel_setup(sc, HSCX_CH_A, BPROT_NONE, 0);

	isic_bchannel_setup(sc, HSCX_CH_B, BPROT_NONE, 0);

	/* setup linktab */

	isic_init_linktab(sc);

	/* set trace level */

	sc->sc_trace = TRACE_OFF;

	sc->sc_state = ISAC_IDLE;

	sc->sc_ibuf = NULL;
	sc->sc_ib = NULL;
	sc->sc_ilen = 0;

	sc->sc_obuf = NULL;
	sc->sc_op = NULL;
	sc->sc_ol = 0;
	sc->sc_freeflag = 0;

	sc->sc_obuf2 = NULL;
	sc->sc_freeflag2 = 0;

#if defined(__NetBSD__) && __NetBSD_Version__ >= 104230000
	callout_init(&sc->sc_T3_callout, 0);
	callout_init(&sc->sc_T4_callout, 0);
#endif

	/* announce chip versions */

	if (sc->sc_isac_version >= ISAC_UNKN) {
		aprint_error(ISIC_FMT
		    "ISAC Version UNKNOWN (VN=0x%x)" TERMFMT, ISIC_PARM,
		    sc->sc_isac_version);
		sc->sc_isac_version = ISAC_UNKN;
	} else {
		aprint_error(ISIC_FMT "ISAC %s (IOM-%c)" TERMFMT, ISIC_PARM,
		    ISACversion[sc->sc_isac_version],
		    sc->sc_bustyp == BUS_TYPE_IOM1 ? '1' : '2');
	}

	if (sc->sc_hscx_version >= HSCX_UNKN) {
		aprint_error(ISIC_FMT "HSCX Version UNKNOWN (VN=0x%x)" TERMFMT,
		    ISIC_PARM, sc->sc_hscx_version);
		sc->sc_hscx_version = HSCX_UNKN;
	} else {
		aprint_error(ISIC_FMT "HSCX %s" TERMFMT, ISIC_PARM,
		    HSCXversion[sc->sc_hscx_version]);
	}

	/* init higher protocol layers and save l2 handle */
	isic_attach_bri(sc, desc->name, &isic_std_driver);
}