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 2007 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef _SYS_USB_UGEN_H
27 #define	_SYS_USB_UGEN_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #ifdef	__cplusplus
32 extern "C" {
33 #endif
34 
35 /*
36  * Header  file  for  applications  written to  USB  Generic Driver (UGEN).
37  * This  provides different  status  values written  to the application by
38  * UGEN.
39  */
40 
41 /*
42  * UGEN  provides a mechanism  to  retrieve  USB bus  specific information
43  * through endpoint status minor nodes (See ugen(7D) for more information).
44  * Whenever an error occurs on any endpoint, the application can retrieve
45  * the last command status (int). Possible values are give below
46  */
47 #define	USB_LC_STAT_NOERROR		0x00	/* No error		  */
48 #define	USB_LC_STAT_CRC			0x01	/* CRC timeout detected   */
49 #define	USB_LC_STAT_BITSTUFFING		0x02	/* Bit-stuffing violation */
50 #define	USB_LC_STAT_DATA_TOGGLE_MM	0x03	/* Data toggle mismatch	  */
51 #define	USB_LC_STAT_STALL		0x04	/* Endpoint stalled	  */
52 #define	USB_LC_STAT_DEV_NOT_RESP	0x05	/* Device not responding  */
53 #define	USB_LC_STAT_PID_CHECKFAILURE	0x06	/* PID Check failure	  */
54 #define	USB_LC_STAT_UNEXP_PID		0x07	/* Unexpected PID	  */
55 #define	USB_LC_STAT_DATA_OVERRUN	0x08	/* Data size exceeded	  */
56 #define	USB_LC_STAT_DATA_UNDERRUN	0x09	/* Less data received	  */
57 #define	USB_LC_STAT_BUFFER_OVERRUN	0x0a	/* Buffer size exceeded	  */
58 #define	USB_LC_STAT_BUFFER_UNDERRUN	0x0b	/* Buffer under run	  */
59 #define	USB_LC_STAT_TIMEOUT		0x0c	/* Command timed out	  */
60 #define	USB_LC_STAT_NOT_ACCESSED	0x0d	/* Not accessed by h/w	  */
61 #define	USB_LC_STAT_UNSPECIFIED_ERR	0x0e	/* Unspecified error	  */
62 #define	USB_LC_STAT_NO_BANDWIDTH	0x41	/* No bandwidth		  */
63 #define	USB_LC_STAT_HW_ERR		0x42	/* Hardware error	  */
64 #define	USB_LC_STAT_SUSPENDED		0x43	/* Device suspended/resumed */
65 #define	USB_LC_STAT_DISCONNECTED	0x44	/* Device disconnected	  */
66 #define	USB_LC_STAT_INTR_BUF_FULL	0x45	/* Interrupt buf was full */
67 #define	USB_LC_STAT_INVALID_REQ		0x46	/* request was invalid	  */
68 #define	USB_LC_STAT_INTERRUPTED		0x47	/* request was interrupted  */
69 #define	USB_LC_STAT_NO_RESOURCES	0x48	/* no resources for req	  */
70 #define	USB_LC_STAT_INTR_POLLING_FAILED	0x49	/* failed to restart poll  */
71 #define	USB_LC_STAT_ISOC_POLLING_FAILED	0x50	/* failed to restart iso poll */
72 #define	USB_LC_STAT_ISOC_UNINITIALIZED	0x51	/* isoc_info not inited yet */
73 #define	USB_LC_STAT_ISOC_PKT_ERROR	0x52	/* All pkts in last req fail */
74 
75 /*
76  * Endpoint control
77  */
78 #define	USB_EP_INTR_ONE_XFER		0x01	/* when this bit is set	*/
79 						/* ugen will poll an intr */
80 						/* endpoint only once	*/
81 
82 /*
83  * Possible Device status (int) values
84  * Application can poll(2) and read(2) device status on device status minor
85  * nodes (See ugen(7D) for more details).
86  */
87 #define	USB_DEV_STAT_ONLINE		0x1	/* Device is online	  */
88 #define	USB_DEV_STAT_DISCONNECTED	0x2	/* Device is disconnected */
89 #define	USB_DEV_STAT_RESUMED		0x4	/* Device resumed	  */
90 #define	USB_DEV_STAT_UNAVAILABLE	0x5	/* Device unavailable	  */
91 
92 /*
93  * Structure for holding isoc data packets information. Application and ugen
94  * driver use these structures to exchange isoc packet information.
95  */
96 typedef struct ugen_isoc_pkt_descr {
97 	/*
98 	 * Set by the application, for all isochronous requests, to the
99 	 * number of bytes to transfer in a packet.
100 	 */
101 	ushort_t	dsc_isoc_pkt_len;
102 
103 	/*
104 	 * Set by ugen to actual number of bytes sent/received in a packet.
105 	 */
106 	ushort_t	dsc_isoc_pkt_actual_len;
107 
108 	/*
109 	 * Per packet status set by ugen driver both for the isochronous IN
110 	 * and OUT requests.
111 	 */
112 	int	dsc_isoc_pkt_status;
113 } ugen_isoc_pkt_descr_t;
114 
115 typedef struct ugen_isoc_req_head {
116 	int	req_isoc_pkts_count; /* pkt count of the isoc request */
117 	ugen_isoc_pkt_descr_t req_isoc_pkt_descrs[1]; /* pkt descriptors */
118 } ugen_isoc_req_head_t;
119 
120 
121 #ifdef	__cplusplus
122 }
123 #endif
124 
125 #endif	/* _SYS_USB_UGEN_H */
126