Changeset eb928c4 in mainline for uspace/drv/bus/usb/xhci/rh.c
- Timestamp:
- 2018-01-08T00:07:00Z (6 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 1102eca
- Parents:
- ecbad17
- git-author:
- Ondřej Hlavatý <aearsis@…> (2018-01-08 00:05:39)
- git-committer:
- Ondřej Hlavatý <aearsis@…> (2018-01-08 00:07:00)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/xhci/rh.c
recbad17 reb928c4 61 61 XHCI_REG_MASK(XHCI_PORT_CEC); 62 62 63 /** 64 * Initialize the roothub subsystem. 65 */ 63 66 int xhci_rh_init(xhci_rh_t *rh, xhci_hc_t *hc) 64 67 { … … 81 84 } 82 85 83 /** Create a device node for device directly connected to RH. 86 /** 87 * Finalize the RH subsystem. 88 */ 89 int xhci_rh_fini(xhci_rh_t *rh) 90 { 91 assert(rh); 92 free(rh->devices_by_port); 93 return EOK; 94 } 95 96 /** 97 * Create and setup a device directly connected to RH. As the xHCI is not using 98 * a virtual usbhub device for RH, this routine is called for devices directly. 84 99 */ 85 100 static int rh_setup_device(xhci_rh_t *rh, uint8_t port_id) … … 89 104 90 105 assert(rh->devices_by_port[port_id - 1] == NULL); 91 92 xhci_bus_t *bus = &rh->hc->bus;93 106 94 107 device_t *dev = hcd_ddf_fun_create(&rh->hc->base); … … 107 120 dev->speed = port_speed->usb_speed; 108 121 109 if ((err = xhci_bus_enumerate_device(bus,dev))) {122 if ((err = bus_device_enumerate(dev))) { 110 123 usb_log_error("Failed to enumerate USB device: %s", str_error(err)); 111 124 return err; … … 134 147 } 135 148 149 /** 150 * Handle a device connection. USB 3+ devices are set up directly, USB 2 and 151 * below first need to have their port reset. 152 */ 136 153 static int handle_connected_device(xhci_rh_t *rh, uint8_t port_id) 137 154 { … … 161 178 usb_log_debug("USB 2 device attached, issuing reset."); 162 179 xhci_rh_reset_port(rh, port_id); 163 /*164 FIXME: we need to wait for the event triggered by the reset165 and then alloc_dev()... can't it be done directly instead of166 going around?167 */168 180 return EOK; 169 181 } 170 182 } 171 183 172 /** Deal with a detached device. 184 /** 185 * Deal with a detached device. 173 186 */ 174 187 static int handle_disconnected_device(xhci_rh_t *rh, uint8_t port_id) … … 194 207 195 208 /* Remove device from XHCI bus. */ 196 if ((err = xhci_bus_remove_device(&rh->hc->bus,&dev->base))) {209 if ((err = bus_device_remove(&dev->base))) { 197 210 usb_log_warning("Failed to remove device " XHCI_DEV_FMT " from XHCI bus: %s", 198 211 XHCI_DEV_ARGS(*dev), str_error(err)); … … 202 215 } 203 216 204 /** Handle an incoming Port Change Detected Event. 217 /** 218 * Handle an incoming Port Change Detected Event. 205 219 */ 206 220 int xhci_rh_handle_port_status_change_event(xhci_hc_t *hc, xhci_trb_t *trb) … … 219 233 } 220 234 235 /** 236 * Handle all changes on all ports. 237 */ 221 238 void xhci_rh_handle_port_change(xhci_rh_t *rh) 222 239 { … … 303 320 } 304 321 305 static inline int get_hub_available_bandwidth(xhci_hc_t *hc, xhci_device_t* dev, uint8_t speed, xhci_port_bandwidth_ctx_t *ctx) 306 { 307 int err = EOK; 308 309 // TODO: find a correct place for this function + API 310 // We need speed, because a root hub device has both USB 2 and USB 3 speeds 311 // and the command can query only one of them 312 // ctx is an out parameter as of now 313 assert(dev); 314 assert(ctx); 315 316 xhci_cmd_t cmd; 317 xhci_cmd_init(&cmd, XHCI_CMD_GET_PORT_BANDWIDTH); 318 319 if ((err = dma_buffer_alloc(&cmd.bandwidth_ctx, sizeof(xhci_port_bandwidth_ctx_t)))) 320 goto end; 321 322 cmd.device_speed = speed; 323 324 if ((err = xhci_cmd_sync(hc, &cmd))) 325 goto end; 326 327 memcpy(ctx, cmd.bandwidth_ctx.virt, sizeof(xhci_port_bandwidth_ctx_t)); 328 329 end: 330 xhci_cmd_fini(&cmd); 331 return err; 332 } 333 322 /** 323 * Get a port speed for a given port id. 324 */ 334 325 const xhci_port_speed_t *xhci_rh_get_port_speed(xhci_rh_t *rh, uint8_t port) 335 326 { … … 340 331 } 341 332 333 /** 334 * Issue a port reset for a given port. 335 */ 342 336 int xhci_rh_reset_port(xhci_rh_t* rh, uint8_t port) 343 337 { … … 349 343 } 350 344 351 int xhci_rh_fini(xhci_rh_t *rh)352 {353 assert(rh);354 free(rh->devices_by_port);355 return EOK;356 }357 358 345 /** 359 346 * @}
Note:
See TracChangeset
for help on using the changeset viewer.