static void spc_intio_attach(device_t parent, device_t self, void *aux) { struct spc_softc *sc = device_private(self); struct intio_attach_args *ia = aux; bus_space_tag_t iot = ia->ia_bst; bus_space_handle_t ioh; sc->sc_dev = self; intio_map_allocate_region(device_parent(parent), ia, INTIO_MAP_ALLOCATE); if (bus_space_map(iot, ia->ia_addr, 0x20, BUS_SPACE_MAP_SHIFTED, &ioh)) { aprint_error(": can't map i/o space\n"); return; } aprint_normal("\n"); sc->sc_iot = iot; sc->sc_ioh = ioh; sc->sc_initiator = IODEVbase->io_sram[0x70] & 0x7; /* XXX */ if (intio_intr_establish(ia->ia_intr, "spc", spc_intr, sc)) panic("spcattach: interrupt vector busy"); spc_attach(sc); }
static void slhci_intio_attach(device_t parent, device_t self, void *aux) { struct slhci_intio_softc *isc = device_private(self); struct slhci_softc *sc = &isc->sc_sc; struct intio_attach_args *ia = aux; bus_space_tag_t iot = ia->ia_bst; bus_space_handle_t ioh; int nc_addr; int nc_size; sc->sc_dev = self; sc->sc_bus.hci_private = sc; printf(": Nereid USB\n"); /* Map I/O space */ if (bus_space_map(iot, ia->ia_addr, SL11_PORTSIZE * 2, BUS_SPACE_MAP_SHIFTED, &ioh)) { printf("%s: can't map I/O space\n", device_xname(self)); return; } nc_addr = ia->ia_addr + NEREID_ADDR_OFFSET; nc_size = 0x02; if (bus_space_map(iot, nc_addr, nc_size, BUS_SPACE_MAP_SHIFTED, &isc->sc_nch)) { printf("%s: can't map I/O control space\n", device_xname(self)); return; } /* Initialize sc */ slhci_preinit(sc, slhci_intio_enable_power, iot, ioh, 30, SL11_IDX_DATA); /* Establish the interrupt handler */ if (intio_intr_establish(ia->ia_intr, "slhci", slhci_intr, sc)) { printf("%s: can't establish interrupt\n", device_xname(self)); return; } /* Reset controller */ bus_space_write_1(iot, isc->sc_nch, NEREID_CTRL, NEREID_CTRL_RESET); delay(40000); slhci_intio_enable_intr(sc, INTR_ON); /* Attach SL811HS/T */ if (slhci_attach(sc)) return; }
static void powsw_attach(device_t parent, device_t self, void *aux) { struct powsw_softc *sc = device_private(self); powsw_desc_t *desc; const char *xname; int unit; int sw; unit = device_unit(self); xname = device_xname(self); desc = &powsw_desc[unit]; memset(sc, 0, sizeof(*sc)); sc->sc_dev = self; sc->sc_mask = desc->mask; sc->sc_prev = -1; powsw_reset_counter(sc); sysmon_task_queue_init(); sc->sc_smpsw.smpsw_name = xname; sc->sc_smpsw.smpsw_type = PSWITCH_TYPE_POWER; if (sysmon_pswitch_register(&sc->sc_smpsw) != 0) panic("can't register with sysmon"); callout_init(&sc->sc_callout, 0); callout_setfunc(&sc->sc_callout, powsw_softintr, sc); if (shutdownhook_establish(powsw_shutdown_check, sc) == NULL) panic("%s: can't establish shutdown hook", xname); if (intio_intr_establish(desc->vector, xname, powsw_intr, sc) < 0) panic("%s: can't establish interrupt", xname); /* Set AER and enable interrupt */ sw = (mfp_get_gpip() & sc->sc_mask); powsw_set_aer(sc, sw ? 0 : 1); mfp_bit_set_ierb(sc->sc_mask); aprint_normal(": %s\n", desc->name); }
void parattach(device_t pdp, device_t dp, void *aux) { struct par_softc *sc = device_private(dp); struct intio_attach_args *ia = aux; int r; par_attached = 1; sc->sc_dev = dp; sc->sc_flags = PARF_ALIVE; aprint_normal(": parallel port (write only, interrupt)\n"); ia->ia_size = 0x2000; r = intio_map_allocate_region(pdp, ia, INTIO_MAP_ALLOCATE); #ifdef DIAGNOSTIC if (r) panic("IO map for PAR corruption??"); #endif sc->sc_bst = ia->ia_bst; r = bus_space_map(sc->sc_bst, ia->ia_addr, ia->ia_size, BUS_SPACE_MAP_SHIFTED, &sc->sc_bsh); #ifdef DIAGNOSTIC if (r) panic("Cannot map IO space for PAR."); #endif intio_set_sicilian_intr(intio_get_sicilian_intr() & ~SICILIAN_INTR_PAR); intio_intr_establish(ia->ia_intr, "par", (intio_intr_handler_t)parintr, (void *)1); callout_init(&sc->sc_timo_ch, 0); callout_init(&sc->sc_start_ch, 0); callout_init(&intr_callout, 0); }
static void kbdattach(device_t parent, device_t self, void *aux) { struct kbd_softc *sc = device_private(self); struct mfp_softc *mfp = device_private(parent); int s; kbd_attached = 1; s = spltty(); /* MFP interrupt #12 is for USART receive buffer full */ intio_intr_establish(mfp->sc_intr + 12, "kbd", kbdintr, sc); sc->sc_softintr_cookie = softint_establish(SOFTINT_SERIAL, kbdsoftint, sc); kbdenable(1); sc->sc_event_mode = 0; sc->sc_events.ev_io = 0; splx(s); aprint_normal("\n"); }
/* * Attach a found zs. */ static void zs_attach(device_t parent, device_t self, void *aux) { struct zsc_softc *zsc = device_private(self); struct intio_attach_args *ia = aux; struct zsc_attach_args zsc_args; volatile struct zschan *zc; struct zs_chanstate *cs; int r, s, zs_unit, channel; zsc->zsc_dev = self; aprint_normal("\n"); zs_unit = device_unit(self); zsc->zsc_addr = (void *)ia->ia_addr; ia->ia_size = 8; r = intio_map_allocate_region(parent, ia, INTIO_MAP_ALLOCATE); #ifdef DIAGNOSTIC if (r) panic("zs: intio IO map corruption"); #endif /* * Initialize software state for each channel. */ for (channel = 0; channel < 2; channel++) { device_t child; zsc_args.channel = channel; zsc_args.hwflags = 0; cs = &zsc->zsc_cs_store[channel]; zsc->zsc_cs[channel] = cs; zs_lock_init(cs); cs->cs_channel = channel; cs->cs_private = NULL; cs->cs_ops = &zsops_null; cs->cs_brg_clk = PCLK / 16; if (channel == 0) zc = (volatile void *)IIOV(&zsc->zsc_addr->zs_chan_a); else zc = (volatile void *)IIOV(&zsc->zsc_addr->zs_chan_b); cs->cs_reg_csr = &zc->zc_csr; cs->cs_reg_data = &zc->zc_data; zs_init_reg[2] = ia->ia_intr; memcpy(cs->cs_creg, zs_init_reg, 16); memcpy(cs->cs_preg, zs_init_reg, 16); if (zc == conschan) { zsc_args.hwflags |= ZS_HWFLAG_CONSOLE; cs->cs_defspeed = zs_get_speed(cs); cs->cs_defcflag = zscn_def_cflag; } else { cs->cs_defspeed = 9600; cs->cs_defcflag = zs_def_cflag; } /* Make these correspond to cs_defcflag (-crtscts) */ cs->cs_rr0_dcd = ZSRR0_DCD; cs->cs_rr0_cts = 0; cs->cs_wr5_dtr = ZSWR5_DTR | ZSWR5_RTS; cs->cs_wr5_rts = 0; /* * Clear the master interrupt enable. * The INTENA is common to both channels, * so just do it on the A channel. */ if (channel == 0) { s = splzs(); zs_write_reg(cs, 9, 0); splx(s); } /* * Look for a child driver for this channel. * The child attach will setup the hardware. */ child = config_found(self, (void *)&zsc_args, zs_print); #if ZSTTY > 0 if (zc == conschan && ((child && strcmp(device_xname(child), "zstty0")) || child == NULL)) /* XXX */ panic("%s: console device mismatch", __func__); #endif if (child == NULL) { /* No sub-driver. Just reset it. */ uint8_t reset = (channel == 0) ? ZSWR9_A_RESET : ZSWR9_B_RESET; s = splzs(); zs_write_reg(cs, 9, reset); splx(s); } } /* * Now safe to install interrupt handlers. */ if (intio_intr_establish(ia->ia_intr, "zs", zshard, zsc)) panic("%s: interrupt vector busy", __func__); zsc->zsc_softintr_cookie = softint_establish(SOFTINT_SERIAL, (void (*)(void *))zsc_intr_soft, zsc); /* XXX; evcnt_attach() ? */ /* * Set the master interrupt enable and interrupt vector. * (common to both channels, do it on A) */ cs = zsc->zsc_cs[0]; s = splzs(); /* interrupt vector */ zs_write_reg(cs, 2, ia->ia_intr); /* master interrupt control (enable) */ zs_write_reg(cs, 9, zs_init_reg[9]); splx(s); }
static void ne_intio_attach(device_t parent, device_t self, void *aux) { struct ne_intio_softc *sc = device_private(self); struct dp8390_softc *dsc = &sc->sc_dp8390; struct intio_attach_args *ia = aux; bus_space_tag_t iot = ia->ia_bst; bus_space_handle_t ioh; bus_space_tag_t asict; bus_space_handle_t asich; const char *typestr; int netype; dsc->sc_dev = self; aprint_normal(": Nereid Ethernet\n"); /* Map I/O space */ if (bus_space_map(iot, ia->ia_addr, NE2000_NPORTS*2, BUS_SPACE_MAP_SHIFTED_EVEN, &ioh)){ aprint_error_dev(self, "can't map I/O space\n"); return; } asict = iot; if (bus_space_subregion(iot, ioh, NE2000_ASIC_OFFSET*2, NE2000_ASIC_NPORTS*2, &asich)) { aprint_error_dev(self, "can't subregion I/O space\n"); return; } dsc->sc_regt = iot; dsc->sc_regh = ioh; sc->sc_asict = asict; sc->sc_asich = asich; /* * detect it again, so we can print some information about * the interface. * XXX: Should I check NE1000 or NE2000 for Nereid? */ netype = ne2000_detect(iot, ioh, asict, asich); switch (netype) { case NE2000_TYPE_NE1000: typestr = "NE1000"; break; case NE2000_TYPE_NE2000: typestr = "NE2000"; break; case NE2000_TYPE_RTL8019: typestr = "NE2000 (RTL8019)"; break; default: aprint_error_dev(self, "where did the card go?!\n"); return; } aprint_normal_dev(self, "%s Ethernet\n", typestr); /* This interface is always enabled */ dsc->sc_enabled = 1; /* * Do generic NE2000 attach. * This will read the mac address from the EEPROM. */ ne2000_attach(sc, NULL); /* Establish the interrupt handler */ if (intio_intr_establish(ia->ia_intr, "ne", dp8390_intr, dsc)) aprint_error_dev(self, "couldn't establish interrupt handler\n"); }