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