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