Changeset 9ee13a7 in mainline
- Timestamp:
- 2017-08-09T17:05:08Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- d31705d
- Parents:
- 6fa91e4c
- Location:
- uspace/drv/bus/usb/xhci
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/xhci/hc.c
r6fa91e4c r9ee13a7 367 367 xhci_free_command(cmd); 368 368 369 for (int i = 0; i < 10; ++i) {370 xhci_cmd_t *cmd2 = xhci_alloc_command();371 xhci_send_enable_slot_command(hc, cmd2);372 xhci_wait_for_command(cmd2, 1000000);373 usb_log_error("Enabled slot ID: %u.", cmd2->slot_id);374 xhci_free_command(cmd2);375 }376 377 369 return EOK; 378 370 } -
uspace/drv/bus/usb/xhci/rh.c
r6fa91e4c r9ee13a7 82 82 83 83 // TODO: where do we save this? the ring should be associated with device structure somewhere 84 xhci_trb_ring_t *ep_ring = malloc32(sizeof(xhci_trb_ring_t));84 xhci_trb_ring_t *ep_ring = malloc32(sizeof(xhci_trb_ring_t)); 85 85 if (!ep_ring) { 86 86 err = ENOMEM; 87 goto err_ring; 88 } 87 goto err_ictx; 88 } 89 89 90 err = xhci_trb_ring_init(ep_ring, hc); 90 if (err) { 91 xhci_trb_ring_fini(ep_ring); 91 if (err) 92 92 goto err_ring; 93 } 94 95 xhci_port_regs_t* regs = &hc->op_regs->portrs[port - 1]; 93 94 xhci_port_regs_t *regs = &hc->op_regs->portrs[port - 1]; 96 95 uint8_t port_speed_id = XHCI_REG_RD(regs, XHCI_PORT_PS); 97 96 98 97 XHCI_EP_TYPE_SET(ictx->endpoint_ctx[0], 4); 99 XHCI_EP_MAX_PACKET_SIZE_SET(ictx->endpoint_ctx[0], 98 XHCI_EP_MAX_PACKET_SIZE_SET(ictx->endpoint_ctx[0], 100 99 hc->speeds[port_speed_id].tx_bps); 101 100 XHCI_EP_MAX_BURST_SIZE_SET(ictx->endpoint_ctx[0], 0); … … 106 105 XHCI_EP_MULT_SET(ictx->endpoint_ctx[0], 0); 107 106 XHCI_EP_ERROR_COUNT_SET(ictx->endpoint_ctx[0], 3); 108 107 109 108 // TODO: What's the alignment? 110 109 xhci_device_ctx_t *dctx = malloc32(sizeof(xhci_device_ctx_t)); 111 110 if (!dctx) { 112 111 err = ENOMEM; 113 goto err_ ctx;112 goto err_ring; 114 113 } 115 114 memset(dctx, 0, sizeof(xhci_device_ctx_t)); 116 115 117 116 hc->dcbaa[slot_id] = addr_to_phys(dctx); 118 117 hc->dcbaa_virt[slot_id] = dctx; 119 118 120 119 cmd = xhci_alloc_command(); 121 120 cmd->ictx = ictx; 122 121 xhci_send_address_device_command(hc, cmd); 123 122 if ((err = xhci_wait_for_command(cmd, 100000)) != EOK) 124 goto err_ctx; 125 126 return EOK; 127 128 err_ctx: 123 goto err_dctx; 124 125 return EOK; 126 127 err_dctx: 128 if (dctx) { 129 free32(dctx); 130 hc->dcbaa[slot_id] = 0; 131 hc->dcbaa_virt[slot_id] = NULL; 132 } 133 err_ring: 134 if (ep_ring) { 135 xhci_trb_ring_fini(ep_ring); 136 free32(ep_ring); 137 } 138 err_ictx: 129 139 if (ictx) { 130 140 /* Avoid double free. */ 131 141 if (cmd && cmd->ictx && cmd->ictx == ictx) 132 142 cmd->ictx = NULL; 133 } 134 err_ring: 135 if (ep_ring) 136 free32(ep_ring); 143 free32(ictx); 144 } 137 145 err_command: 138 146 if (cmd)
Note:
See TracChangeset
for help on using the changeset viewer.