1// Copyright 2016 The Fuchsia Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#pragma once
6
7#include <ddk/protocol/usb.h>
8#include <zircon/listnode.h>
9
10#include "xhci-trb.h"
11
12// this struct contains state needed for a virtual root hub device
13typedef struct {
14    uint32_t num_ports;
15
16    // port status for each of our ports
17    usb_port_status_t*  port_status;
18
19    // maps our virtual port index to actual root hub port index
20    uint8_t* port_map;
21
22    // interrupt requests we have pending from hub driver
23    list_node_t pending_intr_reqs;
24
25    const usb_device_descriptor_t* device_desc;
26    const usb_configuration_descriptor_t* config_desc;
27    usb_speed_t speed;
28} xhci_root_hub_t;
29
30zx_status_t xhci_root_hub_init(xhci_t* xhci, int rh_index);
31void xhci_root_hub_free(xhci_root_hub_t* rh);
32zx_status_t xhci_start_root_hubs(xhci_t* xhci);
33void xhci_stop_root_hubs(xhci_t* xhci);
34zx_status_t xhci_rh_usb_request_queue(xhci_t* xhci, usb_request_t* req, int rh_index);
35void xhci_handle_root_hub_change(xhci_t* xhci);
36