StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
plx.h
1 #ifndef _PCI911_PLX_H_
2 #define _PCI911_PLX_H_
3 
4 /*
5 modification history
6 --------------------
7 01c,23jul96,snc added BTERM definitions for local memory and DMA
8 01b,04mar96,snc fixed PCI_INT_LINE macro definition
9 01a,17may95,snc Written.
10 */
11 
12 #define VULONG volatile unsigned long
13 #define VUSHORT volatile unsigned short
14 #define VUCHAR volatile unsigned char
15 
16 /***** PLX PCI 9060 Definitions *****/
17 #define PCI9060_UNIT0_BASE 0xA0000000
18 #define PCI9060_UNIT1_BASE 0x11100000
19 
20 /* PLX memory base addresses */
21 #define PLX_UNIT0_MEMBASE 0x10000000
22 #define PLX_UNIT1_MEMBASE 0x11000000
23 
24 #define PLX_UNIT0_IOBASE 0x20000000
25 #define PLX_UNIT1_IOBASE 0x22000000
26 
27 /* There are two PCI buses installed. */
28 #define NUM_PCI_BUSES 2
29 #define MAX_PLX_UNITNUM 1
30 #define NUM_PCI_SLOTS 8
31 #define SLOTS_PER_BRIDGE 4
32 #define PCI_MAX_FUNCTIONS 8
33 
34 /* Possible PCI interrupt lines */
35 #define INTA 0
36 #define INTB 1
37 #define INTC 2
38 #define INTD 3
39 
40 /*
41  * Macros to get pointers to word, short,or byte registers in PCI9060.
42  * Registers are directly memory-mapped, starting at the base address for
43  * the PCI9060 in question. Some registers are 32 bits, some 16, some 8.
44  * Since there are two pci chips, these macros take the base address of
45  * the chip as their first parameter, and the offset of the register as
46  * their second.
47  */
48 
49 #define PCI_WORD_REG(n,m) ((VULONG *)(n + m))
50 #define PCI_SHORT_REG(n,m) ((VUSHORT *)(n + m))
51 #define PCI_CHAR_REG(n,m) ((VUCHAR *)(n + m))
52 
53 /*
54  * PLX PCI9060 Configuration Registers
55  */
56 #define PCI_VENDOR_ID(n) PCI_SHORT_REG(n,0x00)
57 #define PCI_DEVICE_ID(n) PCI_SHORT_REG(n,0x02)
58 #define PCI_COMMAND(n) PCI_SHORT_REG(n,0x04)
59 #define PCI_STATUS(n) PCI_SHORT_REG(n,0x06)
60 #define PCI_REV_ID(n) PCI_CHAR_REG(n,0x08)
61 /* Note: Class Code Register occupies the upper 24 bits from the word at 0x08*/
62 #define PCI_CLASS_CODE(n) PCI_WORD_REG(n,0x08)
63 #define PCI_CACHE_LINE_SZ(n) PCI_CHAR_REG(n,0x0c)
64 #define PCI_LATENCY_TIMER(n) PCI_CHAR_REG(n,0x0d)
65 #define PCI_HEADER_TYPE(n) PCI_CHAR_REG(n,0x0e)
66 #define PCI_BIST(n) PCI_CHAR_REG(n,0x0f)
67 #define PCI_BASE_MMAP_REG(n) PCI_WORD_REG(n,0x10)
68 #define PCI_BASE_IOMAP_REG(n) PCI_WORD_REG(n,0x14)
69 #define PCI_BASE_LOCAL_MEM(n) PCI_WORD_REG(n,0x18)
70 #define PCI_BASE_EXP_ROM(n) PCI_WORD_REG(n,0x30)
71 #define PCI_INT_LINE(n) PCI_CHAR_REG(n,0x3c)
72 #define PCI_MIN_GNT(n) PCI_CHAR_REG(n,0x3e)
73 #define PCI_MAX_LAT(n) PCI_CHAR_REG(n,0x3f)
74 
75 /*
76  * Local Configuration Registers - PTOL: PCI to Local
77  * LTOP: Local to PCI
78  * MTOP: Direct Master to PCI
79  * MTOPM: Direct Master to PCI Memory
80  * MTOPI: Direct Master to PCI I/O
81  */
82 #define RANGE_PTOL_MEM(n) PCI_WORD_REG(n,0x80)
83 #define LOCAL_BASE_PTOL_MEM(n) PCI_WORD_REG(n,0x84)
84 #define RANGE_PTOL_ROM(n) PCI_WORD_REG(n,0x90)
85 #define BREQO_CONTROL(n) PCI_WORD_REG(n,0x94)
86 #define BUS_REGION_DESC_PTOL(n) PCI_WORD_REG(n,0x98)
87 #define RANGE_MTOP(n) PCI_WORD_REG(n,0x9c)
88 #define LOCAL_BASE_MTOPM(n) PCI_WORD_REG(n,0xa0)
89 #define LOCAL_BASE_MTOPI(n) PCI_WORD_REG(n,0xa4)
90 #define PCI_BASE_MTOP(n) PCI_WORD_REG(n,0xa8)
91 #define PCI_CONFIG_ADDR_REG(n) PCI_WORD_REG(n,0xac)
92 
93 /* Shared Run-Time Registers */
94 
95 #define PTOL_MBOX0(n) PCI_WORD_REG(n,0xc0)
96 #define PTOL_MBOX1(n) PCI_WORD_REG(n,0xc4)
97 #define PTOL_MBOX2(n) PCI_WORD_REG(n,0xc8)
98 #define PTOL_MBOX3(n) PCI_WORD_REG(n,0xcc)
99 #define LTOP_MBOX4(n) PCI_WORD_REG(n,0xd0)
100 #define LTOP_MBOX5(n) PCI_WORD_REG(n,0xd4)
101 #define LTOP_MBOX6(n) PCI_WORD_REG(n,0xd8)
102 #define LTOP_MBOX7(n) PCI_WORD_REG(n,0xdc)
103 #define PTOL_DOORBELL(n) PCI_WORD_REG(n,0xe0)
104 #define LTOP_DOORBELL(n) PCI_WORD_REG(n,0xe4)
105 #define PCI_INT_CSTAT(n) PCI_WORD_REG(n,0xe8)
106 #define PCI_EEPROM_CTL(n) PCI_WORD_REG(n,0xec)
107 
108 #define PTOL_DOORBELL_PCI_OFFSET 0x60
109 
110 /* Local DMA Registers */
111 
112 #define DMA_CH0_MODE(n) PCI_WORD_REG(n,0x100)
113 #define DMA_CH0_PADDR(n) PCI_WORD_REG(n,0x104)
114 #define DMA_CH0_LADDR(n) PCI_WORD_REG(n,0x108)
115 #define DMA_CH0_BCOUNT(n) PCI_WORD_REG(n,0x10c)
116 #define DMA_CH0_DPTR(n) PCI_WORD_REG(n,0x110)
117 #define DMA_CH1_MODE(n) PCI_WORD_REG(n,0x114)
118 #define DMA_CH1_PADDR(n) PCI_WORD_REG(n,0x118)
119 #define DMA_CH1_LADDR(n) PCI_WORD_REG(n,0x11c)
120 #define DMA_CH1_BCOUNT(n) PCI_WORD_REG(n,0x120)
121 #define DMA_CH1_DPTR(n) PCI_WORD_REG(n,0x124)
122 #define DMA_CMD_STAT(n) PCI_WORD_REG(n,0x128)
123 #define DMA_ARB_REG0(n) PCI_WORD_REG(n,0x12c)
124 #define DMA_ARB_REG1(n) PCI_WORD_REG(n,0x130)
125 
126 /* PCI Command Register Bit Definitions */
127 #define PCI_CMD_IOSPACE (1 << 0)
128 #define PCI_CMD_MEMSPACE (1 << 1)
129 #define PCI_CMD_MASTER_ENAB (1 << 2)
130 #define PCI_CMD_PARITY_RESP (1 << 6)
131 #define PCI_CMD_SERR_ENAB (1 << 8)
132 #define PCI_CMD_FASTBB_ENAB (1 << 9)
133 
134 /* PCI Status Register Bit Definitions */
135 #define PCI_STAT_FASTBB_CAP (1 << 7)
136 #define PCI_DATA_PARITY_ERR (1 << 8)
137 #define PCI_TARGET_ABORT (1 << 11)
138 #define PCI_RCV_TARGET_ABORT (1 << 12)
139 #define PCI_RCV_MASTER_ABORT (1 << 13)
140 #define PCI_SIGNALLED_SERR (1 << 14)
141 #define PCI_BUS_PARITY_ERR (1 << 15)
142 
143 /* retrieve the DEVSEL assertion timing */
144 #define PCI_DEVSEL_TIMING(n) ((*PCI_STATUS(n) & 0x0600) >> 9)
145 
146 /* PCI Class Code Register Bit Definitions - Read Only */
147 #define PCI_REG_LEVEL_PROG_IF(n) ((*PCI_CLASS_CODE(n) & 0x0000ff00) >> 8)
148 #define PCI_SUB_CLASS_ENCODING(n) ((*PCI_CLASS_CODE(n) & 0x00ff0000) >> 16)
149 #define PCI_BASE_CLASS_ENCODING(n) ((*PCI_CLASS_CODE(n) & 0xff000000) >> 24)
150 
151 /* PCI Built-in Self Test Register Bit Definitions */
152 #define PCI_DEVICE_SUPPORTS_BIST (1 << 7)
153 #define PCI_POST_BIST_RESULTS(n,x) (*PCI_BIST(n) |= (x & 0x0f))
154 #define PCI_BIST_INTERRUPT (1 << 6)
155 
156 /* Various Interrupt bits and misc. */
157 #define SIGNALLED_SYSTEM_ERROR (1 << 14)
158 #define RCVD_MASTER_ABORT (1 << 13)
159 #define RCVD_TARGET_ABORT (1 << 12)
160 #define SIGNALLED_TARGET_ABORT (1 << 11)
161 #define LOCAL_INT_ACTIVE (1 << 15)
162 #define LSERR_INT_ENABLE (1 << 0)
163 #define LOCAL_INT_ENABLE (1 << 16)
164 #define PCI_INT_ENABLE (1 << 8)
165 #define LOCAL_DOORBELL_ENABLE (1 << 17)
166 #define PCI_DOORBELL_ENABLE (1 << 9)
167 #define DMA_CH0_INT_ENABLE (1 << 18)
168 #define DMA_CH1_INT_ENABLE (1 << 19)
169 #define LOCAL_DOORBELL_INT (1 << 20)
170 #define DMA_CH0_INT (1 << 21)
171 #define DMA_CH1_INT (1 << 22)
172 #define BIST_INT (1 << 23)
173 #define CPU_MASTER_ABORT (1 << 24)
174 #define DMA0_MASTER_ABORT (1 << 25)
175 #define DMA1_MASTER_ABORT (1 << 26)
176 #define RETRIES_TARGET_ABORT (1 << 27)
177 #define DMA0_DONE (1 << 4)
178 #define DMA1_DONE (1 << 12)
179 #define CLEAR_CH0_INTS (1 << 3)
180 #define CLEAR_CH1_INTS (1 << 11)
181 #define MAX_RETRIES_256 (1 << 12)
182 #define DMA_CH0_ENABLE (1 << 0)
183 #define DMA_CH1_ENABLE (1 << 8)
184 #define DMA_CH0_START (1 << 1)
185 #define DMA_CH1_START (1 << 9)
186 #define DMA_CH0_ABORT (1 << 2)
187 #define DMA_CH1_ABORT (1 << 10)
188 #define DMA_WRITE (1 << 3)
189 #define BIST_NOT_SUPPORTED (0 << 0)
190 #define PCI_BURST_TIME (0xff) /* 255 clocks, first cut */
191 
192 
193 /* some macros */
194 #define CLEAR_SIG_SERR(n) (*PCI_STATUS(n) |= SIGNALLED_SYSTEM_ERROR)
195 #define CLEAR_SIG_ABORT(n) (*PCI_STATUS(n) |= SIGNALLED_TARGET_ABORT)
196 #define CLEAR_MASTER_ABORT(n) (*PCI_STATUS(n) |= RCVD_MASTER_ABORT)
197 #define CLEAR_TARGET_ABORT(n) (*PCI_STATUS(n) |= RCVD_TARGET_ABORT)
198 #define CLEAR_BUS_PARITY_ERROR(n) (*PCI_STATUS(n) |= PCI_BUS_PARITY_ERR)
199 #define CLR_DMA_CH0(n) (*DMA_CMD_STAT(n) |= CLEAR_CH0_INTS)
200 #define CLR_DMA_CH1(n) (*DMA_CMD_STAT(n) |= CLEAR_CH1_INTS)
201 #define DISABLE_DMA_CH0(n) (*DMA_CMD_STAT(n) &= ~(DMA_CH0_ENABLE))
202 #define DISABLE_DMA_CH1(n) (*DMA_CMD_STAT(n) &= ~(DMA_CH1_ENABLE))
203 #define ENABLE_DMA_CH0(n) (*DMA_CMD_STAT(n) |= DMA_CH0_ENABLE)
204 #define ENABLE_DMA_CH1(n) (*DMA_CMD_STAT(n) |= DMA_CH1_ENABLE)
205 #define START_DMA_CH0(n) (*DMA_CMD_STAT(n) |= DMA_CH0_START)
206 #define START_DMA_CH1(n) (*DMA_CMD_STAT(n) |= DMA_CH1_START)
207 #define ABORT_DMA_CH0(n) (*DMA_CMD_STAT(n) |= DMA_CH0_ABORT)
208 #define ABORT_DMA_CH1(n) (*DMA_CMD_STAT(n) |= DMA_CH1_ABORT)
209 #define DMA_CH0_WRITE(n) (*DMA_CH0_DPTR(n) |= DMA_WRITE)
210 #define DMA_CH0_READ(n) (*DMA_CH0_DPTR(n) &= ~(DMA_WRITE))
211 #define DMA_CH1_WRITE(n) (*DMA_CH1_DPTR(n) |= DMA_WRITE)
212 #define DMA_CH1_READ(n) (*DMA_CH1_DPTR(n) &= ~(DMA_WRITE))
213 #define PCI_INIT_DONE(n) (*PCI_EEPROM_CTL(n) |= (1 << 31))
214 #define IS_DONE_SET(n) (*PCI_EEPROM_CTL(n) & (1 << 31))
215 #define DISABLE_LSERR(n) (*PCI_INT_CSTAT(n) &= ~(LSERR_INT_ENABLE))
216 #define ENABLE_LSERR(n) (*PCI_INT_CSTAT(n) |= LSERR_INT_ENABLE)
217 #define PCI_IO_BASEADDR() (0x20000000)
218 #define PCI_MEM_BASEADDR() (0x00000000)
219 
220 /* PCI Bus command encodings - really only 4 bits*/
221 #define PCI_IACK (unsigned char)0x0
222 #define PCI_SPECIAL (unsigned char)0x1
223 #define PCI_IO_RD (unsigned char)0x2
224 #define PCI_IO_WR (unsigned char)0x3
225 #define PCI_MEM_RD (unsigned char)0x6
226 #define PCI_MEM_WR (unsigned char)0x7
227 #define PCI_CFG_RD (unsigned char)0xa
228 #define PCI_CFG_WR (unsigned char)0xb
229 #define PCI_MEM_RD_MULT (unsigned char)0xc
230 #define PCI_DUAL_ADDR (unsigned char)0xd
231 #define PCI_MEM_RD_LINE (unsigned char)0xe
232 #define PCI_MEM_WR_INV (unsigned char)0xf
233 
234 #define DMA_READ_CODE (PCI_MEM_RD << 0)
235 #define DMA_WRITE_CODE (PCI_MEM_WR << 4)
236 #define MASTER_READ_CODE (PCI_MEM_RD << 8)
237 #define MASTER_WRITE_CODE (PCI_MEM_WR << 12)
238 
239 #define RANGE_DRAM_32 0xfe000000 /* 32 bit mem. space, no prefetch */
240 #define RANGE_DRAM_8 0xff800000 /* 32 bit mem. space, no prefetch */
241 #define RANGE_DRAM_2 0xffe00000 /* 32 bit mem. space, no prefetch */
242 
243 #define BASE_DRAM 0x10000001 /* local base and enable */
244 #define NO_IO_SPACE 0x00000000 /* no I/O CFG space in addr. map */
245 #define PCI_MEMORY_SPACE 0x00000000
246 
247 /* BREQo Control */
248 #define BREQO_ENABLE (1 << 4)
249 #define DEADLOCK_TIMEOUT 0x4 /* deadlock after 32 clocks */
250 #define ROM_REMAP_ADDR (0xf << 28) /* Region E is Flash ROM */
251 
252 /* Local Bus Region Descriptor */
253 #define MEM_BUS_32BIT 0x3
254 #define MEM_USE_RDY_INPUT (1 << 6)
255 #define MEM_USE_BTERM_INPUT (1 << 7)
256 #define ROM_BUS_8BIT (0x0 << 16)
257 #define ROM_USE_RDY_INPUT (1 << 22) /* not really necessary */
258 #define MEM_BURST_ENABLE (1 << 24)
259 #define ROM_BURST_DISABLE (0 << 26)
260 #define NO_TRDY_WHEN_TXFULL (1 << 27) /* errata workaround */
261 #define RETRY_TIMEOUT (8 << 28) /* 64 CPU clocks */
262 
263 /* PCI Region Descriptor */
264 #define PCI_MEM_MASTER_ENAB (1 << 0)
265 #define PCI_IO_MASTER_DISAB (0 << 1)
266 #define PCI_IO_MASTER_ENAB (1 << 1)
267 #define PCI_LOCK_ENAB (1 << 2)
268 #define PCI_PREFETCH_DISAB (0 << 3)
269 #define PCI_RELEASE_FIFO_FULL (0 << 4)
270 #define PCI_REMAP_ADDR (0x0000 < 16)
271 
272 #define PCI_CONFIG_DISAB (0 << 31)
273 
274 #define ROM_DECODE_ENABLE (1 << 0)
275 #define ROM_DECODE_DISABLE (0 << 0)
276 
277 #define TEST_VAL (unsigned long) 0x43564d45 /* "CVME" */
278 #define DRAM_2MEG 0x10200000
279 #define DRAM_8MEG 0x10800000
280 #define DRAM_32MEG 0x12000000
281 
282 /* DMA Local Bus Region Descriptor */
283 #define LOCAL_BUS_32BIT 0x3
284 #define USE_RDY_INPUT (1 << 6)
285 #define USE_BTERM_INPUT (1 << 7)
286 #define DMA_BURSTING_ENABLE (1 << 8)
287 #define DMA_BURSTING_DISABLE (0 << 8)
288 #define DMA_CHAINING_DISABLED (0 << 9)
289 #define DMA_INT_ENDOFTRANSFER (1 << 10)
290 
291 /* DMA operational stuff */
292 #define DMA_ARB0_VALUE 0x0 /* Latency and Pause Timers
293  disabled, BREQ input disabled,
294  rotational DMA priority */
295 #define DMA_ARB1_VALUE 0x0 /* DMAs can request both the
296  PCI and Local busses without
297  regard for # of FIFO entries
298  */
299 #define DMA_MODE_VALUE LOCAL_BUS_32BIT | USE_RDY_INPUT
300 
301 /*******************************************************************************
302 *
303 * PCI Configuration Space Header
304 *
305 */
306 
307 typedef struct
308  {
309  unsigned short vendor_id;
310  unsigned short device_id;
311  unsigned short command;
312  unsigned short status;
313  unsigned char revision_id;
314  unsigned char prog_if;
315  unsigned char sub_class;
316  unsigned char base_class;
317  unsigned char cache_line_size;
318  unsigned char latency_timer;
319  unsigned char header_type;
320  unsigned char bist;
321  unsigned long pcibase_mm_regs;
322  unsigned long pcibase_im_regs;
323  unsigned long pcibase_local;
324  unsigned long reserved1[5];
325  unsigned long pcibase_exp_rom;
326  unsigned long reserved2[2];
327  unsigned char int_line;
328  unsigned char int_pin;
329  unsigned char min_gnt;
330  unsigned char max_lat;
332 
333 
334 /* Cyclone PCI-80960 Device Data */
335 #define VENDOR_STAR 0x1111 /* Vendor Id */
336 #define SUNNY_P1 0x0001
337 #define SUNNY_P2 0x0002
338 #define SUNNY_98 0x0003
339 #define REVISION 0 /* Revision */
340 #define BASE_CLASS 0xff /* Base Class = other */
341 #define SUB_CLASS 0x00 /* Sub Class = ? */
342 
343 #define LOCAL_TO_PCI_OFFSET 0x40000000
344 
345 /* configuration offsets */
346 #define VENDOR_ID_OFFSET 0x00
347 #define DEVICE_ID_OFFSET 0x02
348 #define COMMAND_OFFSET 0x04
349 #define STATUS_OFFSET 0x06
350 #define REVISION_OFFSET 0x08
351 #define PROG_IF_OFFSET 0x09
352 #define SUB_CLASS_OFFSET 0x0a
353 #define BASE_CLASS_OFFSET 0x0b
354 #define CACHE_LINE_OFFSET 0x0c
355 #define LATENCY_TIMER_OFFSET 0x0d
356 #define HEADER_TYPE_OFFSET 0x0e
357 #define BIST_OFFSET 0x0f
358 #define REGION0_BASE_OFFSET 0x10
359 #define REGION1_BASE_OFFSET 0x14
360 #define REGION2_BASE_OFFSET 0x18
361 #define REGION3_BASE_OFFSET 0x1c
362 #define REGION4_BASE_OFFSET 0x20
363 #define REGION5_BASE_OFFSET 0x24
364 #define EXP_ROM_OFFSET 0x30
365 #define INT_LINE_OFFSET 0x3c
366 #define INT_PIN_OFFSET 0x3d
367 #define MIN_GNT_OFFSET 0x3e
368 #define MAX_LAT_OFFSET 0x3f
369 
370 #endif