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); }
/* * 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); }
void spic_acpi_attach(struct device *parent, struct device *self, void *aux) { struct spic_acpi_softc *sc = (void *) self; struct acpi_attach_args *aa = aux; struct acpi_io *io; struct acpi_irq *irq; ACPI_STATUS rv; printf(": Sony Programmable I/O Controller\n"); sc->sc_node = aa->aa_node; /* Parse our resources. */ rv = acpi_resource_parse(&sc->sc_spic.sc_dev, sc->sc_node, &sc->sc_res, &acpi_resource_parse_ops_default); if (ACPI_FAILURE(rv)) return; sc->sc_spic.sc_iot = aa->aa_iot; io = acpi_res_io(&sc->sc_res, 0); if (io == NULL) { printf("%s: unable to find io resource\n", sc->sc_spic.sc_dev.dv_xname); return; } if (bus_space_map(sc->sc_spic.sc_iot, io->ar_base, io->ar_length, 0, &sc->sc_spic.sc_ioh) != 0) { printf("%s: unable to map data register\n", sc->sc_spic.sc_dev.dv_xname); return; } irq = acpi_res_irq(&sc->sc_res, 0); if (irq == NULL) { printf("%s: unable to find irq resource\n", sc->sc_spic.sc_dev.dv_xname); /* XXX unmap */ return; } #if 0 sc->sc_ih = isa_intr_establish(NULL, irq->ar_irq, IST_EDGE, IPL_TTY, spic_intr, sc); #endif spic_attach(&sc->sc_spic); }
/* * attimer_acpi_attach: autoconf(9) attach routine */ static void attimer_acpi_attach(device_t parent, device_t self, void *aux) { struct attimer_softc *sc = device_private(self); struct acpi_attach_args *aa = aux; struct acpi_resources res; struct acpi_io *io; ACPI_STATUS rv; sc->sc_dev = self; aprint_naive(": AT Timer\n"); aprint_normal(": AT Timer\n"); /* 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(self, "unable to find i/o register resource\n"); goto out; } sc->sc_iot = aa->aa_iot; sc->sc_size = io->ar_length; if (bus_space_map(sc->sc_iot, io->ar_base, sc->sc_size, 0, &sc->sc_ioh) != 0) { aprint_error_dev(self, "can't map i/o space\n"); goto out; } attimer_attach(sc); out: acpi_resource_cleanup(&res); }
static void pckbc_acpi_attach(device_t parent, device_t self, void *aux) { struct pckbc_acpi_softc *psc = device_private(self); struct pckbc_softc *sc = &psc->sc_pckbc; struct pckbc_internal *t; struct acpi_attach_args *aa = aux; bus_space_handle_t ioh_d, ioh_c; pckbc_slot_t peer; struct acpi_resources res; struct acpi_io *io0, *io1, *ioswap; struct acpi_irq *irq; ACPI_STATUS rv; sc->sc_dv = self; psc->sc_ic = aa->aa_ic; if (acpi_match_hid(aa->aa_node->ad_devinfo, pckbc_acpi_ids_kbd)) { psc->sc_slot = PCKBC_KBD_SLOT; peer = PCKBC_AUX_SLOT; } else if (acpi_match_hid(aa->aa_node->ad_devinfo, pckbc_acpi_ids_ms)) { psc->sc_slot = PCKBC_AUX_SLOT; peer = PCKBC_KBD_SLOT; } else { aprint_error(": unknown port!\n"); panic("pckbc_acpi_attach: impossible"); } aprint_naive("\n"); aprint_normal(": %s port\n", pckbc_slot_names[psc->sc_slot]); /* parse resources */ rv = acpi_resource_parse(sc->sc_dv, aa->aa_node->ad_handle, "_CRS", &res, &acpi_resource_parse_ops_default); if (ACPI_FAILURE(rv)) return; /* find our IRQ */ irq = acpi_res_irq(&res, 0); if (irq == NULL) { aprint_error_dev(self, "unable to find irq resource\n"); goto out; } psc->sc_irq = irq->ar_irq; psc->sc_ist = (irq->ar_type == ACPI_EDGE_SENSITIVE) ? IST_EDGE : IST_LEVEL; if (psc->sc_slot == PCKBC_KBD_SLOT) first = psc; if ((!first || !first->sc_pckbc.id) && (psc->sc_slot == PCKBC_KBD_SLOT)) { io0 = acpi_res_io(&res, 0); io1 = acpi_res_io(&res, 1); if (io0 == NULL || io1 == NULL) { aprint_error_dev(self, "unable to find i/o resources\n"); goto out; } /* * JDM: Some firmware doesn't report resources in the order we * expect; sort IO resources here (lowest first) */ if (io0->ar_base > io1->ar_base) { ioswap = io0; io0 = io1; io1 = ioswap; } if (pckbc_is_console(aa->aa_iot, io0->ar_base)) { t = &pckbc_consdata; ioh_d = t->t_ioh_d; ioh_c = t->t_ioh_c; pckbc_console_attached = 1; /* t->t_cmdbyte was initialized by cnattach */ } else { if (bus_space_map(aa->aa_iot, io0->ar_base, io0->ar_length, 0, &ioh_d) || bus_space_map(aa->aa_iot, io1->ar_base, io1->ar_length, 0, &ioh_c)) panic("pckbc_acpi_attach: couldn't map"); t = malloc(sizeof(struct pckbc_internal), M_DEVBUF, M_WAITOK|M_ZERO); t->t_iot = aa->aa_iot; t->t_ioh_d = ioh_d; t->t_ioh_c = ioh_c; t->t_addr = io0->ar_base; t->t_cmdbyte = KC8_CPU; /* Enable ports */ callout_init(&t->t_cleanup, 0); } t->t_sc = &first->sc_pckbc; first->sc_pckbc.id = t; if (!pmf_device_register(self, NULL, pckbc_resume)) aprint_error_dev(self, "couldn't establish power handler\n"); first->sc_pckbc.intr_establish = pckbc_acpi_intr_establish; config_defer(first->sc_pckbc.sc_dv, pckbc_acpi_finish_attach); } else if (!pmf_device_register(self, NULL, NULL)) aprint_error_dev(self, "couldn't establish power handler\n"); out: acpi_resource_cleanup(&res); }
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); }
/* * acpiec_attach: * * Autoconfiguration `attach' routine. */ void acpiec_attach(struct device *parent, struct device *self, void *aux) { struct acpi_ec_softc *sc = (void *) self; struct acpi_attach_args *aa = aux; struct acpi_io *io0, *io1; ACPI_STATUS rv; FUNCTION_TRACE(__FUNCTION__); printf(": ACPI Embedded Controller\n"); sc->sc_node = aa->aa_node; /* Parse our resources. */ ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "parsing EC resources\n")); rv = acpi_resource_parse(&sc->sc_dev, sc->sc_node, &sc->sc_res, &acpi_resource_parse_ops_default); if (rv != AE_OK) { printf("%s: unable to parse resources: %d\n", sc->sc_dev.dv_xname, rv); return; } sc->sc_data_st = aa->aa_iot; io0 = acpi_res_io(&sc->sc_res, 0); if (io0 == NULL) { printf("%s: unable to find data register resource\n", sc->sc_dev.dv_xname); return; } if (bus_space_map(sc->sc_data_st, io0->ar_base, io0->ar_length, 0, &sc->sc_data_sh) != 0) { printf("%s: unable to map data register\n", sc->sc_dev.dv_xname); return; } sc->sc_csr_st = aa->aa_iot; io1 = acpi_res_io(&sc->sc_res, 1); if (io1 == NULL) { printf("%s: unable to find csr register resource\n", sc->sc_dev.dv_xname); return; } if (bus_space_map(sc->sc_csr_st, io1->ar_base, io1->ar_length, 0, &sc->sc_csr_sh) != 0) { printf("%s: unable to map csr register\n", sc->sc_dev.dv_xname); return; } /* * Install GPE handler. * * We evaluate the _GPE method to find the GPE bit used by the * Embedded Controller to signal status (SCI). */ if ((rv = acpi_eval_integer(sc->sc_node->ad_handle, "_GPE", &sc->sc_gpebit)) != AE_OK) { printf("%s: unable to evaluate _GPE: %d\n", sc->sc_dev.dv_xname, rv); return; } /* * Install a handler for this EC's GPE bit. Note that EC SCIs are * treated as both edge- and level-triggered interrupts; in other words * we clear the status bit immediately after getting an EC-SCI, then * again after we're done processing the event. This guarantees that * events we cause while performing a transaction (e.g. IBE/OBF) get * cleared before re-enabling the GPE. */ if ((rv = AcpiInstallGpeHandler(sc->sc_gpebit, ACPI_EVENT_LEVEL_TRIGGERED | ACPI_EVENT_EDGE_TRIGGERED, EcGpeHandler, sc)) != AE_OK) { printf("%s: unable to install GPE handler: %d\n", sc->sc_dev.dv_xname, rv); return; } /* Install address space handler. */ if ((rv = AcpiInstallAddressSpaceHandler(sc->sc_node->ad_handle, ACPI_ADR_SPACE_EC, EcSpaceHandler, EcSpaceSetup, sc)) != AE_OK) { printf("%s: unable to install address space handler: %d\n", sc->sc_dev.dv_xname, rv); return; } return_VOID; }
static void tpm_acpi_attach(device_t parent, device_t self, void *aux) { struct tpm_softc *sc = device_private(self); struct acpi_attach_args *aa = aux; struct acpi_resources res; struct acpi_io *io; struct acpi_mem *mem; struct acpi_irq *irq; bus_addr_t base; bus_addr_t size; int rv, inum; sc->sc_dev = self; /* Parse our resources */ rv = acpi_resource_parse(self, aa->aa_node->ad_handle, "_CRS", &res, &acpi_resource_parse_ops_default); if (ACPI_FAILURE(rv)) { aprint_error_dev(sc->sc_dev, "cannot parse resources %d\n", rv); return; } io = acpi_res_io(&res, 0); if (io && tpm_legacy_probe(aa->aa_iot, io->ar_base)) { sc->sc_bt = aa->aa_iot; base = io->ar_base; size = io->ar_length; sc->sc_batm = aa->aa_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; mem = NULL; } else { mem = acpi_res_mem(&res, 0); if (mem == NULL) { aprint_error_dev(sc->sc_dev, "cannot find mem\n"); goto out; } if (mem->ar_length != TPM_SIZE) { aprint_error_dev(sc->sc_dev, "wrong size mem %u != %u\n", mem->ar_length, TPM_SIZE); goto out; } base = mem->ar_base; size = mem->ar_length; sc->sc_bt = aa->aa_memt; 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, base, size, 0, &sc->sc_bh)) { aprint_error_dev(sc->sc_dev, "cannot map registers\n"); goto out; } if (mem && !tpm_tis12_probe(sc->sc_bt, sc->sc_bh)) { aprint_error_dev(sc->sc_dev, "1.2 probe failed\n"); goto out1; } irq = acpi_res_irq(&res, 0); if (irq == NULL) inum = -1; else inum = irq->ar_irq; if ((rv = (*sc->sc_init)(sc, inum, device_xname(sc->sc_dev))) != 0) aprint_error_dev(sc->sc_dev, "cannot init device %d\n", rv); goto out1; if (inum != -1 && (sc->sc_ih = isa_intr_establish(aa->aa_ic, irq->ar_irq, IST_EDGE, IPL_TTY, tpm_intr, sc)) == NULL) { aprint_error_dev(sc->sc_dev, "cannot establish interrupt\n"); goto out1; } if (!pmf_device_register(sc->sc_dev, tpm_suspend, tpm_resume)) aprint_error_dev(sc->sc_dev, "Cannot set power mgmt handler\n"); return; out1: bus_space_unmap(sc->sc_bt, sc->sc_bh, size); out: acpi_resource_cleanup(&res); }