xref: /illumos-gate/usr/src/uts/common/sys/usb/hubd/hub.h (revision ba2be53024c0b999e74ba9adcd7d80fec5df8c57)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_SYS_USB_HUB_H
27 #define	_SYS_USB_HUB_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #ifdef	__cplusplus
32 extern "C" {
33 #endif
34 
35 #define	USB_DESCR_TYPE_SETUP_HUB	0x2900
36 
37 /*
38  * Section 11.11.2.1 allows up to 255 ports.
39  * For simplicity, only a maximum of 31 ports is currently allowed
40  */
41 #define	MAX_PORTS 31
42 
43 typedef struct usb_hub_descr {
44 	uchar_t		bDescLength;	/* size of descriptor */
45 	uchar_t		bDescriptorType; /* descriptor type */
46 	uchar_t		bNbrPorts;	/* number of ports */
47 	uint16_t	wHubCharacteristics; /* hub characteristics */
48 	uchar_t		bPwrOn2PwrGood;	/* time in ms from the time */
49 				/* power on sequence begins on a port */
50 				/* until power is good on that port */
51 	uchar_t		bHubContrCurrent; /* max current requirements */
52 	uchar_t		DeviceRemovable;
53 					/* removable device attached */
54 	uchar_t		PortPwrCtrlMask;
55 					/* power control mask */
56 } usb_hub_descr_t;
57 
58 #define	ROOT_HUB_DESCRIPTOR_LENGTH	9
59 #define	ROOT_HUB_DESCRIPTOR_TYPE	0x29
60 #define	ROOT_HUB_ADDR			0x01	/* address of root hub */
61 
62 /* Values for wHubCharacteristics */
63 #define	HUB_CHARS_POWER_SWITCHING_MODE	0x03
64 #define	HUB_CHARS_GANGED_POWER		0x00
65 #define	HUB_CHARS_INDIVIDUAL_PORT_POWER	0x01
66 #define	HUB_CHARS_NO_POWER_SWITCHING	0x02
67 #define	HUB_CHARS_COMPOUND_DEV		0x04
68 #define	HUB_CHARS_GLOBAL_OVER_CURRENT	0x00
69 #define	HUB_CHARS_INDIV_OVER_CURRENT	0x08
70 #define	HUB_CHARS_NO_OVER_CURRENT	0x10
71 #define	HUB_CHARS_TT_THINK_TIME		0x60
72 #define	HUB_CHARS_TT_16FS_TIME		0x20
73 #define	HUB_CHARS_TT_24FS_TIME		0x40
74 #define	HUB_CHARS_TT_32FS_TIME		0x60
75 #define	HUB_CHARS_PORT_INDICATOR	0x80
76 
77 /* Default Power On to Power Good time */
78 #define	HUB_DEFAULT_POPG	10
79 
80 /* Hub Status */
81 #define	HUB_CHANGE_STATUS	0x01
82 
83 /* Class Specific bmRequestType values Table 11-10 */
84 #define	HUB_HANDLE_PORT_FEATURE_TYPE	(USB_DEV_REQ_HOST_TO_DEV \
85 					|USB_DEV_REQ_TYPE_CLASS \
86 					|USB_DEV_REQ_RCPT_OTHER)
87 
88 #define	HUB_GET_PORT_STATUS_TYPE	(USB_DEV_REQ_DEV_TO_HOST \
89 					|USB_DEV_REQ_TYPE_CLASS \
90 					|USB_DEV_REQ_RCPT_OTHER)
91 
92 #define	HUB_CLASS_REQ_TYPE		(USB_DEV_REQ_DEV_TO_HOST \
93 					|USB_DEV_REQ_TYPE_CLASS)
94 
95 #define	HUB_HANDLE_HUB_FEATURE_TYPE	USB_DEV_REQ_TYPE_CLASS
96 
97 /* bmRequestType for getting device status */
98 #define	HUB_GET_DEVICE_STATUS_TYPE	(USB_DEV_REQ_DEV_TO_HOST \
99 					|USB_DEV_REQ_TYPE_STANDARD \
100 					|USB_DEV_REQ_RCPT_DEV)
101 
102 /* Port Status Field Bits - Table 11-15 */
103 #define	PORT_STATUS_CCS		0x0001	/* port connection status */
104 #define	PORT_STATUS_PES		0x0002	/* port enable status */
105 #define	PORT_STATUS_PSS		0x0004	/* port suspend status */
106 #define	PORT_STATUS_POCI	0x0008	/* port over current indicator */
107 #define	PORT_STATUS_PRS		0x0010	/* port reset status */
108 #define	PORT_STATUS_PPS		0x0100	/* port power status */
109 #define	PORT_STATUS_LSDA	0x0200	/* low speed device */
110 #define	PORT_STATUS_HSDA	0x0400	/* high speed device */
111 #define	PORT_STATUS_PIC		0x1000	/* port indicator control */
112 
113 #define	PORT_STATUS_MASK	0x171f
114 #define	PORT_STATUS_OK		0x103	/* connected, enabled, power */
115 
116 /* Port Change Field Bits - Table 11-16 */
117 #define	PORT_CHANGE_CSC		0x0001	/* connect status change */
118 #define	PORT_CHANGE_PESC	0x0002	/* port enable change */
119 #define	PORT_CHANGE_PSSC	0x0004	/* port suspend change */
120 #define	PORT_CHANGE_OCIC	0x0008	/* over current change */
121 #define	PORT_CHANGE_PRSC	0x0010	/* port reset change */
122 
123 #define	PORT_CHANGE_MASK	0x001f
124 
125 /* Hub status Field Bits - Table 11-14 */
126 #define	HUB_LOCAL_POWER_STATUS	0x0001	/* state of the power supply */
127 #define	HUB_OVER_CURRENT	0x0002  /* global hub OC condition */
128 
129 /* Hub change clear feature selectors - Table 11-15 */
130 #define	C_HUB_LOCAL_POWER_STATUS 0x0001 /* state of the power supply */
131 #define	C_HUB_OVER_CURRENT	 0x0002 /* global hub OC condition */
132 
133 /* hub class feature selectors - Table 11-12 */
134 #define	CFS_C_HUB_LOCAL_POWER		0
135 #define	CFS_C_HUB_OVER_CURRENT		1
136 #define	CFS_PORT_CONNECTION		0
137 #define	CFS_PORT_ENABLE			1
138 #define	CFS_PORT_SUSPEND		2
139 #define	CFS_PORT_OVER_CURRENT		3
140 #define	CFS_PORT_RESET			4
141 #define	CFS_PORT_POWER			8
142 #define	CFS_PORT_LOW_SPEED		9
143 #define	CFS_C_PORT_CONNECTION		16
144 #define	CFS_C_PORT_ENABLE		17
145 #define	CFS_C_PORT_SUSPEND		18
146 #define	CFS_C_PORT_OVER_CURRENT 	19
147 #define	CFS_C_PORT_RESET		20
148 
149 #ifdef	__cplusplus
150 }
151 #endif
152 
153 #endif	/* _SYS_USB_HUB_H */
154