Changeset 6fa91e4c in mainline
- Timestamp:
- 2017-08-08T14:09:24Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 9ee13a7
- Parents:
- 834d354
- Location:
- uspace/drv/bus/usb/xhci
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/xhci/hw_struct/context.h
r834d354 r6fa91e4c 52 52 xhci_dword_t reserved[3]; 53 53 54 #define XHCI_EP_TYPE_ISOCH_OUT 1 55 #define XHCI_EP_TYPE_BULK_OUT 2 56 #define XHCI_EP_TYPE_INTERRUPT_OUT 3 57 #define XHCI_EP_TYPE_CONTROL 4 58 #define XHCI_EP_TYPE_ISOCH_IN 5 59 #define XHCI_EP_TYPE_BULK_IN 6 60 #define XHCI_EP_TYPE_INTERRUPT_IN 7 61 62 #define XHCI_EP_TYPE_SET(ctx, val) \ 63 xhci_dword_set_bits(&(ctx).data[1], val, 5, 3) 64 #define XHCI_EP_MAX_PACKET_SIZE_SET(ctx, val) \ 65 xhci_dword_set_bits(&(ctx).data[1], val, 31, 16) 66 #define XHCI_EP_MAX_BURST_SIZE_SET(ctx, val) \ 67 xhci_dword_set_bits(&(ctx).data[1], val, 15, 8) 68 #define XHCI_EP_TR_DPTR_SET(ctx, val) \ 69 xhci_dword_set_bits(&(ctx).data[2], (val >> 4), 63, 4) 70 #define XHCI_EP_DCS_SET(ctx, val) \ 71 xhci_dword_set_bits(&(ctx).data[2], val, 0, 0) 72 #define XHCI_EP_INTERVAL_SET(ctx, val) \ 73 xhci_dword_set_bits(&(ctx).data[0], val, 23, 16) 74 #define XHCI_EP_MAX_P_STREAMS_SET(ctx, val) \ 75 xhci_dword_set_bits(&(ctx).data[0], val, 14, 10) 76 #define XHCI_EP_MULT_SET(ctx, val) \ 77 xhci_dword_set_bits(&(ctx).data[0], val, 9, 8) 78 #define XHCI_EP_ERROR_COUNT_SET(ctx, val) \ 79 xhci_dword_set_bits(&(ctx).data[1], val, 2, 1) 80 54 81 #define XHCI_EP_STATE(ctx) XHCI_DWORD_EXTRACT((ctx).data[0], 2, 0) 55 82 #define XHCI_EP_MULT(ctx) XHCI_DWORD_EXTRACT((ctx).data[0], 9, 8) … … 75 102 xhci_dword_t data [4]; 76 103 xhci_dword_t reserved [4]; 104 105 #define XHCI_SLOT_ROOT_HUB_PORT_SET(ctx, val) \ 106 xhci_dword_set_bits(&(ctx).data[1], val, 23, 16) 107 #define XHCI_SLOT_CTX_ENTRIES_SET(ctx, val) \ 108 xhci_dword_set_bits(&(ctx).data[0], val, 31, 27) 77 109 78 110 #define XHCI_SLOT_ROUTE_STRING(ctx) XHCI_DWORD_EXTRACT((ctx).data[0], 19, 0) -
uspace/drv/bus/usb/xhci/rh.c
r834d354 r6fa91e4c 75 75 XHCI_INPUT_CTRL_CTX_ADD_SET(ictx->ctrl_ctx, 1); 76 76 77 // TODO: Initialize ictx->slot_ctx according to section 4.3.3 78 // point 3. This requires setters for XHCI_SLOT_* and figuring 79 // out how are we supposed to find the root string field, which 80 // can be found in usb3 spec section 8.9. 81 82 // TODO: Allocated and initialize transfer ring for default 83 // control endpoint. 84 85 // TODO: Initialize input default control endpoint 0 context. 77 /* Initialize slot_ctx according to section 4.3.3 point 3. */ 78 /* Attaching to root hub port, root string equals to 0. */ 79 // TODO: shouldn't these macros consider endianity? 80 XHCI_SLOT_ROOT_HUB_PORT_SET(ictx->slot_ctx, port); 81 XHCI_SLOT_CTX_ENTRIES_SET(ictx->slot_ctx, 1); 82 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)); 85 if (!ep_ring) { 86 err = ENOMEM; 87 goto err_ring; 88 } 89 err = xhci_trb_ring_init(ep_ring, hc); 90 if (err) { 91 xhci_trb_ring_fini(ep_ring); 92 goto err_ring; 93 } 94 95 xhci_port_regs_t* regs = &hc->op_regs->portrs[port - 1]; 96 uint8_t port_speed_id = XHCI_REG_RD(regs, XHCI_PORT_PS); 97 98 XHCI_EP_TYPE_SET(ictx->endpoint_ctx[0], 4); 99 XHCI_EP_MAX_PACKET_SIZE_SET(ictx->endpoint_ctx[0], 100 hc->speeds[port_speed_id].tx_bps); 101 XHCI_EP_MAX_BURST_SIZE_SET(ictx->endpoint_ctx[0], 0); 102 XHCI_EP_TR_DPTR_SET(ictx->endpoint_ctx[0], ep_ring->dequeue); 103 XHCI_EP_DCS_SET(ictx->endpoint_ctx[0], 1); 104 XHCI_EP_INTERVAL_SET(ictx->endpoint_ctx[0], 0); 105 XHCI_EP_MAX_P_STREAMS_SET(ictx->endpoint_ctx[0], 0); 106 XHCI_EP_MULT_SET(ictx->endpoint_ctx[0], 0); 107 XHCI_EP_ERROR_COUNT_SET(ictx->endpoint_ctx[0], 3); 86 108 87 109 // TODO: What's the alignment? … … 106 128 err_ctx: 107 129 if (ictx) { 108 / / To avoid double free.130 /* Avoid double free. */ 109 131 if (cmd && cmd->ictx && cmd->ictx == ictx) 110 132 cmd->ictx = NULL; 111 112 free32(ictx); 113 } 133 } 134 err_ring: 135 if (ep_ring) 136 free32(ep_ring); 114 137 err_command: 115 138 if (cmd) … … 121 144 { 122 145 uint8_t link_state = XHCI_REG_RD(regs, XHCI_PORT_PLS); 146 // FIXME: do we have a better way to detect if this is usb2 or usb3 device? 123 147 if (link_state == 0) { 124 / / USB3 is automatically advance to enabled148 /* USB3 is automatically advanced to enabled. */ 125 149 uint8_t port_speed = XHCI_REG_RD(regs, XHCI_PORT_PS); 126 150 usb_log_debug2("Detected new device on port %u, port speed id %u.", port_id, port_speed); … … 128 152 alloc_dev(hc, port_id); 129 153 } else if (link_state == 5) { 130 / / USB 3 failed to enable154 /* USB 3 failed to enable. */ 131 155 usb_log_debug("USB 3 port couldn't be enabled."); 132 156 } else if (link_state == 7) { … … 144 168 xhci_port_regs_t* regs = &hc->op_regs->portrs[port_id - 1]; 145 169 146 / / Port reset change170 /* Port reset change */ 147 171 if (XHCI_REG_RD(regs, XHCI_PORT_PRC)) { 148 / / Clear the flag172 /* Clear the flag. */ 149 173 XHCI_REG_WR(regs, XHCI_PORT_PRC, 1); 150 174 151 175 uint8_t port_speed = XHCI_REG_RD(regs, XHCI_PORT_PS); 152 176 usb_log_debug2("Detected port reset on port %u, port speed id %u.", port_id, port_speed); 153 // TODO: Assign device slot (specification 4.3.2)154 } 155 156 / / Connection status change177 alloc_dev(hc, port_id); 178 } 179 180 /* Connection status change */ 157 181 if (XHCI_REG_RD(regs, XHCI_PORT_CSC)) { 158 182 XHCI_REG_WR(regs, XHCI_PORT_CSC, 1); … … 161 185 handle_connected_device(hc, regs, port_id); 162 186 } else { 163 // Device disconnected187 // TODO: Device disconnected 164 188 } 165 189 }
Note:
See TracChangeset
for help on using the changeset viewer.