Changeset 20eaa82 in mainline for uspace/drv/bus/usb/xhci/rh.c
- Timestamp:
- 2017-10-15T13:44:39Z (6 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 2770b66
- Parents:
- 867b375
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/xhci/rh.c
r867b375 r20eaa82 38 38 #include <usb/debug.h> 39 39 #include <usb/host/utils/malloc32.h> 40 #include <usb/host/bus.h> 40 41 #include <usb/host/ddf_helpers.h> 41 42 … … 73 74 // TODO: This currently assumes the device is attached to rh directly. 74 75 // Also, we should consider moving a lot of functionailty to xhci bus 75 int xhci_rh_address_device(xhci_rh_t *rh, usb_speed_t unused_speed, usb_tt_address_t tt, usb_address_t *address)76 int xhci_rh_address_device(xhci_rh_t *rh, device_t *dev) 76 77 { 77 78 int err; … … 81 82 xhci_cmd_init(&cmd); 82 83 83 uint8_t port = tt.port;84 85 84 /* XXX Certainly not generic solution. */ 86 85 uint32_t route_str = 0; 87 86 88 const xhci_port_speed_t *speed = xhci_rh_get_port_speed(rh, port);87 const xhci_port_speed_t *speed = xhci_rh_get_port_speed(rh, dev->port); 89 88 90 89 xhci_send_enable_slot_command(hc, &cmd); … … 109 108 /* Initialize slot_ctx according to section 4.3.3 point 3. */ 110 109 /* Attaching to root hub port, root string equals to 0. */ 111 XHCI_SLOT_ROOT_HUB_PORT_SET(ictx->slot_ctx, port);110 XHCI_SLOT_ROOT_HUB_PORT_SET(ictx->slot_ctx, dev->port); 112 111 XHCI_SLOT_CTX_ENTRIES_SET(ictx->slot_ctx, 1); 113 112 XHCI_SLOT_ROUTE_STRING_SET(ictx->slot_ctx, route_str); … … 158 157 xhci_cmd_fini(&cmd); 159 158 160 *address = XHCI_SLOT_DEVICE_ADDRESS(dctx->slot_ctx);161 usb_log_debug2("Obtained USB address: %d.\n", *address);159 dev->address = XHCI_SLOT_DEVICE_ADDRESS(dctx->slot_ctx); 160 usb_log_debug2("Obtained USB address: %d.\n", dev->address); 162 161 163 162 // TODO: Ask libusbhost to create a control endpoint for EP0. … … 183 182 } 184 183 184 /** Create a device node for device directly connected to RH. 185 */ 185 186 static int rh_setup_device(xhci_rh_t *rh, uint8_t port_id) 186 187 { 187 /** This should ideally use the libusbhost in a clean and elegant way, 188 * to create child function. The refactoring of libusbhost is not over 189 * yet, so for now it is still quirky. 190 */ 191 192 return hcd_roothub_new_device(rh->hcd_rh, port_id); 188 int err; 189 assert(rh); 190 191 xhci_bus_t *bus = &rh->hc->bus; 192 193 device_t *dev = hcd_ddf_device_create(rh->hc_device, bus->base.device_size); 194 if (!dev) { 195 usb_log_error("Failed to create USB device function."); 196 return ENOMEM; 197 } 198 199 dev->hub = &rh->device; 200 dev->port = port_id; 201 202 if ((err = xhci_bus_enumerate_device(bus, rh->hc, dev))) { 203 usb_log_error("Failed to enumerate USB device: %s", str_error(err)); 204 return err; 205 } 206 207 if (!ddf_fun_get_name(dev->fun)) { 208 device_set_default_name(dev); 209 } 210 211 if ((err = ddf_fun_bind(dev->fun))) { 212 usb_log_error("Device(%d): Failed to register: %s.", dev->address, str_error(err)); 213 goto err_usb_dev; 214 } 215 216 fibril_mutex_lock(&rh->device.guard); 217 list_append(&dev->link, &rh->device.devices); 218 fibril_mutex_unlock(&rh->device.guard); 219 220 return EOK; 221 222 err_usb_dev: 223 hcd_ddf_device_destroy(dev); 224 return err; 193 225 } 194 226
Note:
See TracChangeset
for help on using the changeset viewer.