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