ohcireg.h revision 198151
1198151Sthompsa/* $FreeBSD: head/sys/dev/usb/controller/ohcireg.h 198151 2009-10-15 20:07:08Z thompsa $ */
2198151Sthompsa/*-
3198151Sthompsa * Copyright (c) 1998 The NetBSD Foundation, Inc.
4198151Sthompsa * All rights reserved.
5198151Sthompsa *
6198151Sthompsa * This code is derived from software contributed to The NetBSD Foundation
7198151Sthompsa * by Lennart Augustsson (lennart@augustsson.net) at
8198151Sthompsa * Carlstedt Research & Technology.
9198151Sthompsa *
10198151Sthompsa * Redistribution and use in source and binary forms, with or without
11198151Sthompsa * modification, are permitted provided that the following conditions
12198151Sthompsa * are met:
13198151Sthompsa * 1. Redistributions of source code must retain the above copyright
14198151Sthompsa *    notice, this list of conditions and the following disclaimer.
15198151Sthompsa * 2. Redistributions in binary form must reproduce the above copyright
16198151Sthompsa *    notice, this list of conditions and the following disclaimer in the
17198151Sthompsa *    documentation and/or other materials provided with the distribution.
18198151Sthompsa * 3. All advertising materials mentioning features or use of this software
19198151Sthompsa *    must display the following acknowledgement:
20198151Sthompsa *        This product includes software developed by the NetBSD
21198151Sthompsa *        Foundation, Inc. and its contributors.
22198151Sthompsa * 4. Neither the name of The NetBSD Foundation nor the names of its
23198151Sthompsa *    contributors may be used to endorse or promote products derived
24198151Sthompsa *    from this software without specific prior written permission.
25198151Sthompsa *
26198151Sthompsa * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27198151Sthompsa * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28198151Sthompsa * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29198151Sthompsa * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30198151Sthompsa * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31198151Sthompsa * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32198151Sthompsa * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33198151Sthompsa * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34198151Sthompsa * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35198151Sthompsa * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36198151Sthompsa * POSSIBILITY OF SUCH DAMAGE.
37198151Sthompsa */
38198151Sthompsa
39198151Sthompsa#ifndef _OHCIREG_H_
40198151Sthompsa#define	_OHCIREG_H_
41198151Sthompsa
42198151Sthompsa/* PCI config registers  */
43198151Sthompsa#define	PCI_CBMEM		0x10	/* configuration base memory */
44198151Sthompsa#define	PCI_INTERFACE_OHCI	0x10
45198151Sthompsa
46198151Sthompsa/* OHCI registers */
47198151Sthompsa#define	OHCI_REVISION		0x00	/* OHCI revision */
48198151Sthompsa#define	OHCI_REV_LO(rev)	((rev) & 0xf)
49198151Sthompsa#define	OHCI_REV_HI(rev)	(((rev)>>4) & 0xf)
50198151Sthompsa#define	OHCI_REV_LEGACY(rev)	((rev) & 0x100)
51198151Sthompsa#define	OHCI_CONTROL		0x04
52198151Sthompsa#define	OHCI_CBSR_MASK		0x00000003	/* Control/Bulk Service Ratio */
53198151Sthompsa#define	OHCI_RATIO_1_1		0x00000000
54198151Sthompsa#define	OHCI_RATIO_1_2		0x00000001
55198151Sthompsa#define	OHCI_RATIO_1_3		0x00000002
56198151Sthompsa#define	OHCI_RATIO_1_4		0x00000003
57198151Sthompsa#define	OHCI_PLE		0x00000004	/* Periodic List Enable */
58198151Sthompsa#define	OHCI_IE			0x00000008	/* Isochronous Enable */
59198151Sthompsa#define	OHCI_CLE		0x00000010	/* Control List Enable */
60198151Sthompsa#define	OHCI_BLE		0x00000020	/* Bulk List Enable */
61198151Sthompsa#define	OHCI_HCFS_MASK		0x000000c0	/* HostControllerFunctionalStat
62198151Sthompsa						 * e */
63198151Sthompsa#define	OHCI_HCFS_RESET		0x00000000
64198151Sthompsa#define	OHCI_HCFS_RESUME	0x00000040
65198151Sthompsa#define	OHCI_HCFS_OPERATIONAL	0x00000080
66198151Sthompsa#define	OHCI_HCFS_SUSPEND	0x000000c0
67198151Sthompsa#define	OHCI_IR			0x00000100	/* Interrupt Routing */
68198151Sthompsa#define	OHCI_RWC		0x00000200	/* Remote Wakeup Connected */
69198151Sthompsa#define	OHCI_RWE		0x00000400	/* Remote Wakeup Enabled */
70198151Sthompsa#define	OHCI_COMMAND_STATUS	0x08
71198151Sthompsa#define	OHCI_HCR		0x00000001	/* Host Controller Reset */
72198151Sthompsa#define	OHCI_CLF		0x00000002	/* Control List Filled */
73198151Sthompsa#define	OHCI_BLF		0x00000004	/* Bulk List Filled */
74198151Sthompsa#define	OHCI_OCR		0x00000008	/* Ownership Change Request */
75198151Sthompsa#define	OHCI_SOC_MASK		0x00030000	/* Scheduling Overrun Count */
76198151Sthompsa#define	OHCI_INTERRUPT_STATUS	0x0c
77198151Sthompsa#define	OHCI_SO			0x00000001	/* Scheduling Overrun */
78198151Sthompsa#define	OHCI_WDH		0x00000002	/* Writeback Done Head */
79198151Sthompsa#define	OHCI_SF			0x00000004	/* Start of Frame */
80198151Sthompsa#define	OHCI_RD			0x00000008	/* Resume Detected */
81198151Sthompsa#define	OHCI_UE			0x00000010	/* Unrecoverable Error */
82198151Sthompsa#define	OHCI_FNO		0x00000020	/* Frame Number Overflow */
83198151Sthompsa#define	OHCI_RHSC		0x00000040	/* Root Hub Status Change */
84198151Sthompsa#define	OHCI_OC			0x40000000	/* Ownership Change */
85198151Sthompsa#define	OHCI_MIE		0x80000000	/* Master Interrupt Enable */
86198151Sthompsa#define	OHCI_INTERRUPT_ENABLE	0x10
87198151Sthompsa#define	OHCI_INTERRUPT_DISABLE	0x14
88198151Sthompsa#define	OHCI_HCCA		0x18
89198151Sthompsa#define	OHCI_PERIOD_CURRENT_ED	0x1c
90198151Sthompsa#define	OHCI_CONTROL_HEAD_ED	0x20
91198151Sthompsa#define	OHCI_CONTROL_CURRENT_ED	0x24
92198151Sthompsa#define	OHCI_BULK_HEAD_ED	0x28
93198151Sthompsa#define	OHCI_BULK_CURRENT_ED	0x2c
94198151Sthompsa#define	OHCI_DONE_HEAD		0x30
95198151Sthompsa#define	OHCI_FM_INTERVAL	0x34
96198151Sthompsa#define	OHCI_GET_IVAL(s)	((s) & 0x3fff)
97198151Sthompsa#define	OHCI_GET_FSMPS(s)	(((s) >> 16) & 0x7fff)
98198151Sthompsa#define	OHCI_FIT		0x80000000
99198151Sthompsa#define	OHCI_FM_REMAINING	0x38
100198151Sthompsa#define	OHCI_FM_NUMBER		0x3c
101198151Sthompsa#define	OHCI_PERIODIC_START	0x40
102198151Sthompsa#define	OHCI_LS_THRESHOLD	0x44
103198151Sthompsa#define	OHCI_RH_DESCRIPTOR_A	0x48
104198151Sthompsa#define	OHCI_GET_NDP(s)		((s) & 0xff)
105198151Sthompsa#define	OHCI_PSM		0x0100	/* Power Switching Mode */
106198151Sthompsa#define	OHCI_NPS		0x0200	/* No Power Switching */
107198151Sthompsa#define	OHCI_DT			0x0400	/* Device Type */
108198151Sthompsa#define	OHCI_OCPM		0x0800	/* Overcurrent Protection Mode */
109198151Sthompsa#define	OHCI_NOCP		0x1000	/* No Overcurrent Protection */
110198151Sthompsa#define	OHCI_GET_POTPGT(s)	((s) >> 24)
111198151Sthompsa#define	OHCI_RH_DESCRIPTOR_B	0x4c
112198151Sthompsa#define	OHCI_RH_STATUS		0x50
113198151Sthompsa#define	OHCI_LPS		0x00000001	/* Local Power Status */
114198151Sthompsa#define	OHCI_OCI		0x00000002	/* OverCurrent Indicator */
115198151Sthompsa#define	OHCI_DRWE		0x00008000	/* Device Remote Wakeup Enable */
116198151Sthompsa#define	OHCI_LPSC		0x00010000	/* Local Power Status Change */
117198151Sthompsa#define	OHCI_CCIC		0x00020000	/* OverCurrent Indicator
118198151Sthompsa						 * Change */
119198151Sthompsa#define	OHCI_CRWE		0x80000000	/* Clear Remote Wakeup Enable */
120198151Sthompsa#define	OHCI_RH_PORT_STATUS(n)	(0x50 + ((n)*4))	/* 1 based indexing */
121198151Sthompsa
122198151Sthompsa#define	OHCI_LES		(OHCI_PLE | OHCI_IE | OHCI_CLE | OHCI_BLE)
123198151Sthompsa#define	OHCI_ALL_INTRS		(OHCI_SO | OHCI_WDH | OHCI_SF |		\
124198151Sthompsa				OHCI_RD | OHCI_UE | OHCI_FNO |		\
125198151Sthompsa				OHCI_RHSC | OHCI_OC)
126198151Sthompsa#define	OHCI_NORMAL_INTRS	(OHCI_WDH | OHCI_RD | OHCI_UE | OHCI_RHSC)
127198151Sthompsa
128198151Sthompsa#define	OHCI_FSMPS(i)		(((i-210)*6/7) << 16)
129198151Sthompsa#define	OHCI_PERIODIC(i)	((i)*9/10)
130198151Sthompsa
131198151Sthompsa#endif	/* _OHCIREG_H_ */
132