void * aupci_intr_establish(void *v, pci_intr_handle_t ih, int ipl, int (*handler)(void *), void *arg) { return (au_intr_establish(ih, 0, ipl, IST_LEVEL_LOW, handler, arg)); }
int aucom_aubus_enable(struct com_softc *sc) { struct aucom_aubus_softc *asc = (void *)sc; /* XXX mi prototype */ /* Ignore requests to enable an already enabled console. */ if (ISSET(sc->sc_hwflags, COM_HW_CONSOLE) && (asc->sc_ih != NULL)) return (0); /* Enable the UART module. */ bus_space_write_1(sc->sc_iot, sc->sc_ioh, UART_MODULE_CONTROL, UMC_ME | UMC_CE); /* Establish the interrupt. */ asc->sc_ih = au_intr_establish(asc->sc_irq, 0, IPL_SERIAL, IST_LEVEL, aucomintr, sc); if (asc->sc_ih == NULL) { printf("%s: unable to establish interrupt\n", sc->sc_dev.dv_xname); return (1); } return (0); }
void ohci_aubus_attach(device_t parent, device_t self, void *aux) { ohci_softc_t *sc = device_private(self); void *ih; usbd_status r; uint32_t x, tmp; bus_addr_t usbh_base, usbh_enable; struct aubus_attach_args *aa = aux; r = 0; usbh_base = aa->aa_addrs[0]; usbh_enable = aa->aa_addrs[1]; sc->sc_size = aa->aa_addrs[2]; sc->iot = aa->aa_st; sc->sc_bus.dmatag = (bus_dma_tag_t)aa->aa_dt; sc->sc_dev = self; sc->sc_bus.hci_private = sc; if (bus_space_map(sc->iot, usbh_base, sc->sc_size, 0, &sc->ioh)) { aprint_error_dev(self, "unable to map USBH registers\n"); return; } /* * Enable the USB Host controller here. * As per 7.2 in the Au1500 manual: * * (1) Set CE bit to enable clocks. * (2) Set E to enable OHCI * (3) Clear HCFS in OHCI_CONTROL. * (4) Wait for RD bit to be set. */ x = bus_space_read_4(sc->iot, sc->ioh, usbh_enable); x |= UE_CE; bus_space_write_4(sc->iot, sc->ioh, usbh_enable, x); delay(10); x |= UE_E; #ifdef __MIPSEB__ x |= UE_BE; #endif bus_space_write_4(sc->iot, sc->ioh, usbh_enable, x); delay(10); x = bus_space_read_4(sc->iot, sc->ioh, OHCI_CONTROL); x &= ~(OHCI_HCFS_MASK); bus_space_write_4(sc->iot, sc->ioh, OHCI_CONTROL, x); delay(10); /* Need to read USBH_ENABLE twice in succession according to * au1500 Errata #7. */ for (x = 100; x; x--) { bus_space_read_4(sc->iot, sc->ioh, usbh_enable); tmp = bus_space_read_4(sc->iot, sc->ioh, usbh_enable); if (tmp&UE_RD) break; delay(1000); } printf(": Alchemy OHCI\n"); /* Disable OHCI interrupts */ bus_space_write_4(sc->iot, sc->ioh, OHCI_INTERRUPT_DISABLE, OHCI_ALL_INTRS); /* hook interrupt */ ih = au_intr_establish(aa->aa_irq[0], 0, IPL_USB, IST_LEVEL_LOW, ohci_intr, sc); if (ih == NULL) { aprint_error_dev(self,"couldn't establish interrupt\n"); } sc->sc_endian = OHCI_HOST_ENDIAN; if (x) r = ohci_init(sc); if (r != USBD_NORMAL_COMPLETION) { aprint_error_dev(self, "init failed, error=%d\n", r); au_intr_disestablish(ih); return; } /* Attach USB device */ sc->sc_child = config_found(self, &sc->sc_bus, usbctlprint); }
void ohci_aubus_attach(struct device *parent, struct device *self, void *aux) { ohci_softc_t *sc = (ohci_softc_t *)self; void *ih; usbd_status r; uint32_t x, tmp; struct aubus_attach_args *aa = aux; r = 0; sc->sc_size = USBH_SIZE; sc->iot = aa->aa_st; sc->sc_bus.dmatag = (bus_dma_tag_t)aa->aa_dt; if (bus_space_map(sc->iot, USBH_BASE, USBH_SIZE, 0, &sc->ioh)) { printf("%s: Unable to map USBH registers\n", sc->sc_bus.bdev.dv_xname); return; } /* * Enable the USB Host controller here. * As per 7.2 in the Au1500 manual: * * (1) Set CE bit to enable clocks. * (2) Set E to enable OHCI * (3) Clear HCFS in OHCI_CONTROL. * (4) Wait for RD bit to be set. */ x = bus_space_read_4(sc->iot, sc->ioh, USBH_ENABLE); x |= UE_CE; bus_space_write_4(sc->iot, sc->ioh, USBH_ENABLE, x); delay(10); x |= UE_E; #ifdef __MIPSEB__ x |= UE_BE; #endif bus_space_write_4(sc->iot, sc->ioh, USBH_ENABLE, x); delay(10); x = bus_space_read_4(sc->iot, sc->ioh, OHCI_CONTROL); x &= ~(OHCI_HCFS_MASK); bus_space_write_4(sc->iot, sc->ioh, OHCI_CONTROL, x); delay(10); /* Need to read USBH_ENABLE twice in succession according to * au1500 Errata #7. */ for (x = 100; x; x--) { bus_space_read_4(sc->iot, sc->ioh, USBH_ENABLE); tmp = bus_space_read_4(sc->iot, sc->ioh, USBH_ENABLE); if (tmp&UE_RD) break; delay(1000); } printf(": Au1X00 OHCI\n"); /* Disable OHCI interrupts */ bus_space_write_4(sc->iot, sc->ioh, OHCI_INTERRUPT_DISABLE, OHCI_ALL_INTRS); /* hook interrupt */ ih = au_intr_establish(aa->aa_irq[0], 0, IPL_USB, IST_LEVEL_LOW, ohci_intr, sc); if (ih == NULL) { printf("%s: couldn't establish interrupt\n", sc->sc_bus.bdev.dv_xname); } if (x) r = ohci_init(sc); if (r != USBD_NORMAL_COMPLETION) { printf("%s: init failed, error=%d\n", sc->sc_bus.bdev.dv_xname, r); au_intr_disestablish(ih); return; } /* Attach USB device */ sc->sc_child = config_found((void *)sc, &sc->sc_bus, usbctlprint); }