static void slhci_isa_attach(device_t parent, device_t self, void *aux) { struct slhci_isa_softc *isc = device_private(self); struct slhci_softc *sc = &isc->sc; struct isa_attach_args *ia = aux; bus_space_tag_t iot = ia->ia_iot; bus_space_handle_t ioh; sc->sc_dev = self; sc->sc_bus.hci_private = sc; printf("\n"); /* XXX still needed? */ /* Map I/O space */ if (bus_space_map(iot, ia->ia_io[0].ir_addr, SL11_PORTSIZE, 0, &ioh)) { printf("%s: can't map I/O space\n", SC_NAME(sc)); return; } /* Initialize sc XXX power value unconfirmed */ slhci_preinit(sc, NULL, iot, ioh, 30, SL11_IDX_DATA); /* Establish the interrupt handler */ isc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq[0].ir_irq, IST_EDGE, IPL_USB, slhci_intr, sc); if (isc->sc_ih == NULL) { printf("%s: can't establish interrupt\n", SC_NAME(sc)); return; } /* Attach SL811HS/T */ if (slhci_attach(sc)) printf("%s: slhci_attach failed\n", SC_NAME(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 slhci_opio_attach(struct device *parent, struct device *self, void *aux) { struct slhci_opio_softc *sc = (struct slhci_opio_softc *)self; struct obio_attach_args *oba = aux; struct opio_softc *psc = (struct opio_softc *)device_parent(self); struct obio_softc *bsc = (struct obio_softc *)device_parent(&psc->sc_dev); bus_space_tag_t iot = oba->oba_iot; bus_space_handle_t ioh; printf("\n"); /* Map I/O space */ if (bus_space_map(iot, oba->oba_addr, PORTSIZE, 0, &ioh)) { printf("%s: can't map I/O space\n", sc->sc_sc.sc_bus.bdev.dv_xname); return; } /* Initialize sc */ sc->sc_sc.sc_iot = iot; sc->sc_sc.sc_ioh = ioh; sc->sc_sc.sc_dmat = &pxa2x0_bus_dma_tag; /* XXX */ sc->sc_sc.sc_enable_power = slhci_opio_enable_power; sc->sc_sc.sc_enable_intr = slhci_opio_enable_intr; sc->sc_sc.sc_arg = sc; /* Establish the interrupt handler */ sc->sc_ih = obio_intr_establish(bsc, oba->oba_intr, IPL_BIO, IST_LEVEL_HIGH, slhci_opio_intr, sc); if( sc->sc_ih == NULL) { printf("%s: can't establish interrupt\n", sc->sc_sc.sc_bus.bdev.dv_xname); return; } #if 0 /* Reset controller */ obio_peripheral_reset(bsc, 2, 1); delay(100); obio_peripheral_reset(bsc, 2, 0); delay(40000); #endif bus_space_write_1(iot, ioh, SL11_IDX_ADDR, SL11_CTRL); bus_space_write_1(iot, ioh, SL11_IDX_DATA, 0x01); /* Attach SL811HS/T */ if (slhci_attach(&sc->sc_sc, self)) return; }
static void slhci_zbus_attach(device_t parent, device_t self, void *aux) { struct slhci_zbus_softc *zsc; struct slhci_softc *sc; struct zbus_args *zap; bus_space_tag_t iot; bus_space_handle_t ioh; zap = aux; zsc = device_private(self); sc = &zsc->sc_sc; sc->sc_dev = self; sc->sc_bus.ub_hcpriv = sc; zsc->sc_bst.base = (bus_addr_t)zap->va; zsc->sc_bst.absm = &amiga_bus_stride_1; iot = &zsc->sc_bst; aprint_normal(": Thylacine USB Host Controller\n"); if (bus_space_map(iot, THYLACINE_SLHCI_ADDR_OFFSET, THYLACINE_SIZE, 0, &ioh)) { aprint_error_dev(sc->sc_dev, "can't map the bus\n"); } slhci_preinit(sc, slhci_zbus_enable_power, iot, ioh, 500, THYLACINE_SLHCI_DATA_STRIDE); /* Attach interrupt routine. */ zsc->sc_isr.isr_intr = slhci_intr; zsc->sc_isr.isr_arg = sc; zsc->sc_isr.isr_ipl = 6; add_isr(&zsc->sc_isr); slhci_attach(sc); }
int slhci_pcmcia_enable(struct slhci_pcmcia_softc *psc, int enable) { struct pcmcia_function *pf; struct pcmcia_io_handle *pioh; struct slhci_softc *sc; int error; pf = psc->sc_pf; sc = &psc->sc_slhci; if (enable) { if (psc->sc_flags & PFL_ENABLED) return 0; error = pcmcia_function_configure(pf, slhci_pcmcia_validate_config); if (error) { printf("%s: configure failed, error=%d\n", SC_NAME(sc), error); return 1; } pioh = &pf->cfe->iospace[0].handle; /* The data port is repeated three times; using a stride of * 2 prevents read/write errors on a Clio C-1000 hpcmips * system. */ slhci_preinit(sc, NULL, pioh->iot, pioh->ioh, 100, 2); psc->sc_ih = pcmcia_intr_establish(pf, IPL_USB, slhci_intr, sc); if (psc->sc_ih == NULL) { printf("%s: unable to establish interrupt\n", SC_NAME(sc)); goto fail1; } if (pcmcia_function_enable(pf)) { printf("%s: function enable failed\n", SC_NAME(sc)); goto fail2; } if (slhci_attach(sc)) { printf("%s: slhci_attach failed\n", SC_NAME(sc)); goto fail3; } psc->sc_flags |= PFL_ENABLED; return 0; } else { if (!(psc->sc_flags & PFL_ENABLED)) return 1; psc->sc_flags &= ~PFL_ENABLED; fail3: pcmcia_function_disable(pf); fail2: pcmcia_intr_disestablish(psc->sc_pf, psc->sc_ih); fail1: pcmcia_function_unconfigure(pf); return 1; } }