1 #ifndef __USB_HUB_H
2 #define __USB_HUB_H
3 
4 // usb-hub.c
5 struct usbdevice_s;
6 int usb_hub_setup(struct usbdevice_s *usbdev);
7 
8 
9 /****************************************************************
10  * hub flags
11  ****************************************************************/
12 
13 #define USB_DT_HUB                      (USB_TYPE_CLASS | 0x09)
14 #define USB_DT_HUB3                     (USB_TYPE_CLASS | 0x0a)
15 
16 #define HUB_REQ_SET_HUB_DEPTH           0x0C
17 
18 struct usb_hub_descriptor {
19     u8  bDescLength;
20     u8  bDescriptorType;
21     u8  bNbrPorts;
22     u16 wHubCharacteristics;
23     u8  bPwrOn2PwrGood;
24     u8  bHubContrCurrent;
25     // Variable length fields for DeviceRemovable[], PortPwrCtrlMask[] follow.
26 } PACKED;
27 
28 #define USB_PORT_FEAT_CONNECTION        0
29 #define USB_PORT_FEAT_ENABLE            1
30 #define USB_PORT_FEAT_SUSPEND           2
31 #define USB_PORT_FEAT_OVER_CURRENT      3
32 #define USB_PORT_FEAT_RESET             4
33 #define USB_PORT_FEAT_POWER             8
34 #define USB_PORT_FEAT_LOWSPEED          9
35 #define USB_PORT_FEAT_C_CONNECTION      16
36 #define USB_PORT_FEAT_C_ENABLE          17
37 #define USB_PORT_FEAT_C_SUSPEND         18
38 #define USB_PORT_FEAT_C_OVER_CURRENT    19
39 #define USB_PORT_FEAT_C_RESET           20
40 #define USB_PORT_FEAT_TEST              21
41 #define USB_PORT_FEAT_INDICATOR         22
42 #define USB_PORT_FEAT_C_PORT_L1         23
43 
44 struct usb_port_status {
45     u16 wPortStatus;
46     u16 wPortChange;
47 } PACKED;
48 
49 #define USB_PORT_STAT_CONNECTION        0x0001
50 #define USB_PORT_STAT_ENABLE            0x0002
51 #define USB_PORT_STAT_SUSPEND           0x0004
52 #define USB_PORT_STAT_OVERCURRENT       0x0008
53 #define USB_PORT_STAT_RESET             0x0010
54 #define USB_PORT_STAT_LINK_SHIFT        5
55 #define USB_PORT_STAT_LINK_MASK         (0x7 << USB_PORT_STAT_LINK_SHIFT)
56 #define USB_PORT_STAT_POWER             0x0100
57 #define USB_PORT_STAT_SPEED_SHIFT       9
58 #define USB_PORT_STAT_SPEED_MASK        (0x3 << USB_PORT_STAT_SPEED_SHIFT)
59 #define USB_PORT_STAT_LOW_SPEED         0x0200
60 #define USB_PORT_STAT_HIGH_SPEED        0x0400
61 #define USB_PORT_STAT_TEST              0x0800
62 #define USB_PORT_STAT_INDICATOR         0x1000
63 
64 #endif // ush-hid.h
65