xref: /onnv-gate/usr/src/uts/common/sys/usb/hcd/openhci/ohci.h (revision 7492:2387323b838f)
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*7492SZhigang.Lu@Sun.COM  * Copyright 2008 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_OHCI_H
270Sstevel@tonic-gate #define	_SYS_USB_OHCI_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  * Open Host Controller Driver (OHCI)
360Sstevel@tonic-gate  *
370Sstevel@tonic-gate  * The USB Open Host Controller driver is a software driver which interfaces
380Sstevel@tonic-gate  * to the Universal Serial Bus layer (USBA) and the USB Open Host Controller.
390Sstevel@tonic-gate  * The interface to USB Open Host Controller is defined by the OpenHCI  Host
400Sstevel@tonic-gate  * Controller Interface.
410Sstevel@tonic-gate  *
420Sstevel@tonic-gate  * This header file describes the registers and data structures shared by the
430Sstevel@tonic-gate  * USB Open Host Controller and the USB Open Host Controller Driver.
440Sstevel@tonic-gate  */
450Sstevel@tonic-gate 
460Sstevel@tonic-gate #include <sys/types.h>
470Sstevel@tonic-gate #include <sys/pci.h>
480Sstevel@tonic-gate #include <sys/kstat.h>
490Sstevel@tonic-gate #include <sys/sunddi.h>
500Sstevel@tonic-gate #include <sys/sunndi.h>
510Sstevel@tonic-gate #include <sys/ndi_impldefs.h>
520Sstevel@tonic-gate 
530Sstevel@tonic-gate #include <sys/usb/usba.h>
540Sstevel@tonic-gate 
550Sstevel@tonic-gate #include <sys/usb/usba/hcdi.h>
560Sstevel@tonic-gate 
570Sstevel@tonic-gate #include <sys/usb/hubd/hub.h>
580Sstevel@tonic-gate #include <sys/usb/usba/hubdi.h>
590Sstevel@tonic-gate #include <sys/usb/hubd/hubdvar.h>
600Sstevel@tonic-gate 
610Sstevel@tonic-gate #include <sys/id32.h>
620Sstevel@tonic-gate 
630Sstevel@tonic-gate #define	OHCI_MAX_RH_PORTS		15	/* Maximum root hub ports */
640Sstevel@tonic-gate 
650Sstevel@tonic-gate /*
660Sstevel@tonic-gate  * Each OHCI buffer can hold upto 8k bytes of data. Hence there is a
670Sstevel@tonic-gate  * restriction of 4k alignment while allocating a dma buffer.
680Sstevel@tonic-gate  */
690Sstevel@tonic-gate #define	OHCI_4K_ALIGN			0x1000
700Sstevel@tonic-gate 
710Sstevel@tonic-gate /*
720Sstevel@tonic-gate  * USB Host controller DMA scatter gather list defines for
730Sstevel@tonic-gate  * Sparc and non-sparc architectures.
740Sstevel@tonic-gate  */
750Sstevel@tonic-gate #if defined(__sparc)
760Sstevel@tonic-gate #define	OHCI_DMA_ATTR_MAX_XFER		0xffffffffull
770Sstevel@tonic-gate #define	OHCI_DMA_ATTR_COUNT_MAX		0xffffffffull
780Sstevel@tonic-gate #define	OHCI_DMA_ATTR_GRANULAR		512
790Sstevel@tonic-gate #define	OHCI_DMA_ATTR_ALIGNMENT		OHCI_4K_ALIGN
800Sstevel@tonic-gate #else
810Sstevel@tonic-gate #define	OHCI_DMA_ATTR_MAX_XFER		0x00ffffffull
820Sstevel@tonic-gate #define	OHCI_DMA_ATTR_COUNT_MAX		0x00ffffffull
830Sstevel@tonic-gate #define	OHCI_DMA_ATTR_GRANULAR		1
842125Ssl147100 #define	OHCI_DMA_ATTR_ALIGNMENT		OHCI_4K_ALIGN
850Sstevel@tonic-gate #endif
860Sstevel@tonic-gate 
872125Ssl147100 #define	OHCI_DMA_ATTR_TW_SGLLEN		0x7fffffff	/* not limited */
882125Ssl147100 #define	OHCI_DMA_ATTR_TD_SGLLEN		2	/* maximum 8K per TD */
892125Ssl147100 
900Sstevel@tonic-gate /*
910Sstevel@tonic-gate  * According to the OHCI spec ED and TD need to be 16 byte aligned.
920Sstevel@tonic-gate  * However, iTD needs to be 32 byte aligned.  Since we do not
930Sstevel@tonic-gate  * distinguish between iTD and TD, make them both 32 byte aligned.
940Sstevel@tonic-gate  *
950Sstevel@tonic-gate  * ED   =  16 byte aligned
960Sstevel@tonic-gate  * TD   =  32 byte aligned
970Sstevel@tonic-gate  * HCCA = 256 byte aligned
980Sstevel@tonic-gate  */
990Sstevel@tonic-gate #define	OHCI_DMA_ATTR_ED_ALIGNMENT	0x010
1000Sstevel@tonic-gate #define	OHCI_DMA_ATTR_TD_ALIGNMENT	0x020
1010Sstevel@tonic-gate #define	OHCI_DMA_ATTR_HCCA_ALIGNMENT	0x100
1020Sstevel@tonic-gate 
1030Sstevel@tonic-gate /*
104219Shs155680  * Vendor id and Device id for ULI1575 southbridge.
105219Shs155680  */
106219Shs155680 #define	PCI_ULI1575_VENID	0x10B9
107219Shs155680 #define	PCI_ULI1575_DEVID	0x5237
108219Shs155680 
109219Shs155680 /*
110219Shs155680  * Need a workaround for ULI1575 chipset. Following OHCI
111219Shs155680  * Operational Memory Registers are not cleared to their
112219Shs155680  * default value on reset. Explicitly set the registers
113219Shs155680  * to default value after reset.
114219Shs155680  */
115219Shs155680 #define	HCR_CONTROL_DEFAULT		0x0
116219Shs155680 #define	HCR_INT_ENABLE_DEFAULT		0x0
117219Shs155680 #define	HCR_HCCA_DEFAULT		0x0
118219Shs155680 #define	HCR_CONTROL_HEAD_ED_DEFAULT	0x0
119219Shs155680 #define	HCR_BULK_HEAD_ED_DEFAULT	0x0
120219Shs155680 #define	HCR_FRAME_INTERVAL_DEFAULT	0x2edf
121219Shs155680 #define	HCR_PERIODIC_START_DEFAULT	0x0
122219Shs155680 
123219Shs155680 /*
1240Sstevel@tonic-gate  * OpenHCI Operational Registers
1250Sstevel@tonic-gate  *
1260Sstevel@tonic-gate  * The Host Controller (HC) contains a set of on-chip operational registers
1270Sstevel@tonic-gate  * which are mapped into a noncacheable portion of the system addressable
1280Sstevel@tonic-gate  * space and these registers are also used by the Host Controller Driver
1290Sstevel@tonic-gate  * (HCD).
1300Sstevel@tonic-gate  */
1310Sstevel@tonic-gate typedef volatile struct ohci_regs {
1320Sstevel@tonic-gate 	/* Control and status registers */
1330Sstevel@tonic-gate 	uint32_t 	hcr_revision;		/* Specification version */
1340Sstevel@tonic-gate 	uint32_t	hcr_control;		/* Control information */
1350Sstevel@tonic-gate 	uint32_t	hcr_cmd_status;		/* Controller status */
1360Sstevel@tonic-gate 	uint32_t	hcr_intr_status;	/* Interrupt status register */
1370Sstevel@tonic-gate 	uint32_t 	hcr_intr_enable;	/* Interrupt enable */
1380Sstevel@tonic-gate 	uint32_t	hcr_intr_disable;	/* Interrupt disable */
1390Sstevel@tonic-gate 
1400Sstevel@tonic-gate 	/* Memory pointer registers */
1410Sstevel@tonic-gate 	uint32_t	hcr_HCCA;		/* Pointer to HCCA */
1420Sstevel@tonic-gate 	uint32_t	hcr_periodic_curr;	/* Curr. isoch or int endpt */
1430Sstevel@tonic-gate 	uint32_t	hcr_ctrl_head;		/* Head of contrl list */
1440Sstevel@tonic-gate 	uint32_t	hcr_ctrl_curr;		/* Curr. control endpt */
1450Sstevel@tonic-gate 	uint32_t	hcr_bulk_head;		/* Head of the bulk list */
1460Sstevel@tonic-gate 	uint32_t	hcr_bulk_curr;		/* Curr. bulk endpt */
1470Sstevel@tonic-gate 	uint32_t	hcr_done_head;		/* Head of the done list */
1480Sstevel@tonic-gate 
1490Sstevel@tonic-gate 	/* Frame counter registers */
1500Sstevel@tonic-gate 	uint32_t	hcr_frame_interval;	/* Frame interval value */
1510Sstevel@tonic-gate 	uint32_t 	hcr_frame_remaining;    /* Time remaining in frame */
1520Sstevel@tonic-gate 	uint32_t	hcr_frame_number;	/* Frame number */
1530Sstevel@tonic-gate 	uint32_t	hcr_periodic_strt;	/* Time to start per. list */
1540Sstevel@tonic-gate 	uint32_t	hcr_transfer_ls;	/* Low speed threshold */
1550Sstevel@tonic-gate 
1560Sstevel@tonic-gate 	/* Root hub registers */
1570Sstevel@tonic-gate 	uint32_t	hcr_rh_descriptorA;	/* Root hub register A */
1580Sstevel@tonic-gate 	uint32_t	hcr_rh_descriptorB;	/* Root hub register B */
1590Sstevel@tonic-gate 	uint32_t	hcr_rh_status;		/* Root hub status */
1600Sstevel@tonic-gate 	uint32_t 	hcr_rh_portstatus[OHCI_MAX_RH_PORTS]; /* RH port sts */
1610Sstevel@tonic-gate } ohci_regs_t;
1620Sstevel@tonic-gate 
1630Sstevel@tonic-gate /* hcr_revision bits */
1640Sstevel@tonic-gate #define	HCR_REVISION_1_0	0x00000010	/* Revision 1.0 */
1650Sstevel@tonic-gate #define	HCR_REVISION_MASK	0x000000FF	/* Revision mask */
1660Sstevel@tonic-gate 
1670Sstevel@tonic-gate /* hcr_control bits */
1680Sstevel@tonic-gate #define	HCR_CONTROL_CBSR	0x00000003	/* Control/bulk ratio */
1690Sstevel@tonic-gate #define	HCR_CONTROL_PLE		0x00000004	/* Periodic list enable */
1700Sstevel@tonic-gate #define	HCR_CONTROL_IE		0x00000008	/* Isochronous enable */
1710Sstevel@tonic-gate #define	HCR_CONTROL_CLE		0x00000010	/* Control list enable */
1720Sstevel@tonic-gate #define	HCR_CONTROL_BLE		0x00000020	/* Bulk list enable */
1730Sstevel@tonic-gate #define	HCR_CONTROL_HCFS	0x000000C0	/* Controller state */
1740Sstevel@tonic-gate #define	HCR_CONTROL_IR		0x00000100	/* Interrupt routing */
1750Sstevel@tonic-gate #define	HCR_CONTROL_RWC		0x00000200	/* Remote wakeup connected */
1760Sstevel@tonic-gate #define	HCR_CONTROL_RWE		0x00000400	/* Remote wakeup enabled */
1770Sstevel@tonic-gate 
1780Sstevel@tonic-gate /* Values for the Host Controller Functional State bits (HCR_CONTROL_HCFS) */
1790Sstevel@tonic-gate #define	HCR_CONTROL_RESET	0x00000000	/* USB Reset */
1800Sstevel@tonic-gate #define	HCR_CONTROL_RESUME	0x00000040	/* USB Resume */
1810Sstevel@tonic-gate #define	HCR_CONTROL_OPERAT	0x00000080	/* USB Operational */
1820Sstevel@tonic-gate #define	HCR_CONTROL_SUSPD	0x000000C0	/* USB Suspend */
1830Sstevel@tonic-gate 
1840Sstevel@tonic-gate /* hcr_cmd_status bits */
1850Sstevel@tonic-gate #define	HCR_STATUS_RESET	0x00000001	/* Host controller reset */
1860Sstevel@tonic-gate #define	HCR_STATUS_CLF		0x00000002	/* Control list filled */
1870Sstevel@tonic-gate #define	HCR_STATUS_BLF		0x00000004	/* Bulk list filled */
1880Sstevel@tonic-gate #define	HCR_STATUS_OCR		0x00000008	/* Ownership change */
1890Sstevel@tonic-gate #define	HCR_STATUS_SOC		0x00030000	/* Error frame count */
1900Sstevel@tonic-gate 
1910Sstevel@tonic-gate /* hcr_intr_status bits and hcr_intr_mask bits */
1920Sstevel@tonic-gate #define	HCR_INTR_SO		0x00000001	/* Schedule overrun */
1930Sstevel@tonic-gate #define	HCR_INTR_WDH		0x00000002	/* Writeback done head */
1940Sstevel@tonic-gate #define	HCR_INTR_SOF		0x00000004	/* Start of frame */
1950Sstevel@tonic-gate #define	HCR_INTR_RD		0x00000008	/* Resume detected */
1960Sstevel@tonic-gate #define	HCR_INTR_UE		0x00000010	/* Unrecoverable error */
1970Sstevel@tonic-gate #define	HCR_INTR_FNO		0x00000020	/* Frame no. overflow */
1980Sstevel@tonic-gate #define	HCR_INTR_RHSC		0x00000040	/* Root hub status change */
1990Sstevel@tonic-gate #define	HCR_INTR_OC		0x40000000	/* Change in ownership */
2000Sstevel@tonic-gate #define	HCR_INTR_MIE		0x80000000	/* Master interrupt enable */
2010Sstevel@tonic-gate 
2020Sstevel@tonic-gate /* hcr_frame_interval bits */
2030Sstevel@tonic-gate #define	HCR_FRME_INT_FI		0x00003FFF	/* Frame interval */
2040Sstevel@tonic-gate #define	HCR_FRME_INT_FSMPS	0x7FFF0000	/* Biggest packet */
2050Sstevel@tonic-gate #define	HCR_FRME_FSMPS_SHFT	16		/* FSMPS */
2060Sstevel@tonic-gate #define	HCR_FRME_INT_FIT	0x80000000	/* Frame interval toggle */
2070Sstevel@tonic-gate #define	MAX_OVERHEAD		210		/* Max. bit overhead */
2080Sstevel@tonic-gate 
2090Sstevel@tonic-gate /* hcr_frame_remaining bits */
2100Sstevel@tonic-gate #define	HCR_FRME_REM_FR		0x00003FFF	/* Frame remaining */
2110Sstevel@tonic-gate #define	HCR_FRME_REM_FRT	0x80000000	/* Frame remaining toggle */
2120Sstevel@tonic-gate 
2130Sstevel@tonic-gate /* hcr_transfer_ls */
2140Sstevel@tonic-gate #define	HCR_TRANS_LST		0x000007FF	/* Low Speed threshold */
2150Sstevel@tonic-gate 
2160Sstevel@tonic-gate /* hcr_rh_descriptorA bits */
2170Sstevel@tonic-gate #define	HCR_RHA_NDP		0x000000FF	/* No. of ports */
2180Sstevel@tonic-gate #define	HCR_RHA_PSM		0x00000100	/* Power switch mode */
2190Sstevel@tonic-gate #define	HCR_RHA_NPS		0x00000200	/* No power switching */
2200Sstevel@tonic-gate #define	HCR_RHA_DT		0x00000400	/* Device type */
2210Sstevel@tonic-gate #define	HCR_RHA_OCPM		0x00000800	/* Over-current protection */
2220Sstevel@tonic-gate #define	HCR_RHA_NOCP		0x00001000	/* No over-current protection */
2230Sstevel@tonic-gate #define	HCR_RHA_PTPGT		0xFF000000	/* Power on to power good */
2240Sstevel@tonic-gate #define	HCR_RHA_PTPGT_SHIFT	24		/* Shift bits for ptpgt */
2250Sstevel@tonic-gate 
2260Sstevel@tonic-gate /* hcr_rh_descriptorB bits */
2270Sstevel@tonic-gate #define	HCR_RHB_DR		0x0000FFFF	/* Device removable */
2280Sstevel@tonic-gate #define	HCR_RHB_PPCM		0xFFFF0000	/* PortPowerControlMask */
2290Sstevel@tonic-gate 
2300Sstevel@tonic-gate /* hcr_rh_status bits */
2310Sstevel@tonic-gate #define	HCR_RH_STATUS_LPS	0x00000001	/* Local power status */
2320Sstevel@tonic-gate #define	HCR_RH_STATUS_OCI	0x00000002	/* Over current indicator */
2330Sstevel@tonic-gate #define	HCR_RH_STATUS_DRWE	0x00008000	/* Device remote wakeup */
2340Sstevel@tonic-gate #define	HCR_RH_STATUS_LPSC	0x00010000	/* Local power status change */
2350Sstevel@tonic-gate #define	HCR_RH_STATUS_OCIC	0x00020000	/* Over current indicator */
2360Sstevel@tonic-gate #define	HCR_RH_STATUS_CRWE	0x80000000	/* Clear remote wakeup enable */
2370Sstevel@tonic-gate #define	HCR_RH_STATUS_MASK	0x10038003	/* Status mask */
2382326Ssl147100 #define	HCR_RH_CHNG_MASK	0x00030000	/* Mask for change bits */
2390Sstevel@tonic-gate 
2400Sstevel@tonic-gate /* hcr_rh_portstatus bits */
2410Sstevel@tonic-gate #define	HCR_PORT_CCS		0x00000001	/* Current connect status */
2420Sstevel@tonic-gate #define	HCR_PORT_PES		0x00000002	/* Port enable */
2430Sstevel@tonic-gate #define	HCR_PORT_PSS		0x00000004	/* Port suspend status */
2440Sstevel@tonic-gate #define	HCR_PORT_POCI		0x00000008	/* Port over crrnt indicator */
2450Sstevel@tonic-gate #define	HCR_PORT_PRS		0x00000010	/* Port reset status */
2460Sstevel@tonic-gate #define	HCR_PORT_PPS		0x00000100	/* Port power status */
2470Sstevel@tonic-gate #define	HCR_PORT_CPP		0x00000200	/* Clear port power */
2480Sstevel@tonic-gate #define	HCR_PORT_LSDA		0x00000200	/* Low speed device */
2490Sstevel@tonic-gate #define	HCR_PORT_CSC		0x00010000	/* Connect status change */
2500Sstevel@tonic-gate #define	HCR_PORT_PESC		0x00020000	/* Port enable status change */
2510Sstevel@tonic-gate #define	HCR_PORT_PSSC		0x00040000	/* Port suspend status change */
2520Sstevel@tonic-gate #define	HCR_PORT_OCIC		0x00080000	/* Port over current change */
2530Sstevel@tonic-gate #define	HCR_PORT_PRSC		0x00100000	/* Port reset status chnge */
2540Sstevel@tonic-gate #define	HCR_PORT_MASK		0x001F031F	/* Reserved written as 0 */
2550Sstevel@tonic-gate #define	HCR_PORT_CHNG_MASK	0x001F0000	/* Mask for change bits */
2560Sstevel@tonic-gate 
2570Sstevel@tonic-gate #define	DONE_QUEUE_INTR_COUNTER	0x7		/* Done queue intr counter */
2580Sstevel@tonic-gate 
2590Sstevel@tonic-gate /*
2600Sstevel@tonic-gate  * Host Controller Communications Area
2610Sstevel@tonic-gate  *
2620Sstevel@tonic-gate  * The Host Controller Communications Area (HCCA) is a 256-byte structre
2630Sstevel@tonic-gate  * of system memory that is established by the Host Controller Driver (HCD)
2640Sstevel@tonic-gate  * and this structre is used for communication between HCD and HC. The HCD
2650Sstevel@tonic-gate  * maintains a pointer to this structure in the Host Controller (HC). This
2660Sstevel@tonic-gate  * structure must be aligned to a 256-byte boundary.
2670Sstevel@tonic-gate  */
2680Sstevel@tonic-gate 
2690Sstevel@tonic-gate #define	NUM_INTR_ED_LISTS	32	/* Number of interrupt lists */
2700Sstevel@tonic-gate #define	NUM_STATIC_NODES	31	/* Number of static endpoints */
2710Sstevel@tonic-gate 
2720Sstevel@tonic-gate typedef volatile struct ohci_hcca {
2730Sstevel@tonic-gate 	uint32_t	HccaIntTble[NUM_INTR_ED_LISTS]; /* 32 intr lists */
2740Sstevel@tonic-gate 							/* Ptrs to ohci_ed */
2750Sstevel@tonic-gate 	uint16_t	HccaFrameNo;		/* Current frame number */
2760Sstevel@tonic-gate 	uint16_t 	HccaPad;		/* 0 when HC updates FrameNo */
2770Sstevel@tonic-gate 	uint32_t	HccaDoneHead;		/* Head ptr */
2780Sstevel@tonic-gate 	uint8_t		HccaReserved[120];	/* Reserved area */
2790Sstevel@tonic-gate } ohci_hcca_t;
2800Sstevel@tonic-gate 
2810Sstevel@tonic-gate #define	HCCA_DONE_HEAD_MASK	0xFFFFFFF0	/* Hcca done head mask */
2820Sstevel@tonic-gate #define	HCCA_DONE_HEAD_LSB	0x00000001	/* Lsb of the Done Head */
2830Sstevel@tonic-gate 
2840Sstevel@tonic-gate 
2850Sstevel@tonic-gate /*
2860Sstevel@tonic-gate  * Host Controller Endpoint Descriptor
2870Sstevel@tonic-gate  *
2880Sstevel@tonic-gate  * An Endpoint Descriptor (ED) is a memory structure that describes the
2890Sstevel@tonic-gate  * information necessary for the Host Controller (HC) to communicate with
2900Sstevel@tonic-gate  * a device endpoint.  An ED includes a Transfer Descriptor (TD) pointer.
2910Sstevel@tonic-gate  * This structure must be aligned to a 16 byte boundary.
2920Sstevel@tonic-gate  */
2930Sstevel@tonic-gate typedef volatile struct ohci_ed {
2940Sstevel@tonic-gate 	uint32_t	hced_ctrl;	/* See below */
2950Sstevel@tonic-gate 	uint32_t	hced_tailp;	/* (ohci_td *) End of trans. list */
2960Sstevel@tonic-gate 	uint32_t	hced_headp;	/* (ohci_td *) Next trans. */
2970Sstevel@tonic-gate 	uint32_t	hced_next;	/* (ohci_ed *) Next endpoint */
2980Sstevel@tonic-gate 	uint32_t	hced_prev;	/* (ohci_ed *)Virt addr. of prev ept */
2990Sstevel@tonic-gate 	uint32_t	hced_node;	/* The node that its attached */
3000Sstevel@tonic-gate 	uint32_t	hced_reclaim_next; /* (ohci_ed *) Reclaim list */
3010Sstevel@tonic-gate 	uint32_t	hced_reclaim_frame; /* Reclaim usb frame number */
3020Sstevel@tonic-gate 	uint32_t	hced_state;	/* Endpoint state */
3030Sstevel@tonic-gate 	uint8_t		hce_pad[12];	/* Required padding */
3040Sstevel@tonic-gate } ohci_ed_t;
3050Sstevel@tonic-gate 
3060Sstevel@tonic-gate /*
3070Sstevel@tonic-gate  * hc_endpoint_descriptor control bits
3080Sstevel@tonic-gate  */
3090Sstevel@tonic-gate #define	HC_EPT_FUNC	0x0000007F		/* Address of function */
3100Sstevel@tonic-gate #define	HC_EPT_EP	0x00000780		/* Address of endpoint */
3110Sstevel@tonic-gate #define	HC_EPT_DataFlow 0x00001800		/* Direction of data flow */
3120Sstevel@tonic-gate #define	HC_EPT_DF_IN    0x00001000		/* Data flow in */
3130Sstevel@tonic-gate #define	HC_EPT_DF_OUT	0x00000800		/* Data flow out */
3140Sstevel@tonic-gate #define	HC_EPT_Speed   	0x00002000		/* Speed of the endpoint */
3150Sstevel@tonic-gate #define	HC_EPT_sKip	0x00004000		/* Skip bit */
3160Sstevel@tonic-gate #define	HC_EPT_Format   0x00008000		/* Type of transfer */
3170Sstevel@tonic-gate #define	HC_EPT_MPS	0x0EFF0000		/* Max packet size */
3180Sstevel@tonic-gate #define	HC_EPT_8_MPS	0x00080000		/* 8 byte max packet size */
3190Sstevel@tonic-gate #define	HC_EPT_64_MPS	0x00400000		/* 64 byte max packet size */
3200Sstevel@tonic-gate #define	HC_EPT_Halt	0x00000001		/* Halted */
3210Sstevel@tonic-gate #define	HC_EPT_Carry	0x00000002		/* Toggle carry */
3220Sstevel@tonic-gate 
3230Sstevel@tonic-gate #define	HC_EPT_EP_SHFT	7			/* Bits to shift addr */
3240Sstevel@tonic-gate #define	HC_EPT_MAXPKTSZ	16			/* Bits to shift maxpktsize */
3250Sstevel@tonic-gate 
3260Sstevel@tonic-gate #define	HC_EPT_TD_TAIL	0xFFFFFFF0		/* TD tail mask */
3270Sstevel@tonic-gate #define	HC_EPT_TD_HEAD	0xFFFFFFF0		/* TD head mask */
3280Sstevel@tonic-gate #define	HC_EPT_NEXT	0xFFFFFFF0		/* Next endpoint mask */
3290Sstevel@tonic-gate 
3300Sstevel@tonic-gate /*
3310Sstevel@tonic-gate  * hced_state
3320Sstevel@tonic-gate  *
3330Sstevel@tonic-gate  * ED states
3340Sstevel@tonic-gate  */
3350Sstevel@tonic-gate #define	HC_EPT_FREE	1			/* Free ED */
3360Sstevel@tonic-gate #define	HC_EPT_STATIC	2			/* Static ED */
3370Sstevel@tonic-gate #define	HC_EPT_ACTIVE	3			/* Active ED */
3380Sstevel@tonic-gate 
3390Sstevel@tonic-gate 
3400Sstevel@tonic-gate /*
3410Sstevel@tonic-gate  * Host Controller Transfer Descriptor
3420Sstevel@tonic-gate  *
3430Sstevel@tonic-gate  * A Transfer Descriptor (TD) is a memory structure that describes the
3440Sstevel@tonic-gate  * information necessary for the Host Controller (HC) to transfer a block
3450Sstevel@tonic-gate  * of data to or from a device endpoint. These TD's will be attached to
3460Sstevel@tonic-gate  * a Endpoint Descriptor (ED). This structure includes the fields for both
3470Sstevel@tonic-gate  * General and Isochronous Transfer Descriptors. The General TDs must be
3480Sstevel@tonic-gate  * aligned to 16 byte, where as Isochronous TDs must be aligned to 32 byte.
3490Sstevel@tonic-gate  */
3500Sstevel@tonic-gate typedef	volatile struct ohci_td {
3510Sstevel@tonic-gate 	uint32_t	hctd_ctrl;		/* See below */
3520Sstevel@tonic-gate 	uint32_t	hctd_cbp;		/* Next buffer addr */
3530Sstevel@tonic-gate 	uint32_t	hctd_next_td;		/* Next TD */
3540Sstevel@tonic-gate 	uint32_t	hctd_buf_end;		/* End of buffer */
3550Sstevel@tonic-gate 	uint32_t	hctd_offsets[4];	/* Offsets into buf */
3560Sstevel@tonic-gate 						/* Used only for isoch */
3570Sstevel@tonic-gate 	uint32_t	hctd_trans_wrapper;	/* Transfer wrapper */
3580Sstevel@tonic-gate 	uint32_t	hctd_state;		/* TD state */
3590Sstevel@tonic-gate 	uint32_t	hctd_tw_next_td;	/* Next TD on TW */
3600Sstevel@tonic-gate 	uint32_t	hctd_ctrl_phase;	/* Control Xfer Phase info */
3612125Ssl147100 	uint32_t	hctd_xfer_offs;		/* Starting buffer offset */
3622125Ssl147100 	uint32_t	hctd_xfer_len;		/* Transfer length */
3632125Ssl147100 	uint8_t		hctd_pad[8];		/* Required padding */
3640Sstevel@tonic-gate } ohci_td_t;
3650Sstevel@tonic-gate 
3660Sstevel@tonic-gate /*
3670Sstevel@tonic-gate  * Common hc_td control bits both for the General and Isochronous Transfer
3680Sstevel@tonic-gate  * Descriptors.
3690Sstevel@tonic-gate  */
3700Sstevel@tonic-gate #define	HC_TD_DI	0x00E00000		/* Delay interrupt */
3710Sstevel@tonic-gate #define	HC_TD_0I	0x00000000		/* 0 frame for interrupt */
3720Sstevel@tonic-gate #define	HC_TD_1I	0x00200000		/* 1 frame for interrupt */
3730Sstevel@tonic-gate #define	HC_TD_2I	0x00400000		/* 2 frame for interrupt */
3740Sstevel@tonic-gate #define	HC_TD_3I	0x00600000		/* 3 frame for interrupt */
3750Sstevel@tonic-gate #define	HC_TD_4I	0x00800000		/* 4 frame's for interrupt */
3760Sstevel@tonic-gate #define	HC_TD_5I	0x00A00000		/* 5 frame for interrupt */
3770Sstevel@tonic-gate #define	HC_TD_6I	0x00C00000		/* 6 frame for interrupt */
3780Sstevel@tonic-gate #define	HC_TD_7I	0x00E00000		/* 7 frame for interrupt */
3790Sstevel@tonic-gate #define	HC_TD_CC	0xF0000000		/* Condition code */
3800Sstevel@tonic-gate 
3810Sstevel@tonic-gate #define	HC_TD_R		0x00040000		/* Buffer rounding */
3820Sstevel@tonic-gate #define	HC_TD_PID	0x00180000		/* Pid for the token */
3830Sstevel@tonic-gate #define	HC_TD_SETUP	0x00000000		/* Setup direction */
3840Sstevel@tonic-gate #define	HC_TD_IN	0x00100000		/* In direction */
3850Sstevel@tonic-gate #define	HC_TD_OUT	0x00080000		/* Out direction */
3860Sstevel@tonic-gate #define	HC_TD_DT	0x03000000		/* Data Toggle */
3870Sstevel@tonic-gate #define	HC_TD_MS_DT	0x02000000		/* Master data toggle */
3880Sstevel@tonic-gate #define	HC_TD_DT_0	0x00000000		/* Toggle from TD 0 */
3890Sstevel@tonic-gate #define	HC_TD_DT_1	0x01000000		/* Toggle from TD 1 */
3900Sstevel@tonic-gate #define	HC_TD_EC	0x0C000000		/* Error Count */
3910Sstevel@tonic-gate 
3920Sstevel@tonic-gate /*
3930Sstevel@tonic-gate  * hc_td control bits specific to Isochronous Transfer Descriptors.
3940Sstevel@tonic-gate  */
3950Sstevel@tonic-gate #define	HC_ITD_SF		0x0000FFFF	/* Starting Frame number */
3960Sstevel@tonic-gate #define	HC_ITD_FC		0x07000000	/* Frame count */
3970Sstevel@tonic-gate 
3980Sstevel@tonic-gate #define	HC_ITD_FC_SHIFT		24		/* Frame count shift */
3990Sstevel@tonic-gate #define	HC_ITD_PAGE_MASK	0xFFFFF000
4000Sstevel@tonic-gate #define	HC_ITD_ODD_OFFSET	0xFFFF0000	/* Odd offset */
4010Sstevel@tonic-gate #define	HC_ITD_EVEN_OFFSET	0x0000FFFF	/* Even offset */
4020Sstevel@tonic-gate #define	HC_ITD_OFFSET_SHIFT	16
4033255Slg150142 #define	HC_ITD_OFFSET_CC	0x0000E000	/* CC of offset or PSW N */
4040Sstevel@tonic-gate #define	HC_ITD_OFFSET_ADDR	0x00000FFF	/* Offset N */
4050Sstevel@tonic-gate #define	HC_ITD_4KBOUNDARY_CROSS	0x00001000	/* Set bit 12 for 4k crossing */
4060Sstevel@tonic-gate 
4070Sstevel@tonic-gate /*
4080Sstevel@tonic-gate  * Condition codes both to General and Isochronous Transfer Descriptors.
4090Sstevel@tonic-gate  * Even these condition codes are valid for  offsets of the isochronous
4100Sstevel@tonic-gate  * transfer descriptos.
4110Sstevel@tonic-gate  */
4120Sstevel@tonic-gate #define	HC_TD_CC_NO_E	0x00000000		/* No error */
4130Sstevel@tonic-gate #define	HC_TD_CC_CRC	0x10000000		/* CRC error */
4140Sstevel@tonic-gate #define	HC_TD_CC_BS	0x20000000		/* Bit stuffing */
4150Sstevel@tonic-gate #define	HC_TD_CC_DTM	0x30000000		/* Data Toggle Mismatch */
4160Sstevel@tonic-gate #define	HC_TD_CC_STALL	0x40000000		/* Stall */
4170Sstevel@tonic-gate #define	HC_TD_CC_DNR	0x50000000		/* Device not responding */
4180Sstevel@tonic-gate #define	HC_TD_CC_PCF	0x60000000		/* PID check failure */
4190Sstevel@tonic-gate #define	HC_TD_CC_UPID	0x70000000		/* Unexpected PID */
4200Sstevel@tonic-gate #define	HC_TD_CC_DO	0x80000000		/* Data overrrun */
4210Sstevel@tonic-gate #define	HC_TD_CC_DU	0x90000000		/* Data underrun */
4220Sstevel@tonic-gate #define	HC_TD_CC_BO	0xC0000000		/* Buffer overrun */
4230Sstevel@tonic-gate #define	HC_TD_CC_BU	0xD0000000		/* Buffer underrun */
4240Sstevel@tonic-gate #define	HC_TD_CC_NA	0xF0000000		/* Not accessed */
4250Sstevel@tonic-gate 
4260Sstevel@tonic-gate #define	HC_TD_NEXT	0xFFFFFFF0		/* Next TD */
4270Sstevel@tonic-gate 
4280Sstevel@tonic-gate /*
4290Sstevel@tonic-gate  * Condition codes specific to Isochronous Transfer Descriptors.
4300Sstevel@tonic-gate  */
4310Sstevel@tonic-gate #define	HC_ITD_CC_SHIFT	16			/* ITD CC shift */
4320Sstevel@tonic-gate 
4330Sstevel@tonic-gate /*
4340Sstevel@tonic-gate  * hctd_state
4350Sstevel@tonic-gate  *
4360Sstevel@tonic-gate  * TD States
4370Sstevel@tonic-gate  */
4380Sstevel@tonic-gate #define	HC_TD_FREE	1			/* Free TD */
4390Sstevel@tonic-gate #define	HC_TD_DUMMY	2			/* Dummy TD */
4400Sstevel@tonic-gate #define	HC_TD_ACTIVE	3			/* Active TD */
4410Sstevel@tonic-gate #define	HC_TD_TIMEOUT	4			/* Timeouted TD */
4420Sstevel@tonic-gate #define	HC_TD_RECLAIM	5			/* Reclaimed TD */
4430Sstevel@tonic-gate 
4440Sstevel@tonic-gate /*
4450Sstevel@tonic-gate  * hctd_ctrl_phase
4460Sstevel@tonic-gate  *
4470Sstevel@tonic-gate  * Control Transfer Phase information
4480Sstevel@tonic-gate  */
4490Sstevel@tonic-gate #define	OHCI_CTRL_SETUP_PHASE		1	/* Setup phase */
4500Sstevel@tonic-gate #define	OHCI_CTRL_DATA_PHASE		2	/* Data phase */
4510Sstevel@tonic-gate #define	OHCI_CTRL_STATUS_PHASE		3	/* Status phase */
4520Sstevel@tonic-gate 
4532125Ssl147100 /*
4542125Ssl147100  * Structure for Isoc DMA buffer
4552125Ssl147100  *	One Isoc transfer includes multiple Isoc packets and need to be
4562125Ssl147100  *	transfered in multiple TDs.
4572125Ssl147100  *	One DMA buffer is allocated for one Isoc TD which may hold up
4582125Ssl147100  *	to eight Isoc packets.
4592125Ssl147100  */
4602125Ssl147100 typedef struct ohci_isoc_buf {
4612125Ssl147100 	caddr_t			buf_addr;	/* Starting buffer address */
4622125Ssl147100 	ddi_dma_cookie_t	cookie;		/* DMA cookie */
4632125Ssl147100 	ddi_dma_handle_t	dma_handle;	/* DMA handle */
4642125Ssl147100 	ddi_acc_handle_t	mem_handle;	/* Memory handle */
4652125Ssl147100 	size_t			length;		/* Buffer length */
4662125Ssl147100 	uint_t			ncookies;	/* DMA cookie count */
4672125Ssl147100 	uint_t			index;		/* Index of the TD */
4682125Ssl147100 } ohci_isoc_buf_t;
4690Sstevel@tonic-gate 
4700Sstevel@tonic-gate #ifdef __cplusplus
4710Sstevel@tonic-gate }
4720Sstevel@tonic-gate #endif
4730Sstevel@tonic-gate 
4740Sstevel@tonic-gate #endif	/* _SYS_USB_OHCI_H */
475