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