/* * 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); }
void ym_pnpbios_attach(device_t parent, device_t self, void *aux) { struct ym_softc *sc = device_private(self); struct ad1848_softc *ac = &sc->sc_ad1848.sc_ad1848; struct pnpbiosdev_attach_args *aa = aux; ac->sc_dev = self; if (pnpbios_io_map(aa->pbt, aa->resc, 0, &sc->sc_iot, &sc->sc_sb_ioh) != 0) { printf(": can't map sb i/o space\n"); return; } if (pnpbios_io_map(aa->pbt, aa->resc, 1, &sc->sc_iot, &sc->sc_ioh) != 0) { printf(": can't map sb i/o space\n"); return; } if (pnpbios_io_map(aa->pbt, aa->resc, 2, &sc->sc_iot, &sc->sc_opl_ioh) != 0) { printf(": can't map opl i/o space\n"); return; } #if NMPU_YM > 0 if (pnpbios_io_map(aa->pbt, aa->resc, 3, &sc->sc_iot, &sc->sc_mpu_ioh) != 0) { printf(": can't map mpu i/o space\n"); return; } #endif if (pnpbios_io_map(aa->pbt, aa->resc, 4, &sc->sc_iot, &sc->sc_controlioh) != 0) { printf(": can't map control i/o space\n"); return; } sc->sc_ic = aa->ic; if (pnpbios_getirqnum(aa->pbt, aa->resc, 0, &sc->ym_irq, NULL)) { printf(": can't get IRQ\n"); return; } if (pnpbios_getdmachan(aa->pbt, aa->resc, 0, &sc->ym_playdrq)) { printf(": can't get DMA channel\n"); return; } if (pnpbios_getdmachan(aa->pbt, aa->resc, 1, &sc->ym_recdrq)) sc->ym_recdrq = sc->ym_playdrq; /* half-duplex mode */ printf("\n"); pnpbios_print_devres(self, aa); printf("%s", device_xname(self)); 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; ym_attach(sc); }
/* * ym_acpi_attach: autoconf(9) attach routine */ static void ym_acpi_attach(struct device *parent, struct device *self, void *aux) { struct ym_softc *sc = (struct ym_softc *)self; struct acpi_attach_args *aa = aux; struct acpi_resources res; struct acpi_io *sb_io, *codec_io, *opl_io, *control_io; #if NMPU_YM > 0 struct acpi_io *mpu_io; #endif struct acpi_irq *irq; struct acpi_drq *playdrq, *recdrq; struct ad1848_softc *ac = &sc->sc_ad1848.sc_ad1848; ACPI_STATUS rv; aprint_naive("\n"); aprint_normal("\n"); /* Parse our resources */ rv = acpi_resource_parse(&sc->sc_ad1848.sc_ad1848.sc_dev, aa->aa_node->ad_handle, "_CRS", &res, &acpi_resource_parse_ops_default); if (ACPI_FAILURE(rv)) return; /* * sc_sb_ioh @ 0 * sc_ioh @ 1 * sc_opl_ioh @ 2 * sc_mpu_ioh @ 3 * sc_controlioh @ 4 */ /* Find and map our i/o registers */ sc->sc_iot = aa->aa_iot; sb_io = acpi_res_io(&res, 0); codec_io = acpi_res_io(&res, 1); opl_io = acpi_res_io(&res, 2); #if NMPU_YM > 0 mpu_io = acpi_res_io(&res, 3); #endif control_io = acpi_res_io(&res, 4); if (sb_io == NULL || codec_io == NULL || opl_io == NULL || #if NMPU_YM > 0 mpu_io == NULL || #endif control_io == NULL) { aprint_error_dev(self, "unable to find i/o registers resource\n"); goto out; } if (bus_space_map(sc->sc_iot, sb_io->ar_base, sb_io->ar_length, 0, &sc->sc_sb_ioh) != 0) { aprint_error_dev(self, "unable to map i/o registers (sb)\n"); goto out; } if (bus_space_map(sc->sc_iot, codec_io->ar_base, codec_io->ar_length, 0, &sc->sc_ioh) != 0) { aprint_error_dev(self, "unable to map i/o registers (codec)\n"); goto out; } if (bus_space_map(sc->sc_iot, opl_io->ar_base, opl_io->ar_length, 0, &sc->sc_opl_ioh) != 0) { aprint_error_dev(self, "unable to map i/o registers (opl)\n"); goto out; } #if NMPU_YM > 0 if (bus_space_map(sc->sc_iot, mpu_io->ar_base, mpu_io->ar_length, 0, &sc->sc_mpu_ioh) != 0) { aprint_error_dev(self, "unable to map i/o registers (mpu)\n"); goto out; } #endif if (bus_space_map(sc->sc_iot, control_io->ar_base, control_io->ar_length, 0, &sc->sc_controlioh) != 0) { aprint_error_dev(self, "unable to map i/o registers (control)\n"); goto out; } sc->sc_ic = aa->aa_ic; /* Find our IRQ */ irq = acpi_res_irq(&res, 0); if (irq == NULL) { aprint_error_dev(self, "unable to find irq resource\n"); /* XXX bus_space_unmap */ goto out; } sc->ym_irq = irq->ar_irq; /* Find our playback and record DRQs */ playdrq = acpi_res_drq(&res, 0); recdrq = acpi_res_drq(&res, 1); if (playdrq == NULL) { aprint_error_dev(self, "unable to find drq resources\n"); /* XXX bus_space_unmap */ goto out; } if (recdrq == NULL) { /* half-duplex mode */ sc->ym_recdrq = sc->ym_playdrq = playdrq->ar_drq; } else { sc->ym_playdrq = playdrq->ar_drq; sc->ym_recdrq = recdrq->ar_drq; } 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"); /* XXX cleanup */ goto out; } aprint_normal_dev(self, ""); ac->mode = 2; ac->MCE_bit = MODE_CHANGE_ENABLE; sc->sc_ad1848.sc_ic = sc->sc_ic; /* Attach our ym device */ ym_attach(sc); out: acpi_resource_cleanup(&res); }