Changeset 129b821f in mainline


Ignore:
Timestamp:
2018-01-20T12:34:50Z (7 years ago)
Author:
Ondřej Hlavatý <aearsis@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
682c9354
Parents:
60d3f35
git-author:
Ondřej Hlavatý <aearsis@…> (2018-01-20 12:33:42)
git-committer:
Ondřej Hlavatý <aearsis@…> (2018-01-20 12:34:50)
Message:

usbhub: be aware of its own speed

This resulted in a bunch of changes just because the roothubs in older
HC's are virtual, and need to be aware of their own speed too.

Location:
uspace
Files:
19 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/ehci/hc.c

    r60d3f35 r129b821f  
    473473}
    474474
     475/**
     476 * Setup roothub as a virtual hub.
     477 */
     478int hc_setup_roothub(hc_device_t *hcd)
     479{
     480        return hc_setup_virtual_root_hub(hcd, USB_SPEED_HIGH);
     481}
     482
    475483/** Initialize memory structures used by the EHCI hcd.
    476484 *
  • uspace/drv/bus/usb/ehci/hc.h

    r60d3f35 r129b821f  
    102102int hc_add(hc_device_t *, const hw_res_list_parsed_t *);
    103103int hc_start(hc_device_t *);
     104int hc_setup_roothub(hc_device_t *);
    104105int hc_gen_irq_code(irq_code_t *, hc_device_t *, const hw_res_list_parsed_t *);
    105106int hc_gone(hc_device_t *);
  • uspace/drv/bus/usb/ehci/hw_struct/queue_head.c

    r60d3f35 r129b821f  
    4646        [USB_SPEED_FULL] = QH_EP_CHAR_EPS_FS,
    4747        [USB_SPEED_HIGH] = QH_EP_CHAR_EPS_HS,
    48 
    49         /* Solely for the roothub */
    50         [USB_SPEED_MAX] = 0,
    5148};
    5249
  • uspace/drv/bus/usb/ehci/main.c

    r60d3f35 r129b821f  
    3737#include <io/logctl.h>
    3838#include <usb/host/hcd.h>
    39 #include <usb/host/utility.h>
    4039
    4140#include "res.h"
     
    5251        .claim = disable_legacy,
    5352        .start = hc_start,
    54         .setup_root_hub = hc_setup_virtual_root_hub,
     53        .setup_root_hub = hc_setup_roothub,
    5554        .hc_gone = hc_gone,
    5655};
  • uspace/drv/bus/usb/ohci/hc.c

    r60d3f35 r129b821f  
    540540}
    541541
     542/**
     543 * Setup roothub as a virtual hub.
     544 */
     545int hc_setup_roothub(hc_device_t *hcd)
     546{
     547        return hc_setup_virtual_root_hub(hcd, USB_SPEED_FULL);
     548}
     549
    542550/** Initialize schedule queues
    543551 *
  • uspace/drv/bus/usb/ohci/hc.h

    r60d3f35 r129b821f  
    9393extern int hc_gain_control(hc_device_t *);
    9494extern int hc_start(hc_device_t *);
     95extern int hc_setup_roothub(hc_device_t *);
    9596extern int hc_gone(hc_device_t *);
    9697
  • uspace/drv/bus/usb/ohci/main.c

    r60d3f35 r129b821f  
    4343
    4444#include <usb/debug.h>
    45 #include <usb/host/utility.h>
    4645
    4746#include "hc.h"
     
    5857        .claim = hc_gain_control,
    5958        .start = hc_start,
    60         .setup_root_hub = hc_setup_virtual_root_hub,
     59        .setup_root_hub = hc_setup_roothub,
    6160        .hc_gone = hc_gone,
    6261};
  • uspace/drv/bus/usb/uhci/hc.c

    r60d3f35 r129b821f  
    5151#include <usb/host/utils/malloc32.h>
    5252#include <usb/host/bandwidth.h>
     53#include <usb/host/utility.h>
    5354
    5455#include "uhci_batch.h"
     
    258259}
    259260
     261int hc_setup_roothub(hc_device_t *hcd)
     262{
     263        return hc_setup_virtual_root_hub(hcd, USB_SPEED_FULL);
     264}
     265
    260266/** Safely dispose host controller internal structures
    261267 *
     
    330336
    331337        // Check for the roothub, as it does not schedule into lists
    332         if (ep->device->speed == USB_SPEED_MAX) {
     338        if (ep->device->address == uhci_rh_get_address(&hc->rh)) {
    333339                // FIXME: We shall check the roothub for active transfer. But
    334340                // as it is polling, there is no way to make it stop doing so.
  • uspace/drv/bus/usb/uhci/hc.h

    r60d3f35 r129b821f  
    150150extern int hc_gen_irq_code(irq_code_t *, hc_device_t *, const hw_res_list_parsed_t *);
    151151extern int hc_start(hc_device_t *);
     152extern int hc_setup_roothub(hc_device_t *);
    152153extern int hc_gone(hc_device_t *);
    153154
  • uspace/drv/bus/usb/uhci/main.c

    r60d3f35 r129b821f  
    5858        .hc_add = hc_add,
    5959        .start = hc_start,
    60         .setup_root_hub = hc_setup_virtual_root_hub,
     60        .setup_root_hub = hc_setup_roothub,
    6161        .hc_gone = hc_gone,
    6262};
  • uspace/drv/bus/usb/usbhub/port.c

    r60d3f35 r129b821f  
    8989}
    9090
     91
     92static usb_speed_t get_port_speed(usb_hub_port_t *port, uint32_t status)
     93{
     94        assert(port);
     95        assert(port->hub);
     96
     97        return usb_port_speed(port->hub->speed, status);
     98}
     99
    91100/**
    92101 * Routine for adding a new device.
     
    203212                // The connecting fibril do not touch speed until the port is enabled,
    204213                // so we do not have to lock
    205                 port->speed = usb_port_speed(status);
     214                port->speed = get_port_speed(port, status);
    206215                usb_port_enabled(&port->base);
    207216        } else
  • uspace/drv/bus/usb/usbhub/status.h

    r60d3f35 r129b821f  
    9797    (uint32_usb2host(1 << (16 + USB_HUB_FEATURE_C_HUB_LOCAL_POWER)))
    9898
    99 
    100 /**
    101  * speed getter for port status
    102  *
    103  * @param status
    104  * @return speed of usb device (for more see usb specification)
    105  */
    106 static inline usb_speed_t usb_port_speed(usb_port_status_t status)
     99static inline usb_speed_t usb_port_speed(usb_speed_t hub_speed, uint32_t status)
    107100{
     101        if (hub_speed == USB_SPEED_SUPER)
     102                return USB_SPEED_SUPER;
     103        if (hub_speed == USB_SPEED_HIGH && (status & USB_HUB_PORT_STATUS_HIGH_SPEED))
     104                return USB_SPEED_HIGH;
    108105        if ((status & USB_HUB_PORT_STATUS_LOW_SPEED) != 0)
    109106                return USB_SPEED_LOW;
    110         if ((status & USB_HUB_PORT_STATUS_HIGH_SPEED) != 0)
    111                 return USB_SPEED_HIGH;
    112         /* TODO: add super speed */
    113107        return USB_SPEED_FULL;
    114108}
  • uspace/drv/bus/usb/usbhub/usbhub.c

    r60d3f35 r129b821f  
    116116        }
    117117        hub_dev->usb_device = usb_dev;
     118        hub_dev->speed = usb_device_get_speed(usb_dev);
    118119
    119120        fibril_mutex_initialize(&hub_dev->default_address_guard);
     
    187188        }
    188189
    189         usb_log_info("Controlling hub '%s' (%p: %zu ports).",
     190        usb_log_info("Controlling %s-speed hub '%s' (%p: %zu ports).",
     191            usb_str_speed(hub_dev->speed),
    190192            usb_device_get_name(hub_dev->usb_device), hub_dev,
    191193            hub_dev->port_count);
  • uspace/drv/bus/usb/usbhub/usbhub.h

    r60d3f35 r129b821f  
    5858        /** Port structures, one for each port */
    5959        usb_hub_port_t *ports;
     60        /** Speed of the hub */
     61        usb_speed_t speed;
    6062        /** Generic usb device data*/
    6163        usb_device_t *usb_device;
  • uspace/drv/bus/usb/vhc/main.c

    r60d3f35 r129b821f  
    107107         * needs to be ready at this time.
    108108         */
    109         ret = hc_setup_virtual_root_hub(&vhc->base);
     109        ret = hc_setup_virtual_root_hub(&vhc->base, USB_SPEED_HIGH);
    110110        if (ret != EOK) {
    111111                usb_log_error("Failed to init VHC root hub: %s",
  • uspace/lib/usbdev/include/usb/dev/device.h

    r60d3f35 r129b821f  
    9090int usb_device_unmap_ep(usb_endpoint_mapping_t *);
    9191
     92usb_speed_t usb_device_get_speed(usb_device_t *);
    9293int usb_device_get_iface_number(usb_device_t *);
    9394devman_handle_t usb_device_get_devman_handle(usb_device_t *);
  • uspace/lib/usbdev/src/devdrv.c

    r60d3f35 r129b821f  
    364364}
    365365
     366usb_speed_t usb_device_get_speed(usb_device_t *usb_dev)
     367{
     368        assert(usb_dev);
     369        return usb_dev->speed;
     370}
     371
    366372int usb_device_get_iface_number(usb_device_t *usb_dev)
    367373{
  • uspace/lib/usbhost/include/usb/host/utility.h

    r60d3f35 r129b821f  
    4848int hc_get_ep0_max_packet_size(uint16_t *, bus_t *, device_t *);
    4949void hc_reset_toggles(const usb_transfer_batch_t *batch, endpoint_reset_toggle_t);
    50 int hc_setup_virtual_root_hub(hc_device_t *);
     50int hc_setup_virtual_root_hub(hc_device_t *, usb_speed_t);
    5151int hc_get_device_desc(device_t *, usb_standard_device_descriptor_t *);
    5252int hc_get_hub_desc(device_t *, usb_hub_descriptor_header_t *);
  • uspace/lib/usbhost/src/utility.c

    r60d3f35 r129b821f  
    177177 * @return Error code
    178178 */
    179 int hc_setup_virtual_root_hub(hc_device_t *hcd)
     179int hc_setup_virtual_root_hub(hc_device_t *hcd, usb_speed_t rh_speed)
    180180{
    181181        int err;
     
    183183        assert(hcd);
    184184
    185         device_t *dev = hcd_ddf_fun_create(hcd, USB_SPEED_MAX);
     185        device_t *dev = hcd_ddf_fun_create(hcd, rh_speed);
    186186        if (!dev) {
    187187                usb_log_error("Failed to create function for the root hub.");
Note: See TracChangeset for help on using the changeset viewer.