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