xref: /titanic_41/usr/src/uts/common/sys/usb/usba/usba10.h (revision c138f478d2bc94e73ab8f6a084e323bec25e62f5)
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_USBA10_H
28 #define	_SYS_USB_USBA10_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 /*
37  * **************************************************************************
38  * The following was static in usbai.c, until the usba10 module needed it.
39  * **************************************************************************
40  */
41 
42 int usba_vlog(usb_log_handle_t, uint_t, uint_t, char *, va_list);
43 
44 /*
45  * **************************************************************************
46  * Defs needed only for usba10_calls module.
47  * **************************************************************************
48  */
49 
50 usb_ep_data_t *
51 usb_get_ep_data(
52 	dev_info_t		*dip,
53 	usb_client_dev_data_t	*dev_datap,
54 	uint_t			interface,
55 	uint_t			alternate,
56 	uint_t			type,
57 	uint_t			direction);
58 
59 int
60 usb_ep_num(usb_pipe_handle_t ph);
61 
62 int
63 usb_clear_feature(
64 	dev_info_t		*dip,
65 	usb_pipe_handle_t	ph,
66 	uint_t			type,	/* bmRequestType */
67 	uint_t			feature,
68 	uint_t			what,	/* 0, interface, endpoint number */
69 	usb_flags_t		flags);
70 
71 int
72 usb_pipe_bulk_transfer_size(
73 	dev_info_t		*dip,
74 	size_t			*size);
75 
76 uint_t
77 usb_get_max_isoc_pkts(dev_info_t *dip);
78 
79 int
80 usb_is_pm_enabled(dev_info_t *dip);
81 
82 int
83 usb_log_descr_tree(
84 	usb_client_dev_data_t	*dev_data,
85 	usb_log_handle_t	log_handle,
86 	uint_t			level,
87 	uint_t			mask);
88 
89 int usb_register_client(
90 	dev_info_t			*dip,
91 	uint_t				version,
92 	usb_client_dev_data_t		**dev_data,
93 	usb_reg_parse_lvl_t		parse_level,
94 	usb_flags_t			flags);
95 
96 void usb_unregister_client(
97 	dev_info_t			*dip,
98 	usb_client_dev_data_t		*dev_data);
99 
100 /* allocate a log handle */
101 usb_log_handle_t usb_alloc_log_handle(
102 	dev_info_t	*dip,
103 	char		*name,
104 	uint_t		*errlevel,
105 	uint_t		*mask,
106 	uint_t		*instance_filter,
107 	uint_t		reserved,
108 	usb_flags_t	flags);
109 
110 
111 /* free the log handle */
112 void usb_free_log_handle(
113 	usb_log_handle_t handle);
114 
115 /*
116  * **************************************************************************
117  * Remaining functions are declarations for wrapper functions exported to
118  * legacy drivers.
119  * **************************************************************************
120  */
121 
122 
123 int
124 usba10_usb_register_client(
125 	dev_info_t			*dip,
126 	uint_t				version,
127 	usb_client_dev_data_t		**dev_data,
128 	usb_reg_parse_lvl_t		parse_level,
129 	usb_flags_t			flags);
130 
131 void
132 usba10_usb_unregister_client(
133 	dev_info_t			*dip,
134 	usb_client_dev_data_t		*dev_data);
135 
136 void
137 usba10_usb_free_descr_tree(
138 	dev_info_t			*dip,
139 	usb_client_dev_data_t		*dev_data);
140 
141 size_t
142 usba10_usb_parse_data(
143 	char			*format,
144 	uchar_t 		*data,
145 	size_t			datalen,
146 	void			*structure,
147 	size_t			structlen);
148 
149 usb_ep_data_t *
150 usba10_usb_get_ep_data(
151 	dev_info_t		*dip,
152 	usb_client_dev_data_t	*dev_datap,
153 	uint_t			interface,
154 	uint_t			alternate,
155 	uint_t			type,
156 	uint_t			direction);
157 
158 int
159 usba10_usb_get_string_descr(
160 	dev_info_t		*dip,
161 	uint16_t		langid,
162 	uint8_t			index,
163 	char			*buf,
164 	size_t			buflen);
165 
166 int
167 usba10_usb_get_addr(dev_info_t *dip);
168 
169 int
170 usba10_usb_get_if_number(dev_info_t *dip);
171 
172 boolean_t
173 usba10_usb_owns_device(dev_info_t *dip);
174 
175 int
176 usba10_usb_pipe_get_state(
177 	usb_pipe_handle_t	pipe_handle,
178 	usb_pipe_state_t	*pipe_state,
179 	usb_flags_t		flags);
180 
181 int
182 usba10_usb_ep_num(usb_pipe_handle_t ph);
183 
184 int
185 usba10_usb_pipe_open(
186 	dev_info_t		*dip,
187 	usb_ep_descr_t		*ep,
188 	usb_pipe_policy_t	*pipe_policy,
189 	usb_flags_t		flags,
190 	usb_pipe_handle_t	*pipe_handle);
191 
192 void
193 usba10_usb_pipe_close(
194 	dev_info_t		*dip,
195 	usb_pipe_handle_t	pipe_handle,
196 	usb_flags_t		flags,
197 	void			(*cb)(
198 				    usb_pipe_handle_t	ph,
199 				    usb_opaque_t	arg,	/* cb arg */
200 				    int			rval,
201 				    usb_cb_flags_t	flags),
202 	usb_opaque_t		cb_arg);
203 
204 int
205 usba10_usb_pipe_drain_reqs(
206 	dev_info_t		*dip,
207 	usb_pipe_handle_t	pipe_handle,
208 	uint_t			time,
209 	usb_flags_t		flags,
210 	void			(*cb)(
211 				    usb_pipe_handle_t	ph,
212 				    usb_opaque_t	arg,	/* cb arg */
213 				    int			rval,
214 				    usb_cb_flags_t	flags),
215 	usb_opaque_t		cb_arg);
216 
217 int
218 usba10_usb_pipe_set_private(
219 	usb_pipe_handle_t	pipe_handle,
220 	usb_opaque_t		data);
221 
222 usb_opaque_t
223 usba10_usb_pipe_get_private(usb_pipe_handle_t pipe_handle);
224 
225 void
226 usba10_usb_pipe_reset(
227 	dev_info_t		*dip,
228 	usb_pipe_handle_t	pipe_handle,
229 	usb_flags_t		usb_flags,
230 	void			(*cb)(
231 					usb_pipe_handle_t ph,
232 					usb_opaque_t	arg,
233 					int		rval,
234 					usb_cb_flags_t	flags),
235 	usb_opaque_t		cb_arg);
236 
237 usb_ctrl_req_t *
238 usba10_usb_alloc_ctrl_req(
239 	dev_info_t		*dip,
240 	size_t			len,
241 	usb_flags_t		flags);
242 
243 void
244 usba10_usb_free_ctrl_req(usb_ctrl_req_t *reqp);
245 
246 int
247 usba10_usb_pipe_ctrl_xfer(
248 	usb_pipe_handle_t	pipe_handle,
249 	usb_ctrl_req_t		*reqp,
250 	usb_flags_t		flags);
251 
252 int
253 usba10_usb_get_status(
254 	dev_info_t		*dip,
255 	usb_pipe_handle_t	ph,
256 	uint_t			type,	/* bmRequestType */
257 	uint_t			what,	/* 0, interface, endpoint number */
258 	uint16_t		*status,
259 	usb_flags_t		flags);
260 
261 int
262 usba10_usb_clear_feature(
263 	dev_info_t		*dip,
264 	usb_pipe_handle_t	ph,
265 	uint_t			type,	/* bmRequestType */
266 	uint_t			feature,
267 	uint_t			what,	/* 0, interface, endpoint number */
268 	usb_flags_t		flags);
269 
270 int
271 usba10_usb_pipe_ctrl_xfer_wait(
272 	usb_pipe_handle_t	pipe_handle,
273 	usb_ctrl_setup_t	*setup,
274 	mblk_t			**data,
275 	usb_cr_t		*completion_reason,
276 	usb_cb_flags_t		*cb_flags,
277 	usb_flags_t		flags);
278 
279 int
280 usba10_usb_set_cfg(
281 	dev_info_t		*dip,
282 	uint_t			cfg_index,
283 	usb_flags_t		usb_flags,
284 	void			(*cb)(
285 					usb_pipe_handle_t ph,
286 					usb_opaque_t	arg,
287 					int		rval,
288 					usb_cb_flags_t	flags),
289 	usb_opaque_t		cb_arg);
290 
291 int
292 usba10_usb_get_cfg(
293 	dev_info_t		*dip,
294 	uint_t			*cfgval,
295 	usb_flags_t		usb_flags);
296 
297 int
298 usba10_usb_set_alt_if(
299 	dev_info_t		*dip,
300 	uint_t			interface,
301 	uint_t			alt_number,
302 	usb_flags_t		usb_flags,
303 	void			(*cb)(
304 					usb_pipe_handle_t ph,
305 					usb_opaque_t	arg,
306 					int		rval,
307 					usb_cb_flags_t	flags),
308 	usb_opaque_t		cb_arg);
309 
310 int
311 usba10_usb_get_alt_if(
312 	dev_info_t		*dip,
313 	uint_t			if_number,
314 	uint_t			*alt_number,
315 	usb_flags_t		flags);
316 
317 usb_bulk_req_t *
318 usba10_usb_alloc_bulk_req(
319 	dev_info_t		*dip,
320 	size_t			len,
321 	usb_flags_t		flags);
322 
323 void
324 usba10_usb_free_bulk_req(usb_bulk_req_t *reqp);
325 
326 int
327 usba10_usb_pipe_bulk_xfer(
328 	usb_pipe_handle_t	pipe_handle,
329 	usb_bulk_req_t		*reqp,
330 	usb_flags_t		flags);
331 
332 int
333 usba10_usb_pipe_bulk_transfer_size(
334 	dev_info_t		*dip,
335 	size_t			*size);
336 
337 usb_intr_req_t *
338 usba10_usb_alloc_intr_req(
339 	dev_info_t		*dip,
340 	size_t			len,
341 	usb_flags_t		flags);
342 
343 void
344 usba10_usb_free_intr_req(usb_intr_req_t *reqp);
345 
346 int
347 usba10_usb_pipe_intr_xfer(
348 	usb_pipe_handle_t	pipe_handle,
349 	usb_intr_req_t		*req,
350 	usb_flags_t		flags);
351 
352 void
353 usba10_usb_pipe_stop_intr_polling(
354 	usb_pipe_handle_t	pipe_handle,
355 	usb_flags_t		flags);
356 
357 usb_isoc_req_t *
358 usba10_usb_alloc_isoc_req(
359 	dev_info_t		*dip,
360 	uint_t			isoc_pkts_count,
361 	size_t			len,
362 	usb_flags_t		flags);
363 
364 void
365 usba10_usb_free_isoc_req(usb_isoc_req_t *usb_isoc_req);
366 
367 usb_frame_number_t
368 usba10_usb_get_current_frame_number(dev_info_t	*dip);
369 
370 uint_t
371 usba10_usb_get_max_isoc_pkts(dev_info_t *dip);
372 
373 int
374 usba10_usb_pipe_isoc_xfer(
375 	usb_pipe_handle_t	pipe_handle,
376 	usb_isoc_req_t		*reqp,
377 	usb_flags_t		flags);
378 
379 void
380 usba10_usb_pipe_stop_isoc_polling(
381 	usb_pipe_handle_t	pipe_handle,
382 	usb_flags_t		flags);
383 
384 int
385 usba10_usb_req_raise_power(
386 	dev_info_t	*dip,
387 	int		comp,
388 	int		level,
389 	void		(*cb)(void *arg, int rval),
390 	void		*arg,
391 	usb_flags_t	flags);
392 
393 int
394 usba10_usb_req_lower_power(
395 	dev_info_t	*dip,
396 	int		comp,
397 	int		level,
398 	void		(*cb)(void *arg, int rval),
399 	void		*arg,
400 	usb_flags_t	flags);
401 
402 int
403 usba10_usb_is_pm_enabled(dev_info_t *dip);
404 
405 int
406 usba10_usb_handle_remote_wakeup(
407 	dev_info_t	*dip,
408 	int		cmd);
409 
410 int
411 usba10_usb_create_pm_components(
412 	dev_info_t	*dip,
413 	uint_t		*pwrstates);
414 
415 int
416 usba10_usb_set_device_pwrlvl0(dev_info_t *dip);
417 
418 int
419 usba10_usb_set_device_pwrlvl1(dev_info_t *dip);
420 
421 int
422 usba10_usb_set_device_pwrlvl2(dev_info_t *dip);
423 
424 int
425 usba10_usb_set_device_pwrlvl3(dev_info_t *dip);
426 
427 int
428 usba10_usb_async_req(
429 	dev_info_t	*dip,
430 	void		(*func)(void *),
431 	void		*arg,
432 	usb_flags_t	flag);
433 
434 int
435 usba10_usb_register_event_cbs(
436 	dev_info_t	*dip,
437 	usb_event_t	*usb_evt_data,
438 	usb_flags_t	flags);
439 
440 void
441 usba10_usb_unregister_event_cbs(
442 	dev_info_t	*dip,
443 	usb_event_t	*usb_evt_data);
444 
445 void
446 usba10_usb_fail_checkpoint(
447 	dev_info_t	*dip,
448 	usb_flags_t	flags);
449 
450 usb_log_handle_t
451 usba10_usb_alloc_log_handle(
452 	dev_info_t	*dip,
453 	char		*name,
454 	uint_t		*errlevel,
455 	uint_t		*mask,
456 	uint_t		*instance_filter,
457 	uint_t		show_label,
458 	usb_flags_t	flags);
459 
460 int
461 usba10_usba_vlog(
462 	usb_log_handle_t handle,
463 	uint_t		level,
464 	uint_t		mask,
465 	char		*fmt,
466 	va_list		ap);
467 
468 void
469 usba10_usb_free_log_handle(usb_log_handle_t handle);
470 
471 int
472 usba10_usb_log_descr_tree(
473 	usb_client_dev_data_t	*dev_data,
474 	usb_log_handle_t	log_handle,
475 	uint_t			level,
476 	uint_t			mask);
477 
478 int
479 usba10_usb_print_descr_tree(
480 	dev_info_t		*dip,
481 	usb_client_dev_data_t	*dev_data);
482 
483 int
484 usba10_usb_check_same_device(
485 	dev_info_t		*dip,
486 	usb_log_handle_t	log_handle,
487 	int			log_level,
488 	int			log_mask,
489 	uint_t			check_mask,
490 	char			*device_string);
491 
492 const char *
493 usba10_usb_str_cr(usb_cr_t cr);
494 
495 char *
496 usba10_usb_str_cb_flags(
497 	usb_cb_flags_t cb_flags,
498 	char *buffer,
499 	size_t length);
500 
501 const char *
502 usba10_usb_str_pipe_state(usb_pipe_state_t state);
503 
504 const char *
505 usba10_usb_str_dev_state(int state);
506 
507 const char *
508 usba10_usb_str_rval(int rval);
509 
510 int
511 usba10_usb_rval2errno(int rval);
512 
513 usb_serialization_t
514 usba10_usb_init_serialization(
515 	dev_info_t	*s_dip,
516 	uint_t		flag);
517 
518 void
519 usba10_usb_fini_serialization(usb_serialization_t usb_serp);
520 
521 int
522 usba10_usb_serialize_access(
523 	usb_serialization_t	usb_serp,
524 	uint_t			how_to_wait,
525 	uint_t			delta_timeout);
526 
527 int
528 usba10_usb_try_serialize_access(
529 	usb_serialization_t usb_serp,
530 	uint_t flag);
531 
532 void
533 usba10_usb_release_access(usb_serialization_t usb_serp);
534 
535 #ifdef __cplusplus
536 }
537 #endif
538 
539 #endif /* _SYS_USB_USBA10_H */
540