Import 2.3.25pre1
[davej-history.git] / drivers / usb / hub.h
blobc95a07d74ed19471d8f134979d2ad7126f5939c1
1 #ifndef __LINUX_HUB_H
2 #define __LINUX_HUB_H
4 #include <linux/list.h>
6 /*
7 * Hub Class feature numbers
8 */
9 #define C_HUB_LOCAL_POWER 0
10 #define C_HUB_OVER_CURRENT 1
13 * Port feature numbers
15 #define USB_PORT_FEAT_CONNECTION 0
16 #define USB_PORT_FEAT_ENABLE 1
17 #define USB_PORT_FEAT_SUSPEND 2
18 #define USB_PORT_FEAT_OVER_CURRENT 3
19 #define USB_PORT_FEAT_RESET 4
20 #define USB_PORT_FEAT_POWER 8
21 #define USB_PORT_FEAT_LOWSPEED 9
22 #define USB_PORT_FEAT_C_CONNECTION 16
23 #define USB_PORT_FEAT_C_ENABLE 17
24 #define USB_PORT_FEAT_C_SUSPEND 18
25 #define USB_PORT_FEAT_C_OVER_CURRENT 19
26 #define USB_PORT_FEAT_C_RESET 20
28 struct usb_port_status {
29 __u16 wPortStatus;
30 __u16 wPortChange;
31 } __attribute__ ((packed));
33 /* wPortStatus bits */
34 #define USB_PORT_STAT_CONNECTION 0x0001
35 #define USB_PORT_STAT_ENABLE 0x0002
36 #define USB_PORT_STAT_SUSPEND 0x0004
37 #define USB_PORT_STAT_OVERCURRENT 0x0008
38 #define USB_PORT_STAT_RESET 0x0010
39 #define USB_PORT_STAT_POWER 0x0100
40 #define USB_PORT_STAT_LOW_SPEED 0x0200
42 /* wPortChange bits */
43 #define USB_PORT_STAT_C_CONNECTION 0x0001
44 #define USB_PORT_STAT_C_ENABLE 0x0002
45 #define USB_PORT_STAT_C_SUSPEND 0x0004
46 #define USB_PORT_STAT_C_OVERCURRENT 0x0008
47 #define USB_PORT_STAT_C_RESET 0x0010
49 /* wHubCharacteristics (masks) */
50 #define HUB_CHAR_LPSM 0x0003
51 #define HUB_CHAR_COMPOUND 0x0004
52 #define HUB_CHAR_OCPM 0x0018
54 struct usb_hub_status {
55 __u16 wHubStatus;
56 __u16 wHubChange;
57 } __attribute__ ((packed));
60 *Hub Status & Hub Change bit masks
62 #define HUB_STATUS_LOCAL_POWER 0x0001
63 #define HUB_STATUS_OVERCURRENT 0x0002
65 #define HUB_CHANGE_LOCAL_POWER 0x0001
66 #define HUB_CHANGE_OVERCURRENT 0x0002
68 /* Hub descriptor */
69 struct usb_hub_descriptor {
70 __u8 bLength;
71 __u8 bDescriptorType;
72 __u8 bNbrPorts;
73 __u16 wHubCharacteristics;
74 #if 0
75 __u8 wHubCharacteristics[2]; /* __u16 but not aligned! */
76 #endif
77 __u8 bPwrOn2PwrGood;
78 __u8 bHubContrCurrent;
79 /* DeviceRemovable and PortPwrCtrlMask want to be variable-length
80 bitmaps that hold max 256 entries, but for now they're ignored */
81 #if 0
82 __u8 filler;
83 #endif
84 } __attribute__ ((packed));
86 struct usb_device;
88 typedef enum {
89 USB_PORT_UNPOWERED = 0, /* Default state */
90 USB_PORT_POWERED, /* When we've put power to it */
91 USB_PORT_ENABLED, /* When it's been enabled */
92 USB_PORT_DISABLED, /* If it's been disabled */
93 USB_PORT_ADMINDISABLED, /* Forced down */
94 } usb_hub_port_state;
96 struct usb_hub_port {
97 usb_hub_port_state cstate; /* Configuration state */
99 struct usb_device *child; /* Device attached to this port */
101 struct usb_hub *parent; /* Parent hub */
104 struct usb_hub {
105 /* Device structure */
106 struct usb_device *dev;
108 /* Reference to the hub's polling IRQ and its associated pipe */
109 void *irq_handle;
110 unsigned int irqpipe;
112 /* List of hubs */
113 struct list_head hub_list;
115 /* Temporary event list */
116 struct list_head event_list;
118 /* Number of ports on the hub */
119 int nports;
121 struct usb_hub_port ports[0]; /* Dynamically allocated */
124 #endif