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); }
void wskbd_attach(device_t parent, device_t self, void *aux) { struct wskbd_softc *sc = device_private(self); struct wskbddev_attach_args *ap = aux; #if NWSMUX > 0 int mux, error; #endif sc->sc_base.me_dv = self; sc->sc_isconsole = ap->console; sc->sc_hotkey = NULL; sc->sc_hotkeycookie = NULL; sc->sc_evtrans_len = 0; sc->sc_evtrans = NULL; #if NWSMUX > 0 || NWSDISPLAY > 0 sc->sc_base.me_ops = &wskbd_srcops; #endif #if NWSMUX > 0 mux = device_cfdata(sc->sc_base.me_dv)->wskbddevcf_mux; if (ap->console) { /* Ignore mux for console; it always goes to the console mux. */ /* printf(" (mux %d ignored for console)", mux); */ mux = -1; } if (mux >= 0) aprint_normal(" mux %d", mux); #else if (device_cfdata(sc->sc_base.me_dv)->wskbddevcf_mux >= 0) aprint_normal(" (mux ignored)"); #endif if (ap->console) { sc->id = &wskbd_console_data; } else { sc->id = malloc(sizeof(struct wskbd_internal), M_DEVBUF, M_WAITOK|M_ZERO); sc->id->t_keymap = ap->keymap; wskbd_update_layout(sc->id, ap->keymap->layout); } callout_init(&sc->sc_repeat_ch, 0); callout_setfunc(&sc->sc_repeat_ch, wskbd_repeat, sc); sc->id->t_sc = sc; sc->sc_accessops = ap->accessops; sc->sc_accesscookie = ap->accesscookie; sc->sc_repeating = 0; sc->sc_translating = 1; sc->sc_ledstate = -1; /* force update */ if (wskbd_load_keymap(sc->id->t_keymap, &sc->sc_map, &sc->sc_maplen) != 0) panic("cannot load keymap"); sc->sc_layout = sc->id->t_keymap->layout; /* set default bell and key repeat data */ sc->sc_bell_data = wskbd_default_bell_data; sc->sc_keyrepeat_data = wskbd_default_keyrepeat_data; #ifdef WSDISPLAY_SCROLLSUPPORT sc->sc_scroll_data = wskbd_default_scroll_data; #endif if (ap->console) { KASSERT(wskbd_console_initted); KASSERT(wskbd_console_device == NULL); wskbd_console_device = sc; aprint_naive(": console keyboard"); aprint_normal(": console keyboard"); #if NWSDISPLAY > 0 wsdisplay_set_console_kbd(&sc->sc_base); /* sets me_dispv */ if (sc->sc_base.me_dispdv != NULL) aprint_normal(", using %s", device_xname(sc->sc_base.me_dispdv)); #endif } aprint_naive("\n"); aprint_normal("\n"); #if NWSMUX > 0 if (mux >= 0) { error = wsmux_attach_sc(wsmux_getmux(mux), &sc->sc_base); if (error) aprint_error_dev(sc->sc_base.me_dv, "attach error=%d\n", error); } #endif if (!pmf_device_register(self, wskbd_suspend, NULL)) aprint_error_dev(self, "couldn't establish power handler\n"); else if (!pmf_class_input_register(self)) aprint_error_dev(self, "couldn't register as input device\n"); }