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