xref: /illumos-gate/usr/src/uts/common/sys/usb/hcd/ehci/ehci_polled.h (revision f6f4cb8ada400367a1921f6b93fb9e02f53ac5e6)
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_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 
54 /*
55  * These two flags are used to determine if this structure is already in
56  * use. We should only save off the controller state information once,
57  * restore it once.  These flags are used for the ehci_polled_flags below.
58  */
59 #define	POLLED_INPUT_MODE_INUSE		0x04
60 #define	MAX_NUM_FOR_KEYBOARD		0x8
61 /*
62  * State structure for the POLLED switch off
63  */
64 typedef struct ehci_polled {
65 	/*
66 	 * Pointer to the ehcip structure for the device that is to  be
67 	 * used as input in polled mode.
68 	 */
69 	ehci_state_t	*ehci_polled_ehcip;
70 
71 	/*
72 	 * Pipe handle for the pipe that is to be used as input device
73 	 * in POLLED mode.
74 	 */
75 	usba_pipe_handle_data_t  *ehci_polled_input_pipe_handle;
76 
77 	/* Dummy endpoint descriptor */
78 	ehci_qh_t	*ehci_polled_dummy_qh;
79 
80 	/* Interrupt Endpoint descriptor */
81 	ehci_qh_t	*ehci_polled_qh;	/* Interrupt endpoint */
82 
83 	/*
84 	 * The buffer that the usb scancodes are copied into.
85 	 */
86 	uchar_t		*ehci_polled_buf;
87 
88 	/*
89 	 * This flag is used to determine if the state of the controller
90 	 * has already been saved (enter) or doesn't need to be restored
91 	 * yet (exit).
92 	 */
93 	uint_t		ehci_polled_flags;
94 
95 	/*
96 	 * List of QTD inserted into polled mode periodic schedule list.
97 	 */
98 	ehci_qtd_t	*ehci_polled_active_intr_qtd_list;
99 
100 	/*
101 	 * ehci_hcdi_polled_input_enter() may be called
102 	 * multiple times before the ehci_hcdi_polled_input_exit() is called.
103 	 * For example, the system may:
104 	 *	- go down to kmdb (ehci_hcdi_polled_input_enter())
105 	 *	- down to the ok prompt, $q (ehci_hcdi_polled_input_enter())
106 	 *	- back to kmdb, "go" (ehci_hcdi_polled_input_exit())
107 	 *	- back to the OS, :c at kmdb (ehci_hcdi_polled_input_exit())
108 	 *
109 	 * polled_entry keeps track of how  many times
110 	 * ehci_polled_input_enter/ehci_polled_input_exit have been
111 	 * called so that the host controller isn't switched back to OS mode
112 	 * prematurely.
113 	 */
114 	uint_t		ehci_polled_entry;
115 
116 	/*
117 	 * Save the pointer usb device structure and the endpoint number
118 	 * during the polled initilization.
119 	 */
120 	usba_device_t	*ehci_polled_usb_dev;	/* USB device */
121 
122 	uint8_t		ehci_polled_ep_addr;
123 
124 	boolean_t	ehci_polled_no_sync_flag; /* For schizo bug */
125 } ehci_polled_t;
126 
127 _NOTE(SCHEME_PROTECTS_DATA("Only accessed in POLLED mode",
128 	ehci_polled_t::ehci_polled_flags))
129 _NOTE(DATA_READABLE_WITHOUT_LOCK(ehci_polled_t::ehci_polled_ehcip))
130 _NOTE(SCHEME_PROTECTS_DATA("Only accessed in POLLED mode",
131 	ehci_polled_t::ehci_polled_entry))
132 
133 /*
134  * Time waits for the different EHCI specific polled operations.
135  * These timeout values are specified in terms of microseconds.
136  */
137 #define	EHCI_POLLED_TIMEWAIT	2000	/* General polled time wait */
138 
139 
140 #ifdef __cplusplus
141 }
142 #endif
143 
144 #endif	/* _SYS_USB_EHCI_POLLED_H */
145