17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 502acac7eSsl * Common Development and Distribution License (the "License"). 602acac7eSsl * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 22*269552cdSguoqing zhu - Sun Microsystems - Beijing China * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate #ifndef _SYS_USB_UHCIUTIL_H 277c478bd9Sstevel@tonic-gate #define _SYS_USB_UHCIUTIL_H 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate 307c478bd9Sstevel@tonic-gate #ifdef __cplusplus 317c478bd9Sstevel@tonic-gate extern "C" { 327c478bd9Sstevel@tonic-gate #endif 337c478bd9Sstevel@tonic-gate 347c478bd9Sstevel@tonic-gate /* 357c478bd9Sstevel@tonic-gate * Universal Host Controller Driver(UHCI) 367c478bd9Sstevel@tonic-gate * 377c478bd9Sstevel@tonic-gate * The UHCI driver is a software driver which interfaces to the Universal 387c478bd9Sstevel@tonic-gate * Serial Bus Driver(USBA) and the Host Controller(HC). The interface to 397c478bd9Sstevel@tonic-gate * the Host Controller is defined by the UHCI. 407c478bd9Sstevel@tonic-gate */ 417c478bd9Sstevel@tonic-gate int uhci_hcdi_pipe_open(usba_pipe_handle_data_t *pipe_handle, 427c478bd9Sstevel@tonic-gate usb_flags_t flags); 437c478bd9Sstevel@tonic-gate int uhci_hcdi_pipe_close(usba_pipe_handle_data_t *pipe_handle, 447c478bd9Sstevel@tonic-gate usb_flags_t flags); 457c478bd9Sstevel@tonic-gate int uhci_hcdi_pipe_reset(usba_pipe_handle_data_t *pipe_handle, 467c478bd9Sstevel@tonic-gate usb_flags_t usb_flags); 47*269552cdSguoqing zhu - Sun Microsystems - Beijing China void uhci_hcdi_pipe_reset_data_toggle( 48*269552cdSguoqing zhu - Sun Microsystems - Beijing China usba_pipe_handle_data_t *pipe_handle); 497c478bd9Sstevel@tonic-gate int uhci_hcdi_pipe_ctrl_xfer(usba_pipe_handle_data_t *, 507c478bd9Sstevel@tonic-gate usb_ctrl_req_t *, usb_flags_t); 517c478bd9Sstevel@tonic-gate int uhci_hcdi_pipe_bulk_xfer(usba_pipe_handle_data_t *, 527c478bd9Sstevel@tonic-gate usb_bulk_req_t *, usb_flags_t); 537c478bd9Sstevel@tonic-gate int uhci_hcdi_pipe_isoc_xfer(usba_pipe_handle_data_t *, 547c478bd9Sstevel@tonic-gate usb_isoc_req_t *, usb_flags_t); 557c478bd9Sstevel@tonic-gate int uhci_hcdi_pipe_intr_xfer(usba_pipe_handle_data_t *, 567c478bd9Sstevel@tonic-gate usb_intr_req_t *, usb_flags_t); 577c478bd9Sstevel@tonic-gate int uhci_hcdi_bulk_transfer_size(usba_device_t *usba_device, 587c478bd9Sstevel@tonic-gate size_t *size); 597c478bd9Sstevel@tonic-gate int uhci_hcdi_pipe_stop_intr_polling( 607c478bd9Sstevel@tonic-gate usba_pipe_handle_data_t *pipe_handle, usb_flags_t flags); 617c478bd9Sstevel@tonic-gate int uhci_hcdi_pipe_stop_isoc_polling(usba_pipe_handle_data_t *ph, 627c478bd9Sstevel@tonic-gate usb_flags_t flags); 63fffe0b30Sqz int uhci_hcdi_get_current_frame_number(usba_device_t *usba_device, 64fffe0b30Sqz usb_frame_number_t *frame_number); 65fffe0b30Sqz int uhci_hcdi_get_max_isoc_pkts(usba_device_t *usba_device, 66fffe0b30Sqz uint_t *max_isoc_pkts_per_request); 677c478bd9Sstevel@tonic-gate 687c478bd9Sstevel@tonic-gate /* Root hub prototypes */ 697c478bd9Sstevel@tonic-gate int uhci_handle_root_hub_request( 707c478bd9Sstevel@tonic-gate uhci_state_t *uhcip, 717c478bd9Sstevel@tonic-gate usba_pipe_handle_data_t *pipe_handle, 727c478bd9Sstevel@tonic-gate usb_ctrl_req_t *req); 737c478bd9Sstevel@tonic-gate 747c478bd9Sstevel@tonic-gate void uhci_handle_ctrl_td(uhci_state_t *uhcip, uhci_td_t *td); 757c478bd9Sstevel@tonic-gate int uhci_insert_bulk_td(uhci_state_t *uhcip, 767c478bd9Sstevel@tonic-gate usba_pipe_handle_data_t *ph, 777c478bd9Sstevel@tonic-gate usb_bulk_req_t *req, usb_flags_t flags); 787c478bd9Sstevel@tonic-gate void uhci_handle_intr_td(uhci_state_t *uhcip, uhci_td_t *td); 797c478bd9Sstevel@tonic-gate void uhci_sendup_td_message(uhci_state_t *uhcip, usb_cr_t, 807c478bd9Sstevel@tonic-gate uhci_trans_wrapper_t *tw); 817c478bd9Sstevel@tonic-gate usb_cr_t uhci_parse_td_error(uhci_state_t *uhcip, 827c478bd9Sstevel@tonic-gate uhci_pipe_private_t *pp, uhci_td_t *td); 837c478bd9Sstevel@tonic-gate void uhci_process_submitted_td_queue(uhci_state_t *uhcip); 847c478bd9Sstevel@tonic-gate void uhci_delete_td(uhci_state_t *uhcip, uhci_td_t *td); 857c478bd9Sstevel@tonic-gate 867c478bd9Sstevel@tonic-gate /* global HCDI prototypes */ 877c478bd9Sstevel@tonic-gate usba_hcdi_ops_t *uhci_alloc_hcdi_ops(uhci_state_t *uhcip); 887c478bd9Sstevel@tonic-gate int uhci_hcdi_polled_input_init( 897c478bd9Sstevel@tonic-gate usba_pipe_handle_data_t *uhcip, 907c478bd9Sstevel@tonic-gate uchar_t **polledbuf, usb_console_info_impl_t *info); 917c478bd9Sstevel@tonic-gate int uhci_hcdi_polled_input_enter(usb_console_info_impl_t *info); 927c478bd9Sstevel@tonic-gate int uhci_hcdi_polled_read(usb_console_info_impl_t *info, uint_t *num); 937c478bd9Sstevel@tonic-gate int uhci_hcdi_polled_input_exit(usb_console_info_impl_t *info); 947c478bd9Sstevel@tonic-gate int uhci_hcdi_polled_input_fini(usb_console_info_impl_t *info); 957c478bd9Sstevel@tonic-gate void uhci_hcdi_callback(uhci_state_t *uhcip, 967c478bd9Sstevel@tonic-gate uhci_pipe_private_t *pp, 977c478bd9Sstevel@tonic-gate usba_pipe_handle_data_t *ph, uhci_trans_wrapper_t *tw, 987c478bd9Sstevel@tonic-gate usb_cr_t cr); 997c478bd9Sstevel@tonic-gate 1007c478bd9Sstevel@tonic-gate void uhci_set_dma_attributes(uhci_state_t *uhcip); 1017c478bd9Sstevel@tonic-gate void uhci_remove_qh(uhci_state_t *uhcip, uhci_pipe_private_t *pp); 1027c478bd9Sstevel@tonic-gate void uhci_insert_qh(uhci_state_t *uhcip, 1037c478bd9Sstevel@tonic-gate usba_pipe_handle_data_t *pipe_handle); 1047c478bd9Sstevel@tonic-gate void uhci_decode_ddi_dma_addr_bind_handle_result(uhci_state_t *uhcip, 1057c478bd9Sstevel@tonic-gate int result); 1067c478bd9Sstevel@tonic-gate int uhci_allocate_pools(uhci_state_t *uhcip); 1077c478bd9Sstevel@tonic-gate void uhci_free_pools(uhci_state_t *uhcip); 1087c478bd9Sstevel@tonic-gate int uhci_init_ctlr(uhci_state_t *uhcip); 1097c478bd9Sstevel@tonic-gate void uhci_uninit_ctlr(uhci_state_t *uhcip); 1107c478bd9Sstevel@tonic-gate int uhci_map_regs(uhci_state_t *uhcip); 1117c478bd9Sstevel@tonic-gate void uhci_unmap_regs(uhci_state_t *uhcip); 1127c478bd9Sstevel@tonic-gate int uhci_insert_hc_td(uhci_state_t *uhcip, 1137c478bd9Sstevel@tonic-gate uint32_t buffer_address, size_t hcgtd_length, 1147c478bd9Sstevel@tonic-gate uhci_pipe_private_t *pp, uhci_trans_wrapper_t *tw, 1157c478bd9Sstevel@tonic-gate uchar_t PID, usb_req_attrs_t attrs); 1167c478bd9Sstevel@tonic-gate 1177c478bd9Sstevel@tonic-gate int uhci_allocate_periodic_in_resource(uhci_state_t *uhcip, 1187c478bd9Sstevel@tonic-gate uhci_pipe_private_t *pp, uhci_trans_wrapper_t *tw, 1197c478bd9Sstevel@tonic-gate usb_flags_t flags); 1207c478bd9Sstevel@tonic-gate void uhci_deallocate_periodic_in_resource(uhci_state_t *uhcip, 1217c478bd9Sstevel@tonic-gate uhci_pipe_private_t *pp, uhci_trans_wrapper_t *tw); 1227c478bd9Sstevel@tonic-gate void uhci_do_intrs_stats(uhci_state_t *uhcip, int val); 1237c478bd9Sstevel@tonic-gate void uhci_do_byte_stats(uhci_state_t *, size_t, uint8_t, uint8_t); 1247c478bd9Sstevel@tonic-gate void uhci_deallocate_tw(uhci_state_t *uhcip, uhci_pipe_private_t *pp, 1257c478bd9Sstevel@tonic-gate uhci_trans_wrapper_t *tw); 1267c478bd9Sstevel@tonic-gate 1277c478bd9Sstevel@tonic-gate /* other generic global prototypes */ 1287c478bd9Sstevel@tonic-gate uhci_state_t *uhci_obtain_state(dev_info_t *dip); 1297c478bd9Sstevel@tonic-gate queue_head_t *uhci_alloc_queue_head(uhci_state_t *uhcip); 130fffe0b30Sqz int uhci_state_is_operational(uhci_state_t *uhcip); 1317c478bd9Sstevel@tonic-gate void uhci_save_data_toggle(uhci_pipe_private_t *pp); 1327c478bd9Sstevel@tonic-gate int uhci_wait_for_sof(uhci_state_t *uhcip); 1337c478bd9Sstevel@tonic-gate void uhci_modify_td_active_bits(uhci_state_t *uhcip, 1347c478bd9Sstevel@tonic-gate uhci_pipe_private_t *pp); 1357c478bd9Sstevel@tonic-gate void uhci_deallocate_bandwidth(uhci_state_t *uhcip, 1367c478bd9Sstevel@tonic-gate usba_pipe_handle_data_t *pipe_handle); 1377c478bd9Sstevel@tonic-gate int uhci_allocate_bandwidth(uhci_state_t *uhcip, 1387c478bd9Sstevel@tonic-gate usba_pipe_handle_data_t *pipe_handle, uint_t *node); 1397c478bd9Sstevel@tonic-gate void uhci_remove_tds_tws(uhci_state_t *uhcip, 1407c478bd9Sstevel@tonic-gate usba_pipe_handle_data_t *ph); 1417c478bd9Sstevel@tonic-gate void uhci_free_tw(uhci_state_t *uhcip, uhci_trans_wrapper_t *tw); 1427c478bd9Sstevel@tonic-gate void uhci_insert_qh(uhci_state_t *uhcip, 1437c478bd9Sstevel@tonic-gate usba_pipe_handle_data_t *pipe_handle); 1447c478bd9Sstevel@tonic-gate void uhci_cmd_timeout_hdlr(void *arg); 1457c478bd9Sstevel@tonic-gate 1467c478bd9Sstevel@tonic-gate /* Control prototypes */ 1477c478bd9Sstevel@tonic-gate int uhci_insert_ctrl_td(uhci_state_t *uhcip, 1487c478bd9Sstevel@tonic-gate usba_pipe_handle_data_t *pipe_handle, 1497c478bd9Sstevel@tonic-gate usb_ctrl_req_t *req, usb_flags_t flags); 1507c478bd9Sstevel@tonic-gate 1517c478bd9Sstevel@tonic-gate /* Intr prototypes */ 1527c478bd9Sstevel@tonic-gate int uhci_insert_intr_td(uhci_state_t *uhcip, 1537c478bd9Sstevel@tonic-gate usba_pipe_handle_data_t *pipe_handle, 1547c478bd9Sstevel@tonic-gate usb_intr_req_t *req, usb_flags_t flags); 1557c478bd9Sstevel@tonic-gate 1567c478bd9Sstevel@tonic-gate /* Bulk prototypes */ 1577c478bd9Sstevel@tonic-gate void uhci_handle_bulk_td(uhci_state_t *uhcip, uhci_td_t *td); 1587c478bd9Sstevel@tonic-gate void uhci_fill_in_bulk_isoc_td(uhci_state_t *uhcip, 1597c478bd9Sstevel@tonic-gate uhci_td_t *current_td, uhci_td_t *next_td, 1607c478bd9Sstevel@tonic-gate uint32_t next_td_paddr, usba_pipe_handle_data_t *ph, 16102acac7eSsl uint_t offset, uint_t length, 1627c478bd9Sstevel@tonic-gate uhci_trans_wrapper_t *tw); 1637c478bd9Sstevel@tonic-gate void uhci_remove_bulk_tds_tws(uhci_state_t *uhcip, 1647c478bd9Sstevel@tonic-gate uhci_pipe_private_t *pp, int); 1657c478bd9Sstevel@tonic-gate 1667c478bd9Sstevel@tonic-gate /* Isoc prototypes */ 1677c478bd9Sstevel@tonic-gate int uhci_insert_isoc_td(uhci_state_t *uhcip, 1687c478bd9Sstevel@tonic-gate usba_pipe_handle_data_t *ph, usb_isoc_req_t *isoc_req, 1697c478bd9Sstevel@tonic-gate size_t length, usb_flags_t usb_flags); 1707c478bd9Sstevel@tonic-gate void uhci_handle_isoc_td(uhci_state_t *uhcip, uhci_td_t *td); 1717c478bd9Sstevel@tonic-gate int uhci_start_isoc_receive_polling( 1727c478bd9Sstevel@tonic-gate uhci_state_t *uhcip, usba_pipe_handle_data_t *ph, 1737c478bd9Sstevel@tonic-gate usb_isoc_req_t *isoc_req, usb_flags_t usb_flags); 1747c478bd9Sstevel@tonic-gate void uhci_remove_isoc_tds_tws(uhci_state_t *uhcip, 1757c478bd9Sstevel@tonic-gate uhci_pipe_private_t *ph); 1767c478bd9Sstevel@tonic-gate uint64_t uhci_get_sw_frame_number(uhci_state_t *uhcip); 1777c478bd9Sstevel@tonic-gate void uhci_isoc_update_sw_frame_number(uhci_state_t *uhcip); 1787c478bd9Sstevel@tonic-gate 1797c478bd9Sstevel@tonic-gate /* kstat support */ 1807c478bd9Sstevel@tonic-gate void uhci_create_stats(uhci_state_t *uhcip); 1817c478bd9Sstevel@tonic-gate void uhci_destroy_stats(uhci_state_t *uhcip); 1827c478bd9Sstevel@tonic-gate 1837c478bd9Sstevel@tonic-gate /* arithmetic goodies */ 184fffe0b30Sqz uint_t pow_2(unsigned int x); 185fffe0b30Sqz uint_t log_2(unsigned int x); 1867c478bd9Sstevel@tonic-gate 1877c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1887c478bd9Sstevel@tonic-gate } 1897c478bd9Sstevel@tonic-gate #endif 1907c478bd9Sstevel@tonic-gate 1917c478bd9Sstevel@tonic-gate #endif /* _SYS_USB_UHCIUTIL_H */ 192