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