xref: /illumos-gate/usr/src/uts/common/sys/usb/hcd/uhci/uhcipolled.h (revision 88f8b78a88cbdc6d8c1af5c3e54bc49d25095c98)
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_UHCI_POLLED_H
28 #define	_SYS_USB_UHCI_POLLED_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 /*
37  * This header file describes the data structures required for the Host
38  * Controller Driver (HCD) to work in POLLED mode which will be  either
39  * OBP mode for Sparc architecture or PC PROM mode for X86 architecture
40  */
41 #define	POLLED_RAW_BUF_SIZE	8
42 
43 /*
44  * These two flags are used to determine if this structure is already in
45  * use. We should only save off the controller state information once,
46  * and restore it once. These flags are used by the uhci_polled_flags below.
47  */
48 #define	POLLED_INPUT_MODE		0x01
49 #define	POLLED_INPUT_MODE_INUSE		0x04
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 
110 /*
111  * External Function Prototypes:
112  * These routines are only called from the init and fini functions.
113  * They are allowed to acquire locks.
114  */
115 extern uhci_state_t	*uhci_obtain_state(dev_info_t *);
116 extern queue_head_t	*uhci_alloc_queue_head(uhci_state_t *);
117 extern void		uhci_free_tw(uhci_state_t *, uhci_trans_wrapper_t *);
118 
119 #ifdef	__cplusplus
120 }
121 #endif
122 
123 #endif	/* _SYS_USB_UHCI_POLLED_H */
124