xref: /illumos-gate/usr/src/uts/common/sys/usb/usba/wusba_io.h (revision ff0e937b36dcde1a47ff7b00aa76a491c0dc07a8)
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 2009 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_SYS_USB_WUSBA_IO_H
27 #define	_SYS_USB_WUSBA_IO_H
28 
29 #ifdef	__cplusplus
30 extern "C" {
31 #endif
32 
33 /* ioctl commands between wusb host and the wusbadm tool */
34 #define	WUSB_HC_IOC		('W' << 8)
35 
36 /* get the state of a device corresponding to cdid */
37 #define	WUSB_HC_GET_DSTATE	(WUSB_HC_IOC | 0x01)
38 
39 #define	MAX_USB_NODENAME	256
40 /* for WUSB_HC_GET_DSTATE ioctl */
41 typedef struct wusb_hc_get_dstate {
42 	uint8_t		cdid[16];		/* IN arg */
43 	uint16_t	state;			/* OUT arg - device state */
44 	char		path[MAXPATHLEN];	/* OUT arg - device apid */
45 
46 	/* OUT arg - driver name XXX: need to find MAX nodename len */
47 	char		nodename[MAX_USB_NODENAME];
48 } wusb_hc_get_dstate_t;
49 
50 /* device state, refer to WUSB 1.0 spec - Figure 7.1 */
51 enum wusb_device_state {
52 	WUSB_STATE_UNCONNTED = 0,
53 	WUSB_STATE_CONNTING,		/* sent connection notification */
54 	WUSB_STATE_UNAUTHENTICATED,	/* got connect ACK from host */
55 	WUSB_STATE_DEFAULT,		/* authenticated and usb addr = 0 */
56 	WUSB_STATE_ADDRESSED,		/* non-zero usb addr is assigned */
57 	WUSB_STATE_CONFIGURED,		/* configuration is set */
58 	WUSB_STATE_SLEEPING,
59 	WUSB_STATE_RECONNTING
60 };
61 
62 /* get host 48-bit MAC addr */
63 #define	WUSB_HC_GET_MAC_ADDR	(WUSB_HC_IOC | 0x02)
64 
65 /* load CC to host and update chid when cc list is null */
66 #define	WUSB_HC_ADD_CC		(WUSB_HC_IOC | 0x03)
67 
68 /* remove CC from host */
69 #define	WUSB_HC_REM_CC		(WUSB_HC_IOC | 0x04)
70 
71 /* CC structure for WUSB_HC_ADD_CC and WUSB_HC_REM_CC ioctl */
72 typedef struct wusb_cc {
73 	uint8_t		CHID[16];
74 	uint8_t		CDID[16];
75 	uint8_t		CK[16];
76 } wusb_cc_t;
77 
78 /* set host beaconing channel number */
79 #define	WUSB_HC_SET_CHANNEL	(WUSB_HC_IOC | 0x05)
80 
81 /* start host to accept device connections and transfers */
82 #define	WUSB_HC_START		(WUSB_HC_IOC | 0x06)
83 
84 /*
85  * start flag bitmap for WUSB_HC_START ioctl:
86  * INITIAL_START and CHANNEL_START are exclusive
87  */
88 #define	WUSB_HC_INITIAL_START		0x00000001 /* fully start host */
89 #define	WUSB_HC_CHANNEL_START		0x00000002 /* partially start host */
90 
91 /* stop host functioning */
92 #define	WUSB_HC_STOP		(WUSB_HC_IOC | 0x07)
93 
94 /*
95  * stop flag bitmap for WUSB_HC_STOP ioctl:
96  * FINAL_STOP and CHANNEL_STOP are exclusive, and there must be one
97  * REM_ALL_CC is optional
98  */
99 #define	WUSB_HC_FINAL_STOP		0x00000001 /* fully stop host */
100 #define	WUSB_HC_CHANNEL_STOP		0x00000002 /* partially stop host */
101 #define	WUSB_HC_REM_ALL_CC		0x00000004 /* remove all cc'es */
102 
103 /* start host to accept new device connections */
104 #define	WUSB_HC_START_NA	(WUSB_HC_IOC | 0x08)
105 
106 /* stop host from accepting new device connections */
107 #define	WUSB_HC_STOP_NA		(WUSB_HC_IOC | 0x09)
108 
109 /* get host state */
110 #define	WUSB_HC_GET_HSTATE	(WUSB_HC_IOC | 0x0a)
111 
112 /* host state for WUSB_HC_GET_HSTATE ioctl */
113 enum wusb_host_state {
114 	WUSB_HC_DISCONNTED = 0,
115 	WUSB_HC_STOPPED,	/* default or WUSB_HC_FINAL_STOP is called */
116 	WUSB_HC_STARTED,	/* WUSB_HC_INITIAL_START is called */
117 	WUSB_HC_CH_STOPPED	/* WUSB_HC_CHANNEL_STOP is called */
118 };
119 
120 #ifdef __cplusplus
121 }
122 #endif
123 
124 #endif	/* _SYS_USB_WUSBA_IO_H */
125