ohcireg.h revision 1.1 1 /* $NetBSD: ohcireg.h,v 1.1 1998/07/12 19:51:59 augustss Exp $ */
2
3 /*
4 * Copyright (c) 1998 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * Author: Lennart Augustsson <augustss (at) carlstedt.se>
8 * Carlstedt Research & Technology
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by the NetBSD
21 * Foundation, Inc. and its contributors.
22 * 4. Neither the name of The NetBSD Foundation nor the names of its
23 * contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 * POSSIBILITY OF SUCH DAMAGE.
37 */
38
39 #ifndef _DEV_PCI_UHCIREG_H_
40 #define _DEV_PCI_UHCIREG_H_
41
42 /*** PCI config registers ***/
43
44 #define PCI_CBMEM 0x10 /* configuration base memory */
45
46 /*** OHCI registers */
47
48 #define OHCI_REVISION 0x00 /* OHCI revision # */
49 #define OHCI_REV_LO(rev) ((rev)&0xf)
50 #define OHCI_REV_HI(rev) (((rev)>>4)&0xf)
51 #define OHCI_REV_LEGACY(rev) ((rev) & 0x100)
52
53 #define OHCI_CONTROL 0x04
54 #define OHCI_CBSR_MASK 0x00000003 /* Control/Bulk Service Ratio */
55 #define OHCI_RATIO_1_1 0x00000000
56 #define OHCI_RATIO_1_2 0x00000001
57 #define OHCI_RATIO_1_3 0x00000002
58 #define OHCI_RATIO_1_4 0x00000003
59 #define OHCI_PLE 0x00000004 /* Periodic List Enable */
60 #define OHCI_IE 0x00000008 /* Isochronous Enable */
61 #define OHCI_CLE 0x00000010 /* Control List Enable */
62 #define OHCI_BLE 0x00000020 /* Bulk List Enable */
63 #define OHCI_HCFS_MASK 0x000000c0 /* HostControllerFunctionalState */
64 #define OHCI_HCFS_RESET 0x00000000
65 #define OHCI_HCFS_RESUME 0x00000040
66 #define OHCI_HCFS_OPERATIONAL 0x00000080
67 #define OHCI_HCFS_SUSPEND 0x000000c0
68 #define OHCI_IR 0x00000100 /* Interrupt Routing */
69 #define OHCI_RWC 0x00000200 /* Remote Wakeup Connected */
70 #define OHCI_RWE 0x00000400 /* Remote Wakeup Enabled */
71 #define OHCI_COMMAND_STATUS 0x08
72 #define OHCI_HCR 0x00000001 /* Host Controller Reset */
73 #define OHCI_CLF 0x00000002 /* Control List Filled */
74 #define OHCI_BLF 0x00000004 /* Bulk List Filled */
75 #define OHCI_OCR 0x00000008 /* Ownership Change Request */
76 #define OHCI_SOC_MASK 0x00030000 /* Scheduling Overrun Count */
77 #define OHCI_INTERRUPT_STATUS 0x0c
78 #define OHCI_SO 0x00000001 /* Scheduling Overrun */
79 #define OHCI_WDH 0x00000002 /* Writeback Done Head */
80 #define OHCI_SF 0x00000004 /* Start of Frame */
81 #define OHCI_RD 0x00000008 /* Resume Detected */
82 #define OHCI_UE 0x00000010 /* Unrecoverable Error */
83 #define OHCI_FNO 0x00000020 /* Frame Number Overflow */
84 #define OHCI_RHSC 0x00000040 /* Root Hub Status Change */
85 #define OHCI_OC 0x40000000 /* Ownership Change */
86 #define OHCI_MIE 0x80000000 /* Master Interrupt Enable */
87 #define OHCI_INTERRUPT_ENABLE 0x10
88 #define OHCI_INTERRUPT_DISABLE 0x14
89 #define OHCI_HCCA 0x18
90 #define OHCI_PERIOD_CURRENT_ED 0x1c
91 #define OHCI_CONTROL_HEAD_ED 0x20
92 #define OHCI_CONTROL_CURRENT_ED 0x24
93 #define OHCI_BULK_HEAD_ED 0x28
94 #define OHCI_BULK_CURRENT_ED 0x2c
95 #define OHCI_DONE_HEAD 0x30
96 #define OHCI_FM_INTERVAL 0x34
97 #define OHCI_GET_IVAL(s) ((s) & 0x3fff)
98 #define OHCI_GET_FSMPS(s) (((s) >> 16) & 0x7fff)
99 #define OHCI_FIT 0x80000000
100 #define OHCI_FM_REMAINING 0x38
101 #define OHCI_FM_NUMBER 0x3c
102 #define OHCI_PERIODIC_START 0x40
103 #define OHCI_LS_THRESHOLD 0x44
104 #define OHCI_RH_DESCRIPTOR_A 0x48
105 #define OHCI_GET_NDP(s) ((s) & 0xff)
106 #define OHCI_NPS 0x0100
107 #define OHCI_PSM 0x0200
108 #define OHCI_GET_POTPGT(s) ((s) >> 24)
109 #define OHCI_RH_DESCRIPTOR_B 0x4c
110 #define OHCI_RH_STATUS 0x50
111 #define OHCI_LPS 0x00000001 /* Local Power Status */
112 #define OHCI_OCI 0x00000002 /* OverCurrent Indicator */
113 #define OHCI_DRWE 0x00008000 /* Device Remote Wakeup Enable */
114 #define OHCI_LPSC 0x00010000 /* Local Power Status Change */
115 #define OHCI_CCIC 0x00020000 /* OverCurrent Indicator Change */
116 #define OHCI_CRWE 0x80000000 /* Clear Remote Wakeup Enable */
117 #define OHCI_RH_PORT_STATUS(n) (0x50 + (n)*4) /* 1 based indexing */
118
119 #define OHCI_LES (OHCI_PLE | OHCI_IE | OHCI_CLE | OHCI_BLE)
120 #define OHCI_ALL_INTRS (OHCI_SO | OHCI_WDH | OHCI_SF | OHCI_RD | OHCI_UE | OHCI_FNO | OHCI_RHSC | OHCI_OC)
121 #define OHCI_NORMAL_INTRS (OHCI_SO | OHCI_WDH | OHCI_RD | OHCI_UE | OHCI_RHSC)
122
123 #define OHCI_FSMPS(i) (((i-210)*6/7) << 16)
124 #define OHCI_PERIODIC(i) ((i)*9/10)
125
126 typedef u_int32_t ohci_physaddr_t;
127
128 #define OHCI_NO_INTRS 32
129 struct ohci_hcca {
130 ohci_physaddr_t hcca_interrupt_table[OHCI_NO_INTRS];
131 u_int32_t hcca_frame_number;
132 ohci_physaddr_t hcca_done_head;
133 #define OHCI_DONE_INTRS 1
134 };
135 #define OHCI_HCCA_SIZE 256
136 #define OHCI_HCCA_ALIGN 256
137
138 typedef struct {
139 u_int32_t ed_flags;
140 #define OHCI_ED_GET_FA(s) ((s) & 0x7f)
141 #define OHCI_ED_ADDRMASK 0x0000007f
142 #define OHCI_ED_SET_FA(s) (s)
143 #define OHCI_ED_GET_EN(s) (((s) >> 7) & 0xf)
144 #define OHCI_ED_SET_EN(s) ((s) << 7)
145 #define OHCI_ED_DIR_MASK 0x00001800
146 #define OHCI_ED_DIR_TD 0x00000000
147 #define OHCI_ED_DIR_OUT 0x00000800
148 #define OHCI_ED_DIR_IN 0x00001000
149 #define OHCI_ED_SPEED 0x00002000
150 #define OHCI_ED_SKIP 0x00004000
151 #define OHCI_ED_FORMAT_GEN 0x00000000
152 #define OHCI_ED_FORMAT_ISO 0x00008000
153 #define OHCI_ED_GET_MAXP(s) (((s) >> 16) & 0x07ff)
154 #define OHCI_ED_SET_MAXP(s) ((s) << 16)
155 ohci_physaddr_t ed_tailp;
156 #define OHCI_HALTED 0x00000002
157 #define OHCI_TOGGLECARRY 0x00000001
158 #define OHCI_TAILMASK 0xfffffffc
159 ohci_physaddr_t ed_headp;
160 ohci_physaddr_t ed_nexted;
161 } ohci_ed_t;
162 #define OHCI_ED_SIZE 16
163 #define OHCI_ED_ALIGN 16
164
165 typedef struct {
166 u_int32_t td_flags;
167 #define OHCI_TD_R 0x00040000 /* Buffer Rounding */
168 #define OHCI_TD_DP_MASK 0x00180000 /* Direction / PID */
169 #define OHCI_TD_SETUP 0x00000000
170 #define OHCI_TD_OUT 0x00080000
171 #define OHCI_TD_IN 0x00100000
172 #define OHCI_TD_GET_DI(x) (((x) >> 21) & 7) /* Delay Interrupt */
173 #define OHCI_TD_SET_DI(x) ((x) << 21)
174 #define OHCI_TD_NOINTR 0x00e00000
175 #define OHCI_TD_TOGGLE_CARRY 0x00000000
176 #define OHCI_TD_TOGGLE_0 0x02000000
177 #define OHCI_TD_TOGGLE_1 0x03000000
178 #define OHCI_TD_GET_EC(x) (((x) >> 26) & 3) /* Error Count */
179 #define OHCI_TD_GET_CC(x) ((x) >> 28) /* Condition Code */
180 #define OHCI_TD_NOCC 0xf0000000
181 ohci_physaddr_t td_cbp; /* Current Buffer Pointer */
182 ohci_physaddr_t td_nexttd; /* Next TD */
183 ohci_physaddr_t td_be; /* Buffer End */
184 } ohci_td_t;
185 #define OHCI_TD_SIZE 16
186 #define OHCI_TD_ALIGN 16
187
188 #define OHCI_CC_NO_ERROR 0
189 #define OHCI_CC_CRC 1
190 #define OHCI_CC_BIT_STUFFING 2
191 #define OHCI_CC_DATA_TOGGLE_MISMATCH 3
192 #define OHCI_CC_STALL 4
193 #define OHCI_CC_DEVICE_NOT_RESPONDING 5
194 #define OHCI_CC_PID_CHECK_FAILURE 6
195 #define OHCI_CC_UNEXPECTED_PID 7
196 #define OHCI_CC_DATA_OVERRUN 8
197 #define OHCI_CC_DATA_UNDERRUN 9
198 #define OHCI_CC_BUFFER_OVERRUN 12
199 #define OHCI_CC_BUFFER_UNDERRUN 13
200 #define OHCI_CC_NOT_ACCESSED 15
201
202 #endif /* _DEV_PCI_UHCIREG_H_ */
203