Changeset 60af4cdb in mainline
- Timestamp:
- 2017-10-19T14:01:18Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 0f6b50f
- Parents:
- 95c675b
- Location:
- uspace/drv/bus/usb/xhci
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/xhci/commands.c
r95c675b r60af4cdb 50 50 #define TRB_SET_SUSP(trb, susp) (trb).control |= host2xhci(32, ((susp) & 0x1) << 23) 51 51 #define TRB_SET_SLOT(trb, slot) (trb).control |= host2xhci(32, (slot) << 24) 52 #define TRB_SET_DEV_SPEED(trb, speed) (trb).control |= host2xhci(32, (speed & 0xF) << 16) 52 53 53 54 /** … … 418 419 } 419 420 421 int xhci_get_port_bandwidth_command(xhci_hc_t *hc, xhci_cmd_t *cmd, 422 xhci_port_bandwidth_ctx_t *ctx, uint8_t device_speed) 423 { 424 assert(hc); 425 assert(cmd); 426 427 xhci_trb_clean(&cmd->trb); 428 429 uint64_t phys_addr = (uint64_t) addr_to_phys(ctx); 430 TRB_SET_ICTX(cmd->trb, phys_addr); 431 432 TRB_SET_TYPE(cmd->trb, XHCI_TRB_TYPE_GET_PORT_BANDWIDTH_CMD); 433 TRB_SET_SLOT(cmd->trb, cmd->slot_id); 434 TRB_SET_DEV_SPEED(cmd->trb, device_speed); 435 436 return enqueue_command(hc, cmd, 0, 0); 437 } 438 420 439 int xhci_handle_command_completion(xhci_hc_t *hc, xhci_trb_t *trb) 421 440 { -
uspace/drv/bus/usb/xhci/commands.h
r95c675b r60af4cdb 44 44 typedef struct xhci_hc xhci_hc_t; 45 45 typedef struct xhci_input_ctx xhci_input_ctx_t; 46 typedef struct xhci_port_bandwidth_ctx xhci_port_bandwidth_ctx_t; 46 47 47 48 typedef struct xhci_command { … … 87 88 // TODO: Negotiate bandwidth (optional normative, section 4.6.13). 88 89 // TODO: Set latency tolerance value (optional normative, section 4.6.14). 90 int xhci_get_port_bandwidth_command(xhci_hc_t *, xhci_cmd_t *, xhci_port_bandwidth_ctx_t *, uint8_t); 89 91 // TODO: Get port bandwidth (mandatory, but needs root hub implementation, section 4.6.15). 90 92 // TODO: Force header (mandatory, but needs root hub implementation, section 4.6.16). -
uspace/drv/bus/usb/xhci/hw_struct/context.h
r95c675b r60af4cdb 192 192 } __attribute__((packed)) xhci_input_ctx_t; 193 193 194 /** 195 * Port bandwidth context: section 6.2.6 196 * The number of ports depends on the amount of ports available to the hub. 197 */ 198 typedef struct xhci_port_bandwidth_ctx { 199 uint8_t reserved; 200 uint8_t ports []; 201 } __attribute__((packed)) xhci_port_bandwidth_ctx_t; 202 194 203 #endif -
uspace/drv/bus/usb/xhci/rh.c
r95c675b r60af4cdb 382 382 } 383 383 384 static inline int get_hub_available_bandwidth(xhci_device_t* dev, uint8_t speed, xhci_port_bandwidth_ctx_t *ctx) { 385 // TODO: find a correct place for this function + API 386 // We need speed, because a root hub device has both USB 2 and USB 3 speeds 387 // and the command can query only one of them 388 // ctx is an out parameter as of now 389 assert(dev); 390 391 ctx = malloc(sizeof(xhci_port_bandwidth_ctx_t)); 392 if(!ctx) 393 return ENOMEM; 394 395 xhci_cmd_t cmd; 396 xhci_cmd_init(&cmd); 397 398 xhci_get_port_bandwidth_command(dev->hc, &cmd, ctx, speed); 399 400 int err = xhci_cmd_wait(&cmd, 100000); 401 if(err != EOK) { 402 free(ctx); 403 ctx = NULL; 404 } 405 406 return EOK; 407 } 408 384 409 const xhci_port_speed_t *xhci_rh_get_port_speed(xhci_rh_t *rh, uint8_t port) 385 410 {
Note:
See TracChangeset
for help on using the changeset viewer.