1 #ifndef MEDIATOR_PCIDEV_H_
2 #define MEDIATOR_PCIDEV_H_
4 #include <exec/types.h>
5 #include <exec/libraries.h>
6 #include <exec/execbase.h>
7 #include <exec/nodes.h>
8 #include <exec/lists.h>
14 #include <aros/arossupportbase.h>
15 #include <exec/execbase.h>
17 #include "pci_resource.h"
19 #include LC_LIBDEFS_FILE
21 struct pci_staticdata
{
22 OOP_AttrBase hiddPCIDriverAB
;
25 OOP_Class
*driverClass
;
29 struct Library LibNode
;
30 struct pci_staticdata psd
;
31 struct ConfigDev
*baseDev
;
32 struct ConfigDev
*memDev
;
35 volatile UBYTE
*setup
;
36 volatile ULONG
*config
;
38 /* Access functions */
39 ULONG (*cfg_readl
)(struct pcibase
*base
, UBYTE bus
, UBYTE device
, UBYTE func
, UBYTE reg
);
40 VOID (*cfg_writel
)(struct pcibase
*base
, UBYTE bus
, UBYTE device
, UBYTE func
, UBYTE reg
, ULONG val
);
46 #define BASE(cl) ((struct pcibase*)(cl->UserData))
48 #define PSD(cl) (&((struct pcibase*)cl->UserData)->psd)
50 /* PCI Configspace offsets */
51 #define PCICS_VENDOR 0x00
52 #define PCICS_PRODUCT 0x02
53 #define PCICS_COMMAND 0x04
54 #define PCICS_STATUS 0x06
55 #define PCICS_REVISION 0x08
56 #define PCICS_PROGIF 0x09
57 #define PCICS_SUBCLASS 0x0a
58 #define PCICS_CLASS 0x0b
59 #define PCICS_CACHELS 0x0c
60 #define PCICS_LATENCY 0x0d
61 #define PCICS_HEADERTYPE 0x0e
62 #define PCICS_BIST 0x0f
63 #define PCICS_BAR0 0x10
64 #define PCICS_BAR1 0x14
65 #define PCICS_BAR2 0x18
66 #define PCICS_BAR3 0x1c
67 #define PCICS_BAR4 0x20
68 #define PCICS_BAR5 0x24
69 #define PCICS_CARDBUS_CIS 0x28
70 #define PCICS_SUBVENDOR 0x2c
71 #define PCICS_SUBSYSTEM 0x2e
72 #define PCICS_EXPROM_BASE 0x30
73 #define PCICS_CAP_PTR 0x34
74 #define PCICS_INT_LINE 0x3c
75 #define PCICS_INT_PIN 0x3d
76 #define PCICS_MIN_GNT 0x3e
77 #define PCICS_MAX_LAT 0x3f
80 #define PCIHT_MASK 0x7f
81 #define PCIHT_MULTIFUNC 0x80
83 #define PCIHT_NORMAL 0x00
84 #define PCIHT_BRIDGE 0x01
85 #define PCIHT_CARDBUS 0x02
87 /* PCI Command register bits */
88 #define PCICMB_IODECODE 0
89 #define PCICMB_MEMDECODE 1
90 #define PCICMB_BUSMASTER 2
91 #define PCICMB_SPECIAL 3
92 #define PCICMB_INVALIDATE 4
93 #define PCICMB_VGASNOOP 5
94 #define PCICMB_PARITY 6
95 #define PCICMB_STEPPING 7
97 #define PCICMB_FASTB2B 9
99 #define PCICMF_IODECODE (1 << PCICMB_IODECODE)
100 #define PCICMF_MEMDECODE (1 << PCICMB_MEMDECODE)
101 #define PCICMF_BUSMASTER (1 << PCICMB_BUSMASTER)
102 #define PCICMF_SPECIAL (1 << PCICMB_SPECIAL)
103 #define PCICMF_INVALIDATE (1 << PCICMB_INVALIDATE)
104 #define PCICMF_VGASNOOP (1 << PCICMB_VGASNOOP)
105 #define PCICMF_PARITY (1 << PCICMB_PARITY)
106 #define PCICMF_STEPPING (1 << PCICMB_STEPPING)
107 #define PCICMF_SERR (1 << PCICMB_SERR)
108 #define PCICMF_FASTB2B (1 << PCICMB_FASTB2B)
110 /* PCI Status register bits */
111 #define PCISTB_INTERRUPT_STATUS 3 /* might be AHCI specific */
112 #define PCISTB_CAPABILITES 4
113 #define PCISTB_66MHZ 5
114 #define PCISTB_FASTB2B 7
115 #define PCISTB_PARITY 8
116 #define PCISTB_SIG_TGT_ABORT 11
117 #define PCISTB_REC_TGT_ABORT 12
118 #define PCISTB_REC_MAS_ABORT 13
119 #define PCISTB_SIG_SYSERR 14
120 #define PCISTB_PARITYERR 15
122 #define PCISTF_INTERRUPT_STATUS (1 << PCISTB_INTERRUPT_STATUS)
123 #define PCISTF_CAPABILITIES (1 << PCISTB_CAPABILITES)
124 #define PCISTF_66MHZ (1 << PCISTB_66MHZ)
125 #define PCISTF_FASTB2B (1 << PCISTB_FASTB2B)
126 #define PCISTF_PARITY (1 << PCISTB_PARITY)
127 #define PCISTF_SIG_TGT_ABORT (1 << PCISTB_SIG_TGT_ABORT)
128 #define PCISTF_REC_TGT_ABORT (1 << PCISTB_REC_TGT_ABORT)
129 #define PCISTF_REC_MAS_ABORT (1 << PCISTB_REC_MAS_ABORT)
130 #define PCISTF_SIG_SYSERR (1 << PCISTB_SIG_SYSERR)
131 #define PCISTF_PARITYERR (1 << PCISTB_PARITYERR)
133 #define PCIST_DEVSEL_MASK 0x600
134 #define PCIST_DEVSEL_FAST 0x000
135 #define PCIST_DEVSEL_MEDIUM 0x200
136 #define PCIST_DEVSEL_SLOW 0x400
138 /* PCI BIST register */
139 #define PCIBSB_START 6
140 #define PCIBSB_CAPABLE 7
142 #define PCIBSF_START (1 << PCIBSB_START)
143 #define PCIBSF_CAPABLE (1 << PCIBSB_CAPABLE)
145 #define PCIBS_CODEMASK 0x0f
147 /* PCI BaseAddressRegister defines */
148 #define PCIBAR_MASK_TYPE 0x01
149 #define PCIBAR_TYPE_MMAP 0x00
150 #define PCIBAR_TYPE_IO 0x01
151 #define PCIBAR_MASK_MEM 0xfffffff0
152 #define PCIBAR_MASK_IO 0xfffffffc
154 #define PCIBAR_MEMTYPE_MASK 0x06
155 #define PCIBAR_MEMTYPE_32BIT 0x00
156 #define PCIBAR_MEMTYPE_64BIT 0x04
158 #define PCIBARB_PREFETCHABLE 3
159 #define PCIBARF_PREFETCHABLE (1 << PCIBARB_PREFETCHABLE)
162 * PCI-to-PCI bridge header defines
163 * First 16 bytes are the same as normal PCI dev
164 * Use either PCICS_ or PCIBR_ prefix
166 #define PCIBR_VENDOR PCICS_VENDOR
167 #define PCIBR_PRODUCT PCICS_PRODUCT
168 #define PCIBR_COMMAND PCICS_COMMAND
169 #define PCIBR_STATUS PCICS_STATUS
170 #define PCIBR_REVISION PCICS_REVISION
171 #define PCIBR_PROGIF PCICS_PROGIF
172 #define PCIBR_SUBCLASS PCICS_SUBCLASS
173 #define PCIBR_CLASS PCICS_CLASS
174 #define PCIBR_CACHELS PCICS_CACHELS
175 #define PCIBR_LATENCY PCICS_LATENCY
176 #define PCIBR_HEADERTYPE PCICS_HEADERTYPE
177 #define PCIBR_BIST PCICS_BIST
178 #define PCIBR_BAR0 0x10
179 #define PCIBR_BAR1 0x14
180 #define PCIBR_PRIBUS 0x18
181 #define PCIBR_SECBUS 0x19
182 #define PCIBR_SUBBUS 0x1a
183 #define PCIBR_SECLATENCY 0x1b
184 #define PCIBR_IOBASE 0x1c
185 #define PCIBR_IOLIMIT 0x1d
186 #define PCIBR_SECSTATUS 0x1e
187 #define PCIBR_MEMBASE 0x20
188 #define PCIBR_MEMLIMIT 0x22
189 #define PCIBR_PREFETCHBASE 0x24
190 #define PCIBR_PREFETCHLIMIT 0x26
191 #define PCIBR_PREBASEUPPER 0x28
192 #define PCIBR_PRELIMITUPPER 0x2c
193 #define PCIBR_IOBASEUPPER 0x30
194 #define PCIBR_IOLIMITUPPER 0x32
195 #define PCIBR_CAPPTR 0x34
196 #define PCIBR_EXPROMBASE 0x38
197 #define PCIBR_INT_LINE 0x3c
198 #define PCIBR_INT_PIN 0x3d
199 #define PCIBR_CONTROL 0x3e
201 #define PCICTRLB_ISAENABLE 2
202 #define PCICTRLB_VGAENABLE 3
204 #define PCICTRLF_ISAENABLE (1 << PCICTRLB_ISAENABLE)
205 #define PCICTRLF_VGAENABLE (1 << PCICTRLB_VGAENABLE)
207 /* PCI capabilities */
208 #define PCICAP_POWER_MANAGEMENT 0x01
209 #define PCICAP_AGP 0x02
210 #define PCICAP_VITAL_PRODUCT_DATA 0x03
211 #define PCICAP_SLOT_ID 0x04
212 #define PCICAP_MSI 0x05
213 #define PCICAP_CPCI_HOT_SWAP 0x06
214 #define PCICAP_PCIX 0x07
215 #define PCICAP_HYPER_TRANSPORT 0x08
216 #define PCICAP_VENDOR_SPECIFIC 0x09
217 #define PCICAP_DEBUG_PORT 0x0a
218 #define PCICAP_CPCI_CR 0x0b
219 #define PCICAP_HOT_PLUG_CONTROLLER 0x0c
220 #define PCICAP_SSVPID 0x0d
221 #define PCICAP_AGP3 0x0e
222 #define PCICAP_PCIE 0x10
223 #define PCICAP_MSIX 0x11
224 #define PCICAP_ADVANCED_FEATURES 0x13
226 /* PCI Express Configspace offsets */
227 #define PCIECS_VENDOR PCICS_VENDOR
228 #define PCIECS_PRODUCT PCICS_PRODUCT
229 #define PCIECS_COMMAND PCICS_COMMAND
230 #define PCIECS_STATUS PCICS_STATUS
231 #define PCIECS_REVISION PCICS_REVISION
232 #define PCIECS_PROGIF PCICS_PROGIF
233 #define PCIECS_SUBCLASS PCICS_SUBCLASS
234 #define PCIECS_CLASS PCICS_CLASS
235 #define PCIECS_CACHELS PCICS_CACHELS
236 #define PCIECS_LATENCY PCICS_LATENCY
237 #define PCIECS_HEADERTYPE PCICS_HEADERTYPE
238 #define PCIECS_BIST PCICS_BIST
239 #define PCIECS_CAP_PTR PCICS_CAP_PTR
240 #define PCIECS_INT_LINE PCICS_INT_LINE
241 #define PCIECS_INT_PIN PCICS_INT_PIN
243 /* PCI Express capability structure */
244 #define PCIECS_CAPID 0x00
245 #define PCIECS_NEXTCAP 0x01
246 #define PCIECS_PCIECAP 0x02
247 #define PCIECS_DEVCAP 0x04
248 #define PCIECS_DEVCTL 0x08
249 #define PCIECS_DEVSTS 0x0A
250 #define PCIECS_LINKCAP 0x0C
251 #define PCIECS_LINKCTL 0x10
252 #define PCIECS_LINKSTS 0x12
253 #define PCIECS_SLOTCAP 0x14
254 #define PCIECS_SLOTCTL 0x18
255 #define PCIECS_SLOTSTS 0x1A
256 #define PCIECS_ROOTCTL 0x1C
257 #define PCIECS_ROOTSTS 0x20
258 #define PCIECS_DEVCAP2 0x24
259 #define PCIECS_DEVCTL2 0x28
260 #define PCIECS_DEVSTS2 0x2A
261 #define PCIECS_LINKCAP2 0x2C
262 #define PCIECS_LINKCTL2 0x30
263 #define PCIECS_LINKSTS2 0x32
264 #define PCIECS_SLOTCAP2 0x34
265 #define PCIECS_SLOTCTL2 0x38
266 #define PCIECS_SLOTSTS2 0x3A
268 /* PCI Express capabilities */
269 #define PCIECAP_VER_MASK 0xF
270 #define PCIECAP_VER_10 0x1 /* PCIe spec 1.0 */
271 #define PCIECAP_VER_20 0x2 /* PCIe spec 2.0 */
273 #endif /*MEDIATOR_PCIDEV_H_*/