Changeset 8033f89 in mainline for uspace/drv/bus/usb/xhci/hc.c
- Timestamp:
- 2018-01-23T12:41:22Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- e7e1fd3
- Parents:
- e546142
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/xhci/hc.c
re546142 r8033f89 139 139 140 140 /* 141 * Speed is not implied, but using one of default PSIV. This is142 * not clearly stated in xHCI spec. There is a clear intention143 * to allow xHCI to specify its own speed parameters, but144 * throughout the document, they used fixed values for e.g.145 * High-speed (3), without stating the controller shall have146 * implied default speeds - and for instance Intel controllers147 * do not. So let's check if the values match and if so, accept148 * the implied USB speed too.141 * Speed is not implied, but using one of default PSIV. This 142 * is not clearly stated in xHCI spec. There is a clear 143 * intention to allow xHCI to specify its own speed 144 * parameters, but throughout the document, they used fixed 145 * values for e.g. High-speed (3), without stating the 146 * controller shall have implied default speeds - and for 147 * instance Intel controllers do not. So let's check if the 148 * values match and if so, accept the implied USB speed too. 149 149 * 150 150 * The main reason we need this is the usb_speed to have … … 157 157 && default_psiv_to_port_speed[psiv].tx_bps == bps) { 158 158 speeds[psiv] = default_psiv_to_port_speed[psiv]; 159 usb_log_debug("Assumed default %s speed of USB %u.", usb_str_speed(speeds[psiv].usb_speed), major); 159 usb_log_debug("Assumed default %s speed of USB %u.", 160 usb_str_speed(speeds[psiv].usb_speed), major); 160 161 continue; 161 162 } … … 171 172 if (sim == XHCI_PSI_PLT_SYMM || sim == XHCI_PSI_PLT_TX) { 172 173 speeds[psiv].tx_bps = bps; 173 usb_log_debug("Speed %u set up for bps %" PRIu64 " / %" PRIu64 ".", psiv, speeds[psiv].rx_bps, speeds[psiv].tx_bps); 174 usb_log_debug("Speed %u set up for bps %" PRIu64 175 " / %" PRIu64 ".", psiv, speeds[psiv].rx_bps, 176 speeds[psiv].tx_bps); 174 177 } 175 178 } … … 395 398 memcpy(code->cmds, irq_commands, sizeof(irq_commands)); 396 399 397 void *intr0_iman = RNGABSPTR(hc->mmio_range) + XHCI_REG_RD(hc->cap_regs, XHCI_CAP_RTSOFF) + offsetof(xhci_rt_regs_t, ir[0]); 398 void *usbsts = RNGABSPTR(hc->mmio_range) + XHCI_REG_RD(hc->cap_regs, XHCI_CAP_LENGTH) + offsetof(xhci_op_regs_t, usbsts); 400 void *intr0_iman = RNGABSPTR(hc->mmio_range) 401 + XHCI_REG_RD(hc->cap_regs, XHCI_CAP_RTSOFF) 402 + offsetof(xhci_rt_regs_t, ir[0]); 403 void *usbsts = RNGABSPTR(hc->mmio_range) 404 + XHCI_REG_RD(hc->cap_regs, XHCI_CAP_LENGTH) 405 + offsetof(xhci_op_regs_t, usbsts); 406 399 407 code->cmds[0].addr = intr0_iman; 400 408 code->cmds[1].value = host2xhci(32, 1); … … 447 455 448 456 /* Wait until the HC is halted - it shall take at most 16 ms */ 449 if (xhci_reg_wait(&hc->op_regs->usbsts, XHCI_REG_MASK(XHCI_OP_HCH), XHCI_REG_MASK(XHCI_OP_HCH))) 457 if (xhci_reg_wait(&hc->op_regs->usbsts, XHCI_REG_MASK(XHCI_OP_HCH), 458 XHCI_REG_MASK(XHCI_OP_HCH))) 450 459 return ETIMEOUT; 451 460 … … 533 542 struct timeval tv; 534 543 getuptime(&tv); 535 usb_log_debug("Microframe index wrapped (@%lu.%li, %"PRIu64" total).", tv.tv_sec, tv.tv_usec, hc->wrap_count); 544 usb_log_debug("Microframe index wrapped (@%lu.%li, %"PRIu64" total).", 545 tv.tv_sec, tv.tv_usec, hc->wrap_count); 536 546 hc->wrap_time = ((uint64_t) tv.tv_sec) * 1000000 + ((uint64_t) tv.tv_usec); 537 547 ++hc->wrap_count; … … 596 606 fibril_mutex_lock(&hc->event_fibril_completion.guard); 597 607 hc->event_fibril_completion.active = false; 598 fibril_condvar_wait(&hc->event_fibril_completion.cv, &hc->event_fibril_completion.guard); 608 fibril_condvar_wait(&hc->event_fibril_completion.cv, 609 &hc->event_fibril_completion.guard); 599 610 fibril_mutex_unlock(&hc->event_fibril_completion.guard); 600 611 … … 612 623 * IPC notification will create new event handling fibril for us. 613 624 */ 614 static void hc_run_event_ring(xhci_hc_t *hc, xhci_event_ring_t *event_ring, xhci_interrupter_regs_t *intr) 625 static void hc_run_event_ring(xhci_hc_t *hc, xhci_event_ring_t *event_ring, 626 xhci_interrupter_regs_t *intr) 615 627 { 616 628 int err; … … 666 678 667 679 if (status & XHCI_REG_MASK(XHCI_OP_SRE)) { 668 usb_log_error("Save/Restore error occured. WTF, S/R mechanism not implemented!"); 680 usb_log_error("Save/Restore error occured. WTF, " 681 "S/R mechanism not implemented!"); 669 682 status &= ~XHCI_REG_MASK(XHCI_OP_SRE); 670 683 } … … 674 687 675 688 if (status) { 676 usb_log_error("Non-zero status after interrupt handling (%08x) - missing something?", status); 689 usb_log_error("Non-zero status after interrupt handling (%08x) " 690 " - missing something?", status); 677 691 } 678 692 } … … 688 702 fibril_mutex_lock(&hc->event_fibril_completion.guard); 689 703 while (hc->event_fibril_completion.active) 690 fibril_condvar_wait(&hc->event_fibril_completion.cv, &hc->event_fibril_completion.guard); 704 fibril_condvar_wait(&hc->event_fibril_completion.cv, 705 &hc->event_fibril_completion.guard); 691 706 fibril_mutex_unlock(&hc->event_fibril_completion.guard); 692 707 xhci_sw_ring_fini(&hc->sw_ring); … … 830 845 * we have to rely on reverse mapping on others. */ 831 846 if (!usb_speed_to_psiv[dev->base.speed]) { 832 usb_log_error("Device reported an USB speed (%s) that cannot be mapped to HC port speed.", usb_str_speed(dev->base.speed)); 847 usb_log_error("Device reported an USB speed (%s) that cannot be mapped " 848 "to HC port speed.", usb_str_speed(dev->base.speed)); 833 849 return EINVAL; 834 850 } … … 850 866 851 867 /* Issue Address Device command. */ 852 if ((err = xhci_cmd_sync_inline(hc, ADDRESS_DEVICE, .slot_id = dev->slot_id, .input_ctx = ictx_dma_buf))) 868 if ((err = xhci_cmd_sync_inline(hc, ADDRESS_DEVICE, 869 .slot_id = dev->slot_id, 870 .input_ctx = ictx_dma_buf 871 ))) 853 872 return err; 854 873 … … 875 894 return err; 876 895 877 return xhci_cmd_sync_inline(hc, CONFIGURE_ENDPOINT, .slot_id = dev->slot_id, .input_ctx = ictx_dma_buf); 896 return xhci_cmd_sync_inline(hc, CONFIGURE_ENDPOINT, 897 .slot_id = dev->slot_id, 898 .input_ctx = ictx_dma_buf 899 ); 878 900 } 879 901 … … 888 910 889 911 /* Issue configure endpoint command (sec 4.3.5) with the DC flag. */ 890 return xhci_cmd_sync_inline(hc, CONFIGURE_ENDPOINT, .slot_id = dev->slot_id, .deconfigure = true); 912 return xhci_cmd_sync_inline(hc, CONFIGURE_ENDPOINT, 913 .slot_id = dev->slot_id, 914 .deconfigure = true 915 ); 891 916 } 892 917 … … 917 942 xhci_setup_endpoint_context(ep, ep_ctx); 918 943 919 return xhci_cmd_sync_inline(hc, CONFIGURE_ENDPOINT, .slot_id = dev->slot_id, .input_ctx = ictx_dma_buf); 944 return xhci_cmd_sync_inline(hc, CONFIGURE_ENDPOINT, 945 .slot_id = dev->slot_id, 946 .input_ctx = ictx_dma_buf 947 ); 920 948 } 921 949 … … 941 969 XHCI_INPUT_CTRL_CTX_DROP_SET(*XHCI_GET_CTRL_CTX(ictx, hc), dci); 942 970 943 return xhci_cmd_sync_inline(hc, CONFIGURE_ENDPOINT, .slot_id = dev->slot_id, .input_ctx = ictx_dma_buf); 971 return xhci_cmd_sync_inline(hc, CONFIGURE_ENDPOINT, 972 .slot_id = dev->slot_id, 973 .input_ctx = ictx_dma_buf 974 ); 944 975 } 945 976 … … 971 1002 xhci_setup_endpoint_context(ep, ep_ctx); 972 1003 973 return xhci_cmd_sync_inline(hc, EVALUATE_CONTEXT, .slot_id = dev->slot_id, .input_ctx = ictx_dma_buf); 1004 return xhci_cmd_sync_inline(hc, EVALUATE_CONTEXT, 1005 .slot_id = dev->slot_id, 1006 .input_ctx = ictx_dma_buf 1007 ); 974 1008 } 975 1009 … … 985 1019 const unsigned dci = endpoint_dci(ep); 986 1020 xhci_hc_t * const hc = bus_to_hc(dev->base.bus); 987 return xhci_cmd_sync_inline(hc, STOP_ENDPOINT, .slot_id = dev->slot_id, .endpoint_id = dci); 1021 return xhci_cmd_sync_inline(hc, STOP_ENDPOINT, 1022 .slot_id = dev->slot_id, 1023 .endpoint_id = dci 1024 ); 988 1025 } 989 1026 … … 999 1036 const unsigned dci = endpoint_dci(ep); 1000 1037 xhci_hc_t * const hc = bus_to_hc(dev->base.bus); 1001 return xhci_cmd_sync_inline(hc, RESET_ENDPOINT, .slot_id = dev->slot_id, .endpoint_id = dci); 1038 return xhci_cmd_sync_inline(hc, RESET_ENDPOINT, 1039 .slot_id = dev->slot_id, 1040 .endpoint_id = dci 1041 ); 1002 1042 } 1003 1043 … … 1018 1058 xhci_hc_t * const hc = bus_to_hc(endpoint_get_bus(&ep->base)); 1019 1059 return xhci_cmd_sync_inline(hc, SET_TR_DEQUEUE_POINTER, 1020 1021 1022 1023 1024 1060 .slot_id = dev->slot_id, 1061 .endpoint_id = dci, 1062 .stream_id = stream_id, 1063 .dequeue_ptr = addr, 1064 ); 1025 1065 } 1026 1066
Note:
See TracChangeset
for help on using the changeset viewer.