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 5*02acac7eSsl * Common Development and Distribution License (the "License"). 6*02acac7eSsl * 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*02acac7eSsl * Copyright 2006 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 #pragma ident "%Z%%M% %I% %E% SMI" 307c478bd9Sstevel@tonic-gate 317c478bd9Sstevel@tonic-gate #ifdef __cplusplus 327c478bd9Sstevel@tonic-gate extern "C" { 337c478bd9Sstevel@tonic-gate #endif 347c478bd9Sstevel@tonic-gate 357c478bd9Sstevel@tonic-gate /* 367c478bd9Sstevel@tonic-gate * Universal Host Controller Driver(UHCI) 377c478bd9Sstevel@tonic-gate * 387c478bd9Sstevel@tonic-gate * The UHCI driver is a software driver which interfaces to the Universal 397c478bd9Sstevel@tonic-gate * Serial Bus Driver(USBA) and the Host Controller(HC). The interface to 407c478bd9Sstevel@tonic-gate * the Host Controller is defined by the UHCI. 417c478bd9Sstevel@tonic-gate */ 427c478bd9Sstevel@tonic-gate int uhci_hcdi_pipe_open(usba_pipe_handle_data_t *pipe_handle, 437c478bd9Sstevel@tonic-gate usb_flags_t flags); 447c478bd9Sstevel@tonic-gate int uhci_hcdi_pipe_close(usba_pipe_handle_data_t *pipe_handle, 457c478bd9Sstevel@tonic-gate usb_flags_t flags); 467c478bd9Sstevel@tonic-gate int uhci_hcdi_pipe_reset(usba_pipe_handle_data_t *pipe_handle, 477c478bd9Sstevel@tonic-gate usb_flags_t usb_flags); 487c478bd9Sstevel@tonic-gate int uhci_hcdi_pipe_ctrl_xfer(usba_pipe_handle_data_t *, 497c478bd9Sstevel@tonic-gate usb_ctrl_req_t *, usb_flags_t); 507c478bd9Sstevel@tonic-gate int uhci_hcdi_pipe_bulk_xfer(usba_pipe_handle_data_t *, 517c478bd9Sstevel@tonic-gate usb_bulk_req_t *, usb_flags_t); 527c478bd9Sstevel@tonic-gate int uhci_hcdi_pipe_isoc_xfer(usba_pipe_handle_data_t *, 537c478bd9Sstevel@tonic-gate usb_isoc_req_t *, usb_flags_t); 547c478bd9Sstevel@tonic-gate int uhci_hcdi_pipe_intr_xfer(usba_pipe_handle_data_t *, 557c478bd9Sstevel@tonic-gate usb_intr_req_t *, usb_flags_t); 567c478bd9Sstevel@tonic-gate int uhci_hcdi_bulk_transfer_size(usba_device_t *usba_device, 577c478bd9Sstevel@tonic-gate size_t *size); 587c478bd9Sstevel@tonic-gate int uhci_hcdi_pipe_stop_intr_polling( 597c478bd9Sstevel@tonic-gate usba_pipe_handle_data_t *pipe_handle, usb_flags_t flags); 607c478bd9Sstevel@tonic-gate int uhci_hcdi_pipe_stop_isoc_polling(usba_pipe_handle_data_t *ph, 617c478bd9Sstevel@tonic-gate usb_flags_t flags); 627c478bd9Sstevel@tonic-gate usb_frame_number_t uhci_hcdi_get_current_frame_number( 637c478bd9Sstevel@tonic-gate usba_device_t *usba_device); 647c478bd9Sstevel@tonic-gate uint_t uhci_hcdi_get_max_isoc_pkts(usba_device_t *usba_device); 657c478bd9Sstevel@tonic-gate 667c478bd9Sstevel@tonic-gate /* Root hub prototypes */ 677c478bd9Sstevel@tonic-gate int uhci_handle_root_hub_request( 687c478bd9Sstevel@tonic-gate uhci_state_t *uhcip, 697c478bd9Sstevel@tonic-gate usba_pipe_handle_data_t *pipe_handle, 707c478bd9Sstevel@tonic-gate usb_ctrl_req_t *req); 717c478bd9Sstevel@tonic-gate 727c478bd9Sstevel@tonic-gate void uhci_handle_ctrl_td(uhci_state_t *uhcip, uhci_td_t *td); 737c478bd9Sstevel@tonic-gate int uhci_insert_bulk_td(uhci_state_t *uhcip, 747c478bd9Sstevel@tonic-gate usba_pipe_handle_data_t *ph, 757c478bd9Sstevel@tonic-gate usb_bulk_req_t *req, usb_flags_t flags); 767c478bd9Sstevel@tonic-gate void uhci_handle_intr_td(uhci_state_t *uhcip, uhci_td_t *td); 777c478bd9Sstevel@tonic-gate void uhci_sendup_td_message(uhci_state_t *uhcip, usb_cr_t, 787c478bd9Sstevel@tonic-gate uhci_trans_wrapper_t *tw); 797c478bd9Sstevel@tonic-gate usb_cr_t uhci_parse_td_error(uhci_state_t *uhcip, 807c478bd9Sstevel@tonic-gate uhci_pipe_private_t *pp, uhci_td_t *td); 817c478bd9Sstevel@tonic-gate void uhci_process_submitted_td_queue(uhci_state_t *uhcip); 827c478bd9Sstevel@tonic-gate void uhci_delete_td(uhci_state_t *uhcip, uhci_td_t *td); 837c478bd9Sstevel@tonic-gate 847c478bd9Sstevel@tonic-gate /* global HCDI prototypes */ 857c478bd9Sstevel@tonic-gate usba_hcdi_ops_t *uhci_alloc_hcdi_ops(uhci_state_t *uhcip); 867c478bd9Sstevel@tonic-gate int uhci_hcdi_polled_input_init( 877c478bd9Sstevel@tonic-gate usba_pipe_handle_data_t *uhcip, 887c478bd9Sstevel@tonic-gate uchar_t **polledbuf, usb_console_info_impl_t *info); 897c478bd9Sstevel@tonic-gate int uhci_hcdi_polled_input_enter(usb_console_info_impl_t *info); 907c478bd9Sstevel@tonic-gate int uhci_hcdi_polled_read(usb_console_info_impl_t *info, uint_t *num); 917c478bd9Sstevel@tonic-gate int uhci_hcdi_polled_input_exit(usb_console_info_impl_t *info); 927c478bd9Sstevel@tonic-gate int uhci_hcdi_polled_input_fini(usb_console_info_impl_t *info); 937c478bd9Sstevel@tonic-gate void uhci_hcdi_callback(uhci_state_t *uhcip, 947c478bd9Sstevel@tonic-gate uhci_pipe_private_t *pp, 957c478bd9Sstevel@tonic-gate usba_pipe_handle_data_t *ph, uhci_trans_wrapper_t *tw, 967c478bd9Sstevel@tonic-gate usb_cr_t cr); 977c478bd9Sstevel@tonic-gate 987c478bd9Sstevel@tonic-gate void uhci_set_dma_attributes(uhci_state_t *uhcip); 997c478bd9Sstevel@tonic-gate void uhci_remove_qh(uhci_state_t *uhcip, uhci_pipe_private_t *pp); 1007c478bd9Sstevel@tonic-gate void uhci_insert_qh(uhci_state_t *uhcip, 1017c478bd9Sstevel@tonic-gate usba_pipe_handle_data_t *pipe_handle); 1027c478bd9Sstevel@tonic-gate void uhci_decode_ddi_dma_addr_bind_handle_result(uhci_state_t *uhcip, 1037c478bd9Sstevel@tonic-gate int result); 1047c478bd9Sstevel@tonic-gate int uhci_allocate_pools(uhci_state_t *uhcip); 1057c478bd9Sstevel@tonic-gate void uhci_free_pools(uhci_state_t *uhcip); 1067c478bd9Sstevel@tonic-gate int uhci_init_ctlr(uhci_state_t *uhcip); 1077c478bd9Sstevel@tonic-gate void uhci_uninit_ctlr(uhci_state_t *uhcip); 1087c478bd9Sstevel@tonic-gate int uhci_map_regs(uhci_state_t *uhcip); 1097c478bd9Sstevel@tonic-gate void uhci_unmap_regs(uhci_state_t *uhcip); 1107c478bd9Sstevel@tonic-gate int uhci_insert_hc_td(uhci_state_t *uhcip, 1117c478bd9Sstevel@tonic-gate uint32_t buffer_address, size_t hcgtd_length, 1127c478bd9Sstevel@tonic-gate uhci_pipe_private_t *pp, uhci_trans_wrapper_t *tw, 1137c478bd9Sstevel@tonic-gate uchar_t PID, usb_req_attrs_t attrs); 1147c478bd9Sstevel@tonic-gate 1157c478bd9Sstevel@tonic-gate int uhci_allocate_periodic_in_resource(uhci_state_t *uhcip, 1167c478bd9Sstevel@tonic-gate uhci_pipe_private_t *pp, uhci_trans_wrapper_t *tw, 1177c478bd9Sstevel@tonic-gate usb_flags_t flags); 1187c478bd9Sstevel@tonic-gate void uhci_deallocate_periodic_in_resource(uhci_state_t *uhcip, 1197c478bd9Sstevel@tonic-gate uhci_pipe_private_t *pp, uhci_trans_wrapper_t *tw); 1207c478bd9Sstevel@tonic-gate void uhci_do_intrs_stats(uhci_state_t *uhcip, int val); 1217c478bd9Sstevel@tonic-gate void uhci_do_byte_stats(uhci_state_t *, size_t, uint8_t, uint8_t); 1227c478bd9Sstevel@tonic-gate void uhci_deallocate_tw(uhci_state_t *uhcip, uhci_pipe_private_t *pp, 1237c478bd9Sstevel@tonic-gate uhci_trans_wrapper_t *tw); 1247c478bd9Sstevel@tonic-gate 1257c478bd9Sstevel@tonic-gate /* other generic global prototypes */ 1267c478bd9Sstevel@tonic-gate uhci_state_t *uhci_obtain_state(dev_info_t *dip); 1277c478bd9Sstevel@tonic-gate queue_head_t *uhci_alloc_queue_head(uhci_state_t *uhcip); 1287c478bd9Sstevel@tonic-gate void uhci_save_data_toggle(uhci_pipe_private_t *pp); 1297c478bd9Sstevel@tonic-gate int uhci_wait_for_sof(uhci_state_t *uhcip); 1307c478bd9Sstevel@tonic-gate void uhci_modify_td_active_bits(uhci_state_t *uhcip, 1317c478bd9Sstevel@tonic-gate uhci_pipe_private_t *pp); 1327c478bd9Sstevel@tonic-gate void uhci_deallocate_bandwidth(uhci_state_t *uhcip, 1337c478bd9Sstevel@tonic-gate usba_pipe_handle_data_t *pipe_handle); 1347c478bd9Sstevel@tonic-gate int uhci_allocate_bandwidth(uhci_state_t *uhcip, 1357c478bd9Sstevel@tonic-gate usba_pipe_handle_data_t *pipe_handle, uint_t *node); 1367c478bd9Sstevel@tonic-gate void uhci_remove_tds_tws(uhci_state_t *uhcip, 1377c478bd9Sstevel@tonic-gate usba_pipe_handle_data_t *ph); 1387c478bd9Sstevel@tonic-gate void uhci_free_tw(uhci_state_t *uhcip, uhci_trans_wrapper_t *tw); 1397c478bd9Sstevel@tonic-gate void uhci_insert_qh(uhci_state_t *uhcip, 1407c478bd9Sstevel@tonic-gate usba_pipe_handle_data_t *pipe_handle); 1417c478bd9Sstevel@tonic-gate void uhci_cmd_timeout_hdlr(void *arg); 1427c478bd9Sstevel@tonic-gate 1437c478bd9Sstevel@tonic-gate /* Control prototypes */ 1447c478bd9Sstevel@tonic-gate int uhci_insert_ctrl_td(uhci_state_t *uhcip, 1457c478bd9Sstevel@tonic-gate usba_pipe_handle_data_t *pipe_handle, 1467c478bd9Sstevel@tonic-gate usb_ctrl_req_t *req, usb_flags_t flags); 1477c478bd9Sstevel@tonic-gate 1487c478bd9Sstevel@tonic-gate /* Intr prototypes */ 1497c478bd9Sstevel@tonic-gate int uhci_insert_intr_td(uhci_state_t *uhcip, 1507c478bd9Sstevel@tonic-gate usba_pipe_handle_data_t *pipe_handle, 1517c478bd9Sstevel@tonic-gate usb_intr_req_t *req, usb_flags_t flags); 1527c478bd9Sstevel@tonic-gate 1537c478bd9Sstevel@tonic-gate /* Bulk prototypes */ 1547c478bd9Sstevel@tonic-gate void uhci_handle_bulk_td(uhci_state_t *uhcip, uhci_td_t *td); 1557c478bd9Sstevel@tonic-gate void uhci_fill_in_bulk_isoc_td(uhci_state_t *uhcip, 1567c478bd9Sstevel@tonic-gate uhci_td_t *current_td, uhci_td_t *next_td, 1577c478bd9Sstevel@tonic-gate uint32_t next_td_paddr, usba_pipe_handle_data_t *ph, 158*02acac7eSsl uint_t offset, uint_t length, 1597c478bd9Sstevel@tonic-gate uhci_trans_wrapper_t *tw); 1607c478bd9Sstevel@tonic-gate void uhci_remove_bulk_tds_tws(uhci_state_t *uhcip, 1617c478bd9Sstevel@tonic-gate uhci_pipe_private_t *pp, int); 1627c478bd9Sstevel@tonic-gate 1637c478bd9Sstevel@tonic-gate /* Isoc prototypes */ 1647c478bd9Sstevel@tonic-gate int uhci_insert_isoc_td(uhci_state_t *uhcip, 1657c478bd9Sstevel@tonic-gate usba_pipe_handle_data_t *ph, usb_isoc_req_t *isoc_req, 1667c478bd9Sstevel@tonic-gate size_t length, usb_flags_t usb_flags); 1677c478bd9Sstevel@tonic-gate void uhci_handle_isoc_td(uhci_state_t *uhcip, uhci_td_t *td); 1687c478bd9Sstevel@tonic-gate int uhci_start_isoc_receive_polling( 1697c478bd9Sstevel@tonic-gate uhci_state_t *uhcip, usba_pipe_handle_data_t *ph, 1707c478bd9Sstevel@tonic-gate usb_isoc_req_t *isoc_req, usb_flags_t usb_flags); 1717c478bd9Sstevel@tonic-gate void uhci_remove_isoc_tds_tws(uhci_state_t *uhcip, 1727c478bd9Sstevel@tonic-gate uhci_pipe_private_t *ph); 1737c478bd9Sstevel@tonic-gate uint64_t uhci_get_sw_frame_number(uhci_state_t *uhcip); 1747c478bd9Sstevel@tonic-gate void uhci_isoc_update_sw_frame_number(uhci_state_t *uhcip); 1757c478bd9Sstevel@tonic-gate 1767c478bd9Sstevel@tonic-gate /* kstat support */ 1777c478bd9Sstevel@tonic-gate void uhci_create_stats(uhci_state_t *uhcip); 1787c478bd9Sstevel@tonic-gate void uhci_destroy_stats(uhci_state_t *uhcip); 1797c478bd9Sstevel@tonic-gate 1807c478bd9Sstevel@tonic-gate /* arithmetic goodies */ 1817c478bd9Sstevel@tonic-gate uint_t pow_2(unsigned int x); 1827c478bd9Sstevel@tonic-gate uint_t log_2(unsigned int x); 1837c478bd9Sstevel@tonic-gate 1847c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1857c478bd9Sstevel@tonic-gate } 1867c478bd9Sstevel@tonic-gate #endif 1877c478bd9Sstevel@tonic-gate 1887c478bd9Sstevel@tonic-gate #endif /* _SYS_USB_UHCIUTIL_H */ 189