xref: /titanic_52/usr/src/uts/common/sys/usb/hcd/ehci/ehci_polled.h (revision 9b58c2ad19d1f06f07604b0f61b7ff38f757c8fa)
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_EHCI_POLLED_H
27 #define	_SYS_USB_EHCI_POLLED_H
28 
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
34 /*
35  * Enchanced Host Controller Driver (EHCI)
36  *
37  * The EHCI driver is a software driver which interfaces to the Universal
38  * Serial Bus layer (USBA) and the Host Controller (HC). The interface to
39  * the Host Controller is defined by the EHCI Host Controller Interface.
40  *
41  * This header file describes the data structures required for the EHCI
42  * Driver to work in POLLED mode which will be  either OBP mode for Sparc
43  * architecture or PC PROM mode for X86 architecture
44  */
45 
46 #define	POLLED_RAW_BUF_SIZE	8
47 
48 /*
49  * These two  flags are used to determine if this structure is already
50  * in use.
51  */
52 #define	POLLED_INPUT_MODE		0x01
53 #define	POLLED_OUTPUT_MODE		0x10
54 
55 /*
56  * These two flags are used to determine if this structure is already in
57  * use. We should only save off the controller state information once,
58  * restore it once.  These flags are used for the ehci_polled_flags below.
59  */
60 #define	POLLED_INPUT_MODE_INUSE		0x04
61 #define	POLLED_OUTPUT_MODE_INUSE	0x40
62 #define	MAX_NUM_FOR_KEYBOARD		0x8
63 /*
64  * State structure for the POLLED switch off
65  */
66 typedef struct ehci_polled {
67 	/*
68 	 * Pointer to the ehcip structure for the device that is to  be
69 	 * used as input in polled mode.
70 	 */
71 	ehci_state_t	*ehci_polled_ehcip;
72 
73 	/*
74 	 * Pipe handle for the pipe that is to be used as input device
75 	 * in POLLED mode.
76 	 */
77 	usba_pipe_handle_data_t  *ehci_polled_input_pipe_handle;
78 
79 	/* Dummy endpoint descriptor */
80 	ehci_qh_t	*ehci_polled_dummy_qh;
81 
82 	/* Interrupt Endpoint descriptor */
83 	ehci_qh_t	*ehci_polled_qh;	/* Interrupt endpoint */
84 
85 	/*
86 	 * The buffer that the usb scancodes are copied into.
87 	 */
88 	uchar_t		*ehci_polled_buf;
89 
90 	/*
91 	 * This flag is used to determine if the state of the controller
92 	 * has already been saved (enter) or doesn't need to be restored
93 	 * yet (exit).
94 	 */
95 	uint_t		ehci_polled_flags;
96 
97 	/*
98 	 * List of QTD inserted into polled mode periodic schedule list.
99 	 */
100 	ehci_qtd_t	*ehci_polled_active_intr_qtd_list;
101 
102 	/*
103 	 * ehci_hcdi_polled_input_enter() may be called
104 	 * multiple times before the ehci_hcdi_polled_input_exit() is called.
105 	 * For example, the system may:
106 	 *	- go down to kmdb (ehci_hcdi_polled_input_enter())
107 	 *	- down to the ok prompt, $q (ehci_hcdi_polled_input_enter())
108 	 *	- back to kmdb, "go" (ehci_hcdi_polled_input_exit())
109 	 *	- back to the OS, :c at kmdb (ehci_hcdi_polled_input_exit())
110 	 *
111 	 * polled_entry keeps track of how  many times
112 	 * ehci_polled_input_enter/ehci_polled_input_exit have been
113 	 * called so that the host controller isn't switched back to OS mode
114 	 * prematurely.
115 	 */
116 	uint_t		ehci_polled_entry;
117 
118 	/*
119 	 * Save the pointer usb device structure and the endpoint number
120 	 * during the polled initilization.
121 	 */
122 	usba_device_t	*ehci_polled_usb_dev;	/* USB device */
123 
124 	uint8_t		ehci_polled_ep_addr;
125 
126 	boolean_t	ehci_polled_no_sync_flag; /* For schizo bug */
127 } ehci_polled_t;
128 
129 _NOTE(SCHEME_PROTECTS_DATA("Only accessed in POLLED mode",
130 	ehci_polled_t::ehci_polled_flags))
131 _NOTE(DATA_READABLE_WITHOUT_LOCK(ehci_polled_t::ehci_polled_ehcip))
132 _NOTE(SCHEME_PROTECTS_DATA("Only accessed in POLLED mode",
133 	ehci_polled_t::ehci_polled_entry))
134 
135 /*
136  * Time waits for the different EHCI specific polled operations.
137  * These timeout values are specified in terms of microseconds.
138  */
139 #define	EHCI_POLLED_TIMEWAIT	2000	/* General polled time wait */
140 
141 
142 #ifdef __cplusplus
143 }
144 #endif
145 
146 #endif	/* _SYS_USB_EHCI_POLLED_H */
147