xref: /onnv-gate/usr/src/uts/common/sys/usb/hcd/uhci/uhciutil.h (revision 8945:e7c1b5757cd7)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
52125Ssl147100  * Common Development and Distribution License (the "License").
62125Ssl147100  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
22*8945SGuoqing.Zhu@Sun.COM  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
230Sstevel@tonic-gate  * Use is subject to license terms.
240Sstevel@tonic-gate  */
250Sstevel@tonic-gate 
260Sstevel@tonic-gate #ifndef _SYS_USB_UHCIUTIL_H
270Sstevel@tonic-gate #define	_SYS_USB_UHCIUTIL_H
280Sstevel@tonic-gate 
290Sstevel@tonic-gate 
300Sstevel@tonic-gate #ifdef __cplusplus
310Sstevel@tonic-gate extern "C" {
320Sstevel@tonic-gate #endif
330Sstevel@tonic-gate 
340Sstevel@tonic-gate /*
350Sstevel@tonic-gate  * Universal Host Controller Driver(UHCI)
360Sstevel@tonic-gate  *
370Sstevel@tonic-gate  * The UHCI driver is a software driver which interfaces to the Universal
380Sstevel@tonic-gate  * Serial Bus Driver(USBA) and the Host Controller(HC). The interface to
390Sstevel@tonic-gate  * the Host Controller is defined by the UHCI.
400Sstevel@tonic-gate  */
410Sstevel@tonic-gate int	uhci_hcdi_pipe_open(usba_pipe_handle_data_t *pipe_handle,
420Sstevel@tonic-gate 		    usb_flags_t flags);
430Sstevel@tonic-gate int	uhci_hcdi_pipe_close(usba_pipe_handle_data_t *pipe_handle,
440Sstevel@tonic-gate 		    usb_flags_t flags);
450Sstevel@tonic-gate int	uhci_hcdi_pipe_reset(usba_pipe_handle_data_t *pipe_handle,
460Sstevel@tonic-gate 		    usb_flags_t usb_flags);
47*8945SGuoqing.Zhu@Sun.COM void	uhci_hcdi_pipe_reset_data_toggle(
48*8945SGuoqing.Zhu@Sun.COM 	    usba_pipe_handle_data_t *pipe_handle);
490Sstevel@tonic-gate int	uhci_hcdi_pipe_ctrl_xfer(usba_pipe_handle_data_t *,
500Sstevel@tonic-gate 		    usb_ctrl_req_t *, usb_flags_t);
510Sstevel@tonic-gate int	uhci_hcdi_pipe_bulk_xfer(usba_pipe_handle_data_t *,
520Sstevel@tonic-gate 		    usb_bulk_req_t *, usb_flags_t);
530Sstevel@tonic-gate int	uhci_hcdi_pipe_isoc_xfer(usba_pipe_handle_data_t *,
540Sstevel@tonic-gate 		    usb_isoc_req_t *, usb_flags_t);
550Sstevel@tonic-gate int	uhci_hcdi_pipe_intr_xfer(usba_pipe_handle_data_t *,
560Sstevel@tonic-gate 		    usb_intr_req_t *, usb_flags_t);
570Sstevel@tonic-gate int	uhci_hcdi_bulk_transfer_size(usba_device_t *usba_device,
580Sstevel@tonic-gate 		    size_t  *size);
590Sstevel@tonic-gate int	uhci_hcdi_pipe_stop_intr_polling(
600Sstevel@tonic-gate 		    usba_pipe_handle_data_t *pipe_handle, usb_flags_t flags);
610Sstevel@tonic-gate int	uhci_hcdi_pipe_stop_isoc_polling(usba_pipe_handle_data_t *ph,
620Sstevel@tonic-gate 		    usb_flags_t flags);
635773Sqz150045 int	uhci_hcdi_get_current_frame_number(usba_device_t *usba_device,
645773Sqz150045 		    usb_frame_number_t	*frame_number);
655773Sqz150045 int	uhci_hcdi_get_max_isoc_pkts(usba_device_t *usba_device,
665773Sqz150045 		    uint_t	*max_isoc_pkts_per_request);
670Sstevel@tonic-gate 
680Sstevel@tonic-gate /* Root hub prototypes */
690Sstevel@tonic-gate int	uhci_handle_root_hub_request(
700Sstevel@tonic-gate 		    uhci_state_t		*uhcip,
710Sstevel@tonic-gate 		    usba_pipe_handle_data_t	*pipe_handle,
720Sstevel@tonic-gate 		    usb_ctrl_req_t	*req);
730Sstevel@tonic-gate 
740Sstevel@tonic-gate void	uhci_handle_ctrl_td(uhci_state_t *uhcip, uhci_td_t *td);
750Sstevel@tonic-gate int	uhci_insert_bulk_td(uhci_state_t *uhcip,
760Sstevel@tonic-gate 		    usba_pipe_handle_data_t *ph,
770Sstevel@tonic-gate 		    usb_bulk_req_t *req, usb_flags_t flags);
780Sstevel@tonic-gate void	uhci_handle_intr_td(uhci_state_t *uhcip, uhci_td_t *td);
790Sstevel@tonic-gate void	uhci_sendup_td_message(uhci_state_t *uhcip, usb_cr_t,
800Sstevel@tonic-gate 		    uhci_trans_wrapper_t *tw);
810Sstevel@tonic-gate usb_cr_t uhci_parse_td_error(uhci_state_t *uhcip,
820Sstevel@tonic-gate 		    uhci_pipe_private_t *pp, uhci_td_t *td);
830Sstevel@tonic-gate void	uhci_process_submitted_td_queue(uhci_state_t *uhcip);
840Sstevel@tonic-gate void	uhci_delete_td(uhci_state_t *uhcip, uhci_td_t *td);
850Sstevel@tonic-gate 
860Sstevel@tonic-gate /* global HCDI prototypes */
870Sstevel@tonic-gate usba_hcdi_ops_t	*uhci_alloc_hcdi_ops(uhci_state_t *uhcip);
880Sstevel@tonic-gate int	uhci_hcdi_polled_input_init(
890Sstevel@tonic-gate 		    usba_pipe_handle_data_t *uhcip,
900Sstevel@tonic-gate 		    uchar_t **polledbuf, usb_console_info_impl_t *info);
910Sstevel@tonic-gate int	uhci_hcdi_polled_input_enter(usb_console_info_impl_t *info);
920Sstevel@tonic-gate int	uhci_hcdi_polled_read(usb_console_info_impl_t *info, uint_t *num);
930Sstevel@tonic-gate int	uhci_hcdi_polled_input_exit(usb_console_info_impl_t *info);
940Sstevel@tonic-gate int	uhci_hcdi_polled_input_fini(usb_console_info_impl_t *info);
950Sstevel@tonic-gate void	uhci_hcdi_callback(uhci_state_t *uhcip,
960Sstevel@tonic-gate 		    uhci_pipe_private_t *pp,
970Sstevel@tonic-gate 		    usba_pipe_handle_data_t *ph, uhci_trans_wrapper_t *tw,
980Sstevel@tonic-gate 		    usb_cr_t cr);
990Sstevel@tonic-gate 
1000Sstevel@tonic-gate void	uhci_set_dma_attributes(uhci_state_t *uhcip);
1010Sstevel@tonic-gate void	uhci_remove_qh(uhci_state_t *uhcip, uhci_pipe_private_t *pp);
1020Sstevel@tonic-gate void	uhci_insert_qh(uhci_state_t *uhcip,
1030Sstevel@tonic-gate 		    usba_pipe_handle_data_t *pipe_handle);
1040Sstevel@tonic-gate void	uhci_decode_ddi_dma_addr_bind_handle_result(uhci_state_t *uhcip,
1050Sstevel@tonic-gate 		    int result);
1060Sstevel@tonic-gate int	uhci_allocate_pools(uhci_state_t *uhcip);
1070Sstevel@tonic-gate void	uhci_free_pools(uhci_state_t *uhcip);
1080Sstevel@tonic-gate int	uhci_init_ctlr(uhci_state_t *uhcip);
1090Sstevel@tonic-gate void	uhci_uninit_ctlr(uhci_state_t *uhcip);
1100Sstevel@tonic-gate int	uhci_map_regs(uhci_state_t *uhcip);
1110Sstevel@tonic-gate void	uhci_unmap_regs(uhci_state_t *uhcip);
1120Sstevel@tonic-gate int	uhci_insert_hc_td(uhci_state_t *uhcip,
1130Sstevel@tonic-gate 		    uint32_t buffer_address, size_t hcgtd_length,
1140Sstevel@tonic-gate 		    uhci_pipe_private_t	*pp, uhci_trans_wrapper_t *tw,
1150Sstevel@tonic-gate 		    uchar_t PID, usb_req_attrs_t attrs);
1160Sstevel@tonic-gate 
1170Sstevel@tonic-gate int	uhci_allocate_periodic_in_resource(uhci_state_t *uhcip,
1180Sstevel@tonic-gate 		    uhci_pipe_private_t *pp, uhci_trans_wrapper_t *tw,
1190Sstevel@tonic-gate 		    usb_flags_t flags);
1200Sstevel@tonic-gate void	uhci_deallocate_periodic_in_resource(uhci_state_t *uhcip,
1210Sstevel@tonic-gate 		    uhci_pipe_private_t *pp, uhci_trans_wrapper_t *tw);
1220Sstevel@tonic-gate void	uhci_do_intrs_stats(uhci_state_t *uhcip, int val);
1230Sstevel@tonic-gate void	uhci_do_byte_stats(uhci_state_t *, size_t, uint8_t, uint8_t);
1240Sstevel@tonic-gate void	uhci_deallocate_tw(uhci_state_t *uhcip, uhci_pipe_private_t *pp,
1250Sstevel@tonic-gate 		    uhci_trans_wrapper_t *tw);
1260Sstevel@tonic-gate 
1270Sstevel@tonic-gate /* other generic global prototypes */
1280Sstevel@tonic-gate uhci_state_t	*uhci_obtain_state(dev_info_t *dip);
1290Sstevel@tonic-gate queue_head_t	*uhci_alloc_queue_head(uhci_state_t *uhcip);
1305773Sqz150045 int	uhci_state_is_operational(uhci_state_t *uhcip);
1310Sstevel@tonic-gate void	uhci_save_data_toggle(uhci_pipe_private_t *pp);
1320Sstevel@tonic-gate int	uhci_wait_for_sof(uhci_state_t *uhcip);
1330Sstevel@tonic-gate void	uhci_modify_td_active_bits(uhci_state_t *uhcip,
1340Sstevel@tonic-gate 	    uhci_pipe_private_t *pp);
1350Sstevel@tonic-gate void	uhci_deallocate_bandwidth(uhci_state_t *uhcip,
1360Sstevel@tonic-gate 		usba_pipe_handle_data_t *pipe_handle);
1370Sstevel@tonic-gate int	uhci_allocate_bandwidth(uhci_state_t *uhcip,
1380Sstevel@tonic-gate 		    usba_pipe_handle_data_t *pipe_handle, uint_t *node);
1390Sstevel@tonic-gate void	uhci_remove_tds_tws(uhci_state_t *uhcip,
1400Sstevel@tonic-gate 		usba_pipe_handle_data_t *ph);
1410Sstevel@tonic-gate void	uhci_free_tw(uhci_state_t *uhcip, uhci_trans_wrapper_t *tw);
1420Sstevel@tonic-gate void	uhci_insert_qh(uhci_state_t *uhcip,
1430Sstevel@tonic-gate 		usba_pipe_handle_data_t *pipe_handle);
1440Sstevel@tonic-gate void	uhci_cmd_timeout_hdlr(void *arg);
1450Sstevel@tonic-gate 
1460Sstevel@tonic-gate /* Control prototypes */
1470Sstevel@tonic-gate int	uhci_insert_ctrl_td(uhci_state_t *uhcip,
1480Sstevel@tonic-gate 		usba_pipe_handle_data_t *pipe_handle,
1490Sstevel@tonic-gate 		usb_ctrl_req_t *req, usb_flags_t flags);
1500Sstevel@tonic-gate 
1510Sstevel@tonic-gate /* Intr prototypes */
1520Sstevel@tonic-gate int	uhci_insert_intr_td(uhci_state_t *uhcip,
1530Sstevel@tonic-gate 		usba_pipe_handle_data_t *pipe_handle,
1540Sstevel@tonic-gate 		usb_intr_req_t *req, usb_flags_t flags);
1550Sstevel@tonic-gate 
1560Sstevel@tonic-gate /* Bulk prototypes */
1570Sstevel@tonic-gate void	uhci_handle_bulk_td(uhci_state_t *uhcip, uhci_td_t *td);
1580Sstevel@tonic-gate void	uhci_fill_in_bulk_isoc_td(uhci_state_t *uhcip,
1590Sstevel@tonic-gate 		uhci_td_t *current_td, uhci_td_t *next_td,
1600Sstevel@tonic-gate 		uint32_t next_td_paddr, usba_pipe_handle_data_t *ph,
1612125Ssl147100 		uint_t offset, uint_t length,
1620Sstevel@tonic-gate 		uhci_trans_wrapper_t *tw);
1630Sstevel@tonic-gate void	uhci_remove_bulk_tds_tws(uhci_state_t *uhcip,
1640Sstevel@tonic-gate 		uhci_pipe_private_t *pp, int);
1650Sstevel@tonic-gate 
1660Sstevel@tonic-gate /* Isoc prototypes */
1670Sstevel@tonic-gate int	uhci_insert_isoc_td(uhci_state_t *uhcip,
1680Sstevel@tonic-gate 		usba_pipe_handle_data_t *ph, usb_isoc_req_t *isoc_req,
1690Sstevel@tonic-gate 		size_t length, usb_flags_t usb_flags);
1700Sstevel@tonic-gate void	uhci_handle_isoc_td(uhci_state_t *uhcip, uhci_td_t *td);
1710Sstevel@tonic-gate int	uhci_start_isoc_receive_polling(
1720Sstevel@tonic-gate 		uhci_state_t *uhcip, usba_pipe_handle_data_t *ph,
1730Sstevel@tonic-gate 		usb_isoc_req_t *isoc_req, usb_flags_t usb_flags);
1740Sstevel@tonic-gate void	uhci_remove_isoc_tds_tws(uhci_state_t *uhcip,
1750Sstevel@tonic-gate 		uhci_pipe_private_t *ph);
1760Sstevel@tonic-gate uint64_t uhci_get_sw_frame_number(uhci_state_t *uhcip);
1770Sstevel@tonic-gate void	uhci_isoc_update_sw_frame_number(uhci_state_t *uhcip);
1780Sstevel@tonic-gate 
1790Sstevel@tonic-gate /* kstat support */
1800Sstevel@tonic-gate void	uhci_create_stats(uhci_state_t *uhcip);
1810Sstevel@tonic-gate void	uhci_destroy_stats(uhci_state_t *uhcip);
1820Sstevel@tonic-gate 
1830Sstevel@tonic-gate /* arithmetic goodies */
1845773Sqz150045 uint_t	pow_2(unsigned int x);
1855773Sqz150045 uint_t	log_2(unsigned int x);
1860Sstevel@tonic-gate 
1870Sstevel@tonic-gate #ifdef __cplusplus
1880Sstevel@tonic-gate }
1890Sstevel@tonic-gate #endif
1900Sstevel@tonic-gate 
1910Sstevel@tonic-gate #endif /* _SYS_USB_UHCIUTIL_H */
192