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