static void atppc_acpi_attach(device_t parent, device_t self, void *aux) { struct atppc_softc *sc = device_private(self); struct atppc_acpi_softc *asc = device_private(self); struct acpi_attach_args *aa = aux; struct acpi_resources res; struct acpi_io *io; struct acpi_irq *irq; struct acpi_drq *drq; ACPI_STATUS rv; int nirq; sc->sc_dev_ok = ATPPC_NOATTACH; sc->sc_dev = self; /* parse resources */ rv = acpi_resource_parse(sc->sc_dev, 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(sc->sc_dev, "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(sc->sc_dev, "unable to find irq resource\n"); goto out; } nirq = irq->ar_irq; /* find our DRQ */ drq = acpi_res_drq(&res, 0); if (drq == NULL) { aprint_error_dev(sc->sc_dev, "unable to find drq resource\n"); goto out; } asc->sc_drq = drq->ar_drq; /* Attach */ sc->sc_iot = aa->aa_iot; sc->sc_has = 0; asc->sc_ic = aa->aa_ic; sc->sc_dev_ok = ATPPC_ATTACHED; if (bus_space_map(sc->sc_iot, io->ar_base, io->ar_length, 0, &sc->sc_ioh) != 0) { aprint_error_dev(self, "attempt to map bus space failed, device not " "properly attached.\n"); goto out; } sc->sc_ieh = isa_intr_establish(aa->aa_ic, nirq, (irq->ar_type == ACPI_EDGE_SENSITIVE) ? IST_EDGE : IST_LEVEL, IPL_TTY, atppcintr, sc->sc_dev); /* setup DMA hooks */ if (atppc_isadma_setup(sc, asc->sc_ic, asc->sc_drq) == 0) { sc->sc_has |= ATPPC_HAS_DMA; sc->sc_dma_start = atppc_acpi_dma_start; sc->sc_dma_finish = atppc_acpi_dma_finish; sc->sc_dma_abort = atppc_acpi_dma_abort; sc->sc_dma_malloc = atppc_acpi_dma_malloc; sc->sc_dma_free = atppc_acpi_dma_free; } sc->sc_has |= ATPPC_HAS_INTR; /* Run soft configuration attach */ atppc_sc_attach(sc); out: acpi_resource_cleanup(&res); }
/* * 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); }