Changeset 20eaa82 in mainline for uspace/drv/bus/usb/xhci/bus.c
- Timestamp:
- 2017-10-15T13:44:39Z (8 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/bus.c
r867b375 r20eaa82 35 35 #include <adt/hash_table.h> 36 36 #include <adt/hash.h> 37 #include <usb/host/ddf_helpers.h> 37 38 #include <usb/host/endpoint.h> 39 #include <usb/host/hcd.h> 38 40 #include <usb/debug.h> 39 41 40 42 #include <assert.h> 41 43 #include <errno.h> 44 #include <str_error.h> 42 45 #include <macros.h> 43 46 #include <stdbool.h> … … 53 56 xhci_device_t *device; 54 57 } hashed_device_t; 58 59 /** TODO: Still some copy-pasta left... 60 */ 61 int xhci_bus_enumerate_device(xhci_bus_t *bus, xhci_hc_t *hc, device_t *dev) 62 { 63 int err; 64 65 /* TODO: get speed from the default address reservation */ 66 dev->speed = USB_SPEED_FULL; 67 68 /* Manage TT */ 69 if (dev->hub->speed == USB_SPEED_HIGH && usb_speed_is_11(dev->speed)) { 70 /* For LS devices under HS hub */ 71 /* TODO: How about SS hubs? */ 72 dev->tt.address = dev->hub->address; 73 dev->tt.port = dev->port; 74 } 75 else { 76 /* Inherit hub's TT */ 77 dev->tt = dev->hub->tt; 78 } 79 80 /* Assign an address to the device */ 81 if ((err = xhci_rh_address_device(&hc->rh, dev))) { 82 usb_log_error("Failed to setup address of the new device: %s", str_error(err)); 83 return err; 84 } 85 86 /* Read the device descriptor, derive the match ids */ 87 if ((err = hcd_ddf_device_explore(hc->hcd, dev))) { 88 usb_log_error("Device(%d): Failed to explore device: %s", dev->address, str_error(err)); 89 bus_release_address(&bus->base, dev->address); 90 return err; 91 } 92 93 return EOK; 94 } 95 96 static int enumerate_device(bus_t *bus, hcd_t *hcd, device_t *dev) 97 { 98 xhci_hc_t *hc = hcd_get_driver_data(hcd); 99 assert(hc); 100 101 return xhci_bus_enumerate_device((xhci_bus_t *) bus, hc, dev); 102 } 103 104 static int remove_device(bus_t *bus, hcd_t *hcd, device_t *dev) 105 { 106 // TODO: Implement me! 107 108 return ENOTSUP; 109 } 55 110 56 111 /** Ops receive generic bus_t pointer. */ … … 214 269 } 215 270 216 static int get_speed(bus_t *bus_base, usb_address_t address, usb_speed_t *speed)217 {218 xhci_bus_t *bus = bus_to_xhci_bus(bus_base);219 assert(bus);220 221 // TODO: Use `xhci_get_port_speed` once we find the port corresponding to `address`.222 *speed = USB_SPEED_SUPER;223 return EOK;224 }225 226 271 static int release_address(bus_t *bus_base, usb_address_t address) 227 272 { … … 255 300 256 301 static const bus_ops_t xhci_bus_ops = { 302 .enumerate_device = enumerate_device, 303 .remove_device = remove_device, 304 257 305 .create_endpoint = create_endpoint, 258 306 .destroy_endpoint = destroy_endpoint, … … 263 311 264 312 .request_address = request_address, 265 .get_speed = get_speed,266 313 .release_address = release_address, 267 314 .reset_toggle = reset_toggle, … … 303 350 assert(bus); 304 351 305 bus_init(&bus->base );352 bus_init(&bus->base, sizeof(device_t)); 306 353 307 354 if (!hash_table_create(&bus->devices, 0, 0, &device_ht_ops)) { … … 320 367 hash_table_destroy(&bus->devices); 321 368 } 369 322 370 /** 323 371 * @}
Note:
See TracChangeset
for help on using the changeset viewer.