xref: /illumos-gate/usr/src/uts/common/io/usb/usba/usba10_calls.c (revision c3937c08b16d32677a7dc955a81325f2e7a61b5d)
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 
28 /*
29  * Bridge module containing functions with different names than those in the
30  * usba10 module, so the usba10 module can call functions in this (usba) module.
31  *
32  * The usba10 module is present to satisfy a runtime loader dependency for
33  * legacy DDK drivers (V0.8).  The usba10 module calls functions in this (usba)
34  * module to carry out driver requests.
35  *
36  * The intent is that this file disappear once krtld functionality is improved
37  * so that drivers dependent on usba10 can call into usba without these wrapper
38  * functions.
39  *
40  * Please see the on81-patch gate usr/src/uts/common/sys/usba10/usba10_usbai.h
41  * header file for descriptions and comments for these functions.
42  */
43 
44 #include <sys/usb/usba.h>
45 #include <sys/usb/usba/usbai_private.h>
46 #include <sys/usb/usba/usba10.h>
47 
48 #ifndef __lock_lint
49 
50 int
51 usba10_usb_register_client(
52 	dev_info_t			*dip,
53 	uint_t				version,
54 	usb_client_dev_data_t		**dev_data,
55 	usb_reg_parse_lvl_t		parse_level,
56 	usb_flags_t			flags)
57 {
58 	return (usb_register_client(
59 	    dip, version, dev_data, parse_level, flags));
60 }
61 
62 
63 void
64 usba10_usb_unregister_client(
65 	dev_info_t			*dip,
66 	usb_client_dev_data_t		*dev_data)
67 {
68 	usb_unregister_client(dip, dev_data);
69 }
70 
71 
72 void
73 usba10_usb_free_descr_tree(
74 	dev_info_t			*dip,
75 	usb_client_dev_data_t		*dev_data)
76 {
77 	usb_free_descr_tree(dip, dev_data);
78 }
79 
80 
81 size_t
82 usba10_usb_parse_data(
83 	char			*format,
84 	const uchar_t 		*data,
85 	size_t			datalen,
86 	void			*structure,
87 	size_t			structlen)
88 {
89 	return (usb_parse_data(
90 	    format, data, datalen, structure, structlen));
91 }
92 
93 usb_ep_data_t *
94 usba10_usb_get_ep_data(
95 	dev_info_t		*dip,
96 	usb_client_dev_data_t	*dev_datap,
97 	uint_t			interface,
98 	uint_t			alternate,
99 	uint_t			type,
100 	uint_t			direction)
101 {
102 	return (usb_get_ep_data(
103 	    dip, dev_datap, interface, alternate, type, direction));
104 }
105 
106 
107 int
108 usba10_usb_get_string_descr(
109 	dev_info_t		*dip,
110 	uint16_t		langid,
111 	uint8_t			index,
112 	char			*buf,
113 	size_t			buflen)
114 {
115 	return (usb_get_string_descr(dip, langid, index, buf, buflen));
116 }
117 
118 
119 int
120 usba10_usb_get_addr(dev_info_t *dip)
121 {
122 	return (usb_get_addr(dip));
123 }
124 
125 
126 int
127 usba10_usb_get_if_number(dev_info_t *dip)
128 {
129 	return (usb_get_if_number(dip));
130 }
131 
132 
133 boolean_t
134 usba10_usb_owns_device(dev_info_t *dip)
135 {
136 	return (usb_owns_device(dip));
137 }
138 
139 
140 int
141 usba10_usb_pipe_get_state(
142 	usb_pipe_handle_t	pipe_handle,
143 	usb_pipe_state_t	*pipe_state,
144 	usb_flags_t		flags)
145 {
146 	return (usb_pipe_get_state(pipe_handle, pipe_state, flags));
147 }
148 
149 
150 int
151 usba10_usb_ep_num(usb_pipe_handle_t ph)
152 {
153 	return (usb_ep_num(ph));
154 }
155 
156 
157 int
158 usba10_usb_pipe_open(
159 	dev_info_t		*dip,
160 	usb_ep_descr_t		*ep,
161 	usb_pipe_policy_t	*pipe_policy,
162 	usb_flags_t		flags,
163 	usb_pipe_handle_t	*pipe_handle)
164 {
165 	return (usb_pipe_open(dip, ep, pipe_policy, flags, pipe_handle));
166 }
167 
168 
169 void
170 usba10_usb_pipe_close(
171 	dev_info_t		*dip,
172 	usb_pipe_handle_t	pipe_handle,
173 	usb_flags_t		flags,
174 	void			(*cb)(
175 				    usb_pipe_handle_t	ph,
176 				    usb_opaque_t	arg,	/* cb arg */
177 				    int			rval,
178 				    usb_cb_flags_t	flags),
179 	usb_opaque_t		cb_arg)
180 {
181 	usb_pipe_close(dip, pipe_handle, flags, cb, cb_arg);
182 }
183 
184 
185 int
186 usba10_usb_pipe_drain_reqs(
187 	dev_info_t		*dip,
188 	usb_pipe_handle_t	pipe_handle,
189 	uint_t			time,
190 	usb_flags_t		flags,
191 	void			(*cb)(
192 				    usb_pipe_handle_t	ph,
193 				    usb_opaque_t	arg,	/* cb arg */
194 				    int			rval,
195 				    usb_cb_flags_t	flags),
196 	usb_opaque_t		cb_arg)
197 {
198 	return (usb_pipe_drain_reqs(
199 	    dip, pipe_handle, time, flags, cb, cb_arg));
200 }
201 
202 
203 int
204 usba10_usb_pipe_set_private(
205 	usb_pipe_handle_t	pipe_handle,
206 	usb_opaque_t		data)
207 {
208 	return (usb_pipe_set_private(pipe_handle, data));
209 }
210 
211 
212 usb_opaque_t
213 usba10_usb_pipe_get_private(usb_pipe_handle_t pipe_handle)
214 {
215 	return (usb_pipe_get_private(pipe_handle));
216 }
217 
218 
219 void
220 usba10_usb_pipe_reset(
221 	dev_info_t		*dip,
222 	usb_pipe_handle_t	pipe_handle,
223 	usb_flags_t		usb_flags,
224 	void			(*cb)(
225 					usb_pipe_handle_t ph,
226 					usb_opaque_t	arg,
227 					int		rval,
228 					usb_cb_flags_t	flags),
229 	usb_opaque_t		cb_arg)
230 {
231 	usb_pipe_reset(dip, pipe_handle, usb_flags, cb, cb_arg);
232 }
233 
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 	return (usb_alloc_ctrl_req(dip, len, flags));
242 }
243 
244 
245 void
246 usba10_usb_free_ctrl_req(usb_ctrl_req_t *reqp)
247 {
248 	usb_free_ctrl_req(reqp);
249 }
250 
251 
252 int
253 usba10_usb_pipe_ctrl_xfer(
254 	usb_pipe_handle_t	pipe_handle,
255 	usb_ctrl_req_t		*reqp,
256 	usb_flags_t		flags)
257 {
258 	return (usb_pipe_ctrl_xfer(pipe_handle, reqp, flags));
259 }
260 
261 
262 int
263 usba10_usb_get_status(
264 	dev_info_t		*dip,
265 	usb_pipe_handle_t	ph,
266 	uint_t			type,	/* bmRequestType */
267 	uint_t			what,	/* 0, interface, endpoint number */
268 	uint16_t		*status,
269 	usb_flags_t		flags)
270 {
271 	return (usb_get_status(dip, ph, type, what, status, flags));
272 }
273 
274 
275 int
276 usba10_usb_clear_feature(
277 	dev_info_t		*dip,
278 	usb_pipe_handle_t	ph,
279 	uint_t			type,	/* bmRequestType */
280 	uint_t			feature,
281 	uint_t			what,	/* 0, interface, endpoint number */
282 	usb_flags_t		flags)
283 {
284 	return (usb_clear_feature(dip, ph, type, feature, what, flags));
285 }
286 
287 
288 int
289 usba10_usb_pipe_ctrl_xfer_wait(
290 	usb_pipe_handle_t	pipe_handle,
291 	usb_ctrl_setup_t	*setup,
292 	mblk_t			**data,
293 	usb_cr_t		*completion_reason,
294 	usb_cb_flags_t		*cb_flags,
295 	usb_flags_t		flags)
296 {
297 	return (usb_pipe_ctrl_xfer_wait(
298 	    pipe_handle, setup, data, completion_reason, cb_flags, flags));
299 }
300 
301 
302 int
303 usba10_usb_set_cfg(
304 	dev_info_t		*dip,
305 	uint_t			cfg_index,
306 	usb_flags_t		usb_flags,
307 	void			(*cb)(
308 					usb_pipe_handle_t ph,
309 					usb_opaque_t	arg,
310 					int		rval,
311 					usb_cb_flags_t	flags),
312 	usb_opaque_t		cb_arg)
313 {
314 	return (usb_set_cfg(dip, cfg_index, usb_flags, cb, cb_arg));
315 }
316 
317 
318 int
319 usba10_usb_get_cfg(
320 	dev_info_t		*dip,
321 	uint_t			*cfgval,
322 	usb_flags_t		usb_flags)
323 {
324 	return (usb_get_cfg(dip, cfgval, usb_flags));
325 }
326 
327 
328 int
329 usba10_usb_set_alt_if(
330 	dev_info_t		*dip,
331 	uint_t			interface,
332 	uint_t			alt_number,
333 	usb_flags_t		usb_flags,
334 	void			(*cb)(
335 					usb_pipe_handle_t ph,
336 					usb_opaque_t	arg,
337 					int		rval,
338 					usb_cb_flags_t	flags),
339 	usb_opaque_t		cb_arg)
340 {
341 	return (usb_set_alt_if(
342 	    dip, interface, alt_number, usb_flags, cb, cb_arg));
343 }
344 
345 
346 int
347 usba10_usb_get_alt_if(
348 	dev_info_t		*dip,
349 	uint_t			if_number,
350 	uint_t			*alt_number,
351 	usb_flags_t		flags)
352 {
353 	return (usb_get_alt_if(dip, if_number, alt_number, flags));
354 }
355 
356 
357 usb_bulk_req_t *
358 usba10_usb_alloc_bulk_req(
359 	dev_info_t		*dip,
360 	size_t			len,
361 	usb_flags_t		flags)
362 {
363 	return (usb_alloc_bulk_req(dip, len, flags));
364 }
365 
366 
367 void
368 usba10_usb_free_bulk_req(usb_bulk_req_t *reqp)
369 {
370 	usb_free_bulk_req(reqp);
371 }
372 
373 
374 int
375 usba10_usb_pipe_bulk_xfer(
376 	usb_pipe_handle_t	pipe_handle,
377 	usb_bulk_req_t		*reqp,
378 	usb_flags_t		flags)
379 {
380 	return (usb_pipe_bulk_xfer(pipe_handle, reqp, flags));
381 }
382 
383 
384 int
385 usba10_usb_pipe_bulk_transfer_size(
386 	dev_info_t		*dip,
387 	size_t			*size)
388 {
389 	return (usb_pipe_bulk_transfer_size(dip, size));
390 }
391 
392 
393 usb_intr_req_t *
394 usba10_usb_alloc_intr_req(
395 	dev_info_t		*dip,
396 	size_t			len,
397 	usb_flags_t		flags)
398 {
399 	return (usb_alloc_intr_req(dip, len, flags));
400 }
401 
402 
403 void
404 usba10_usb_free_intr_req(usb_intr_req_t *reqp)
405 {
406 	usb_free_intr_req(reqp);
407 }
408 
409 
410 int
411 usba10_usb_pipe_intr_xfer(
412 	usb_pipe_handle_t	pipe_handle,
413 	usb_intr_req_t		*req,
414 	usb_flags_t		flags)
415 {
416 	return (usb_pipe_intr_xfer(pipe_handle, req, flags));
417 }
418 
419 
420 void
421 usba10_usb_pipe_stop_intr_polling(
422 	usb_pipe_handle_t	pipe_handle,
423 	usb_flags_t		flags)
424 {
425 	usb_pipe_stop_intr_polling(pipe_handle, flags);
426 }
427 
428 
429 usb_isoc_req_t *
430 usba10_usb_alloc_isoc_req(
431 	dev_info_t		*dip,
432 	uint_t			isoc_pkts_count,
433 	size_t			len,
434 	usb_flags_t		flags)
435 {
436 	return (usb_alloc_isoc_req(dip, isoc_pkts_count, len, flags));
437 }
438 
439 
440 void
441 usba10_usb_free_isoc_req(usb_isoc_req_t *usb_isoc_req)
442 {
443 	usb_free_isoc_req(usb_isoc_req);
444 }
445 
446 
447 usb_frame_number_t
448 usba10_usb_get_current_frame_number(dev_info_t	*dip)
449 {
450 	return (usb_get_current_frame_number(dip));
451 }
452 
453 
454 uint_t
455 usba10_usb_get_max_isoc_pkts(dev_info_t *dip)
456 {
457 	return (usb_get_max_isoc_pkts(dip));
458 }
459 
460 
461 int
462 usba10_usb_pipe_isoc_xfer(
463 	usb_pipe_handle_t	pipe_handle,
464 	usb_isoc_req_t		*reqp,
465 	usb_flags_t		flags)
466 {
467 	return (usb_pipe_isoc_xfer(pipe_handle, reqp, flags));
468 }
469 
470 
471 void
472 usba10_usb_pipe_stop_isoc_polling(
473 	usb_pipe_handle_t	pipe_handle,
474 	usb_flags_t		flags)
475 {
476 	usb_pipe_stop_isoc_polling(pipe_handle, flags);
477 }
478 
479 
480 int
481 usba10_usb_req_raise_power(
482 	dev_info_t	*dip,
483 	int		comp,
484 	int		level,
485 	void		(*cb)(void *arg, int rval),
486 	void		*arg,
487 	usb_flags_t	flags)
488 {
489 	return (usb_req_raise_power(dip, comp, level, cb, arg, flags));
490 }
491 
492 
493 int
494 usba10_usb_req_lower_power(
495 	dev_info_t	*dip,
496 	int		comp,
497 	int		level,
498 	void		(*cb)(void *arg, int rval),
499 	void		*arg,
500 	usb_flags_t	flags)
501 {
502 	return (usb_req_raise_power(dip, comp, level, cb, arg, flags));
503 }
504 
505 
506 int
507 usba10_usb_is_pm_enabled(dev_info_t *dip)
508 {
509 	return (usb_is_pm_enabled(dip));
510 }
511 
512 int
513 usba10_usb_handle_remote_wakeup(
514 	dev_info_t	*dip,
515 	int		cmd)
516 {
517 	return (usb_handle_remote_wakeup(dip, cmd));
518 }
519 
520 
521 int
522 usba10_usb_create_pm_components(
523 	dev_info_t	*dip,
524 	uint_t		*pwrstates)
525 {
526 	return (usb_create_pm_components(dip, pwrstates));
527 }
528 
529 
530 int
531 usba10_usb_set_device_pwrlvl0(dev_info_t *dip)
532 {
533 	return (usb_set_device_pwrlvl0(dip));
534 }
535 
536 
537 int
538 usba10_usb_set_device_pwrlvl1(dev_info_t *dip)
539 {
540 	return (usb_set_device_pwrlvl1(dip));
541 }
542 
543 
544 int
545 usba10_usb_set_device_pwrlvl2(dev_info_t *dip)
546 {
547 	return (usb_set_device_pwrlvl2(dip));
548 }
549 
550 
551 int
552 usba10_usb_set_device_pwrlvl3(dev_info_t *dip)
553 {
554 	return (usb_set_device_pwrlvl3(dip));
555 }
556 
557 
558 int
559 usba10_usb_async_req(
560 	dev_info_t	*dip,
561 	void		(*func)(void *),
562 	void		*arg,
563 	usb_flags_t	flag)
564 {
565 	return (usb_async_req(dip, func, arg, flag));
566 }
567 
568 
569 int
570 usba10_usb_register_event_cbs(
571 	dev_info_t	*dip,
572 	usb_event_t	*usb_evt_data,
573 	usb_flags_t	flags)
574 {
575 	return (usb_register_event_cbs(dip, usb_evt_data, flags));
576 }
577 
578 
579 void
580 usba10_usb_unregister_event_cbs(
581 	dev_info_t	*dip,
582 	usb_event_t	*usb_evt_data)
583 {
584 	usb_unregister_event_cbs(dip, usb_evt_data);
585 }
586 
587 
588 void
589 usba10_usb_fail_checkpoint(
590 	dev_info_t	*dip,
591 	usb_flags_t	flags)
592 {
593 	usb_fail_checkpoint(dip, flags);
594 }
595 
596 
597 int
598 usba10_usba_vlog(
599 	usb_log_handle_t	handle,
600 	uint_t			level,
601 	uint_t			mask,
602 	char			*fmt,
603 	va_list			ap)
604 {
605 	return (usba_vlog(handle, level, mask, fmt, ap));
606 }
607 
608 
609 usb_log_handle_t
610 usba10_usb_alloc_log_handle(
611 	dev_info_t	*dip,
612 	char		*name,
613 	uint_t		*errlevel,
614 	uint_t		*mask,
615 	uint_t		*instance_filter,
616 	uint_t		show_label,
617 	usb_flags_t	flags)
618 {
619 	return (usb_alloc_log_handle(
620 	    dip, name, errlevel, mask, instance_filter, show_label, flags));
621 }
622 
623 
624 void
625 usba10_usb_free_log_handle(usb_log_handle_t handle)
626 {
627 	usb_free_log_handle(handle);
628 }
629 
630 
631 int
632 usba10_usb_log_descr_tree(
633 	usb_client_dev_data_t	*dev_data,
634 	usb_log_handle_t	log_handle,
635 	uint_t			level,
636 	uint_t			mask)
637 {
638 	return (usb_log_descr_tree(dev_data, log_handle, level, mask));
639 }
640 
641 
642 int
643 usba10_usb_print_descr_tree(
644 	dev_info_t		*dip,
645 	usb_client_dev_data_t	*dev_data)
646 {
647 	return (usb_print_descr_tree(dip, dev_data));
648 }
649 
650 
651 int
652 usba10_usb_check_same_device(
653 	dev_info_t		*dip,
654 	usb_log_handle_t	log_handle,
655 	int			log_level,
656 	int			log_mask,
657 	uint_t			check_mask,
658 	char			*device_string)
659 {
660 	return (usb_check_same_device(
661 	    dip, log_handle, log_level, log_mask, check_mask, device_string));
662 }
663 
664 
665 const char *
666 usba10_usb_str_cr(usb_cr_t cr)
667 {
668 	return (usb_str_cr(cr));
669 }
670 
671 
672 char *
673 usba10_usb_str_cb_flags(
674 	usb_cb_flags_t cb_flags,
675 	char *buffer,
676 	size_t length)
677 {
678 	return (usb_str_cb_flags(cb_flags, buffer, length));
679 }
680 
681 
682 const char *
683 usba10_usb_str_pipe_state(usb_pipe_state_t state)
684 {
685 	return (usb_str_pipe_state(state));
686 }
687 
688 
689 const char *
690 usba10_usb_str_dev_state(int state)
691 {
692 	return (usb_str_dev_state(state));
693 }
694 
695 
696 const char *
697 usba10_usb_str_rval(int rval)
698 {
699 	return (usb_str_rval(rval));
700 }
701 
702 
703 int
704 usba10_usb_rval2errno(int rval)
705 {
706 	return (usb_rval2errno(rval));
707 }
708 
709 
710 usb_serialization_t
711 usba10_usb_init_serialization(
712 	dev_info_t	*s_dip,
713 	uint_t		flag)
714 {
715 	return (usb_init_serialization(s_dip, flag));
716 }
717 
718 
719 void
720 usba10_usb_fini_serialization(usb_serialization_t usb_serp)
721 {
722 	usb_fini_serialization(usb_serp);
723 }
724 
725 
726 int
727 usba10_usb_serialize_access(
728 	usb_serialization_t	usb_serp,
729 	uint_t			how_to_wait,
730 	uint_t			delta_timeout)
731 {
732 	return (usb_serialize_access(
733 	    usb_serp, how_to_wait, delta_timeout));
734 }
735 
736 
737 int
738 usba10_usb_try_serialize_access(
739 	usb_serialization_t usb_serp,
740 	uint_t flag)
741 {
742 	return (usb_try_serialize_access(usb_serp, flag));
743 }
744 
745 
746 void
747 usba10_usb_release_access(usb_serialization_t usb_serp)
748 {
749 	usb_release_access(usb_serp);
750 }
751 
752 #endif
753