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, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_SYS_USB_OHCI_POLLED_H
28 #define	_SYS_USB_OHCI_POLLED_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 /*
37  * Open Host Controller Driver (OHCI)
38  *
39  * The USB Open Host Controller driver is a software driver which interfaces
40  * to the Universal Serial Bus layer (USBA) and the USB Open Host Controller.
41  * The interface to USB Open Host Controller is defined by the OpenHCI  Host
42  * Controller Interface.
43  *
44  * This header file describes the data structures required for the USB Open
45  * Host Controller Driver to work in POLLED mode which will be either OBP
46  * mode for Sparc architecture or PC PROM mode for X86 architecture
47  */
48 
49 #define	POLLED_RAW_BUF_SIZE	8
50 
51 /*
52  * These two  flags are used to determine if this structure is already
53  * in use.
54  */
55 #define	POLLED_INPUT_MODE		0x01
56 
57 /*
58  * These two flags are used to determine if this structure is already in
59  * use. We should only save off the controller state information once,
60  * restore it once.  These flags are used for the ohci_polled_flags below.
61  */
62 #define	POLLED_INPUT_MODE_INUSE		0x04
63 
64 /*
65  * For ohci bandwidth of low speed interrupt devices limits,
66  * one host controller can support 6 keyboards only.
67  */
68 #define	MAX_NUM_FOR_KEYBOARD		0x6
69 /*
70  * State structure for the POLLED switch off
71  */
72 typedef struct ohci_polled {
73 	/*
74 	 * Pointer to the ohcip structure for the device that is to  be
75 	 * used as input in polled mode.
76 	 */
77 	ohci_state_t	*ohci_polled_ohcip;
78 
79 	/*
80 	 * Pipe handle for the pipe that is to be used as input device
81 	 * in POLLED mode.
82 	 */
83 	usba_pipe_handle_data_t  *ohci_polled_input_pipe_handle;
84 
85 	/* Dummy endpoint descriptor */
86 	ohci_ed_t	*ohci_polled_dummy_ed;
87 
88 	/* Interrupt Endpoint descriptor */
89 	ohci_ed_t	*ohci_polled_ed;	/* Interrupt endpoint */
90 
91 	/*
92 	 * The buffer that the usb scancodes are copied into.
93 	 */
94 	uchar_t		*ohci_polled_buf;
95 
96 	/*
97 	 * This flag is used to determine if the state of the controller
98 	 * has already been saved (enter) or doesn't need to be restored
99 	 * yet (exit).
100 	 */
101 	uint_t		ohci_polled_flags;
102 
103 	/*
104 	 * The read or write routines may take TD's of the done head that
105 	 * are not intended for them.
106 	 */
107 	ohci_td_t	*ohci_polled_input_done_head;
108 
109 	/*
110 	 * This is the tail for the above ohci_polled_input_done_head;
111 	 */
112 	ohci_td_t	*ohci_polled_input_done_tail;
113 
114 	/*
115 	 * ohci_hcdi_polled_input_enter() may be called
116 	 * multiple times before the ohci_hcdi_polled_input_exit() is called.
117 	 * For example, the system may:
118 	 *	- go down to kmdb (ohci_hcdi_polled_input_enter())
119 	 *	- down to the ok prompt, $q (ohci_hcdi_polled_input_enter())
120 	 *	- back to kmdb, "go" (ohci_hcdi_polled_input_exit())
121 	 *	- back to the OS, :c at kmdb (ohci_hcdi_polled_input_exit())
122 	 *
123 	 * polled_entry keeps track of how  many times
124 	 * ohci_polled_input_enter/ohci_polled_input_exit have been
125 	 * called so that the host controller isn't switched back to OS mode
126 	 * prematurely.
127 	 */
128 	uint_t		ohci_polled_entry;
129 
130 	/*
131 	 * Save the pointer usb device structure and the endpoint number
132 	 * during the polled initilization.
133 	 */
134 	usba_device_t	*ohci_polled_usb_dev;	/* USB device */
135 
136 	uint8_t		ohci_polled_ep_addr;
137 
138 	boolean_t	ohci_polled_no_sync_flag; /* For schizo bug */
139 } ohci_polled_t;
140 
141 _NOTE(SCHEME_PROTECTS_DATA("Only accessed in POLLED mode",
142 	ohci_polled_t::ohci_polled_flags))
143 _NOTE(DATA_READABLE_WITHOUT_LOCK(ohci_polled_t::ohci_polled_ohcip))
144 _NOTE(SCHEME_PROTECTS_DATA("Only accessed in POLLED mode",
145 	ohci_polled_t::ohci_polled_entry))
146 
147 
148 #ifdef __cplusplus
149 }
150 #endif
151 
152 #endif	/* _SYS_USB_OHCI_POLLED_H */
153