• Home
  • Raw
  • Download

Lines Matching refs:sc

80 	struct xhci_softc	*sc;  member
118 static void xhci_ctx_set_le32(struct xhci_softc *sc, volatile uint32_t *ptr, uint32_t val);
119 static uint32_t xhci_ctx_get_le32(struct xhci_softc *sc, volatile uint32_t *ptr);
120 static void xhci_ctx_set_le64(struct xhci_softc *sc, volatile uint64_t *ptr, uint64_t val);
122 static uint64_t xhci_ctx_get_le64(struct xhci_softc *sc, volatile uint64_t *ptr);
138 xhci_dump_endpoint(struct xhci_softc *sc, struct xhci_endp_ctx *pep) in xhci_dump_endpoint() argument
141 DPRINTFN(5, "dwEpCtx0=0x%08x\n", xhci_ctx_get_le32(sc, &pep->dwEpCtx0)); in xhci_dump_endpoint()
142 DPRINTFN(5, "dwEpCtx1=0x%08x\n", xhci_ctx_get_le32(sc, &pep->dwEpCtx1)); in xhci_dump_endpoint()
143 DPRINTFN(5, "qwEpCtx2=0x%016llx\n", (long long)xhci_ctx_get_le64(sc, &pep->qwEpCtx2)); in xhci_dump_endpoint()
144 DPRINTFN(5, "dwEpCtx4=0x%08x\n", xhci_ctx_get_le32(sc, &pep->dwEpCtx4)); in xhci_dump_endpoint()
145 DPRINTFN(5, "dwEpCtx5=0x%08x\n", xhci_ctx_get_le32(sc, &pep->dwEpCtx5)); in xhci_dump_endpoint()
146 DPRINTFN(5, "dwEpCtx6=0x%08x\n", xhci_ctx_get_le32(sc, &pep->dwEpCtx6)); in xhci_dump_endpoint()
147 DPRINTFN(5, "dwEpCtx7=0x%08x\n", xhci_ctx_get_le32(sc, &pep->dwEpCtx7)); in xhci_dump_endpoint()
151 xhci_dump_device(struct xhci_softc *sc, struct xhci_slot_ctx *psl) in xhci_dump_device() argument
154 DPRINTFN(5, "dwSctx0=0x%08x\n", xhci_ctx_get_le32(sc, &psl->dwSctx0)); in xhci_dump_device()
155 DPRINTFN(5, "dwSctx1=0x%08x\n", xhci_ctx_get_le32(sc, &psl->dwSctx1)); in xhci_dump_device()
156 DPRINTFN(5, "dwSctx2=0x%08x\n", xhci_ctx_get_le32(sc, &psl->dwSctx2)); in xhci_dump_device()
157 DPRINTFN(5, "dwSctx3=0x%08x\n", xhci_ctx_get_le32(sc, &psl->dwSctx3)); in xhci_dump_device()
174 struct xhci_softc *sc = XHCI_BUS2SC(bus); in xhci_iterate_hw_softc() local
177 cb(bus, &sc->sc_hw.root_pc, &sc->sc_hw.root_pg, in xhci_iterate_hw_softc()
180 cb(bus, &sc->sc_hw.ctx_pc, &sc->sc_hw.ctx_pg, in xhci_iterate_hw_softc()
183 for (i = 0; i != sc->sc_noscratch; i++) { in xhci_iterate_hw_softc()
184 cb(bus, &sc->sc_hw.scratch_pc[i], &sc->sc_hw.scratch_pg[i], in xhci_iterate_hw_softc()
190 xhci_ctx_set_le32(struct xhci_softc *sc, volatile uint32_t *ptr, uint32_t val) in xhci_ctx_set_le32() argument
193 if (sc->sc_ctx_is_64_byte) { in xhci_ctx_set_le32()
203 xhci_ctx_get_le32(struct xhci_softc *sc, volatile uint32_t *ptr) in xhci_ctx_get_le32() argument
206 if (sc->sc_ctx_is_64_byte) { in xhci_ctx_get_le32()
216 xhci_ctx_set_le64(struct xhci_softc *sc, volatile uint64_t *ptr, uint64_t val) in xhci_ctx_set_le64() argument
219 if (sc->sc_ctx_is_64_byte) { in xhci_ctx_set_le64()
230 xhci_ctx_get_le64(struct xhci_softc *sc, volatile uint64_t *ptr) in xhci_ctx_get_le64() argument
233 if (sc->sc_ctx_is_64_byte) { in xhci_ctx_get_le64()
244 xhci_reset_command_queue_locked(struct xhci_softc *sc) in xhci_reset_command_queue_locked() argument
253 temp = XREAD4(sc, oper, XHCI_CRCR_LO); in xhci_reset_command_queue_locked()
265 XWRITE4(sc, oper, XHCI_CRCR_LO, temp | XHCI_CRCR_LO_CS); in xhci_reset_command_queue_locked()
266 XWRITE4(sc, oper, XHCI_CRCR_HI, 0); in xhci_reset_command_queue_locked()
268 XWRITE4(sc, oper, XHCI_CRCR_LO, temp | XHCI_CRCR_LO_CA); in xhci_reset_command_queue_locked()
269 XWRITE4(sc, oper, XHCI_CRCR_HI, 0); in xhci_reset_command_queue_locked()
272 usb_pause_mtx(&sc->sc_bus.bus_mtx, hz / 4); in xhci_reset_command_queue_locked()
275 temp = XREAD4(sc, oper, XHCI_CRCR_LO); in xhci_reset_command_queue_locked()
283 sc->sc_command_ccs = 1; in xhci_reset_command_queue_locked()
284 sc->sc_command_idx = 0; in xhci_reset_command_queue_locked()
286 usbd_get_page(&sc->sc_hw.root_pc, 0, &buf_res); in xhci_reset_command_queue_locked()
298 usb_pc_cpu_flush(&sc->sc_hw.root_pc); in xhci_reset_command_queue_locked()
300 XWRITE4(sc, oper, XHCI_CRCR_LO, ((uint32_t)addr) | XHCI_CRCR_LO_RCS); in xhci_reset_command_queue_locked()
301 XWRITE4(sc, oper, XHCI_CRCR_HI, (uint32_t)(addr >> 32)); in xhci_reset_command_queue_locked()
307 xhci_start_controller(struct xhci_softc *sc) in xhci_start_controller() argument
319 sc->sc_event_ccs = 1; in xhci_start_controller()
320 sc->sc_event_idx = 0; in xhci_start_controller()
321 sc->sc_command_ccs = 1; in xhci_start_controller()
322 sc->sc_command_idx = 0; in xhci_start_controller()
325 XWRITE4(sc, oper, XHCI_USBCMD, XHCI_CMD_HCRST); in xhci_start_controller()
329 temp = (XREAD4(sc, oper, XHCI_USBCMD) & XHCI_CMD_HCRST) | in xhci_start_controller()
330 (XREAD4(sc, oper, XHCI_USBSTS) & XHCI_STS_CNR); in xhci_start_controller()
336 device_printf(sc->sc_bus.parent, "Controller " in xhci_start_controller()
343 XREAD4(sc, oper, XHCI_CONFIG), sc->sc_noslot); in xhci_start_controller()
345 XWRITE4(sc, oper, XHCI_CONFIG, sc->sc_noslot); in xhci_start_controller()
347 temp = XREAD4(sc, oper, XHCI_USBSTS); in xhci_start_controller()
350 XWRITE4(sc, oper, XHCI_USBSTS, temp); in xhci_start_controller()
352 XWRITE4(sc, oper, XHCI_DNCTRL, 0); in xhci_start_controller()
355 usbd_get_page(&sc->sc_hw.ctx_pc, 0, &buf_res); in xhci_start_controller()
369 for (i = 0; i != sc->sc_noscratch; i++) { in xhci_start_controller()
371 usbd_get_page(&sc->sc_hw.scratch_pc[i], 0, &buf_scp); in xhci_start_controller()
377 XWRITE4(sc, oper, XHCI_DCBAAP_LO, (uint32_t)addr); in xhci_start_controller()
378 XWRITE4(sc, oper, XHCI_DCBAAP_HI, (uint32_t)(addr >> 32)); in xhci_start_controller()
379 XWRITE4(sc, oper, XHCI_DCBAAP_LO, (uint32_t)addr); in xhci_start_controller()
380 XWRITE4(sc, oper, XHCI_DCBAAP_HI, (uint32_t)(addr >> 32)); in xhci_start_controller()
384 XREAD4(sc, runt, XHCI_ERSTSZ(0)), sc->sc_erst_max); in xhci_start_controller()
386 XWRITE4(sc, runt, XHCI_ERSTSZ(0), XHCI_ERSTS_SET(sc->sc_erst_max)); in xhci_start_controller()
389 XWRITE4(sc, runt, XHCI_IMOD(0), sc->sc_imod_default); in xhci_start_controller()
391 usbd_get_page(&sc->sc_hw.root_pc, 0, &buf_res); in xhci_start_controller()
409 XWRITE4(sc, runt, XHCI_ERDP_LO(0), (uint32_t)addr); in xhci_start_controller()
410 XWRITE4(sc, runt, XHCI_ERDP_HI(0), (uint32_t)(addr >> 32)); in xhci_start_controller()
416 XWRITE4(sc, runt, XHCI_ERSTBA_LO(0), (uint32_t)addr); in xhci_start_controller()
417 XWRITE4(sc, runt, XHCI_ERSTBA_HI(0), (uint32_t)(addr >> 32)); in xhci_start_controller()
420 temp = XREAD4(sc, runt, XHCI_IMAN(0)); in xhci_start_controller()
422 XWRITE4(sc, runt, XHCI_IMAN(0), temp); in xhci_start_controller()
430 XWRITE4(sc, oper, XHCI_CRCR_LO, ((uint32_t)addr) | XHCI_CRCR_LO_RCS); in xhci_start_controller()
431 XWRITE4(sc, oper, XHCI_CRCR_HI, (uint32_t)(addr >> 32)); in xhci_start_controller()
435 usb_bus_mem_flush_all(&sc->sc_bus, &xhci_iterate_hw_softc); in xhci_start_controller()
438 XWRITE4(sc, oper, XHCI_USBCMD, XHCI_CMD_RS | in xhci_start_controller()
443 temp = XREAD4(sc, oper, XHCI_USBSTS) & XHCI_STS_HCH; in xhci_start_controller()
448 XWRITE4(sc, oper, XHCI_USBCMD, 0); in xhci_start_controller()
449 device_printf(sc->sc_bus.parent, "Run timeout.\n"); in xhci_start_controller()
454 xhci_do_poll(&sc->sc_bus); in xhci_start_controller()
456 if (sc->sc_port_route != NULL) { in xhci_start_controller()
458 (void)sc->sc_port_route(sc->sc_bus.parent, in xhci_start_controller()
465 xhci_halt_controller(struct xhci_softc *sc) in xhci_halt_controller() argument
472 sc->sc_capa_off = 0; in xhci_halt_controller()
473 sc->sc_oper_off = XREAD1(sc, capa, XHCI_CAPLENGTH); in xhci_halt_controller()
474 sc->sc_runt_off = XREAD4(sc, capa, XHCI_RTSOFF) & ~0xF; in xhci_halt_controller()
475 sc->sc_door_off = XREAD4(sc, capa, XHCI_DBOFF) & ~0x3; in xhci_halt_controller()
478 XWRITE4(sc, oper, XHCI_USBCMD, 0); in xhci_halt_controller()
482 temp = XREAD4(sc, oper, XHCI_USBSTS) & XHCI_STS_HCH; in xhci_halt_controller()
488 device_printf(sc->sc_bus.parent, "Controller halt timeout.\n"); in xhci_halt_controller()
495 xhci_reset_controller(struct xhci_softc *sc) in xhci_reset_controller() argument
503 XWRITE4(sc, oper, XHCI_USBCMD, XHCI_CMD_HCRST); in xhci_reset_controller()
507 temp = (XREAD4(sc, oper, XHCI_USBCMD) & XHCI_CMD_HCRST) | in xhci_reset_controller()
508 (XREAD4(sc, oper, XHCI_USBSTS) & XHCI_STS_CNR); in xhci_reset_controller()
514 device_printf(sc->sc_bus.parent, "Controller " in xhci_reset_controller()
522 xhci_init(struct xhci_softc *sc, device_t self, uint8_t dma32) in xhci_init() argument
529 sc->sc_bus.parent = self; in xhci_init()
532 sc->sc_bus.usbrev = USB_REV_3_0; in xhci_init()
535 sc->sc_bus.methods = &xhci_bus_methods; in xhci_init()
538 sc->sc_bus.devices = sc->sc_devices; in xhci_init()
539 sc->sc_bus.devices_max = XHCI_MAX_DEVICES; in xhci_init()
542 sc->sc_event_ccs = 1; in xhci_init()
543 sc->sc_command_ccs = 1; in xhci_init()
546 sc->sc_capa_off = 0; in xhci_init()
547 sc->sc_oper_off = XREAD1(sc, capa, XHCI_CAPLENGTH); in xhci_init()
548 sc->sc_runt_off = XREAD4(sc, capa, XHCI_RTSOFF) & ~0x1F; in xhci_init()
549 sc->sc_door_off = XREAD4(sc, capa, XHCI_DBOFF) & ~0x3; in xhci_init()
551 DPRINTF("CAPLENGTH=0x%x\n", sc->sc_oper_off); in xhci_init()
552 DPRINTF("RUNTIMEOFFSET=0x%x\n", sc->sc_runt_off); in xhci_init()
553 DPRINTF("DOOROFFSET=0x%x\n", sc->sc_door_off); in xhci_init()
555 DPRINTF("xHCI version = 0x%04x\n", XREAD2(sc, capa, XHCI_HCIVERSION)); in xhci_init()
557 if (!(XREAD4(sc, oper, XHCI_PAGESIZE) & XHCI_PAGESIZE_4K)) { in xhci_init()
558 device_printf(sc->sc_bus.parent, "Controller does " in xhci_init()
563 temp = XREAD4(sc, capa, XHCI_HCSPARAMS0); in xhci_init()
569 sc->sc_ctx_is_64_byte = 1; in xhci_init()
571 sc->sc_ctx_is_64_byte = 0; in xhci_init()
575 sc->sc_bus.dma_bits = (XHCI_HCS0_AC64(temp) && in xhci_init()
579 sc->sc_ctx_is_64_byte ? 64 : 32, (int)sc->sc_bus.dma_bits); in xhci_init()
581 temp = XREAD4(sc, capa, XHCI_HCSPARAMS1); in xhci_init()
584 sc->sc_noport = XHCI_HCS1_N_PORTS(temp); in xhci_init()
586 if (sc->sc_noport == 0) { in xhci_init()
587 device_printf(sc->sc_bus.parent, "Invalid number " in xhci_init()
588 "of ports: %u\n", sc->sc_noport); in xhci_init()
592 sc->sc_noslot = XHCI_HCS1_DEVSLOT_MAX(temp); in xhci_init()
594 DPRINTF("Max slots: %u\n", sc->sc_noslot); in xhci_init()
596 if (sc->sc_noslot > XHCI_MAX_DEVICES) in xhci_init()
597 sc->sc_noslot = XHCI_MAX_DEVICES; in xhci_init()
599 temp = XREAD4(sc, capa, XHCI_HCSPARAMS2); in xhci_init()
604 sc->sc_noscratch = XHCI_HCS2_SPB_MAX(temp); in xhci_init()
606 if (sc->sc_noscratch > XHCI_MAX_SCRATCHPADS) { in xhci_init()
607 device_printf(sc->sc_bus.parent, "XHCI request " in xhci_init()
612 DPRINTF("Max scratch: %u\n", sc->sc_noscratch); in xhci_init()
615 sc->sc_erst_max = 1U << XHCI_HCS2_ERST_MAX(temp); in xhci_init()
616 if (sc->sc_erst_max > XHCI_MAX_RSEG) in xhci_init()
617 sc->sc_erst_max = XHCI_MAX_RSEG; in xhci_init()
619 temp = XREAD4(sc, capa, XHCI_HCSPARAMS3); in xhci_init()
622 sc->sc_exit_lat_max = XHCI_HCS3_U1_DEL(temp) + in xhci_init()
626 if (sc->sc_imod_default == 0) in xhci_init()
627 sc->sc_imod_default = XHCI_IMOD_DEFAULT; in xhci_init()
630 if (usb_bus_mem_alloc_all(&sc->sc_bus, in xhci_init()
636 cv_init(&sc->sc_cmd_cv, "CMDQ"); in xhci_init()
637 sx_init(&sc->sc_cmd_sx, "CMDQ lock"); in xhci_init()
639 sc->sc_config_msg[0].hdr.pm_callback = &xhci_configure_msg; in xhci_init()
640 sc->sc_config_msg[0].bus = &sc->sc_bus; in xhci_init()
641 sc->sc_config_msg[1].hdr.pm_callback = &xhci_configure_msg; in xhci_init()
642 sc->sc_config_msg[1].bus = &sc->sc_bus; in xhci_init()
648 xhci_uninit(struct xhci_softc *sc) in xhci_uninit() argument
656 usb_bus_mem_free_all(&sc->sc_bus, &xhci_iterate_hw_softc); in xhci_uninit()
658 cv_destroy(&sc->sc_cmd_cv); in xhci_uninit()
659 sx_destroy(&sc->sc_cmd_sx); in xhci_uninit()
665 struct xhci_softc *sc = XHCI_BUS2SC(bus); in xhci_set_hw_power_sleep() local
670 (void)xhci_halt_controller(sc); in xhci_set_hw_power_sleep()
671 (void)xhci_reset_controller(sc); in xhci_set_hw_power_sleep()
675 (void)xhci_halt_controller(sc); in xhci_set_hw_power_sleep()
676 (void)xhci_reset_controller(sc); in xhci_set_hw_power_sleep()
680 (void)xhci_start_controller(sc); in xhci_set_hw_power_sleep()
857 xhci_check_transfer(struct xhci_softc *sc, struct xhci_trb *trb) in xhci_check_transfer() argument
889 if (index > sc->sc_noslot) { in xhci_check_transfer()
899 pepext = &sc->sc_hw.devs[index].endp[epno]; in xhci_check_transfer()
1025 xhci_check_command(struct xhci_softc *sc, struct xhci_trb *trb) in xhci_check_command() argument
1027 if (sc->sc_cmd_addr == trb->qwTrb0) { in xhci_check_command()
1029 sc->sc_cmd_result[0] = trb->dwTrb2; in xhci_check_command()
1030 sc->sc_cmd_result[1] = trb->dwTrb3; in xhci_check_command()
1031 (void)cv_signal(&sc->sc_cmd_cv); in xhci_check_command()
1038 xhci_interrupt_poll(struct xhci_softc *sc) in xhci_interrupt_poll() argument
1051 usbd_get_page(&sc->sc_hw.root_pc, 0, &buf_res); in xhci_interrupt_poll()
1057 usb_pc_cpu_invalidate(&sc->sc_hw.root_pc); in xhci_interrupt_poll()
1059 i = sc->sc_event_idx; in xhci_interrupt_poll()
1060 j = sc->sc_event_ccs; in xhci_interrupt_poll()
1080 xhci_check_transfer(sc, &phwr->hwr_events[i]); in xhci_interrupt_poll()
1083 retval |= xhci_check_command(sc, &phwr->hwr_events[i]); in xhci_interrupt_poll()
1102 sc->sc_event_idx = i; in xhci_interrupt_poll()
1103 sc->sc_event_ccs = j; in xhci_interrupt_poll()
1118 XWRITE4(sc, runt, XHCI_ERDP_LO(0), (uint32_t)addr); in xhci_interrupt_poll()
1119 XWRITE4(sc, runt, XHCI_ERDP_HI(0), (uint32_t)(addr >> 32)); in xhci_interrupt_poll()
1125 xhci_do_command(struct xhci_softc *sc, struct xhci_trb *trb, in xhci_do_command() argument
1137 XHCI_CMD_ASSERT_LOCKED(sc); in xhci_do_command()
1141 usbd_get_page(&sc->sc_hw.root_pc, 0, &buf_res); in xhci_do_command()
1147 USB_BUS_LOCK(&sc->sc_bus); in xhci_do_command()
1149 i = sc->sc_command_idx; in xhci_do_command()
1150 j = sc->sc_command_ccs; in xhci_do_command()
1161 usb_pc_cpu_flush(&sc->sc_hw.root_pc); in xhci_do_command()
1174 usb_pc_cpu_flush(&sc->sc_hw.root_pc); in xhci_do_command()
1179 sc->sc_cmd_addr = htole64(addr); in xhci_do_command()
1195 usb_pc_cpu_flush(&sc->sc_hw.root_pc); in xhci_do_command()
1201 sc->sc_command_idx = i; in xhci_do_command()
1202 sc->sc_command_ccs = j; in xhci_do_command()
1204 XWRITE4(sc, door, XHCI_DOORBELL(0), 0); in xhci_do_command()
1206 err = (usb_error_t)cv_timedwait(&sc->sc_cmd_cv, &sc->sc_bus.bus_mtx, in xhci_do_command()
1213 if ((err != 0) && (xhci_interrupt_poll(sc) != 0)) { in xhci_do_command()
1228 (xhci_reset_command_queue_locked(sc) == 0)) { in xhci_do_command()
1245 usb_bus_reset_async_locked(&sc->sc_bus); in xhci_do_command()
1251 temp = le32toh(sc->sc_cmd_result[0]); in xhci_do_command()
1254 (XHCI_TRB_3_SLOT_GET(le32toh(sc->sc_cmd_result[1]))))) { in xhci_do_command()
1259 trb->dwTrb2 = sc->sc_cmd_result[0]; in xhci_do_command()
1260 trb->dwTrb3 = sc->sc_cmd_result[1]; in xhci_do_command()
1263 USB_BUS_UNLOCK(&sc->sc_bus); in xhci_do_command()
1269 xhci_cmd_enable_slot(struct xhci_softc *sc, uint8_t *pslot) in xhci_cmd_enable_slot() argument
1281 err = xhci_do_command(sc, &trb, XHCI_DO_CMD_TIMEOUT/* ms */); in xhci_cmd_enable_slot()
1294 xhci_cmd_disable_slot(struct xhci_softc *sc, uint8_t slot_id) in xhci_cmd_disable_slot() argument
1308 return (xhci_do_command(sc, &trb, XHCI_DO_CMD_TIMEOUT/* ms */)); in xhci_cmd_disable_slot()
1312 xhci_cmd_set_address(struct xhci_softc *sc, uint64_t input_ctx, in xhci_cmd_set_address() argument
1330 return (xhci_do_command(sc, &trb, XHCI_DO_CMD_TIMEOUT/* ms */)); in xhci_cmd_set_address()
1338 struct xhci_softc *sc = XHCI_BUS2SC(udev->bus); in xhci_set_address() local
1353 hdev = &sc->sc_hw.devs[index]; in xhci_set_address()
1358 XHCI_CMD_LOCK(sc); in xhci_set_address()
1412 err = xhci_cmd_set_address(sc, buf_inp.physaddr, in xhci_set_address()
1416 temp = le32toh(sc->sc_cmd_result[0]); in xhci_set_address()
1417 if ((address == 0) && (sc->sc_port_route != NULL) && in xhci_set_address()
1422 (void)sc->sc_port_route(sc->sc_bus.parent, 0, ~0); in xhci_set_address()
1436 temp = xhci_ctx_get_le32(sc, &pdev->ctx_slot.dwSctx3); in xhci_set_address()
1452 XHCI_CMD_UNLOCK(sc); in xhci_set_address()
1461 xhci_cmd_configure_ep(struct xhci_softc *sc, uint64_t input_ctx, in xhci_cmd_configure_ep() argument
1479 return (xhci_do_command(sc, &trb, XHCI_DO_CMD_TIMEOUT/* ms */)); in xhci_cmd_configure_ep()
1483 xhci_cmd_evaluate_ctx(struct xhci_softc *sc, uint64_t input_ctx, in xhci_cmd_evaluate_ctx() argument
1497 return (xhci_do_command(sc, &trb, XHCI_DO_CMD_TIMEOUT/* ms */)); in xhci_cmd_evaluate_ctx()
1501 xhci_cmd_reset_ep(struct xhci_softc *sc, uint8_t preserve, in xhci_cmd_reset_ep() argument
1520 return (xhci_do_command(sc, &trb, XHCI_DO_CMD_TIMEOUT/* ms */)); in xhci_cmd_reset_ep()
1524 xhci_cmd_set_tr_dequeue_ptr(struct xhci_softc *sc, uint64_t dequeue_ptr, in xhci_cmd_set_tr_dequeue_ptr() argument
1542 return (xhci_do_command(sc, &trb, XHCI_DO_CMD_TIMEOUT/* ms */)); in xhci_cmd_set_tr_dequeue_ptr()
1546 xhci_cmd_stop_ep(struct xhci_softc *sc, uint8_t suspend, in xhci_cmd_stop_ep() argument
1565 return (xhci_do_command(sc, &trb, XHCI_DO_CMD_TIMEOUT/* ms */)); in xhci_cmd_stop_ep()
1569 xhci_cmd_reset_dev(struct xhci_softc *sc, uint8_t slot_id) in xhci_cmd_reset_dev() argument
1583 return (xhci_do_command(sc, &trb, XHCI_DO_CMD_TIMEOUT/* ms */)); in xhci_cmd_reset_dev()
1590 xhci_interrupt(unsigned int irq, struct xhci_softc *sc) in xhci_interrupt() argument
1595 USB_BUS_LOCK(&sc->sc_bus); in xhci_interrupt()
1597 status = XREAD4(sc, oper, XHCI_USBSTS); in xhci_interrupt()
1601 XWRITE4(sc, oper, XHCI_USBSTS, status); in xhci_interrupt()
1605 temp = XREAD4(sc, runt, XHCI_IMAN(0)); in xhci_interrupt()
1609 XWRITE4(sc, runt, XHCI_IMAN(0), temp); in xhci_interrupt()
1612 (void)xhci_interrupt_poll(sc); in xhci_interrupt()
1617 xhci_root_intr(sc); in xhci_interrupt()
1635 USB_BUS_UNLOCK(&sc->sc_bus); in xhci_interrupt()
1657 struct xhci_softc *sc = XHCI_BUS2SC(bus); in xhci_do_poll() local
1659 USB_BUS_LOCK(&sc->sc_bus); in xhci_do_poll()
1660 (void)xhci_interrupt_poll(sc); in xhci_do_poll()
1661 USB_BUS_UNLOCK(&sc->sc_bus); in xhci_do_poll()
1981 temp.sc = XHCI_BUS2SC(xfer->xroot->bus); in xhci_setup_generic_chain()
2019 x = XREAD4(temp.sc, runt, XHCI_MFINDEX); in xhci_setup_generic_chain()
2064 usb_isoc_time_expand(&temp.sc->sc_bus, x / 8) + in xhci_setup_generic_chain()
2190 if (xhcictlstep || temp.sc->sc_ctlstep) { in xhci_setup_generic_chain()
2221 xhci_set_slot_pointer(struct xhci_softc *sc, uint8_t index, uint64_t dev_addr) in xhci_set_slot_pointer() argument
2226 usbd_get_page(&sc->sc_hw.ctx_pc, 0, &buf_res); in xhci_set_slot_pointer()
2234 usb_pc_cpu_flush(&sc->sc_hw.ctx_pc); in xhci_set_slot_pointer()
2240 struct xhci_softc *sc = XHCI_BUS2SC(udev->bus); in xhci_configure_mask() local
2249 usbd_get_page(&sc->sc_hw.devs[index].input_pc, 0, &buf_inp); in xhci_configure_mask()
2255 xhci_ctx_set_le32(sc, &pinp->ctx_input.dwInCtx0, mask); in xhci_configure_mask()
2256 xhci_ctx_set_le32(sc, &pinp->ctx_input.dwInCtx1, 0); in xhci_configure_mask()
2262 xhci_ctx_set_le32(sc, &pinp->ctx_input.dwInCtx0, in xhci_configure_mask()
2266 xhci_ctx_set_le32(sc, &pinp->ctx_input.dwInCtx1, mask); in xhci_configure_mask()
2278 if (x > sc->sc_hw.devs[index].context_num) in xhci_configure_mask()
2279 sc->sc_hw.devs[index].context_num = x; in xhci_configure_mask()
2281 x = sc->sc_hw.devs[index].context_num; in xhci_configure_mask()
2284 temp = xhci_ctx_get_le32(sc, &pinp->ctx_slot.dwSctx0); in xhci_configure_mask()
2287 xhci_ctx_set_le32(sc, &pinp->ctx_slot.dwSctx0, temp); in xhci_configure_mask()
2289 usb_pc_cpu_flush(&sc->sc_hw.devs[index].input_pc); in xhci_configure_mask()
2301 struct xhci_softc *sc = XHCI_BUS2SC(udev->bus); in xhci_configure_endpoint() local
2311 usbd_get_page(&sc->sc_hw.devs[index].input_pc, 0, &buf_inp); in xhci_configure_endpoint()
2389 xhci_ctx_set_le32(sc, &pinp->ctx_ep[epno - 1].dwEpCtx0, temp); in xhci_configure_endpoint()
2424 xhci_ctx_set_le32(sc, &pinp->ctx_ep[epno - 1].dwEpCtx1, temp); in xhci_configure_endpoint()
2425 xhci_ctx_set_le64(sc, &pinp->ctx_ep[epno - 1].qwEpCtx2, ring_addr); in xhci_configure_endpoint()
2442 xhci_ctx_set_le32(sc, &pinp->ctx_ep[epno - 1].dwEpCtx4, temp); in xhci_configure_endpoint()
2445 xhci_dump_endpoint(sc, &pinp->ctx_ep[epno - 1]); in xhci_configure_endpoint()
2447 usb_pc_cpu_flush(&sc->sc_hw.devs[index].input_pc); in xhci_configure_endpoint()
2498 struct xhci_softc *sc = XHCI_BUS2SC(udev->bus); in xhci_configure_device() local
2514 pcinp = &sc->sc_hw.devs[index].input_pc; in xhci_configure_device()
2552 sc->sc_hw.devs[index].context_num + 1); in xhci_configure_device()
2566 if ((sc->sc_hw.devs[index].nports != 0) && in xhci_configure_device()
2586 is_hub = sc->sc_hw.devs[index].nports != 0 && in xhci_configure_device()
2593 xhci_ctx_set_le32(sc, &pinp->ctx_slot.dwSctx0, temp); in xhci_configure_device()
2599 sc->sc_hw.devs[index].nports); in xhci_configure_device()
2604 switch (sc->sc_hw.devs[index].state) { in xhci_configure_device()
2608 temp |= XHCI_SCTX_1_MAX_EL_SET(sc->sc_exit_lat_max); in xhci_configure_device()
2619 xhci_ctx_set_le32(sc, &pinp->ctx_slot.dwSctx1, temp); in xhci_configure_device()
2625 sc->sc_hw.devs[index].tt); in xhci_configure_device()
2645 xhci_ctx_set_le32(sc, &pinp->ctx_slot.dwSctx2, temp); in xhci_configure_device()
2654 xhci_ctx_set_le32(sc, &pinp->ctx_slot.dwSctx3, temp); in xhci_configure_device()
2657 xhci_dump_device(sc, &pinp->ctx_slot); in xhci_configure_device()
2667 struct xhci_softc *sc = XHCI_BUS2SC(udev->bus); in xhci_alloc_device_ext() local
2679 pc = &sc->sc_hw.devs[index].device_pc; in xhci_alloc_device_ext()
2680 pg = &sc->sc_hw.devs[index].device_pg; in xhci_alloc_device_ext()
2683 pc->tag_parent = sc->sc_bus.dma_parent_tag; in xhci_alloc_device_ext()
2685 if (usb_pc_alloc_mem(pc, pg, sc->sc_ctx_is_64_byte ? in xhci_alloc_device_ext()
2692 pc = &sc->sc_hw.devs[index].input_pc; in xhci_alloc_device_ext()
2693 pg = &sc->sc_hw.devs[index].input_pg; in xhci_alloc_device_ext()
2696 pc->tag_parent = sc->sc_bus.dma_parent_tag; in xhci_alloc_device_ext()
2698 if (usb_pc_alloc_mem(pc, pg, sc->sc_ctx_is_64_byte ? in xhci_alloc_device_ext()
2707 pc = &sc->sc_hw.devs[index].endpoint_pc[i]; in xhci_alloc_device_ext()
2708 pg = &sc->sc_hw.devs[index].endpoint_pg[i]; in xhci_alloc_device_ext()
2711 pc->tag_parent = sc->sc_bus.dma_parent_tag; in xhci_alloc_device_ext()
2737 xhci_set_slot_pointer(sc, index, buf_dev.physaddr); in xhci_alloc_device_ext()
2750 struct xhci_softc *sc = XHCI_BUS2SC(udev->bus); in xhci_free_device_ext() local
2755 xhci_set_slot_pointer(sc, index, 0); in xhci_free_device_ext()
2757 usb_pc_free_mem(&sc->sc_hw.devs[index].device_pc); in xhci_free_device_ext()
2758 usb_pc_free_mem(&sc->sc_hw.devs[index].input_pc); in xhci_free_device_ext()
2760 usb_pc_free_mem(&sc->sc_hw.devs[index].endpoint_pc[i]); in xhci_free_device_ext()
2766 struct xhci_softc *sc = XHCI_BUS2SC(udev->bus); in xhci_get_endpoint_ext() local
2781 pc = &sc->sc_hw.devs[index].endpoint_pc[epno]; in xhci_get_endpoint_ext()
2785 pepext = &sc->sc_hw.devs[index].endp[epno]; in xhci_get_endpoint_ext()
2796 struct xhci_softc *sc = XHCI_BUS2SC(xfer->xroot->bus); in xhci_endpoint_doorbell() local
2808 XWRITE4(sc, door, XHCI_DOORBELL(index), in xhci_endpoint_doorbell()
2894 struct xhci_softc *sc = XHCI_BUS2SC(xfer->xroot->bus); in xhci_transfer_insert() local
2899 (void)usb_proc_msignal(USB_BUS_CONTROL_XFER_PROC(&sc->sc_bus), in xhci_transfer_insert()
2900 &sc->sc_config_msg[0], &sc->sc_config_msg[1]); in xhci_transfer_insert()
2978 xhci_root_intr(struct xhci_softc *sc) in xhci_root_intr() argument
2982 USB_BUS_LOCK_ASSERT(&sc->sc_bus, MA_OWNED); in xhci_root_intr()
2985 (void)memset_s(sc->sc_hub_idata, sizeof(sc->sc_hub_idata), 0, sizeof(sc->sc_hub_idata)); in xhci_root_intr()
2987 for (i = 1; i <= sc->sc_noport; i++) { in xhci_root_intr()
2989 if (XREAD4(sc, oper, XHCI_PORTSC(i)) & ( in xhci_root_intr()
2994 sc->sc_hub_idata[i / 8] |= 1 << (i % 8); in xhci_root_intr()
2998 uhub_root_intr(&sc->sc_bus, sc->sc_hub_idata, in xhci_root_intr()
2999 sizeof(sc->sc_hub_idata)); in xhci_root_intr()
3234 struct xhci_softc *sc = XHCI_BUS2SC(udev->bus); in xhci_roothub_exec() local
3246 USB_BUS_LOCK_ASSERT(&sc->sc_bus, MA_OWNED); in xhci_roothub_exec()
3249 ptr = (const void *)&sc->sc_hub_desc; in xhci_roothub_exec()
3273 sc->sc_hub_desc.temp[0] = sc->sc_conf; in xhci_roothub_exec()
3311 str_ptr = sc->sc_vendor; in xhci_roothub_exec()
3324 sc->sc_hub_desc.temp, in xhci_roothub_exec()
3325 sizeof(sc->sc_hub_desc.temp), in xhci_roothub_exec()
3336 sc->sc_hub_desc.temp[0] = 0; in xhci_roothub_exec()
3340 USETW(sc->sc_hub_desc.stat.wStatus, UDS_SELF_POWERED); in xhci_roothub_exec()
3345 USETW(sc->sc_hub_desc.stat.wStatus, 0); in xhci_roothub_exec()
3358 sc->sc_conf = value; in xhci_roothub_exec()
3378 (index > sc->sc_noport)) { in xhci_roothub_exec()
3384 v = XREAD4(sc, oper, port); in xhci_roothub_exec()
3390 XWRITE4(sc, oper, port, v | XHCI_PS_WRC); in xhci_roothub_exec()
3393 XWRITE4(sc, oper, port, v | XHCI_PS_CEC); in xhci_roothub_exec()
3397 XWRITE4(sc, oper, port, v | XHCI_PS_PLC); in xhci_roothub_exec()
3400 XWRITE4(sc, oper, port, v | XHCI_PS_CSC); in xhci_roothub_exec()
3403 XWRITE4(sc, oper, port, v | XHCI_PS_PEC); in xhci_roothub_exec()
3406 XWRITE4(sc, oper, port, v | XHCI_PS_OCC); in xhci_roothub_exec()
3409 XWRITE4(sc, oper, port, v | XHCI_PS_PRC); in xhci_roothub_exec()
3412 XWRITE4(sc, oper, port, v | XHCI_PS_PED); in xhci_roothub_exec()
3415 XWRITE4(sc, oper, port, v & ~XHCI_PS_PP); in xhci_roothub_exec()
3418 XWRITE4(sc, oper, port, v & ~XHCI_PS_PIC_SET(3)); in xhci_roothub_exec()
3424 XWRITE4(sc, oper, port, v | in xhci_roothub_exec()
3429 usb_pause_mtx(&sc->sc_bus.bus_mtx, hz / 50); in xhci_roothub_exec()
3432 XWRITE4(sc, oper, port, v | in xhci_roothub_exec()
3447 v = XREAD4(sc, capa, XHCI_HCSPARAMS0); in xhci_roothub_exec()
3449 sc->sc_hub_desc.hubd = xhci_hubd; in xhci_roothub_exec()
3451 sc->sc_hub_desc.hubd.bNbrPorts = sc->sc_noport; in xhci_roothub_exec()
3463 USETW(sc->sc_hub_desc.hubd.wHubCharacteristics, i); in xhci_roothub_exec()
3466 sc->sc_hub_desc.hubd.bPwrOn2PwrGood = 10; in xhci_roothub_exec()
3468 for (j = 1; j <= sc->sc_noport; j++) { in xhci_roothub_exec()
3469 v = XREAD4(sc, oper, XHCI_PORTSC(j)); in xhci_roothub_exec()
3471 sc->sc_hub_desc.hubd. in xhci_roothub_exec()
3475 len = sc->sc_hub_desc.hubd.bLength; in xhci_roothub_exec()
3480 (void)memset_s(sc->sc_hub_desc.temp, sizeof(sc->sc_hub_desc.temp), 0, len); in xhci_roothub_exec()
3487 (index > sc->sc_noport)) { in xhci_roothub_exec()
3492 v = XREAD4(sc, oper, XHCI_PORTSC(index)); in xhci_roothub_exec()
3528 USETW(sc->sc_hub_desc.ps.wPortStatus, i); in xhci_roothub_exec()
3546 USETW(sc->sc_hub_desc.ps.wPortChange, i); in xhci_roothub_exec()
3547 len = sizeof(sc->sc_hub_desc.ps); in xhci_roothub_exec()
3563 (index > sc->sc_noport)) { in xhci_roothub_exec()
3569 v = XREAD4(sc, oper, port) & ~XHCI_PS_CLEAR; in xhci_roothub_exec()
3578 v = XREAD4(sc, oper, port); in xhci_roothub_exec()
3581 XWRITE4(sc, oper, port, v); in xhci_roothub_exec()
3589 v = XREAD4(sc, oper, port); in xhci_roothub_exec()
3592 XWRITE4(sc, oper, port, v); in xhci_roothub_exec()
3595 XWRITE4(sc, oper, port, v | XHCI_PS_WPR); in xhci_roothub_exec()
3598 XWRITE4(sc, oper, port, v | in xhci_roothub_exec()
3601 usb_pause_mtx(&sc->sc_bus.bus_mtx, hz / 250); in xhci_roothub_exec()
3614 XWRITE4(sc, oper, port, v | in xhci_roothub_exec()
3619 XWRITE4(sc, oper, port, v | XHCI_PS_PR); in xhci_roothub_exec()
3623 XWRITE4(sc, oper, port, v | XHCI_PS_PP); in xhci_roothub_exec()
3634 XWRITE4(sc, oper, port, v); in xhci_roothub_exec()
3761 struct xhci_softc *sc = XHCI_BUS2SC(xfer->xroot->bus); in xhci_configure_reset_endpoint() local
3778 pcinp = &sc->sc_hw.devs[index].input_pc; in xhci_configure_reset_endpoint()
3795 XHCI_CMD_LOCK(sc); in xhci_configure_reset_endpoint()
3802 XHCI_CMD_UNLOCK(sc); in xhci_configure_reset_endpoint()
3811 err = xhci_cmd_stop_ep(sc, 0, epno, index); in xhci_configure_reset_endpoint()
3816 err = xhci_cmd_reset_ep(sc, 0, epno, index); in xhci_configure_reset_endpoint()
3821 err = xhci_cmd_set_tr_dequeue_ptr(sc, in xhci_configure_reset_endpoint()
3837 err = xhci_cmd_configure_ep(sc, buf_inp.physaddr, 0, index); in xhci_configure_reset_endpoint()
3839 err = xhci_cmd_evaluate_ctx(sc, buf_inp.physaddr, index); in xhci_configure_reset_endpoint()
3844 XHCI_CMD_UNLOCK(sc); in xhci_configure_reset_endpoint()
3858 struct xhci_softc *sc = XHCI_BUS2SC(xfer->xroot->bus); in xhci_start_dma_delay() local
3861 usbd_transfer_enqueue(&sc->sc_bus.intr_q, xfer); in xhci_start_dma_delay()
3863 (void)usb_proc_msignal(USB_BUS_CONTROL_XFER_PROC(&sc->sc_bus), in xhci_start_dma_delay()
3864 &sc->sc_config_msg[0], &sc->sc_config_msg[1]); in xhci_start_dma_delay()
3870 struct xhci_softc *sc; in xhci_configure_msg() local
3874 sc = XHCI_BUS2SC(((struct usb_bus_msg *)pm)->bus); in xhci_configure_msg()
3877 TAILQ_FOREACH(xfer, &sc->sc_bus.intr_q.head, wait_entry) { in xhci_configure_msg()
3910 USB_BUS_UNLOCK(&sc->sc_bus); in xhci_configure_msg()
3914 USB_BUS_LOCK(&sc->sc_bus); in xhci_configure_msg()
3937 TAILQ_FOREACH(xfer, &sc->sc_bus.intr_q.head, wait_entry) { in xhci_configure_msg()
4004 struct xhci_softc *sc = XHCI_BUS2SC(udev->bus); in xhci_device_init() local
4012 XHCI_CMD_LOCK(sc); in xhci_device_init()
4016 udev->controller_slot_id = sc->sc_noslot + 1; in xhci_device_init()
4020 err = xhci_cmd_enable_slot(sc, &temp); in xhci_device_init()
4023 XHCI_CMD_UNLOCK(sc); in xhci_device_init()
4027 if (temp > sc->sc_noslot) { in xhci_device_init()
4028 XHCI_CMD_UNLOCK(sc); in xhci_device_init()
4032 if (sc->sc_hw.devs[temp].state != XHCI_ST_DISABLED) { in xhci_device_init()
4034 XHCI_CMD_UNLOCK(sc); in xhci_device_init()
4044 (void)memset_s(&sc->sc_hw.devs[temp], sizeof(sc->sc_hw.devs[0]), 0, sizeof(sc->sc_hw.devs[0])); in xhci_device_init()
4048 sc->sc_hw.devs[temp].state = XHCI_ST_ENABLED; in xhci_device_init()
4052 XHCI_CMD_UNLOCK(sc); in xhci_device_init()
4065 struct xhci_softc *sc = XHCI_BUS2SC(udev->bus); in xhci_device_uninit() local
4072 XHCI_CMD_LOCK(sc); in xhci_device_uninit()
4076 if (index <= sc->sc_noslot) { in xhci_device_uninit()
4077 (void)xhci_cmd_disable_slot(sc, index); in xhci_device_uninit()
4078 sc->sc_hw.devs[index].state = XHCI_ST_DISABLED; in xhci_device_uninit()
4084 XHCI_CMD_UNLOCK(sc); in xhci_device_uninit()
4100 struct xhci_softc *sc = XHCI_BUS2SC(udev->bus); in xhci_device_resume() local
4113 XHCI_CMD_LOCK(sc); in xhci_device_resume()
4121 XWRITE4(sc, door, XHCI_DOORBELL(index), in xhci_device_resume()
4128 XHCI_CMD_UNLOCK(sc); in xhci_device_resume()
4134 struct xhci_softc *sc = XHCI_BUS2SC(udev->bus); in xhci_device_suspend() local
4147 XHCI_CMD_LOCK(sc); in xhci_device_suspend()
4152 err = xhci_cmd_stop_ep(sc, 1, n, index); in xhci_device_suspend()
4159 XHCI_CMD_UNLOCK(sc); in xhci_device_suspend()
4171 struct xhci_softc *sc = XHCI_BUS2SC(udev->bus); in xhci_device_state_change() local
4185 err = uhub_query_info(udev, &sc->sc_hw.devs[index].nports, in xhci_device_state_change()
4186 &sc->sc_hw.devs[index].tt); in xhci_device_state_change()
4188 sc->sc_hw.devs[index].nports = 0; in xhci_device_state_change()
4191 XHCI_CMD_LOCK(sc); in xhci_device_state_change()
4195 if (sc->sc_hw.devs[index].state == XHCI_ST_DEFAULT) in xhci_device_state_change()
4199 sc->sc_hw.devs[index].state = XHCI_ST_DEFAULT; in xhci_device_state_change()
4202 sc->sc_hw.devs[index].context_num = 0; in xhci_device_state_change()
4204 err = xhci_cmd_reset_dev(sc, index); in xhci_device_state_change()
4213 if (sc->sc_hw.devs[index].state == XHCI_ST_ADDRESSED) in xhci_device_state_change()
4216 sc->sc_hw.devs[index].state = XHCI_ST_ADDRESSED; in xhci_device_state_change()
4221 err = xhci_cmd_configure_ep(sc, 0, 1, index); in xhci_device_state_change()
4230 if (sc->sc_hw.devs[index].state == XHCI_ST_CONFIGURED) in xhci_device_state_change()
4234 sc->sc_hw.devs[index].state = XHCI_ST_CONFIGURED; in xhci_device_state_change()
4237 sc->sc_hw.devs[index].context_num = 0; in xhci_device_state_change()
4239 usbd_get_page(&sc->sc_hw.devs[index].input_pc, 0, &buf_inp); in xhci_device_state_change()
4249 err = xhci_cmd_evaluate_ctx(sc, buf_inp.physaddr, index); in xhci_device_state_change()
4259 XHCI_CMD_UNLOCK(sc); in xhci_device_state_change()