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