xref: /onnv-gate/usr/src/uts/common/sys/usb/hcd/openhci/ohcid.h (revision 9095:ef4ae1685182)
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*9095SZhigang.Lu@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_OHCID_H
270Sstevel@tonic-gate #define	_SYS_USB_OHCID_H
280Sstevel@tonic-gate 
290Sstevel@tonic-gate #ifdef	__cplusplus
300Sstevel@tonic-gate extern "C" {
310Sstevel@tonic-gate #endif
320Sstevel@tonic-gate 
330Sstevel@tonic-gate /*
340Sstevel@tonic-gate  * Open Host Controller Driver (OHCI)
350Sstevel@tonic-gate  *
360Sstevel@tonic-gate  * The USB Open Host Controller driver is a software driver which interfaces
370Sstevel@tonic-gate  * to the Universal Serial Bus layer (USBA) and the USB Open Host Controller.
380Sstevel@tonic-gate  * The interface to USB Open Host Controller is defined by the OpenHCI  Host
390Sstevel@tonic-gate  * Controller Interface.
400Sstevel@tonic-gate  *
410Sstevel@tonic-gate  * This header file describes the data structures required for the USB Open
420Sstevel@tonic-gate  * Host Controller Driver to maintain state of USB Open Host Controller, to
430Sstevel@tonic-gate  * perform different USB transfers and for the bandwidth allocations.
440Sstevel@tonic-gate  */
450Sstevel@tonic-gate 
460Sstevel@tonic-gate #include <sys/usb/hcd/openhci/ohci.h>
470Sstevel@tonic-gate #include <sys/usb/hcd/openhci/ohci_hub.h>
480Sstevel@tonic-gate 
490Sstevel@tonic-gate /*
500Sstevel@tonic-gate  * OpenHCI interrupt status information structure
510Sstevel@tonic-gate  *
520Sstevel@tonic-gate  * The Host Controller Driver (HCD) has to maintain two different sets of
530Sstevel@tonic-gate  * Host Controller (HC) state information that includes HC registers, the
540Sstevel@tonic-gate  * interrupt tables etc.. for the normal and polled modes.  In	addition,
550Sstevel@tonic-gate  * suppose if we switched to polled mode while ohci  interrupt handler is
560Sstevel@tonic-gate  * executing in the normal mode then we need to save the interrupt status
570Sstevel@tonic-gate  * information that includes interrupts for which ohci interrupt  handler
580Sstevel@tonic-gate  * is called and HCCA done head list in the polled mode. This infromation
590Sstevel@tonic-gate  * will be used later in normal mode to  service those missed interrupts.
600Sstevel@tonic-gate  * This will avoid race conditions like missing of normal mode's ohci SOF
610Sstevel@tonic-gate  * and WriteDoneHead interrupts because of this polled switch.
620Sstevel@tonic-gate  */
630Sstevel@tonic-gate typedef struct ohci_save_intr_sts {
640Sstevel@tonic-gate 	/*
650Sstevel@tonic-gate 	 * The following field has set of flags & these flags will be set
660Sstevel@tonic-gate 	 * in the ohci interrupt handler to indicate that currently  ohci
670Sstevel@tonic-gate 	 * interrupt handler is in execution and also while critical code
680Sstevel@tonic-gate 	 * execution within the ohci interrupt handler.  These flags will
690Sstevel@tonic-gate 	 * be verified in polled mode while saving the normal mode's ohci
700Sstevel@tonic-gate 	 * interrupt status information.
710Sstevel@tonic-gate 	 */
720Sstevel@tonic-gate 	uint_t		ohci_intr_flag;		/* Intr handler flags */
730Sstevel@tonic-gate 
740Sstevel@tonic-gate 	/*
750Sstevel@tonic-gate 	 * The following fields will be used to save the interrupt status
760Sstevel@tonic-gate 	 * and the HCCA done head list that the ohci interrupt handler is
770Sstevel@tonic-gate 	 * currently handling.
780Sstevel@tonic-gate 	 */
790Sstevel@tonic-gate 	uint_t		ohci_curr_intr_sts;	/* Current interrupts */
800Sstevel@tonic-gate 	ohci_td_t	*ohci_curr_done_lst;	/* Current done head  */
810Sstevel@tonic-gate 
820Sstevel@tonic-gate 	/*
830Sstevel@tonic-gate 	 * The following fields will be used to save the interrupt status
840Sstevel@tonic-gate 	 * and the HCCA done list currently being handled by the critical
850Sstevel@tonic-gate 	 * section of the ohci interrupt handler..
860Sstevel@tonic-gate 	 */
870Sstevel@tonic-gate 	uint_t		ohci_critical_intr_sts;	/* Critical interrupts */
880Sstevel@tonic-gate 	ohci_td_t	*ohci_critical_done_lst; /* Critical done head */
890Sstevel@tonic-gate 
900Sstevel@tonic-gate 	/*
910Sstevel@tonic-gate 	 * The following fields will be used to save the interrupt status
920Sstevel@tonic-gate 	 * and HCCA done head list by the polled code if an  interrupt is
930Sstevel@tonic-gate 	 * pending when polled code is entered. These missed interrupts &
940Sstevel@tonic-gate 	 * done list will be serviced either in current  normal mode ohci
950Sstevel@tonic-gate 	 * interrupt handler execution or during the next  ohci interrupt
960Sstevel@tonic-gate 	 * handler execution.
970Sstevel@tonic-gate 	 */
980Sstevel@tonic-gate 	uint_t		ohci_missed_intr_sts;	/* Missed interrupts */
990Sstevel@tonic-gate 	ohci_td_t	*ohci_missed_done_lst;	/* Missed done head  */
1000Sstevel@tonic-gate } ohci_save_intr_sts_t;
1010Sstevel@tonic-gate 
1020Sstevel@tonic-gate /*
1030Sstevel@tonic-gate  * These flags will be set in the the normal mode ohci	interrupt handler
1040Sstevel@tonic-gate  * to indicate that currently ohci interrupt handler is in  execution and
1050Sstevel@tonic-gate  * also while critical code  execution within the ohci interrupt handler.
1060Sstevel@tonic-gate  * These flags will be verified in the polled mode while saving the normal
1070Sstevel@tonic-gate  * mode's ohci interrupt status infromation.
1080Sstevel@tonic-gate  */
1090Sstevel@tonic-gate #define		OHCI_INTR_HANDLING	0x01	/* Handling ohci intrs */
1100Sstevel@tonic-gate #define		OHCI_INTR_CRITICAL	0x02	/* Critical intr code  */
1110Sstevel@tonic-gate 
1120Sstevel@tonic-gate 
1130Sstevel@tonic-gate /*
1140Sstevel@tonic-gate  * OpenHCI Host Controller state structure
1150Sstevel@tonic-gate  *
1160Sstevel@tonic-gate  * The Host Controller Driver (HCD) maintains the state of Host Controller
1170Sstevel@tonic-gate  * (HC). There is an ohci_state structure per instance	of the OpenHCI
1180Sstevel@tonic-gate  * host controller.
1190Sstevel@tonic-gate  */
1200Sstevel@tonic-gate 
1210Sstevel@tonic-gate typedef struct ohci_state {
1220Sstevel@tonic-gate 	dev_info_t		*ohci_dip;		/* Dip of HC */
1230Sstevel@tonic-gate 	uint_t			ohci_instance;
1240Sstevel@tonic-gate 	usba_hcdi_ops_t		*ohci_hcdi_ops;		/* HCDI structure */
1250Sstevel@tonic-gate 	uint_t			ohci_flags;		/* Used for cleanup */
1260Sstevel@tonic-gate 	uint16_t		ohci_vendor_id;		/* chip vendor */
1270Sstevel@tonic-gate 	uint16_t		ohci_device_id;		/* chip device */
1280Sstevel@tonic-gate 	uint8_t			ohci_rev_id;		/* chip revison */
1290Sstevel@tonic-gate 
1300Sstevel@tonic-gate 	ohci_regs_t		*ohci_regsp;		/* Host ctlr regs */
1310Sstevel@tonic-gate 	ddi_acc_handle_t	ohci_regs_handle;	/* Reg handle */
1320Sstevel@tonic-gate 
1330Sstevel@tonic-gate 	ddi_acc_handle_t	ohci_config_handle;	/* Config space hndle */
1340Sstevel@tonic-gate 	uint_t			ohci_frame_interval;	/* Frme inter reg */
1350Sstevel@tonic-gate 	ddi_dma_attr_t		ohci_dma_attr;		/* DMA attributes */
1360Sstevel@tonic-gate 
1370Sstevel@tonic-gate 	ddi_intr_handle_t	*ohci_htable;		/* intr handle */
138965Sgovinda 	int			ohci_intr_type;		/* intr type used */
139965Sgovinda 	int			ohci_intr_cnt;		/* # of intrs inuse */
1400Sstevel@tonic-gate 	uint_t			ohci_intr_pri;		/* intr priority */
141965Sgovinda 	int			ohci_intr_cap;		/* intr capabilities */
1427842SZhigang.Lu@Sun.COM 	boolean_t		ohci_msi_enabled;	/* default to true */
1430Sstevel@tonic-gate 	kmutex_t		ohci_int_mutex;		/* Mutex for struct */
1440Sstevel@tonic-gate 
1450Sstevel@tonic-gate 	/* HCCA area */
1460Sstevel@tonic-gate 	ohci_hcca_t		*ohci_hccap;		/* Virtual HCCA ptr */
1470Sstevel@tonic-gate 	ddi_dma_cookie_t	ohci_hcca_cookie;	/* DMA cookie */
1480Sstevel@tonic-gate 	ddi_dma_handle_t	ohci_hcca_dma_handle;	/* DMA handle */
1490Sstevel@tonic-gate 	ddi_acc_handle_t	ohci_hcca_mem_handle;	/* Memory handle */
1500Sstevel@tonic-gate 
1510Sstevel@tonic-gate 	/*
1520Sstevel@tonic-gate 	 * There are two pools of memory. One pool contains the memory for
1530Sstevel@tonic-gate 	 * the transfer descriptors and other pool contains the memory for
1540Sstevel@tonic-gate 	 * the endpoint descriptors. The advantage of the pools is that it's
1550Sstevel@tonic-gate 	 * easy to go back and forth between the iommu and the cpu addresses.
1560Sstevel@tonic-gate 	 *
1570Sstevel@tonic-gate 	 * The pools are protected by the ohci_int_mutex because the memory
1580Sstevel@tonic-gate 	 * in the pools may be accessed by either the host controller or the
1590Sstevel@tonic-gate 	 * host controller driver.
1600Sstevel@tonic-gate 	 */
1610Sstevel@tonic-gate 
1620Sstevel@tonic-gate 	/* General transfer descriptor pool */
1630Sstevel@tonic-gate 	ohci_td_t		*ohci_td_pool_addr;	/* Start of the pool */
1640Sstevel@tonic-gate 	ddi_dma_cookie_t	ohci_td_pool_cookie;	/* DMA cookie */
1650Sstevel@tonic-gate 	ddi_dma_handle_t	ohci_td_pool_dma_handle;	/* DMA hndle */
1660Sstevel@tonic-gate 	ddi_acc_handle_t	ohci_td_pool_mem_handle;	/* Mem hndle */
1670Sstevel@tonic-gate 
1680Sstevel@tonic-gate 	/* Endpoint descriptor pool */
1690Sstevel@tonic-gate 	ohci_ed_t		*ohci_ed_pool_addr;	/* Start of the pool */
1700Sstevel@tonic-gate 	ddi_dma_cookie_t	ohci_ed_pool_cookie;	/* DMA cookie */
1710Sstevel@tonic-gate 	ddi_dma_handle_t	ohci_ed_pool_dma_handle;	/* DMA handle */
1720Sstevel@tonic-gate 	ddi_acc_handle_t	ohci_ed_pool_mem_handle;	/* Mem handle */
1730Sstevel@tonic-gate 	uint_t			ohci_dma_addr_bind_flag;	/* DMA flag */
1740Sstevel@tonic-gate 
1750Sstevel@tonic-gate 	/* Condition variables */
1760Sstevel@tonic-gate 	kcondvar_t		ohci_SOF_cv;		/* SOF variable */
1770Sstevel@tonic-gate 
1780Sstevel@tonic-gate 	/* Semaphore to serialize opens and closes */
1790Sstevel@tonic-gate 	ksema_t			ohci_ocsem;
1800Sstevel@tonic-gate 
1810Sstevel@tonic-gate 	/*
1820Sstevel@tonic-gate 	 * Bandwidth fields
1830Sstevel@tonic-gate 	 *
1840Sstevel@tonic-gate 	 * The ohci_bandwidth array keeps track of the allocated bandwidth
1850Sstevel@tonic-gate 	 * for this host controller. The total bandwidth allocated for least
1860Sstevel@tonic-gate 	 * allocated list out of the 32 periodic lists is represented by the
1870Sstevel@tonic-gate 	 * ohci_periodic_minimum_bandwidth field.
1880Sstevel@tonic-gate 	 */
1890Sstevel@tonic-gate 	uint_t			ohci_periodic_minimum_bandwidth;
1900Sstevel@tonic-gate 	uint_t			ohci_periodic_bandwidth[NUM_INTR_ED_LISTS];
1910Sstevel@tonic-gate 
1920Sstevel@tonic-gate 	/* Different transfer open pipe counts */
1930Sstevel@tonic-gate 	uint_t			ohci_open_pipe_count;
1940Sstevel@tonic-gate 	uint_t			ohci_open_ctrl_pipe_count;
1950Sstevel@tonic-gate 	uint_t			ohci_open_bulk_pipe_count;
1960Sstevel@tonic-gate 	uint_t			ohci_open_periodic_pipe_count;
1970Sstevel@tonic-gate 	uint_t			ohci_open_isoch_pipe_count;
1980Sstevel@tonic-gate 	/*
1990Sstevel@tonic-gate 	 * Endpoint Reclamation List
2000Sstevel@tonic-gate 	 *
2010Sstevel@tonic-gate 	 * The interrupt or isochronous list processing cannot be stopped
2020Sstevel@tonic-gate 	 * when a periodic endpoint is removed from the list. The endpoints
2030Sstevel@tonic-gate 	 * are detached from the interrupt lattice tree and put on to the
2040Sstevel@tonic-gate 	 * reclaimation list. On next SOF interrupt all those endpoints,
2050Sstevel@tonic-gate 	 * which are on the reclaimation list will be deallocated.
2060Sstevel@tonic-gate 	 */
2070Sstevel@tonic-gate 	ohci_ed_t		*ohci_reclaim_list;	/* Reclaimation list */
2080Sstevel@tonic-gate 
2090Sstevel@tonic-gate 	ohci_root_hub_t		ohci_root_hub;		/* Root hub info */
2100Sstevel@tonic-gate 
2110Sstevel@tonic-gate 	/*
2120Sstevel@tonic-gate 	 * Global transfer timeout handling & this transfer timeout handling
2130Sstevel@tonic-gate 	 * will be per USB Host Controller.
2140Sstevel@tonic-gate 	 */
2150Sstevel@tonic-gate 	struct ohci_trans_wrapper *ohci_timeout_list;	/* Timeout List */
2160Sstevel@tonic-gate 	timeout_id_t		ohci_timer_id;		/* Timer id  */
2170Sstevel@tonic-gate 
2180Sstevel@tonic-gate 	/* Frame number overflow information */
2190Sstevel@tonic-gate 	usb_frame_number_t	ohci_fno;
2200Sstevel@tonic-gate 
2210Sstevel@tonic-gate 	/* For Schedule Overrun error counter */
2220Sstevel@tonic-gate 	uint_t			ohci_so_error;
2230Sstevel@tonic-gate 
2240Sstevel@tonic-gate 	/* For host controller error counter */
2250Sstevel@tonic-gate 	uint_t			ohci_hc_error;
2260Sstevel@tonic-gate 
2270Sstevel@tonic-gate 	/* For SOF interrupt event */
2280Sstevel@tonic-gate 	boolean_t		ohci_sof_flag;
2290Sstevel@tonic-gate 
2300Sstevel@tonic-gate 	/* Openhci Host Controller Software State information */
2310Sstevel@tonic-gate 	uint_t			ohci_hc_soft_state;
2320Sstevel@tonic-gate 
2330Sstevel@tonic-gate 	/*
2340Sstevel@tonic-gate 	 * ohci_save_intr_stats is used to save the normal mode interrupt
2350Sstevel@tonic-gate 	 * status information while executing interrupt handler & also by
2360Sstevel@tonic-gate 	 * the polled code if an interrupt is pending for the normal mode
2370Sstevel@tonic-gate 	 * when polled code is entered.
2380Sstevel@tonic-gate 	 */
2390Sstevel@tonic-gate 	ohci_save_intr_sts_t	ohci_save_intr_sts;
2400Sstevel@tonic-gate 
2410Sstevel@tonic-gate 	/*
2420Sstevel@tonic-gate 	 * Saved copy of the ohci registers of the normal mode & change
2430Sstevel@tonic-gate 	 * required ohci registers values for the polled mode operation.
2440Sstevel@tonic-gate 	 * Before returning from the polled mode to normal mode replace
2450Sstevel@tonic-gate 	 * the required current registers with this saved ohci registers
2460Sstevel@tonic-gate 	 * copy.
2470Sstevel@tonic-gate 	 */
2480Sstevel@tonic-gate 	ohci_regs_t	ohci_polled_save_regs;
2490Sstevel@tonic-gate 
2500Sstevel@tonic-gate 	/*
2510Sstevel@tonic-gate 	 * Saved copy of the interrupt table used in normal ohci mode and
2520Sstevel@tonic-gate 	 * replace this table by another interrupt table that used in the
2530Sstevel@tonic-gate 	 * POLLED mode.
2540Sstevel@tonic-gate 	 */
2550Sstevel@tonic-gate 	ohci_ed_t	*ohci_polled_save_IntTble[NUM_INTR_ED_LISTS];
2560Sstevel@tonic-gate 
2570Sstevel@tonic-gate 	/* ohci polled mode enter counter for the input devices */
2580Sstevel@tonic-gate 	uint_t			ohci_polled_enter_count;
2590Sstevel@tonic-gate 
2600Sstevel@tonic-gate 	/*
2610Sstevel@tonic-gate 	 * Counter for polled mode and used in suspend mode to see if
2620Sstevel@tonic-gate 	 * there is a input device connected.
2630Sstevel@tonic-gate 	 */
2640Sstevel@tonic-gate 	uint_t			ohci_polled_kbd_count;
2650Sstevel@tonic-gate 
2660Sstevel@tonic-gate 	/* Done list for the Polled mode */
2670Sstevel@tonic-gate 	ohci_td_t		*ohci_polled_done_list;
2680Sstevel@tonic-gate 
2690Sstevel@tonic-gate 	/* Log handle for debug, console, log messages */
2700Sstevel@tonic-gate 	usb_log_handle_t	ohci_log_hdl;
2710Sstevel@tonic-gate 
2720Sstevel@tonic-gate 	/* Kstat structures */
2730Sstevel@tonic-gate 	kstat_t			*ohci_intrs_stats;
2740Sstevel@tonic-gate 	kstat_t			*ohci_total_stats;
2750Sstevel@tonic-gate 	kstat_t			*ohci_count_stats[USB_N_COUNT_KSTATS];
2760Sstevel@tonic-gate } ohci_state_t;
2770Sstevel@tonic-gate 
2780Sstevel@tonic-gate typedef struct ohci_intrs_stats {
2790Sstevel@tonic-gate 	struct kstat_named	ohci_hcr_intr_so;
2800Sstevel@tonic-gate 	struct kstat_named	ohci_hcr_intr_wdh;
2810Sstevel@tonic-gate 	struct kstat_named	ohci_hcr_intr_sof;
2820Sstevel@tonic-gate 	struct kstat_named	ohci_hcr_intr_rd;
2830Sstevel@tonic-gate 	struct kstat_named	ohci_hcr_intr_ue;
2840Sstevel@tonic-gate 	struct kstat_named	ohci_hcr_intr_fno;
2850Sstevel@tonic-gate 	struct kstat_named	ohci_hcr_intr_rhsc;
2860Sstevel@tonic-gate 	struct kstat_named	ohci_hcr_intr_oc;
2870Sstevel@tonic-gate 	struct kstat_named	ohci_hcr_intr_not_claimed;
2880Sstevel@tonic-gate 	struct kstat_named	ohci_hcr_intr_total;
2890Sstevel@tonic-gate } ohci_intrs_stats_t;
2900Sstevel@tonic-gate 
2910Sstevel@tonic-gate /*
2920Sstevel@tonic-gate  * ohci kstat defines
2930Sstevel@tonic-gate  */
2940Sstevel@tonic-gate #define	OHCI_INTRS_STATS(ohci)	((ohci)->ohci_intrs_stats)
2950Sstevel@tonic-gate #define	OHCI_INTRS_STATS_DATA(ohci)	\
2960Sstevel@tonic-gate 	((ohci_intrs_stats_t *)OHCI_INTRS_STATS((ohci))->ks_data)
2970Sstevel@tonic-gate 
2980Sstevel@tonic-gate #define	OHCI_TOTAL_STATS(ohci)	((ohci)->ohci_total_stats)
2990Sstevel@tonic-gate #define	OHCI_TOTAL_STATS_DATA(ohci)	(KSTAT_IO_PTR((ohci)->ohci_total_stats))
3000Sstevel@tonic-gate #define	OHCI_CTRL_STATS(ohci)	\
3010Sstevel@tonic-gate 	(KSTAT_IO_PTR((ohci)->ohci_count_stats[USB_EP_ATTR_CONTROL]))
3020Sstevel@tonic-gate #define	OHCI_BULK_STATS(ohci)	\
3030Sstevel@tonic-gate 	(KSTAT_IO_PTR((ohci)->ohci_count_stats[USB_EP_ATTR_BULK]))
3040Sstevel@tonic-gate #define	OHCI_INTR_STATS(ohci)	\
3050Sstevel@tonic-gate 	(KSTAT_IO_PTR((ohci)->ohci_count_stats[USB_EP_ATTR_INTR]))
3060Sstevel@tonic-gate #define	OHCI_ISOC_STATS(ohci)	\
3070Sstevel@tonic-gate 	(KSTAT_IO_PTR((ohci)->ohci_count_stats[USB_EP_ATTR_ISOCH]))
3080Sstevel@tonic-gate 
3090Sstevel@tonic-gate /* warlock directives, stable data */
3100Sstevel@tonic-gate _NOTE(MUTEX_PROTECTS_DATA(ohci_state_t::ohci_int_mutex, ohci_state_t))
3110Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(ohci_state_t::ohci_intr_pri))
3120Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(ohci_state_t::ohci_dip))
3130Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(ohci_state_t::ohci_regsp))
3140Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(ohci_state_t::ohci_instance))
3150Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(ohci_state_t::ohci_vendor_id))
3160Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(ohci_state_t::ohci_device_id))
3170Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(ohci_state_t::ohci_rev_id))
3180Sstevel@tonic-gate 
3190Sstevel@tonic-gate /* this may not be stable data in the future */
3200Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(ohci_state_t::ohci_td_pool_addr))
3210Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(ohci_state_t::ohci_td_pool_mem_handle))
3220Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(ohci_state_t::ohci_ed_pool_addr))
3230Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(ohci_state_t::ohci_ed_pool_mem_handle))
3240Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(ohci_state_t::ohci_td_pool_cookie))
3250Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(ohci_state_t::ohci_ed_pool_cookie))
3260Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(ohci_state_t::ohci_hcca_mem_handle))
3270Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(ohci_state_t::ohci_hccap))
3280Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(ohci_state_t::ohci_dma_addr_bind_flag))
3290Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(ohci_state_t::ohci_log_hdl))
3300Sstevel@tonic-gate 
3310Sstevel@tonic-gate _NOTE(LOCK_ORDER(ohci_state::ohci_int_mutex \
3320Sstevel@tonic-gate 		usba_pipe_handle_data::p_mutex \
3330Sstevel@tonic-gate 		usba_device::usb_mutex \
3340Sstevel@tonic-gate 		usba_ph_impl::usba_ph_mutex))
3350Sstevel@tonic-gate 
3360Sstevel@tonic-gate /*
3370Sstevel@tonic-gate  * Host Contoller Software States
3380Sstevel@tonic-gate  *
3390Sstevel@tonic-gate  * OHCI_CTLR_INIT_STATE:
3400Sstevel@tonic-gate  *	The host controller soft state will be set to this during the
3410Sstevel@tonic-gate  *	ohci_attach.
3420Sstevel@tonic-gate  *
3430Sstevel@tonic-gate  * OHCI_CTLR_SUSPEND_STATE:
3440Sstevel@tonic-gate  *	The host controller soft state will be set to this during the
3450Sstevel@tonic-gate  *	ohci_cpr_suspend.
3460Sstevel@tonic-gate  *
3470Sstevel@tonic-gate  * OHCI_CTLR_OPERATIONAL_STATE:
3480Sstevel@tonic-gate  *	The host controller soft state will be set to this after moving
3490Sstevel@tonic-gate  *	host controller to operational state and host controller start
3500Sstevel@tonic-gate  *	generating SOF successfully.
3510Sstevel@tonic-gate  *
3520Sstevel@tonic-gate  * OHCI_CTLR_ERROR_STATE:
3530Sstevel@tonic-gate  *	The host controller soft state will be set to this during the
3540Sstevel@tonic-gate  *	no SOF or UE error conditions.
3550Sstevel@tonic-gate  *
3560Sstevel@tonic-gate  *	Under this state or condition, only pipe stop polling, pipe reset
3570Sstevel@tonic-gate  *	and pipe close are allowed. But all other entry points like  pipe
3580Sstevel@tonic-gate  *	open, get/set pipe policy, cotrol send/receive, bulk send/receive
3590Sstevel@tonic-gate  *	isoch send/receive, start polling etc. will fail.
3600Sstevel@tonic-gate  *
3610Sstevel@tonic-gate  * State Diagram for the host controller software state
3620Sstevel@tonic-gate  *
3630Sstevel@tonic-gate  *
3640Sstevel@tonic-gate  * ohci_attach->[INIT_STATE]
3650Sstevel@tonic-gate  *	|
3660Sstevel@tonic-gate  *	|	-------->----[ERROR_STATE]--<-----------<---
3670Sstevel@tonic-gate  *	|      |      Failure (UE/no SOF condition)	    |
3680Sstevel@tonic-gate  *	|      ^					    ^
3690Sstevel@tonic-gate  *	V      |      Success				    |
3700Sstevel@tonic-gate  * ohci_init_ctlr--->--------[OPERATIONAL_STATE]------>-ohci_send/recv/polling
3710Sstevel@tonic-gate  *	^					    |
3720Sstevel@tonic-gate  *	|					    |
3730Sstevel@tonic-gate  *	|					    V
3740Sstevel@tonic-gate  *	-<-ohci_cpr_resume--[SUSPEND_STATE]-<-ohci_cpr_suspend
3750Sstevel@tonic-gate  */
3760Sstevel@tonic-gate #define	OHCI_CTLR_INIT_STATE		0	/* Initilization state */
3770Sstevel@tonic-gate #define	OHCI_CTLR_SUSPEND_STATE		1	/* Suspend state */
3780Sstevel@tonic-gate #define	OHCI_CTLR_OPERATIONAL_STATE	2	/* Operational state */
3790Sstevel@tonic-gate #define	OHCI_CTLR_ERROR_STATE		3	/* Ue error or no sof state */
3800Sstevel@tonic-gate 
3810Sstevel@tonic-gate /*
3820Sstevel@tonic-gate  * Define all ohci's Vendor-id and Device-id Here
3830Sstevel@tonic-gate  */
3840Sstevel@tonic-gate #define	RIO_VENDOR	0x108e
3850Sstevel@tonic-gate #define	RIO_DEVICE	0x1103
3860Sstevel@tonic-gate #define	OHCI_IS_RIO(ohcip)	(ohcip->ohci_vendor_id == RIO_VENDOR)
3870Sstevel@tonic-gate 
3880Sstevel@tonic-gate /*
3890Sstevel@tonic-gate  * Periodic and non-periodic macros
3900Sstevel@tonic-gate  */
3910Sstevel@tonic-gate #define	OHCI_PERIODIC_ENDPOINT(endpoint) (((endpoint->bmAttributes &\
3920Sstevel@tonic-gate 				USB_EP_ATTR_MASK) == USB_EP_ATTR_INTR) ||\
3930Sstevel@tonic-gate 				((endpoint->bmAttributes &\
3940Sstevel@tonic-gate 				USB_EP_ATTR_MASK) == USB_EP_ATTR_ISOCH))
3950Sstevel@tonic-gate 
3960Sstevel@tonic-gate #define	OHCI_NON_PERIODIC_ENDPOINT(endpoint) (((endpoint->bmAttributes &\
3970Sstevel@tonic-gate 				USB_EP_ATTR_MASK) == USB_EP_ATTR_CONTROL) ||\
3980Sstevel@tonic-gate 				((endpoint->bmAttributes &\
3990Sstevel@tonic-gate 				USB_EP_ATTR_MASK) == USB_EP_ATTR_BULK))
4000Sstevel@tonic-gate 
4010Sstevel@tonic-gate /*
4020Sstevel@tonic-gate  * OHCI ED and TD Pool sizes.
4030Sstevel@tonic-gate  */
4040Sstevel@tonic-gate #define	OHCI_ED_POOL_SIZE	100
4050Sstevel@tonic-gate #define	OHCI_TD_POOL_SIZE	200
4060Sstevel@tonic-gate 
4070Sstevel@tonic-gate /*
4080Sstevel@tonic-gate  * ohci_dma_addr_bind_flag values
4090Sstevel@tonic-gate  *
4100Sstevel@tonic-gate  * This flag indicates if the various DMA addresses allocated by the OHCI
4110Sstevel@tonic-gate  * have been bound to their respective handles. This is needed to recover
4120Sstevel@tonic-gate  * without errors from ohci_cleanup when it calls ddi_dma_unbind_handle()
4130Sstevel@tonic-gate  */
4140Sstevel@tonic-gate #define	OHCI_TD_POOL_BOUND	0x01	/* For TD pools  */
4150Sstevel@tonic-gate #define	OHCI_ED_POOL_BOUND	0x02	/* For ED pools  */
4160Sstevel@tonic-gate #define	OHCI_HCCA_DMA_BOUND	0x04	/* For HCCA area */
4170Sstevel@tonic-gate 
4180Sstevel@tonic-gate /*
4190Sstevel@tonic-gate  * Maximum SOF wait count
4200Sstevel@tonic-gate  */
4210Sstevel@tonic-gate #define	MAX_SOF_WAIT_COUNT	2	/* Wait for maximum SOF frames */
4220Sstevel@tonic-gate 
4230Sstevel@tonic-gate 
4240Sstevel@tonic-gate /*
4250Sstevel@tonic-gate  * Pipe private structure
4260Sstevel@tonic-gate  *
4270Sstevel@tonic-gate  * There is an instance of this structure per pipe.  This structure holds
4280Sstevel@tonic-gate  * HCD specific pipe information.  A pointer to this structure is kept in
4290Sstevel@tonic-gate  * the USBA pipe handle (usba_pipe_handle_data_t).
4300Sstevel@tonic-gate  */
4310Sstevel@tonic-gate typedef struct ohci_pipe_private {
4320Sstevel@tonic-gate 	usba_pipe_handle_data_t	*pp_pipe_handle;	/* Back ptr to handle */
4330Sstevel@tonic-gate 	ohci_ed_t		*pp_ept;		/* Pipe's ept */
4340Sstevel@tonic-gate 
4350Sstevel@tonic-gate 	/* State of the pipe */
4360Sstevel@tonic-gate 	uint_t			pp_state;		/* See below */
4370Sstevel@tonic-gate 
4380Sstevel@tonic-gate 	/* Local copy of the pipe policy */
4390Sstevel@tonic-gate 	usb_pipe_policy_t	pp_policy;
4400Sstevel@tonic-gate 
4410Sstevel@tonic-gate 	/* For Periodic Pipes Only */
4420Sstevel@tonic-gate 	uint_t			pp_node;		/* Node in lattice */
4430Sstevel@tonic-gate 	uint_t			pp_cur_periodic_req_cnt; /* Curr req count */
4440Sstevel@tonic-gate 	uint_t			pp_max_periodic_req_cnt; /* Max req count */
4450Sstevel@tonic-gate 
4460Sstevel@tonic-gate 	/* For isochronous pipe only */
4470Sstevel@tonic-gate 	usb_frame_number_t	pp_next_frame_number;	/* Next frame no */
4480Sstevel@tonic-gate 
4490Sstevel@tonic-gate 	/*
4500Sstevel@tonic-gate 	 * Each pipe may have multiple transfer wrappers. Each transfer
4510Sstevel@tonic-gate 	 * wrapper represents a USB transfer on the bus.  A transfer is
4520Sstevel@tonic-gate 	 * made up of one or more transactions.
4530Sstevel@tonic-gate 	 */
4540Sstevel@tonic-gate 	struct ohci_trans_wrapper *pp_tw_head;	/* Head of the list */
4550Sstevel@tonic-gate 	struct ohci_trans_wrapper *pp_tw_tail;	/* Tail of the list */
4560Sstevel@tonic-gate 
4570Sstevel@tonic-gate 	/* Done td count */
4580Sstevel@tonic-gate 	uint_t			pp_count_done_tds;	/* Done td count */
4590Sstevel@tonic-gate 
4600Sstevel@tonic-gate 	/* Errors */
4610Sstevel@tonic-gate 	usb_cr_t		pp_error;		/* Pipe error */
4620Sstevel@tonic-gate 
4630Sstevel@tonic-gate 	/* Flags */
4640Sstevel@tonic-gate 	uint_t			pp_flag;		/* Flags */
4650Sstevel@tonic-gate 
4660Sstevel@tonic-gate 	/* Condition variable for transfers completion event */
4670Sstevel@tonic-gate 	kcondvar_t		pp_xfer_cmpl_cv;	/* Xfer completion */
4680Sstevel@tonic-gate 
4690Sstevel@tonic-gate 	/*
4700Sstevel@tonic-gate 	 * HCD gets Interrupt/Isochronous IN polling request only once and
4710Sstevel@tonic-gate 	 * it has to insert next polling requests after completion of first
4720Sstevel@tonic-gate 	 * request until either stop polling/pipe close is called. So  HCD
4730Sstevel@tonic-gate 	 * has to take copy of the original Interrupt/Isochronous IN request.
4740Sstevel@tonic-gate 	 */
4750Sstevel@tonic-gate 	usb_opaque_t		pp_client_periodic_in_reqp;
4760Sstevel@tonic-gate } ohci_pipe_private_t;
4770Sstevel@tonic-gate 
4780Sstevel@tonic-gate /* warlock directives, stable data */
4790Sstevel@tonic-gate _NOTE(MUTEX_PROTECTS_DATA(ohci_state_t::ohci_int_mutex, ohci_pipe_private_t))
4800Sstevel@tonic-gate 
4810Sstevel@tonic-gate /*
4820Sstevel@tonic-gate  * Pipe states
4830Sstevel@tonic-gate  *
4840Sstevel@tonic-gate  * ohci pipe states will be similar to usba. Refer usbai.h.
4850Sstevel@tonic-gate  */
4860Sstevel@tonic-gate #define	OHCI_PIPE_STATE_IDLE		1	/* Pipe is in ready state */
4870Sstevel@tonic-gate #define	OHCI_PIPE_STATE_ACTIVE		2	/* Pipe is in busy state */
4880Sstevel@tonic-gate #define	OHCI_PIPE_STATE_ERROR		3	/* Pipe is in error state */
4890Sstevel@tonic-gate 
4900Sstevel@tonic-gate /* Additional ohci pipe states for the ohci_pipe_cleanup */
4910Sstevel@tonic-gate #define	OHCI_PIPE_STATE_CLOSE		4	/* Pipe close */
4920Sstevel@tonic-gate #define	OHCI_PIPE_STATE_RESET		5	/* Pipe reset */
4930Sstevel@tonic-gate #define	OHCI_PIPE_STATE_STOP_POLLING	6	/* Pipe stop polling */
4940Sstevel@tonic-gate 
4950Sstevel@tonic-gate /*
4960Sstevel@tonic-gate  * Pipe specific Flags
4970Sstevel@tonic-gate  */
4980Sstevel@tonic-gate #define	OHCI_ISOC_XFER_CONTINUE	1	/* For isoc transfers */
4990Sstevel@tonic-gate 
5000Sstevel@tonic-gate /*
5010Sstevel@tonic-gate  * The maximum allowable usb isochronous data transfer size or maximum
5020Sstevel@tonic-gate  * number of isochronous data packets.
5030Sstevel@tonic-gate  *
5040Sstevel@tonic-gate  * Each usb isochronous request must not exceed multiples of isochronous
5050Sstevel@tonic-gate  * endpoint packet size and OHCI_MAX_ISOC_PKTS_PER_XFER.
5060Sstevel@tonic-gate  *
5070Sstevel@tonic-gate  * Ex: usb isochronous endpoint maximum packet size is 64 bytes
5080Sstevel@tonic-gate  *     maximum usb isochronous request will be OHCI_MAX_ISOC_PKTS_PER_XFER
5090Sstevel@tonic-gate  *     * 64 bytes
5100Sstevel@tonic-gate  */
5110Sstevel@tonic-gate #define		OHCI_MAX_ISOC_PKTS_PER_XFER	256	/* Max pkts per req */
5120Sstevel@tonic-gate 
5130Sstevel@tonic-gate /*
5140Sstevel@tonic-gate  * The ohci supports maximum of eight isochronous data packets per transfer
5150Sstevel@tonic-gate  * descriptor.
5160Sstevel@tonic-gate  */
5170Sstevel@tonic-gate #define		OHCI_ISOC_PKTS_PER_TD		8	/* Packets per TD */
5180Sstevel@tonic-gate 
5190Sstevel@tonic-gate /*
5200Sstevel@tonic-gate  * USB frame offset
5210Sstevel@tonic-gate  *
5220Sstevel@tonic-gate  * Add appropriate frame offset to the current usb frame number and use it
5230Sstevel@tonic-gate  * as a starting frame number for a given usb isochronous request.
5240Sstevel@tonic-gate  */
5250Sstevel@tonic-gate #define		OHCI_FRAME_OFFSET		2	/* Frame offset */
5260Sstevel@tonic-gate 
5270Sstevel@tonic-gate /*
5280Sstevel@tonic-gate  * Default usb isochronous receive packets per request before ohci will do
5290Sstevel@tonic-gate  * callback.
5300Sstevel@tonic-gate  */
5310Sstevel@tonic-gate #define		OHCI_DEFAULT_ISOC_RCV_PKTS	1	/* isoc pkts per req */
5320Sstevel@tonic-gate 
5330Sstevel@tonic-gate /*
5340Sstevel@tonic-gate  * Different interrupt polling intervals supported
5350Sstevel@tonic-gate  */
5360Sstevel@tonic-gate #define		INTR_1MS_POLL	1
5370Sstevel@tonic-gate #define		INTR_2MS_POLL	2
5380Sstevel@tonic-gate #define		INTR_4MS_POLL	4
5390Sstevel@tonic-gate #define		INTR_8MS_POLL	8
5400Sstevel@tonic-gate #define		INTR_16MS_POLL	16
5410Sstevel@tonic-gate #define		INTR_32MS_POLL	32
5420Sstevel@tonic-gate 
5430Sstevel@tonic-gate /*
5440Sstevel@tonic-gate  * Number of interrupt/isochronous transfer requests that should
5450Sstevel@tonic-gate  * be maintained on the interrupt/isochronous endpoint corresponding
5460Sstevel@tonic-gate  * to different polling intervals supported.
5470Sstevel@tonic-gate  */
5480Sstevel@tonic-gate #define		INTR_1MS_REQS	4	/* 1ms polling interval */
5490Sstevel@tonic-gate #define		INTR_2MS_REQS	2	/* 2ms polling interval */
5500Sstevel@tonic-gate #define		INTR_XMS_REQS	1	/* Between 4ms and 32ms */
5510Sstevel@tonic-gate 
5520Sstevel@tonic-gate /* Function prototype */
5530Sstevel@tonic-gate typedef void (*ohci_handler_function_t)(
5540Sstevel@tonic-gate 	ohci_state_t			*ohcip,
5550Sstevel@tonic-gate 	ohci_pipe_private_t		*pp,
5560Sstevel@tonic-gate 	struct ohci_trans_wrapper	*tw,
5570Sstevel@tonic-gate 	ohci_td_t			*td,
5580Sstevel@tonic-gate 	void				*ohci_handle_callback_value);
5590Sstevel@tonic-gate 
5600Sstevel@tonic-gate 
5610Sstevel@tonic-gate /*
5620Sstevel@tonic-gate  * Transfer wrapper
5630Sstevel@tonic-gate  *
5640Sstevel@tonic-gate  * The transfer wrapper represents a USB transfer on the bus and there
5650Sstevel@tonic-gate  * is one instance per USB transfer.  A transfer is made up of one or
5662125Ssl147100  * more transactions. OHCI uses one TD for one transaction. So one
5672125Ssl147100  * transfer wrapper may have one or more TDs associated.
5680Sstevel@tonic-gate  *
5690Sstevel@tonic-gate  * Control and bulk pipes will have one transfer wrapper per transfer
5700Sstevel@tonic-gate  * and where as Isochronous and Interrupt pipes will only have one
5710Sstevel@tonic-gate  * transfer wrapper. The transfers wrapper are continually reused for
5720Sstevel@tonic-gate  * the Interrupt and Isochronous pipes as those pipes are polled.
5732125Ssl147100  *
5742125Ssl147100  * Control, bulk and interrupt transfers will have one DMA buffer per
5752125Ssl147100  * transfer. The data to be transferred are contained in the DMA buffer
5762125Ssl147100  * which is virtually contiguous but physically discontiguous. When
5772125Ssl147100  * preparing the TDs for a USB transfer, the DMA cookies contained in
5782125Ssl147100  * the buffer need to be walked through to retrieve the DMA addresses.
5792125Ssl147100  *
5802125Ssl147100  * Isochronous transfers may have multiple DMA buffers per transfer
5812125Ssl147100  * with each isoc TD having a DMA buffer. And one isoc TD may hold up to
5822125Ssl147100  * eight isoc packets, but two cookies at most.
5830Sstevel@tonic-gate  */
5840Sstevel@tonic-gate typedef struct ohci_trans_wrapper {
5850Sstevel@tonic-gate 	struct ohci_trans_wrapper	*tw_next;	/* Next wrapper */
5860Sstevel@tonic-gate 	ohci_pipe_private_t		*tw_pipe_private; /* Back ptr */
5870Sstevel@tonic-gate 	ddi_dma_handle_t		tw_dmahandle;	/* DMA handle */
5880Sstevel@tonic-gate 	ddi_acc_handle_t		tw_accesshandle; /* Acc hndle */
5890Sstevel@tonic-gate 	ddi_dma_cookie_t		tw_cookie;	/* DMA cookie */
5900Sstevel@tonic-gate 	uint32_t			tw_id;		/* 32bit ID */
5910Sstevel@tonic-gate 	size_t				tw_length;	/* Txfer length */
5920Sstevel@tonic-gate 	char				*tw_buf;	/* Buffer for Xfer */
5932125Ssl147100 	uint_t				tw_ncookies;	/* DMA cookie count */
5942125Ssl147100 	uint_t				tw_cookie_idx;	/* DMA cookie index */
5952125Ssl147100 	size_t				tw_dma_offs;	/* DMA buffer offset */
5960Sstevel@tonic-gate 	usb_flags_t			tw_flags;	/* Flags */
5970Sstevel@tonic-gate 	uint_t				tw_num_tds;	/* Number of TDs */
5980Sstevel@tonic-gate 	ohci_td_t			*tw_hctd_head;	/* Head TD */
5990Sstevel@tonic-gate 	ohci_td_t			*tw_hctd_tail;	/* Tail TD */
6000Sstevel@tonic-gate 	uint_t				tw_direction;	/* Direction of TD */
6013255Slg150142 	uint_t				tw_pkt_idx;	/* packet index */
6020Sstevel@tonic-gate 
6030Sstevel@tonic-gate 	/* We preallocate all the td's for each tw and place them here */
6040Sstevel@tonic-gate 	ohci_td_t			*tw_hctd_free_list;
6050Sstevel@tonic-gate 
6060Sstevel@tonic-gate 	/* Current transfer request pointer */
6070Sstevel@tonic-gate 	usb_opaque_t			tw_curr_xfer_reqp;
6080Sstevel@tonic-gate 
6090Sstevel@tonic-gate 	/* Current isochronous packet descriptor pointer */
6100Sstevel@tonic-gate 	usb_isoc_pkt_descr_t		*tw_curr_isoc_pktp;
6110Sstevel@tonic-gate 
6122125Ssl147100 	/* Isochronous DMA handlers and buffer pointers are stored here */
6132125Ssl147100 	ohci_isoc_buf_t			*tw_isoc_bufs;
6142125Ssl147100 	size_t				tw_isoc_strtlen;
6152125Ssl147100 
6160Sstevel@tonic-gate 	/* Transfer timeout information */
6170Sstevel@tonic-gate 	uint_t				tw_timeout;	/* Timeout value */
6180Sstevel@tonic-gate 	struct ohci_trans_wrapper	*tw_timeout_next; /* Xfer Timeout Q */
6190Sstevel@tonic-gate 
6200Sstevel@tonic-gate 	/*
6210Sstevel@tonic-gate 	 * This is the function to call when this td is done. This way
6220Sstevel@tonic-gate 	 * we don't have to look in the td to figure out what kind it is.
6230Sstevel@tonic-gate 	 */
6240Sstevel@tonic-gate 	ohci_handler_function_t		tw_handle_td;
6250Sstevel@tonic-gate 
6260Sstevel@tonic-gate 	/*
6270Sstevel@tonic-gate 	 * This is the callback value used when processing a done td.
6280Sstevel@tonic-gate 	 */
6290Sstevel@tonic-gate 	usb_opaque_t			tw_handle_callback_value;
6300Sstevel@tonic-gate } ohci_trans_wrapper_t;
6310Sstevel@tonic-gate 
6320Sstevel@tonic-gate _NOTE(MUTEX_PROTECTS_DATA(ohci_state_t::ohci_int_mutex, ohci_trans_wrapper))
6330Sstevel@tonic-gate 
6340Sstevel@tonic-gate 
6350Sstevel@tonic-gate /*
6360Sstevel@tonic-gate  * Time waits for the different OHCI specific operations.
6370Sstevel@tonic-gate  * These timeout values are specified in terms of microseconds.
6380Sstevel@tonic-gate  */
6390Sstevel@tonic-gate #define	OHCI_RESET_TIMEWAIT	10000	/* HC reset waiting time */
6400Sstevel@tonic-gate #define	OHCI_RESUME_TIMEWAIT	40000	/* HC resume waiting time */
6410Sstevel@tonic-gate #define	OHCI_TIMEWAIT		10000	/* HC any other waiting time */
6420Sstevel@tonic-gate 
6430Sstevel@tonic-gate /* These timeout values are specified in seconds */
6440Sstevel@tonic-gate #define	OHCI_DEFAULT_XFER_TIMEOUT	5 /* Default transfer timeout */
6450Sstevel@tonic-gate #define	OHCI_MAX_SOF_TIMEWAIT		3 /* Maximum SOF waiting time */
6460Sstevel@tonic-gate #define	OHCI_XFER_CMPL_TIMEWAIT		3 /* Xfers completion timewait */
6470Sstevel@tonic-gate 
6480Sstevel@tonic-gate /* OHCI flags for general use */
6490Sstevel@tonic-gate #define	OHCI_FLAGS_NOSLEEP	0x000	/* Don't wait for SOF */
6500Sstevel@tonic-gate #define	OHCI_FLAGS_SLEEP	0x100	/* Wait for SOF */
6510Sstevel@tonic-gate #define	OHCI_FLAGS_DMA_SYNC	0x200	/* Call ddi_dma_sync */
6520Sstevel@tonic-gate 
6530Sstevel@tonic-gate /*
6540Sstevel@tonic-gate  * Maximum allowable data transfer  size per transaction as supported
6550Sstevel@tonic-gate  * by OHCI is 8k. (See Open Host Controller Interface Spec rev 1.0a)
6560Sstevel@tonic-gate  */
6570Sstevel@tonic-gate #define	OHCI_MAX_TD_XFER_SIZE	0x2000	/* Maxmum data per transaction */
6580Sstevel@tonic-gate 
6590Sstevel@tonic-gate /*
6602125Ssl147100  * One OHCI TD allows two physically discontiguous pages. The page size
6612125Ssl147100  * is 4k.
6622125Ssl147100  */
6632125Ssl147100 #define	OHCI_MAX_TD_BUF_SIZE	0x1000
6642125Ssl147100 
6652125Ssl147100 /*
6660Sstevel@tonic-gate  * The maximum allowable bulk data transfer size. It can be different
6670Sstevel@tonic-gate  * from OHCI_MAX_TD_XFER_SIZE and if it is more then ohci driver will
6680Sstevel@tonic-gate  * take care of  breaking a bulk data request into  multiples of ohci
6690Sstevel@tonic-gate  * OHCI_MAX_TD_XFER_SIZE  until request is satisfied.  Currently this
6700Sstevel@tonic-gate  * value is set to 256k bytes.
6710Sstevel@tonic-gate  */
6720Sstevel@tonic-gate #define	OHCI_MAX_BULK_XFER_SIZE	0x40000	/* Maximum bulk transfer size */
6730Sstevel@tonic-gate 
6740Sstevel@tonic-gate /*
6750Sstevel@tonic-gate  * Timeout flags
6760Sstevel@tonic-gate  *
6770Sstevel@tonic-gate  * These flags will be used to stop the timer before timeout handler
6780Sstevel@tonic-gate  * gets executed.
6790Sstevel@tonic-gate  */
6800Sstevel@tonic-gate #define	OHCI_REMOVE_XFER_IFLAST	1	/* Stop the timer if  it is last TD */
6810Sstevel@tonic-gate #define	OHCI_REMOVE_XFER_ALWAYS	2	/* Stop the timer without condition */
6820Sstevel@tonic-gate 
6830Sstevel@tonic-gate 
6840Sstevel@tonic-gate /*
6850Sstevel@tonic-gate  * Bandwidth allocation
6860Sstevel@tonic-gate  *
6870Sstevel@tonic-gate  * The following definitions are  used during  bandwidth calculations
6880Sstevel@tonic-gate  * for a given endpoint maximum packet size.
6890Sstevel@tonic-gate  */
6900Sstevel@tonic-gate #define	MAX_USB_BUS_BANDWIDTH	1500	/* Up to 1500 bytes per frame */
6910Sstevel@tonic-gate #define	MAX_POLL_INTERVAL	255	/* Maximum polling interval */
6920Sstevel@tonic-gate #define	MIN_POLL_INTERVAL	1	/* Minimum polling interval */
6930Sstevel@tonic-gate #define	SOF			6	/* Length in bytes of SOF */
6940Sstevel@tonic-gate #define	EOF			4	/* Length in bytes of EOF */
6950Sstevel@tonic-gate #define	TREE_HEIGHT		5	/* Log base 2 of 32 */
6960Sstevel@tonic-gate 
6970Sstevel@tonic-gate /*
6980Sstevel@tonic-gate  * Minimum polling interval for low speed endpoint
6990Sstevel@tonic-gate  *
7000Sstevel@tonic-gate  * According USB Specifications, a full-speed endpoint can specify
7010Sstevel@tonic-gate  * a desired polling interval 1ms to 255ms and a low speed endpoints
7020Sstevel@tonic-gate  * are limited to specifying only 10ms to 255ms. But some old keyboards
7030Sstevel@tonic-gate  * and mice uses polling interval of 8ms. For compatibility purpose,
7040Sstevel@tonic-gate  * we are using polling interval between 8ms and 255ms for low speed
7050Sstevel@tonic-gate  * endpoints. But ohci driver will reject any low speed endpoints which
7060Sstevel@tonic-gate  * request polling interval less than 8ms.
7070Sstevel@tonic-gate  */
7080Sstevel@tonic-gate #define	MIN_LOW_SPEED_POLL_INTERVAL	8
7090Sstevel@tonic-gate 
7100Sstevel@tonic-gate /*
7110Sstevel@tonic-gate  * For non-periodic transfers, reserve atleast for one low-speed device
7120Sstevel@tonic-gate  * transaction. According to USB Bandwidth Analysis white paper and also
7130Sstevel@tonic-gate  * as per OHCI Specification 1.0a, section 7.3.5, page 123, one low-speed
7140Sstevel@tonic-gate  * transaction takes 0x628h full speed bits (197 bytes), which comes to
7150Sstevel@tonic-gate  * around 13% of USB frame time.
7160Sstevel@tonic-gate  *
7170Sstevel@tonic-gate  * The periodic transfers will  get around 87% of USB frame time.
7180Sstevel@tonic-gate  */
7190Sstevel@tonic-gate #define	MAX_NON_PERIODIC_BANDWIDTH	197
7200Sstevel@tonic-gate #define	MAX_PERIODIC_BANDWIDTH		(MAX_USB_BUS_BANDWIDTH - SOF - \
7210Sstevel@tonic-gate 					EOF - MAX_NON_PERIODIC_BANDWIDTH)
7220Sstevel@tonic-gate 
7230Sstevel@tonic-gate /*
7240Sstevel@tonic-gate  * The USB periodic transfers like interrupt and isochronous transfers
7250Sstevel@tonic-gate  * after completion of SOF and USB non-periodic transfers.
7260Sstevel@tonic-gate  */
7270Sstevel@tonic-gate #define	PERIODIC_XFER_STARTS		(MAX_USB_BUS_BANDWIDTH - \
7280Sstevel@tonic-gate 					SOF - MAX_NON_PERIODIC_BANDWIDTH)
7290Sstevel@tonic-gate 
7300Sstevel@tonic-gate /* Number of Bits Per Byte */
7310Sstevel@tonic-gate #define	BITS_PER_BYTE			8
7320Sstevel@tonic-gate 
7330Sstevel@tonic-gate /*
7340Sstevel@tonic-gate  * The following are the protocol overheads in terms of Bytes for the
7350Sstevel@tonic-gate  * different transfer types.  All these protocol overhead  values are
7360Sstevel@tonic-gate  * derived from the 5.9.3 section of USB Specification	and  with the
7370Sstevel@tonic-gate  * help of Bandwidth Analysis white paper which is posted on the  USB
7380Sstevel@tonic-gate  * developer forum.
7390Sstevel@tonic-gate  */
7400Sstevel@tonic-gate #define	FS_NON_ISOC_PROTO_OVERHEAD	14
7410Sstevel@tonic-gate #define	FS_ISOC_INPUT_PROTO_OVERHEAD	11
7420Sstevel@tonic-gate #define	FS_ISOC_OUTPUT_PROTO_OVERHEAD	10
7430Sstevel@tonic-gate #define	LOW_SPEED_PROTO_OVERHEAD	97
7440Sstevel@tonic-gate #define	HUB_LOW_SPEED_PROTO_OVERHEAD	01
7450Sstevel@tonic-gate 
7460Sstevel@tonic-gate /*
7470Sstevel@tonic-gate  * The Host Controller (HC) delays are the USB host controller specific
7480Sstevel@tonic-gate  * delays. The value shown below is the host  controller delay for  the
7490Sstevel@tonic-gate  * RIO USB host controller.  This value was calculated and  given by the
7500Sstevel@tonic-gate  * Sun USB hardware people.
7510Sstevel@tonic-gate  */
7520Sstevel@tonic-gate #define	HOST_CONTROLLER_DELAY		18
7530Sstevel@tonic-gate 
7540Sstevel@tonic-gate /*
7550Sstevel@tonic-gate  * The low speed clock below represents that to transmit one low-speed
7560Sstevel@tonic-gate  * bit takes eight times more than one full speed bit time.
7570Sstevel@tonic-gate  */
7580Sstevel@tonic-gate #define	LOW_SPEED_CLOCK			8
7590Sstevel@tonic-gate 
7600Sstevel@tonic-gate 
7610Sstevel@tonic-gate /*
7620Sstevel@tonic-gate  * Macros for setting/getting information
7630Sstevel@tonic-gate  */
7640Sstevel@tonic-gate #define	Get_ED(addr)		ddi_get32(ohcip->ohci_ed_pool_mem_handle, \
7650Sstevel@tonic-gate 					(uint32_t *)&addr)
7660Sstevel@tonic-gate 
7670Sstevel@tonic-gate #define	Set_ED(addr, val)	ddi_put32(ohcip->ohci_ed_pool_mem_handle,  \
7680Sstevel@tonic-gate 					((uint32_t *)&addr), \
7690Sstevel@tonic-gate 					((int32_t)(val)))
7700Sstevel@tonic-gate 
7710Sstevel@tonic-gate #define	Get_TD(addr)		ddi_get32(ohcip->ohci_td_pool_mem_handle, \
7720Sstevel@tonic-gate 					(uint32_t *)&addr)
7730Sstevel@tonic-gate 
7740Sstevel@tonic-gate #define	Set_TD(addr, val)	ddi_put32(ohcip->ohci_td_pool_mem_handle, \
7750Sstevel@tonic-gate 					((uint32_t *)&addr), \
7760Sstevel@tonic-gate 					((uint32_t)(uintptr_t)(val)))
7770Sstevel@tonic-gate 
7780Sstevel@tonic-gate #define	Get_HCCA(addr)		ddi_get32(ohcip->ohci_hcca_mem_handle, \
7790Sstevel@tonic-gate 					(uint32_t *)&addr)
7800Sstevel@tonic-gate 
7810Sstevel@tonic-gate #define	Set_HCCA(addr, val)	ddi_put32(ohcip->ohci_hcca_mem_handle, \
7820Sstevel@tonic-gate 					((uint32_t *)&addr), \
7830Sstevel@tonic-gate 					((int32_t)(val)))
7840Sstevel@tonic-gate 
7850Sstevel@tonic-gate #define	Get_OpReg(addr)		ddi_get32(ohcip->ohci_regs_handle, \
7860Sstevel@tonic-gate 					(uint32_t *)&ohcip->ohci_regsp->addr)
7870Sstevel@tonic-gate 
7880Sstevel@tonic-gate #define	Set_OpReg(addr, val)	ddi_put32(ohcip->ohci_regs_handle, \
7890Sstevel@tonic-gate 				((uint32_t *)&ohcip->ohci_regsp->addr), \
7900Sstevel@tonic-gate 					((int32_t)(val)))
7910Sstevel@tonic-gate 
7920Sstevel@tonic-gate #define	Sync_HCCA(ohcip)	(void) ddi_dma_sync( \
7930Sstevel@tonic-gate 				ohcip->ohci_hcca_dma_handle, \
7940Sstevel@tonic-gate 				0, sizeof (ohci_hcca_t), \
7950Sstevel@tonic-gate 				DDI_DMA_SYNC_FORCPU);
7960Sstevel@tonic-gate 
7970Sstevel@tonic-gate #define	Sync_ED_TD_Pool(ohcip)	(void) ddi_dma_sync( \
7980Sstevel@tonic-gate 				ohcip->ohci_ed_pool_dma_handle, \
7990Sstevel@tonic-gate 				0, OHCI_ED_POOL_SIZE * sizeof (ohci_ed_t), \
8000Sstevel@tonic-gate 				DDI_DMA_SYNC_FORCPU); \
8010Sstevel@tonic-gate 				(void) ddi_dma_sync( \
8020Sstevel@tonic-gate 				ohcip->ohci_td_pool_dma_handle, \
8030Sstevel@tonic-gate 				0, OHCI_TD_POOL_SIZE * sizeof (ohci_td_t), \
8040Sstevel@tonic-gate 				DDI_DMA_SYNC_FORCPU);
8050Sstevel@tonic-gate 
8060Sstevel@tonic-gate #define	Sync_IO_Buffer(dma_handle, length) \
8070Sstevel@tonic-gate 				(void) ddi_dma_sync(dma_handle, \
8080Sstevel@tonic-gate 				0, length, DDI_DMA_SYNC_FORCPU);
809*9095SZhigang.Lu@Sun.COM #define	Sync_IO_Buffer_for_device(dma_handle, length) \
810*9095SZhigang.Lu@Sun.COM 				(void) ddi_dma_sync(dma_handle, \
811*9095SZhigang.Lu@Sun.COM 				0, length, DDI_DMA_SYNC_FORDEV);
8120Sstevel@tonic-gate 
8130Sstevel@tonic-gate /*
8140Sstevel@tonic-gate  * Macros to speed handling of 32bit IDs
8150Sstevel@tonic-gate  */
8160Sstevel@tonic-gate #define	OHCI_GET_ID(x)		id32_alloc((void *)(x), KM_SLEEP)
8170Sstevel@tonic-gate #define	OHCI_LOOKUP_ID(x)	id32_lookup((x))
8180Sstevel@tonic-gate #define	OHCI_FREE_ID(x)		id32_free((x))
8190Sstevel@tonic-gate 
8200Sstevel@tonic-gate 
8210Sstevel@tonic-gate /*
8220Sstevel@tonic-gate  * Miscellaneous definitions.
8230Sstevel@tonic-gate  */
8240Sstevel@tonic-gate 
8250Sstevel@tonic-gate /* Data toggle bits */
8260Sstevel@tonic-gate #define	DATA0		0
8270Sstevel@tonic-gate #define	DATA1		1
8280Sstevel@tonic-gate 
8290Sstevel@tonic-gate /* sKip bit actions */
8300Sstevel@tonic-gate #define	CLEAR_sKip	0
8310Sstevel@tonic-gate #define	SET_sKip	1
8320Sstevel@tonic-gate 
8330Sstevel@tonic-gate typedef uint_t		skip_bit_t;
8340Sstevel@tonic-gate 
8350Sstevel@tonic-gate /*
8360Sstevel@tonic-gate  * Setup Packet
8370Sstevel@tonic-gate  */
8380Sstevel@tonic-gate typedef struct setup_pkt {
8390Sstevel@tonic-gate 	uchar_t	bmRequestType;
8400Sstevel@tonic-gate 	uchar_t	bRequest;
8410Sstevel@tonic-gate 	ushort_t wValue;
8420Sstevel@tonic-gate 	ushort_t wIndex;
8430Sstevel@tonic-gate 	ushort_t wLength;
8440Sstevel@tonic-gate }setup_pkt_t;
8450Sstevel@tonic-gate 
8460Sstevel@tonic-gate #define	SETUP_SIZE		8	/* Setup packet is always 8 bytes */
8470Sstevel@tonic-gate 
8480Sstevel@tonic-gate #define	REQUEST_TYPE_OFFSET	0
8490Sstevel@tonic-gate #define	REQUEST_OFFSET		1
8500Sstevel@tonic-gate #define	VALUE_OFFSET		2
8510Sstevel@tonic-gate #define	INDEX_OFFSET		4
8520Sstevel@tonic-gate #define	LENGTH_OFFSET		6
8530Sstevel@tonic-gate 
8540Sstevel@tonic-gate #define	TYPE_DEV_TO_HOST	0x80000000
8550Sstevel@tonic-gate #define	DEVICE			0x00000001
8560Sstevel@tonic-gate #define	CONFIGURATION		0x00000002
8570Sstevel@tonic-gate 
8580Sstevel@tonic-gate /*
8590Sstevel@tonic-gate  * The following are used in attach to	 indicate
8600Sstevel@tonic-gate  * what has been succesfully allocated, so detach
8610Sstevel@tonic-gate  * can remove them.
8620Sstevel@tonic-gate  */
8630Sstevel@tonic-gate #define	OHCI_ATTACH		0x01	/* ohci driver initilization */
8640Sstevel@tonic-gate #define	OHCI_ZALLOC		0x02	/* Memory for ohci state structure */
8650Sstevel@tonic-gate #define	OHCI_INTR		0x04	/* Interrupt handler registered */
8660Sstevel@tonic-gate #define	OHCI_USBAREG		0x08	/* USBA registered */
8670Sstevel@tonic-gate #define	OHCI_RHREG		0x10	/* Root hub driver loaded */
8680Sstevel@tonic-gate 
8690Sstevel@tonic-gate #define	OHCI_UNIT(dev)	(getminor((dev)) & ~HUBD_IS_ROOT_HUB)
8700Sstevel@tonic-gate 
8710Sstevel@tonic-gate /*
8720Sstevel@tonic-gate  * Debug printing
8730Sstevel@tonic-gate  * Masks
8740Sstevel@tonic-gate  */
8750Sstevel@tonic-gate #define	PRINT_MASK_ATTA		0x00000001	/* Attach time */
8760Sstevel@tonic-gate #define	PRINT_MASK_LISTS	0x00000002	/* List management */
8770Sstevel@tonic-gate #define	PRINT_MASK_ROOT_HUB	0x00000004	/* Root hub stuff */
8780Sstevel@tonic-gate #define	PRINT_MASK_ALLOC	0x00000008	/* Alloc/dealloc descr */
8790Sstevel@tonic-gate #define	PRINT_MASK_INTR		0x00000010	/* Interrupt handling */
8800Sstevel@tonic-gate #define	PRINT_MASK_BW		0x00000020	/* Bandwidth */
8810Sstevel@tonic-gate #define	PRINT_MASK_CBOPS	0x00000040	/* CB-OPS */
8820Sstevel@tonic-gate #define	PRINT_MASK_HCDI		0x00000080	/* HCDI entry points */
8830Sstevel@tonic-gate #define	PRINT_MASK_DUMPING	0x00000100	/* Dump ohci info */
8840Sstevel@tonic-gate #define	PRINT_MASK_ALL		0xFFFFFFFF
8850Sstevel@tonic-gate 
8860Sstevel@tonic-gate 
8870Sstevel@tonic-gate /* Polling support */
8880Sstevel@tonic-gate int		ohci_hcdi_polled_input_init(
8890Sstevel@tonic-gate 				usba_pipe_handle_data_t	*ph,
8900Sstevel@tonic-gate 				uchar_t			**polled_buf,
8910Sstevel@tonic-gate 				usb_console_info_impl_t	*info);
8920Sstevel@tonic-gate int		ohci_hcdi_polled_input_enter(
8930Sstevel@tonic-gate 				usb_console_info_impl_t	*info);
8940Sstevel@tonic-gate int		ohci_hcdi_polled_read(
8950Sstevel@tonic-gate 				usb_console_info_impl_t	*info,
8960Sstevel@tonic-gate 				uint_t			*num_characters);
8970Sstevel@tonic-gate int		ohci_hcdi_polled_input_exit(
8980Sstevel@tonic-gate 				usb_console_info_impl_t	*info);
8990Sstevel@tonic-gate int		ohci_hcdi_polled_input_fini(
9000Sstevel@tonic-gate 				usb_console_info_impl_t	*info);
9010Sstevel@tonic-gate 
902*9095SZhigang.Lu@Sun.COM int		ohci_hcdi_polled_output_init(
903*9095SZhigang.Lu@Sun.COM 				usba_pipe_handle_data_t	*ph,
904*9095SZhigang.Lu@Sun.COM 				usb_console_info_impl_t	*console_output_info);
905*9095SZhigang.Lu@Sun.COM int		ohci_hcdi_polled_output_enter(
906*9095SZhigang.Lu@Sun.COM 				usb_console_info_impl_t	*info);
907*9095SZhigang.Lu@Sun.COM int		ohci_hcdi_polled_write(
908*9095SZhigang.Lu@Sun.COM 				usb_console_info_impl_t *info,
909*9095SZhigang.Lu@Sun.COM 				uchar_t *buf,
910*9095SZhigang.Lu@Sun.COM 				uint_t num_characters,
911*9095SZhigang.Lu@Sun.COM 				uint_t *num_characters_written);
912*9095SZhigang.Lu@Sun.COM int		ohci_hcdi_polled_output_exit(
913*9095SZhigang.Lu@Sun.COM 				usb_console_info_impl_t	*info);
914*9095SZhigang.Lu@Sun.COM int		ohci_hcdi_polled_output_fini(
915*9095SZhigang.Lu@Sun.COM 				usb_console_info_impl_t *info);
916*9095SZhigang.Lu@Sun.COM 
9170Sstevel@tonic-gate /* Root hub related functions */
9180Sstevel@tonic-gate int		ohci_init_root_hub(
9190Sstevel@tonic-gate 				ohci_state_t		*ohcip);
9200Sstevel@tonic-gate int		ohci_load_root_hub_driver(
9210Sstevel@tonic-gate 				ohci_state_t		*ohcip);
9220Sstevel@tonic-gate int		ohci_unload_root_hub_driver(
9230Sstevel@tonic-gate 				ohci_state_t		*ohcip);
9240Sstevel@tonic-gate int		ohci_handle_root_hub_pipe_open(
9250Sstevel@tonic-gate 				usba_pipe_handle_data_t	*ph,
9260Sstevel@tonic-gate 				usb_flags_t		flags);
9270Sstevel@tonic-gate int		ohci_handle_root_hub_pipe_close(
9280Sstevel@tonic-gate 				usba_pipe_handle_data_t	*ph);
9290Sstevel@tonic-gate int		ohci_handle_root_hub_pipe_reset(
9300Sstevel@tonic-gate 				usba_pipe_handle_data_t	*ph,
9310Sstevel@tonic-gate 				usb_flags_t		flags);
9320Sstevel@tonic-gate int		ohci_handle_root_hub_request(
9330Sstevel@tonic-gate 				ohci_state_t		*ohcip,
9340Sstevel@tonic-gate 				usba_pipe_handle_data_t	*ph,
9350Sstevel@tonic-gate 				usb_ctrl_req_t		*ctrl_reqp);
9360Sstevel@tonic-gate int		ohci_handle_root_hub_pipe_start_intr_polling(
9370Sstevel@tonic-gate 				usba_pipe_handle_data_t	*ph,
9380Sstevel@tonic-gate 				usb_intr_req_t		*intr_reqp,
9390Sstevel@tonic-gate 				usb_flags_t		flags);
9400Sstevel@tonic-gate void		ohci_handle_root_hub_pipe_stop_intr_polling(
9410Sstevel@tonic-gate 				usba_pipe_handle_data_t	*ph,
9420Sstevel@tonic-gate 				usb_flags_t		flags);
9430Sstevel@tonic-gate void		ohci_handle_root_hub_status_change(void *arg);
9440Sstevel@tonic-gate 
9450Sstevel@tonic-gate /* Endpoint Descriptor (ED) related functions */
9460Sstevel@tonic-gate ohci_ed_t	*ohci_alloc_hc_ed(
9470Sstevel@tonic-gate 				ohci_state_t		*ohcip,
9480Sstevel@tonic-gate 				usba_pipe_handle_data_t	*ph);
9490Sstevel@tonic-gate void		ohci_deallocate_ed(
9500Sstevel@tonic-gate 				ohci_state_t		*ohcip,
9510Sstevel@tonic-gate 				ohci_ed_t		*old_ed);
9520Sstevel@tonic-gate uint32_t	ohci_ed_cpu_to_iommu(
9530Sstevel@tonic-gate 				ohci_state_t		*ohcip,
9540Sstevel@tonic-gate 				ohci_ed_t		*addr);
9550Sstevel@tonic-gate 
9560Sstevel@tonic-gate /* Transfer Descriptor (TD) related functions */
9570Sstevel@tonic-gate int		ohci_start_periodic_pipe_polling(
9580Sstevel@tonic-gate 				ohci_state_t		*ohcip,
9590Sstevel@tonic-gate 				usba_pipe_handle_data_t	*ph,
9600Sstevel@tonic-gate 				usb_opaque_t		periodic_in_reqp,
9610Sstevel@tonic-gate 				usb_flags_t		flags);
9620Sstevel@tonic-gate void		ohci_traverse_tds(
9630Sstevel@tonic-gate 				ohci_state_t		*ohcip,
9640Sstevel@tonic-gate 				usba_pipe_handle_data_t	*ph);
9650Sstevel@tonic-gate void		ohci_deallocate_td(
9660Sstevel@tonic-gate 				ohci_state_t		*ohcip,
9670Sstevel@tonic-gate 				ohci_td_t		*old_td);
9680Sstevel@tonic-gate uint32_t	ohci_td_cpu_to_iommu(
9690Sstevel@tonic-gate 				ohci_state_t		*ohcip,
9700Sstevel@tonic-gate 				ohci_td_t		*addr);
9710Sstevel@tonic-gate ohci_td_t	*ohci_td_iommu_to_cpu(
9720Sstevel@tonic-gate 				ohci_state_t		*ohcip,
9730Sstevel@tonic-gate 				uintptr_t		addr);
9742125Ssl147100 size_t		ohci_get_td_residue(
9752125Ssl147100 				ohci_state_t		*ohcip,
9762125Ssl147100 				ohci_td_t		*td);
9772125Ssl147100 void		ohci_init_td(
9782125Ssl147100 				ohci_state_t		*ohcip,
9792125Ssl147100 				ohci_trans_wrapper_t	*tw,
9802125Ssl147100 				uint32_t		hctd_dma_offs,
9812125Ssl147100 				size_t			hctd_length,
9822125Ssl147100 				ohci_td_t		*td);
9830Sstevel@tonic-gate 
9840Sstevel@tonic-gate /* Transfer Wrapper (TW) functions */
9850Sstevel@tonic-gate void		ohci_deallocate_tw_resources(
9860Sstevel@tonic-gate 				ohci_state_t		*ohcip,
9870Sstevel@tonic-gate 				ohci_pipe_private_t	*pp,
9880Sstevel@tonic-gate 				ohci_trans_wrapper_t	*tw);
9890Sstevel@tonic-gate 
9900Sstevel@tonic-gate /* Interrupt Handling functions */
9910Sstevel@tonic-gate void		ohci_handle_frame_number_overflow(
9920Sstevel@tonic-gate 				ohci_state_t		*ohcip);
9930Sstevel@tonic-gate 
9940Sstevel@tonic-gate /* Miscillaneous functions */
9950Sstevel@tonic-gate ohci_state_t	*ohci_obtain_state(
9960Sstevel@tonic-gate 				dev_info_t		*dip);
9970Sstevel@tonic-gate int		ohci_state_is_operational(
9980Sstevel@tonic-gate 				ohci_state_t		*ohcip);
9990Sstevel@tonic-gate int		ohci_do_soft_reset(
10000Sstevel@tonic-gate 				ohci_state_t		*ohcip);
10010Sstevel@tonic-gate usb_frame_number_t ohci_get_current_frame_number(
10020Sstevel@tonic-gate 				ohci_state_t		*ohcip);
10030Sstevel@tonic-gate void		ohci_handle_outstanding_requests(
10040Sstevel@tonic-gate 				ohci_state_t		*ohcip,
10050Sstevel@tonic-gate 				ohci_pipe_private_t	*pp);
1006*9095SZhigang.Lu@Sun.COM int	ohci_allocate_tds_for_tw(
1007*9095SZhigang.Lu@Sun.COM 				ohci_state_t		*ohcip,
1008*9095SZhigang.Lu@Sun.COM 				ohci_trans_wrapper_t	*tw,
1009*9095SZhigang.Lu@Sun.COM 				size_t			td_count);
10100Sstevel@tonic-gate 
10110Sstevel@tonic-gate #ifdef __cplusplus
10120Sstevel@tonic-gate }
10130Sstevel@tonic-gate #endif
10140Sstevel@tonic-gate 
10150Sstevel@tonic-gate #endif /* _SYS_USB_OHCID_H */
1016