Changeset 9f685aa in mainline for uspace/drv/bus/usb/usbhub/usbhub.c


Ignore:
Timestamp:
2018-01-22T20:06:41Z (7 years ago)
Author:
Ondřej Hlavatý <aearsis@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
34d750c
Parents:
effbef3
git-author:
Ondřej Hlavatý <aearsis@…> (2018-01-22 20:04:03)
git-committer:
Ondřej Hlavatý <aearsis@…> (2018-01-22 20:06:41)
Message:

usbhub: turns out MTT is a bit different

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/usbhub/usbhub.c

    reffbef3 r9f685aa  
    5858#define HUB_FNC_NAME "hub"
    5959
     60#define HUB_STATUS_CHANGE_EP(protocol) { \
     61        .transfer_type = USB_TRANSFER_INTERRUPT, \
     62        .direction = USB_DIRECTION_IN, \
     63        .interface_class = USB_CLASS_HUB, \
     64        .interface_subclass = 0, \
     65        .interface_protocol = (protocol), \
     66        .flags = 0 \
     67}
     68
    6069/** Hub status-change endpoint description.
    6170 *
    6271 * For more information see section 11.15.1 of USB 1.1 specification.
    6372 */
    64 const usb_endpoint_description_t hub_status_change_endpoint_description =
    65 {
    66         .transfer_type = USB_TRANSFER_INTERRUPT,
    67         .direction = USB_DIRECTION_IN,
    68         .interface_class = USB_CLASS_HUB,
    69         .interface_subclass = 0,
    70         .interface_protocol = -1,
    71         .flags = 0
     73static const usb_endpoint_description_t
     74        status_change_single_tt_only = HUB_STATUS_CHANGE_EP(0),
     75        status_change_mtt_available = HUB_STATUS_CHANGE_EP(1);
     76
     77const usb_endpoint_description_t *usb_hub_endpoints [] = {
     78        &status_change_single_tt_only,
     79        &status_change_mtt_available,
    7280};
     81
    7382
    7483/** Standard get hub global status request */
     
    135144                    str_error(opResult));
    136145                return opResult;
     146        }
     147
     148        const usb_endpoint_description_t *status_change = hub_dev->mtt_available
     149            ? &status_change_mtt_available
     150            : &status_change_single_tt_only;
     151
     152        usb_endpoint_mapping_t *status_change_mapping
     153                = usb_device_get_mapped_ep_desc(hub_dev->usb_device, status_change);
     154        if (!status_change_mapping) {
     155                usb_log_error("Failed to map the Status Change Endpoint of a hub.");
     156                return EIO;
    137157        }
    138158
     
    168188
    169189        polling->device = hub_dev->usb_device;
    170         polling->ep_mapping = usb_device_get_mapped_ep_desc(hub_dev->usb_device,
    171             &hub_status_change_endpoint_description);
     190        polling->ep_mapping = status_change_mapping;
    172191        polling->request_size = ((hub_dev->port_count + 1 + 7) / 8);
    173192        polling->buffer = malloc(polling->request_size);
     
    339358        /* Get hub descriptor. */
    340359        usb_log_debug("(%p): Retrieving descriptor.", hub_dev);
    341         usb_pipe_t *control_pipe =
    342             usb_device_get_default_pipe(hub_dev->usb_device);
     360        usb_pipe_t *control_pipe = usb_device_get_default_pipe(hub_dev->usb_device);
    343361
    344362        usb_descriptor_type_t desc_type = hub_dev->speed >= USB_SPEED_SUPER
     
    383401        hub_dev->per_port_power =
    384402            descriptor.characteristics & HUB_CHAR_POWER_PER_PORT_FLAG;
     403
     404        const uint8_t protocol = usb_device_descriptors(hub_dev->usb_device)
     405                ->device.device_protocol;
     406        hub_dev->mtt_available = (protocol == 2);
    385407
    386408        usb_hub_power_ports(hub_dev);
     
    434456        }
    435457
    436         /* Check if this is a MTT hub */
    437         const size_t device_protocol =
    438             usb_device_descriptors(usb_device)->device.device_protocol;
    439         if (device_protocol == 2) {
    440                 usb_log_debug("This is a MTT hub. MTT not supported, switching to Single-TT.");
    441                 opResult = usb_request_set_interface(usb_device_get_default_pipe(usb_device), 1, 0);
    442                 if (opResult != EOK)
    443                         usb_log_error("Failed to switch to Single-TT protocol.");
    444         }
    445458        return opResult;
    446459}
Note: See TracChangeset for help on using the changeset viewer.