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