xref: /illumos-gate/usr/src/uts/common/sys/usb/hcd/uhci/uhcipolled.h (revision 46b592853d0f4f11781b6b0a7533f267c6aee132)
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_UHCI_POLLED_H
27 #define	_SYS_USB_UHCI_POLLED_H
28 
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
34 /*
35  * This header file describes the data structures required for the Host
36  * Controller Driver (HCD) to work in POLLED mode which will be  either
37  * OBP mode for Sparc architecture or PC PROM mode for X86 architecture
38  */
39 #define	POLLED_RAW_BUF_SIZE	8
40 
41 /*
42  * These two flags are used to determine if this structure is already in
43  * use. We should only save off the controller state information once,
44  * and restore it once. These flags are used by the uhci_polled_flags below.
45  */
46 #define	POLLED_INPUT_MODE		0x01
47 #define	POLLED_INPUT_MODE_INUSE		0x04
48 #define	POLLED_OUTPUT_MODE		0x10
49 #define	POLLED_OUTPUT_MODE_INUSE	0x40
50 
51 /*
52  * For uhci bandwidth of low speed interrupt devices limits,
53  * one host controller can support 7 keyboards only.
54  */
55 
56 #define	MAX_NUM_FOR_KEYBORAD		0x7
57 
58 /*
59  * State structure for the POLLED switch off
60  */
61 typedef struct uhci_polled {
62 	/*
63 	 * Pointer to the uhcip structure for the device that is to  be
64 	 * used as input in polled mode.
65 	 */
66 	uhci_state_t *uhci_polled_uhcip;
67 
68 	/*
69 	 * Pipe handle for the pipe that is to be used as input device
70 	 * in POLLED mode.
71 	 */
72 	usba_pipe_handle_data_t  *uhci_polled_ph;
73 
74 	/* Interrupt Endpoint descriptor */
75 	queue_head_t		*uhci_polled_qh;
76 
77 	/* Transfer descriptor for polling the device */
78 	uhci_td_t		*uhci_polled_td;
79 	/*
80 	 * The buffer that the usb scancodes are copied into.
81 	 */
82 	uchar_t			*uhci_polled_buf;
83 
84 	/*
85 	 * This flag is used to determine if the state of the controller
86 	 * has already been saved (enter) or doesn't need to be restored
87 	 * yet (exit).
88 	 */
89 	uint_t			uhci_polled_flags;
90 	ushort_t		uhci_polled_entry;
91 } uhci_polled_t;
92 
93 _NOTE(SCHEME_PROTECTS_DATA("Only accessed in POLLED mode",
94 	uhci_polled_t::uhci_polled_flags))
95 _NOTE(DATA_READABLE_WITHOUT_LOCK(uhci_polled_t::uhci_polled_uhcip))
96 _NOTE(SCHEME_PROTECTS_DATA("Only accessed in POLLED mode",
97 	uhci_polled_t::uhci_polled_entry))
98 
99 /*
100  * POLLED entry points
101  *	These functions are entry points into the POLLED code.
102  */
103 int	uhci_hcdi_polled_input_init(usba_pipe_handle_data_t *, uchar_t **,
104 	    usb_console_info_impl_t *);
105 int	uhci_hcdi_polled_input_fini(usb_console_info_impl_t *);
106 int	uhci_hcdi_polled_input_enter(usb_console_info_impl_t *);
107 int	uhci_hcdi_polled_input_exit(usb_console_info_impl_t *);
108 int	uhci_hcdi_polled_read(usb_console_info_impl_t *, uint_t *);
109 int	uhci_hcdi_polled_output_init(usba_pipe_handle_data_t *,
110 	    usb_console_info_impl_t *);
111 int	uhci_hcdi_polled_output_fini(usb_console_info_impl_t *);
112 int	uhci_hcdi_polled_output_enter(usb_console_info_impl_t *);
113 int	uhci_hcdi_polled_output_exit(usb_console_info_impl_t *);
114 int	uhci_hcdi_polled_write(usb_console_info_impl_t *, uchar_t *,
115 	    uint_t, uint_t *);
116 
117 /*
118  * External Function Prototypes:
119  * These routines are only called from the init and fini functions.
120  * They are allowed to acquire locks.
121  */
122 extern uhci_state_t	*uhci_obtain_state(dev_info_t *);
123 extern queue_head_t	*uhci_alloc_queue_head(uhci_state_t *);
124 extern void		uhci_free_tw(uhci_state_t *, uhci_trans_wrapper_t *);
125 
126 #ifdef	__cplusplus
127 }
128 #endif
129 
130 #endif	/* _SYS_USB_UHCI_POLLED_H */
131