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_OHCI_POLLED_H
27 #define	_SYS_USB_OHCI_POLLED_H
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
33 /*
34  * Open Host Controller Driver (OHCI)
35  *
36  * The USB Open Host Controller driver is a software driver which interfaces
37  * to the Universal Serial Bus layer (USBA) and the USB Open Host Controller.
38  * The interface to USB Open Host Controller is defined by the OpenHCI  Host
39  * Controller Interface.
40  *
41  * This header file describes the data structures required for the USB Open
42  * Host Controller Driver to work in POLLED mode which will be either OBP
43  * mode for Sparc 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 ohci_polled_flags below.
59  */
60 #define	POLLED_INPUT_MODE_INUSE		0x04
61 #define	POLLED_OUTPUT_MODE_INUSE	0x40
62 
63 /*
64  * For ohci bandwidth of low speed interrupt devices limits,
65  * one host controller can support 6 keyboards only.
66  */
67 #define	MAX_NUM_FOR_KEYBOARD		0x6
68 /*
69  * State structure for the POLLED switch off
70  */
71 typedef struct ohci_polled {
72 	/*
73 	 * Pointer to the ohcip structure for the device that is to  be
74 	 * used as input in polled mode.
75 	 */
76 	ohci_state_t	*ohci_polled_ohcip;
77 
78 	/*
79 	 * Pipe handle for the pipe that is to be used as input device
80 	 * in POLLED mode.
81 	 */
82 	usba_pipe_handle_data_t  *ohci_polled_input_pipe_handle;
83 
84 	/* Dummy endpoint descriptor */
85 	ohci_ed_t	*ohci_polled_dummy_ed;
86 
87 	/* Interrupt Endpoint descriptor */
88 	ohci_ed_t	*ohci_polled_ed;	/* Interrupt endpoint */
89 
90 	/*
91 	 * The buffer that the usb scancodes are copied into.
92 	 */
93 	uchar_t		*ohci_polled_buf;
94 
95 	/*
96 	 * This flag is used to determine if the state of the controller
97 	 * has already been saved (enter) or doesn't need to be restored
98 	 * yet (exit).
99 	 */
100 	uint_t		ohci_polled_flags;
101 
102 	/*
103 	 * The read or write routines may take TD's of the done head that
104 	 * are not intended for them.
105 	 */
106 	ohci_td_t	*ohci_polled_input_done_head;
107 
108 	/*
109 	 * This is the tail for the above ohci_polled_input_done_head;
110 	 */
111 	ohci_td_t	*ohci_polled_input_done_tail;
112 
113 	/*
114 	 * ohci_hcdi_polled_input_enter() may be called
115 	 * multiple times before the ohci_hcdi_polled_input_exit() is called.
116 	 * For example, the system may:
117 	 *	- go down to kmdb (ohci_hcdi_polled_input_enter())
118 	 *	- down to the ok prompt, $q (ohci_hcdi_polled_input_enter())
119 	 *	- back to kmdb, "go" (ohci_hcdi_polled_input_exit())
120 	 *	- back to the OS, :c at kmdb (ohci_hcdi_polled_input_exit())
121 	 *
122 	 * polled_entry keeps track of how  many times
123 	 * ohci_polled_input_enter/ohci_polled_input_exit have been
124 	 * called so that the host controller isn't switched back to OS mode
125 	 * prematurely.
126 	 */
127 	uint_t		ohci_polled_entry;
128 
129 	/*
130 	 * Save the pointer usb device structure and the endpoint number
131 	 * during the polled initilization.
132 	 */
133 	usba_device_t	*ohci_polled_usb_dev;	/* USB device */
134 
135 	uint8_t		ohci_polled_ep_addr;
136 
137 	boolean_t	ohci_polled_no_sync_flag; /* For schizo bug */
138 } ohci_polled_t;
139 
140 _NOTE(SCHEME_PROTECTS_DATA("Only accessed in POLLED mode",
141 	ohci_polled_t::ohci_polled_flags))
142 _NOTE(DATA_READABLE_WITHOUT_LOCK(ohci_polled_t::ohci_polled_ohcip))
143 _NOTE(SCHEME_PROTECTS_DATA("Only accessed in POLLED mode",
144 	ohci_polled_t::ohci_polled_entry))
145 
146 
147 #ifdef __cplusplus
148 }
149 #endif
150 
151 #endif	/* _SYS_USB_OHCI_POLLED_H */
152