1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate 
27*7c478bd9Sstevel@tonic-gate #ifndef _SYS_USB_EHCI_XFER_H
28*7c478bd9Sstevel@tonic-gate #define	_SYS_USB_EHCI_XFER_H
29*7c478bd9Sstevel@tonic-gate 
30*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
31*7c478bd9Sstevel@tonic-gate 
32*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
33*7c478bd9Sstevel@tonic-gate extern "C" {
34*7c478bd9Sstevel@tonic-gate #endif
35*7c478bd9Sstevel@tonic-gate 
36*7c478bd9Sstevel@tonic-gate /*
37*7c478bd9Sstevel@tonic-gate  * Enchanced Host Controller Driver (EHCI)
38*7c478bd9Sstevel@tonic-gate  *
39*7c478bd9Sstevel@tonic-gate  * The EHCI driver is a software driver which interfaces to the Universal
40*7c478bd9Sstevel@tonic-gate  * Serial Bus layer (USBA) and the Host Controller (HC). The interface to
41*7c478bd9Sstevel@tonic-gate  * the Host Controller is defined by the EHCI Host Controller Interface.
42*7c478bd9Sstevel@tonic-gate  *
43*7c478bd9Sstevel@tonic-gate  * This header file describes the data structures and function prototypes
44*7c478bd9Sstevel@tonic-gate  * required for the EHCI Driver to perform different USB transfers.
45*7c478bd9Sstevel@tonic-gate  */
46*7c478bd9Sstevel@tonic-gate 
47*7c478bd9Sstevel@tonic-gate /* EHCI Queue Head (QH) related functions */
48*7c478bd9Sstevel@tonic-gate extern ehci_qh_t *ehci_alloc_qh(
49*7c478bd9Sstevel@tonic-gate 				ehci_state_t		*ehcip,
50*7c478bd9Sstevel@tonic-gate 				usba_pipe_handle_data_t	*ph,
51*7c478bd9Sstevel@tonic-gate 				uint_t			flag);
52*7c478bd9Sstevel@tonic-gate extern void	ehci_insert_qh(
53*7c478bd9Sstevel@tonic-gate 				ehci_state_t		*ehcip,
54*7c478bd9Sstevel@tonic-gate 				usba_pipe_handle_data_t	*ph);
55*7c478bd9Sstevel@tonic-gate extern void	ehci_remove_qh(
56*7c478bd9Sstevel@tonic-gate 				ehci_state_t		*ehcip,
57*7c478bd9Sstevel@tonic-gate 				ehci_pipe_private_t	*pp,
58*7c478bd9Sstevel@tonic-gate 				boolean_t		reclaim);
59*7c478bd9Sstevel@tonic-gate extern void	ehci_deallocate_qh(
60*7c478bd9Sstevel@tonic-gate 				ehci_state_t		*ehcip,
61*7c478bd9Sstevel@tonic-gate 				ehci_qh_t		*old_qh);
62*7c478bd9Sstevel@tonic-gate extern uint32_t	ehci_qh_cpu_to_iommu(
63*7c478bd9Sstevel@tonic-gate 				ehci_state_t		*ehcip,
64*7c478bd9Sstevel@tonic-gate 				ehci_qh_t		*addr);
65*7c478bd9Sstevel@tonic-gate extern ehci_qh_t *ehci_qh_iommu_to_cpu(
66*7c478bd9Sstevel@tonic-gate 				ehci_state_t		*ehcip,
67*7c478bd9Sstevel@tonic-gate 				uintptr_t		addr);
68*7c478bd9Sstevel@tonic-gate 
69*7c478bd9Sstevel@tonic-gate /* EHCI Queue Element Transfer Descriptor (QTD) related functions */
70*7c478bd9Sstevel@tonic-gate extern ehci_trans_wrapper_t *ehci_allocate_ctrl_resources(
71*7c478bd9Sstevel@tonic-gate 				ehci_state_t		*ehcip,
72*7c478bd9Sstevel@tonic-gate 				ehci_pipe_private_t	*pp,
73*7c478bd9Sstevel@tonic-gate 				usb_ctrl_req_t		*ctrl_reqp,
74*7c478bd9Sstevel@tonic-gate 				usb_flags_t		usb_flags);
75*7c478bd9Sstevel@tonic-gate extern void	ehci_insert_ctrl_req(
76*7c478bd9Sstevel@tonic-gate 				ehci_state_t		*ehcip,
77*7c478bd9Sstevel@tonic-gate 				usba_pipe_handle_data_t	*ph,
78*7c478bd9Sstevel@tonic-gate 				usb_ctrl_req_t		*ctrl_reqp,
79*7c478bd9Sstevel@tonic-gate 				ehci_trans_wrapper_t	*tw,
80*7c478bd9Sstevel@tonic-gate 				usb_flags_t		usb_flags);
81*7c478bd9Sstevel@tonic-gate extern ehci_trans_wrapper_t *ehci_allocate_bulk_resources(
82*7c478bd9Sstevel@tonic-gate 				ehci_state_t		*ehcip,
83*7c478bd9Sstevel@tonic-gate 				ehci_pipe_private_t	*pp,
84*7c478bd9Sstevel@tonic-gate 				usb_bulk_req_t		*bulk_reqp,
85*7c478bd9Sstevel@tonic-gate 				usb_flags_t		usb_flags);
86*7c478bd9Sstevel@tonic-gate extern void	ehci_insert_bulk_req(
87*7c478bd9Sstevel@tonic-gate 				ehci_state_t		*ehcip,
88*7c478bd9Sstevel@tonic-gate 				usba_pipe_handle_data_t	*ph,
89*7c478bd9Sstevel@tonic-gate 				usb_bulk_req_t		*bulk_reqp,
90*7c478bd9Sstevel@tonic-gate 				ehci_trans_wrapper_t	*tw,
91*7c478bd9Sstevel@tonic-gate 				usb_flags_t		flags);
92*7c478bd9Sstevel@tonic-gate extern int	ehci_start_periodic_pipe_polling(
93*7c478bd9Sstevel@tonic-gate 				ehci_state_t		*ehcip,
94*7c478bd9Sstevel@tonic-gate 				usba_pipe_handle_data_t	*ph,
95*7c478bd9Sstevel@tonic-gate 				usb_opaque_t		periodic_in_reqp,
96*7c478bd9Sstevel@tonic-gate 				usb_flags_t		flags);
97*7c478bd9Sstevel@tonic-gate extern ehci_trans_wrapper_t *ehci_allocate_intr_resources(
98*7c478bd9Sstevel@tonic-gate 				ehci_state_t		*ehcip,
99*7c478bd9Sstevel@tonic-gate 				usba_pipe_handle_data_t	*ph,
100*7c478bd9Sstevel@tonic-gate 				usb_intr_req_t		*intr_reqp,
101*7c478bd9Sstevel@tonic-gate 				usb_flags_t		usb_flags);
102*7c478bd9Sstevel@tonic-gate extern void	ehci_insert_intr_req(
103*7c478bd9Sstevel@tonic-gate 				ehci_state_t		*ehcip,
104*7c478bd9Sstevel@tonic-gate 				ehci_pipe_private_t	*pp,
105*7c478bd9Sstevel@tonic-gate 				ehci_trans_wrapper_t	*tw,
106*7c478bd9Sstevel@tonic-gate 				usb_flags_t		flags);
107*7c478bd9Sstevel@tonic-gate extern int	ehci_stop_periodic_pipe_polling(
108*7c478bd9Sstevel@tonic-gate 				ehci_state_t		*ehcip,
109*7c478bd9Sstevel@tonic-gate 				usba_pipe_handle_data_t	*ph,
110*7c478bd9Sstevel@tonic-gate 				usb_flags_t		flags);
111*7c478bd9Sstevel@tonic-gate extern int	ehci_insert_qtd(
112*7c478bd9Sstevel@tonic-gate 				ehci_state_t		*ehcip,
113*7c478bd9Sstevel@tonic-gate 				uint_t			qtd_ctrl,
114*7c478bd9Sstevel@tonic-gate 				uint32_t		qtd_iommu_cbp,
115*7c478bd9Sstevel@tonic-gate 				size_t			qtd_length,
116*7c478bd9Sstevel@tonic-gate 				uint32_t		qtd_flag,
117*7c478bd9Sstevel@tonic-gate 				ehci_pipe_private_t	*pp,
118*7c478bd9Sstevel@tonic-gate 				ehci_trans_wrapper_t	*tw);
119*7c478bd9Sstevel@tonic-gate extern void	ehci_remove_qtd_from_active_qtd_list(
120*7c478bd9Sstevel@tonic-gate 				ehci_state_t		*ehcip,
121*7c478bd9Sstevel@tonic-gate 				ehci_qtd_t		*curr_qtd);
122*7c478bd9Sstevel@tonic-gate extern void	ehci_deallocate_qtd(
123*7c478bd9Sstevel@tonic-gate 				ehci_state_t		*ehcip,
124*7c478bd9Sstevel@tonic-gate 				ehci_qtd_t		*old_qtd);
125*7c478bd9Sstevel@tonic-gate extern uint32_t	ehci_qtd_cpu_to_iommu(
126*7c478bd9Sstevel@tonic-gate 				ehci_state_t		*ehcip,
127*7c478bd9Sstevel@tonic-gate 				ehci_qtd_t		*addr);
128*7c478bd9Sstevel@tonic-gate extern ehci_qtd_t *ehci_qtd_iommu_to_cpu(
129*7c478bd9Sstevel@tonic-gate 				ehci_state_t		*ehcip,
130*7c478bd9Sstevel@tonic-gate 				uintptr_t		addr);
131*7c478bd9Sstevel@tonic-gate 
132*7c478bd9Sstevel@tonic-gate /* Transfer Wrapper (TW) functions */
133*7c478bd9Sstevel@tonic-gate extern int	ehci_allocate_tds_for_tw(
134*7c478bd9Sstevel@tonic-gate 				ehci_state_t		*ehcip,
135*7c478bd9Sstevel@tonic-gate 				ehci_pipe_private_t	*pp,
136*7c478bd9Sstevel@tonic-gate 				ehci_trans_wrapper_t	*tw,
137*7c478bd9Sstevel@tonic-gate 				size_t			qtd_count);
138*7c478bd9Sstevel@tonic-gate extern void	ehci_stop_xfer_timer(
139*7c478bd9Sstevel@tonic-gate 				ehci_state_t		*ehcip,
140*7c478bd9Sstevel@tonic-gate 				ehci_trans_wrapper_t	*tw,
141*7c478bd9Sstevel@tonic-gate 				uint_t			flag);
142*7c478bd9Sstevel@tonic-gate extern void	ehci_deallocate_tw(
143*7c478bd9Sstevel@tonic-gate 				ehci_state_t		*ehcip,
144*7c478bd9Sstevel@tonic-gate 				ehci_pipe_private_t	*pp,
145*7c478bd9Sstevel@tonic-gate 				ehci_trans_wrapper_t	*tw);
146*7c478bd9Sstevel@tonic-gate extern void	ehci_free_dma_resources(
147*7c478bd9Sstevel@tonic-gate 				ehci_state_t		*ehcip,
148*7c478bd9Sstevel@tonic-gate 				usba_pipe_handle_data_t	*ph);
149*7c478bd9Sstevel@tonic-gate 
150*7c478bd9Sstevel@tonic-gate /* Miscillaneous functions */
151*7c478bd9Sstevel@tonic-gate extern int	ehci_allocate_intr_in_resource(
152*7c478bd9Sstevel@tonic-gate 				ehci_state_t		*ehcip,
153*7c478bd9Sstevel@tonic-gate 				ehci_pipe_private_t	*pp,
154*7c478bd9Sstevel@tonic-gate 				ehci_trans_wrapper_t	*tw,
155*7c478bd9Sstevel@tonic-gate 				usb_flags_t		flags);
156*7c478bd9Sstevel@tonic-gate extern void	ehci_deallocate_intr_in_resource(
157*7c478bd9Sstevel@tonic-gate 				ehci_state_t		*ehcip,
158*7c478bd9Sstevel@tonic-gate 				ehci_pipe_private_t	*pp,
159*7c478bd9Sstevel@tonic-gate 				ehci_trans_wrapper_t	*tw);
160*7c478bd9Sstevel@tonic-gate extern void	ehci_pipe_cleanup(
161*7c478bd9Sstevel@tonic-gate 				ehci_state_t		*ehcip,
162*7c478bd9Sstevel@tonic-gate 				usba_pipe_handle_data_t	*ph);
163*7c478bd9Sstevel@tonic-gate extern void	ehci_check_for_transfers_completion(
164*7c478bd9Sstevel@tonic-gate 				ehci_state_t		*ehcip,
165*7c478bd9Sstevel@tonic-gate 				ehci_pipe_private_t	*pp);
166*7c478bd9Sstevel@tonic-gate extern void	ehci_restore_data_toggle(
167*7c478bd9Sstevel@tonic-gate 				ehci_state_t		*ehcip,
168*7c478bd9Sstevel@tonic-gate 				usba_pipe_handle_data_t	*ph);
169*7c478bd9Sstevel@tonic-gate extern void	ehci_handle_outstanding_requests(
170*7c478bd9Sstevel@tonic-gate 				ehci_state_t		*ehcip,
171*7c478bd9Sstevel@tonic-gate 				ehci_pipe_private_t	*pp);
172*7c478bd9Sstevel@tonic-gate extern void	ehci_do_client_periodic_in_req_callback(
173*7c478bd9Sstevel@tonic-gate 				ehci_state_t		*ehcip,
174*7c478bd9Sstevel@tonic-gate 				ehci_pipe_private_t	*pp,
175*7c478bd9Sstevel@tonic-gate 				usb_cr_t		completion_reason);
176*7c478bd9Sstevel@tonic-gate extern void	ehci_hcdi_callback(
177*7c478bd9Sstevel@tonic-gate 				usba_pipe_handle_data_t	*ph,
178*7c478bd9Sstevel@tonic-gate 				ehci_trans_wrapper_t	*tw,
179*7c478bd9Sstevel@tonic-gate 				usb_cr_t		completion_reason);
180*7c478bd9Sstevel@tonic-gate extern void	ehci_handle_clear_tt_buffer(
181*7c478bd9Sstevel@tonic-gate 				ehci_state_t		*ehcip,
182*7c478bd9Sstevel@tonic-gate 				ehci_pipe_private_t	*pp,
183*7c478bd9Sstevel@tonic-gate 				ehci_trans_wrapper_t	*tw,
184*7c478bd9Sstevel@tonic-gate 				ehci_qtd_t		*qtd,
185*7c478bd9Sstevel@tonic-gate 				void			*);
186*7c478bd9Sstevel@tonic-gate extern void	ehci_handle_clear_tt_buffer_error(
187*7c478bd9Sstevel@tonic-gate 				ehci_state_t		*ehcip,
188*7c478bd9Sstevel@tonic-gate 				ehci_pipe_private_t	*hub_pp,
189*7c478bd9Sstevel@tonic-gate 				ehci_trans_wrapper_t	*tw,
190*7c478bd9Sstevel@tonic-gate 				ehci_qtd_t		*qtd,
191*7c478bd9Sstevel@tonic-gate 				void			*,
192*7c478bd9Sstevel@tonic-gate 				usb_cr_t		error);
193*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus
194*7c478bd9Sstevel@tonic-gate }
195*7c478bd9Sstevel@tonic-gate #endif
196*7c478bd9Sstevel@tonic-gate 
197*7c478bd9Sstevel@tonic-gate #endif /* _SYS_USB_EHCI_XFER_H */
198