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 2004 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _SYS_USB_EHCI_XFER_H
28 #define	_SYS_USB_EHCI_XFER_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 /*
37  * Enchanced Host Controller Driver (EHCI)
38  *
39  * The EHCI driver is a software driver which interfaces to the Universal
40  * Serial Bus layer (USBA) and the Host Controller (HC). The interface to
41  * the Host Controller is defined by the EHCI Host Controller Interface.
42  *
43  * This header file describes the data structures and function prototypes
44  * required for the EHCI Driver to perform different USB transfers.
45  */
46 
47 /* EHCI Queue Head (QH) related functions */
48 extern ehci_qh_t *ehci_alloc_qh(
49 				ehci_state_t		*ehcip,
50 				usba_pipe_handle_data_t	*ph,
51 				uint_t			flag);
52 extern void	ehci_insert_qh(
53 				ehci_state_t		*ehcip,
54 				usba_pipe_handle_data_t	*ph);
55 extern void	ehci_remove_qh(
56 				ehci_state_t		*ehcip,
57 				ehci_pipe_private_t	*pp,
58 				boolean_t		reclaim);
59 extern void	ehci_deallocate_qh(
60 				ehci_state_t		*ehcip,
61 				ehci_qh_t		*old_qh);
62 extern uint32_t	ehci_qh_cpu_to_iommu(
63 				ehci_state_t		*ehcip,
64 				ehci_qh_t		*addr);
65 extern ehci_qh_t *ehci_qh_iommu_to_cpu(
66 				ehci_state_t		*ehcip,
67 				uintptr_t		addr);
68 
69 /* EHCI Queue Element Transfer Descriptor (QTD) related functions */
70 extern ehci_trans_wrapper_t *ehci_allocate_ctrl_resources(
71 				ehci_state_t		*ehcip,
72 				ehci_pipe_private_t	*pp,
73 				usb_ctrl_req_t		*ctrl_reqp,
74 				usb_flags_t		usb_flags);
75 extern void	ehci_insert_ctrl_req(
76 				ehci_state_t		*ehcip,
77 				usba_pipe_handle_data_t	*ph,
78 				usb_ctrl_req_t		*ctrl_reqp,
79 				ehci_trans_wrapper_t	*tw,
80 				usb_flags_t		usb_flags);
81 extern ehci_trans_wrapper_t *ehci_allocate_bulk_resources(
82 				ehci_state_t		*ehcip,
83 				ehci_pipe_private_t	*pp,
84 				usb_bulk_req_t		*bulk_reqp,
85 				usb_flags_t		usb_flags);
86 extern void	ehci_insert_bulk_req(
87 				ehci_state_t		*ehcip,
88 				usba_pipe_handle_data_t	*ph,
89 				usb_bulk_req_t		*bulk_reqp,
90 				ehci_trans_wrapper_t	*tw,
91 				usb_flags_t		flags);
92 extern int	ehci_start_periodic_pipe_polling(
93 				ehci_state_t		*ehcip,
94 				usba_pipe_handle_data_t	*ph,
95 				usb_opaque_t		periodic_in_reqp,
96 				usb_flags_t		flags);
97 extern ehci_trans_wrapper_t *ehci_allocate_intr_resources(
98 				ehci_state_t		*ehcip,
99 				usba_pipe_handle_data_t	*ph,
100 				usb_intr_req_t		*intr_reqp,
101 				usb_flags_t		usb_flags);
102 extern void	ehci_insert_intr_req(
103 				ehci_state_t		*ehcip,
104 				ehci_pipe_private_t	*pp,
105 				ehci_trans_wrapper_t	*tw,
106 				usb_flags_t		flags);
107 extern int	ehci_stop_periodic_pipe_polling(
108 				ehci_state_t		*ehcip,
109 				usba_pipe_handle_data_t	*ph,
110 				usb_flags_t		flags);
111 extern int	ehci_insert_qtd(
112 				ehci_state_t		*ehcip,
113 				uint_t			qtd_ctrl,
114 				uint32_t		qtd_iommu_cbp,
115 				size_t			qtd_length,
116 				uint32_t		qtd_flag,
117 				ehci_pipe_private_t	*pp,
118 				ehci_trans_wrapper_t	*tw);
119 extern void	ehci_remove_qtd_from_active_qtd_list(
120 				ehci_state_t		*ehcip,
121 				ehci_qtd_t		*curr_qtd);
122 extern void	ehci_deallocate_qtd(
123 				ehci_state_t		*ehcip,
124 				ehci_qtd_t		*old_qtd);
125 extern uint32_t	ehci_qtd_cpu_to_iommu(
126 				ehci_state_t		*ehcip,
127 				ehci_qtd_t		*addr);
128 extern ehci_qtd_t *ehci_qtd_iommu_to_cpu(
129 				ehci_state_t		*ehcip,
130 				uintptr_t		addr);
131 
132 /* Transfer Wrapper (TW) functions */
133 extern int	ehci_allocate_tds_for_tw(
134 				ehci_state_t		*ehcip,
135 				ehci_pipe_private_t	*pp,
136 				ehci_trans_wrapper_t	*tw,
137 				size_t			qtd_count);
138 extern void	ehci_stop_xfer_timer(
139 				ehci_state_t		*ehcip,
140 				ehci_trans_wrapper_t	*tw,
141 				uint_t			flag);
142 extern void	ehci_deallocate_tw(
143 				ehci_state_t		*ehcip,
144 				ehci_pipe_private_t	*pp,
145 				ehci_trans_wrapper_t	*tw);
146 extern void	ehci_free_dma_resources(
147 				ehci_state_t		*ehcip,
148 				usba_pipe_handle_data_t	*ph);
149 
150 /* Miscillaneous functions */
151 extern int	ehci_allocate_intr_in_resource(
152 				ehci_state_t		*ehcip,
153 				ehci_pipe_private_t	*pp,
154 				ehci_trans_wrapper_t	*tw,
155 				usb_flags_t		flags);
156 extern void	ehci_deallocate_intr_in_resource(
157 				ehci_state_t		*ehcip,
158 				ehci_pipe_private_t	*pp,
159 				ehci_trans_wrapper_t	*tw);
160 extern void	ehci_pipe_cleanup(
161 				ehci_state_t		*ehcip,
162 				usba_pipe_handle_data_t	*ph);
163 extern void	ehci_check_for_transfers_completion(
164 				ehci_state_t		*ehcip,
165 				ehci_pipe_private_t	*pp);
166 extern void	ehci_restore_data_toggle(
167 				ehci_state_t		*ehcip,
168 				usba_pipe_handle_data_t	*ph);
169 extern void	ehci_handle_outstanding_requests(
170 				ehci_state_t		*ehcip,
171 				ehci_pipe_private_t	*pp);
172 extern void	ehci_do_client_periodic_in_req_callback(
173 				ehci_state_t		*ehcip,
174 				ehci_pipe_private_t	*pp,
175 				usb_cr_t		completion_reason);
176 extern void	ehci_hcdi_callback(
177 				usba_pipe_handle_data_t	*ph,
178 				ehci_trans_wrapper_t	*tw,
179 				usb_cr_t		completion_reason);
180 extern void	ehci_handle_clear_tt_buffer(
181 				ehci_state_t		*ehcip,
182 				ehci_pipe_private_t	*pp,
183 				ehci_trans_wrapper_t	*tw,
184 				ehci_qtd_t		*qtd,
185 				void			*);
186 extern void	ehci_handle_clear_tt_buffer_error(
187 				ehci_state_t		*ehcip,
188 				ehci_pipe_private_t	*hub_pp,
189 				ehci_trans_wrapper_t	*tw,
190 				ehci_qtd_t		*qtd,
191 				void			*,
192 				usb_cr_t		error);
193 #ifdef __cplusplus
194 }
195 #endif
196 
197 #endif /* _SYS_USB_EHCI_XFER_H */
198