summaryrefslogtreecommitdiffstats
path: root/board/mpl/pati/pati.h
blob: 86c7a41cc8b4e577235fd051cd058482e49f33ae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
/*
 * (C) Copyright 2003
 * Denis Peter, d.peter@mpl.ch
 * See file CREDITS for list of people who contributed to this
 * project.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of
 * the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 * MA 02111-1307 USA
 */
/************************************************************************
 * MACROS and register definitions for PATI Registers
 ************************************************************************/
#ifndef __PATI_H_
#define __PATI_H_	1

#define PLD_PART_ID		0x0
#define PLD_BOARD_TIMING	0x4
#define PLD_CONF_REG1		0x8
#define PLD_CONF_REG2		0xC
#define PLD_CONF_RES		0x10

#define SET_REG_BIT(y,x) (y<<(31-x))
#define GET_REG_BIT(y,x) ((y>>(31-x)) & 0x1L)

/* SDRAM Controller PLD_PART_ID */
/* 9  10 11 12 13 14 19 31 */
#define SDRAM_PART3	9
#define SDRAM_PART2	10
#define SDRAM_PART1	11
#define SDRAM_PART0	12
#define SDRAM_ID3	13
#define SDRAM_ID2	14
#define SDRAM_ID1	19
#define SDRAM_ID0	31

#define SDRAM_PART(x)	(	\
	(GET_REG_BIT(x,SDRAM_PART3)<<3) |\
	(GET_REG_BIT(x,SDRAM_PART2)<<2) |\
	(GET_REG_BIT(x,SDRAM_PART1)<<1) |\
	(GET_REG_BIT(x,SDRAM_PART0)))

#define SDRAM_ID(x)	(	\
	(GET_REG_BIT(x,SDRAM_ID3)<<3) |\
	(GET_REG_BIT(x,SDRAM_ID2)<<2) |\
	(GET_REG_BIT(x,SDRAM_ID1)<<1) |\
	(GET_REG_BIT(x,SDRAM_ID0)))

/* System Controller */
/* 0  1 3 4 5 16 20 28 29 30 */
#define SYSCNTR_PART4	0
#define SYSCNTR_PART3	1
#define SYSCNTR_PART2	3
#define SYSCNTR_PART1	4
#define SYSCNTR_PART0	5
#define SYSCNTR_ID4	16
#define SYSCNTR_ID3	20
#define SYSCNTR_ID2	28
#define SYSCNTR_ID1	29
#define SYSCNTR_ID0	30

#define SYSCNTR_PART(x)	(	\
	(GET_REG_BIT(x,SYSCNTR_PART4)<<4) |\
	(GET_REG_BIT(x,SYSCNTR_PART3)<<3) |\
	(GET_REG_BIT(x,SYSCNTR_PART2)<<2) |\
	(GET_REG_BIT(x,SYSCNTR_PART1)<<1) |\
	(GET_REG_BIT(x,SYSCNTR_PART0)))

#define SYSCNTR_ID(x)	(	\
	(GET_REG_BIT(x,SYSCNTR_ID4)<<4) |\
	(GET_REG_BIT(x,SYSCNTR_ID3)<<3) |\
	(GET_REG_BIT(x,SYSCNTR_ID2)<<2) |\
	(GET_REG_BIT(x,SYSCNTR_ID1)<<1) |\
	(GET_REG_BIT(x,SYSCNTR_ID0)))

/* SDRAM Controller PLD_BOARD_TIMING */
/* 9  10 11 12 13 14 19 31 */
#define SDRAM_CAL	9
#define SDRAM_RCD	10
#define SDRAM_WREQ	11
#define SDRAM_PR	12
#define SDRAM_RC	13
#define SDRAM_LMR	14
#define SDRAM_IIP	19
#define SDRAM_RES0	31
/* System Controller */
/* 0  1 3 4 5 16 20 28 29 30 */
#define SYSCNTR_BREV0	0
#define SYSCNTR_BREV1	1
#define SYSCNTR_BREV2	3
#define SYSCNTR_BREV3	4
#define SYSCNTR_RES0	5
#define SYSCNTR_RES1	16
#define SYSCNTR_RES2	20
#define SYSCNTR_FLWAIT2	28
#define SYSCNTR_FLWAIT1	29
#define SYSCNTR_FLWAIT0	30

#define SYSCNTR_BREV(x)	(	\
	(GET_REG_BIT(x,SYSCNTR_BREV3)<<3) |\
	(GET_REG_BIT(x,SYSCNTR_BREV2)<<2) |\
	(GET_REG_BIT(x,SYSCNTR_BREV1)<<1) |\
	(GET_REG_BIT(x,SYSCNTR_BREV0)))

#define GET_SYSCNTR_FLWAIT(x)	(	\
	(GET_REG_BIT(x,SYSCNTR_FLWAIT2)<<2) |\
	(GET_REG_BIT(x,SYSCNTR_FLWAIT1)<<1) |\
	(GET_REG_BIT(x,SYSCNTR_FLWAIT0)))

#define SET_SYSCNTR_FLWAIT(x)	(	\
	(SET_REG_BIT(((x & 0x04)!=0),SYSCNTR_FLWAIT2)) |\
	(SET_REG_BIT(((x & 0x02)!=0)x,SYSCNTR_FLWAIT1)) |\
	(SET_REG_BIT(((x & 0x01)!=0)x,SYSCNTR_FLWAIT0)))

/* SDRAM Controller REG 2*/
/* 9  10 11 12 13 14 19 31 */
#define SDRAM_MUX0	9
#define SDRAM_MUX1	10
#define SDRAM_PDIS	11
#define SDRAM_RES1	12
#define SDRAM_RES2	13
#define SDRAM_RES3	14
#define SDRAM_RES4	19
#define SDRAM_RIP	31

#define GET_SDRAM_MUX(x)	(	\
	(GET_REG_BIT(x,SDRAM_MUX1)<<1)| \
	(GET_REG_BIT(x,SDRAM_MUX0)))


/* System Controller */
/* 0  1 3 4 5 16 20 28 29 30 */
#define SYSCNTR_FLAG	0
#define SYSCNTR_IP	1
#define SYSCNTR_BIND2	3
#define SYSCNTR_BIND1	4
#define SYSCNTR_BIND0	5
#define SYSCNTR_PRM	16
#define SYSCNTR_ICW	20
#define SYSCNTR_ISB2	28
#define SYSCNTR_ISB1	29
#define SYSCNTR_ISB0	30

#define GET_SYSCNTR_BOOTIND(x)	(	\
	(GET_REG_BIT(x,SYSCNTR_BIND2)<<2) |\
	(GET_REG_BIT(x,SYSCNTR_BIND1)<<1) |\
	(GET_REG_BIT(x,SYSCNTR_BIND0)))

#define SET_SYSCNTR_BOOTIND(x)	(	\
	(SET_REG_BIT(((x & 0x04)!=0),SYSCNTR_BIND2)) |\
	(SET_REG_BIT(((x & 0x02)!=0)x,SYSCNTR_BIND1))| \
	(SET_REG_BIT(((x & 0x01)!=0)x,SYSCNTR_BIND0)))

#define GET_SYSCNTR_ISB(x)	(	\
	(GET_REG_BIT(x,SYSCNTR_ISB2)<<2)| \
	(GET_REG_BIT(x,SYSCNTR_ISB1)<<1)| \
	(GET_REG_BIT(x,SYSCNTR_ISB0)))

#define SET_SYSCNTR_ISB(x)	(	\
	(SET_REG_BIT(((x & 0x04)!=0),SYSCNTR_ISB2))| \
	(SET_REG_BIT(((x & 0x02)!=0)x,SYSCNTR_ISB))| \
	(SET_REG_BIT(((x & 0x01)!=0)x,SYSCNTR_ISB0)))

/* SDRAM Controller REG 3*/
/* 9  10 11 12 13 14 19 31 */
#define SDRAM_RES5	9
#define SDRAM_CFG1	10
#define SDRAM_CFG2	11
#define SDRAM_CFG3	12
#define SDRAM_RES6	13
#define SDRAM_CFG5	14
#define SDRAM_CFG6	19
#define SDRAM_RES7	31

#define GET_SDRAM_CFG(x)	(	\
	(GET_REG_BIT(x,SDRAM_CFG6)<<4) |\
	(GET_REG_BIT(x,SDRAM_CFG5)<<3) |\
	(GET_REG_BIT(x,SDRAM_CFG3)<<2) |\
	(GET_REG_BIT(x,SDRAM_CFG2)<<1) |\
	(GET_REG_BIT(x,SDRAM_CFG1)))

/* System Controller */
/* 0  1 3 4 5 16 20 28 29 30 */
#define SYSCNTR_BDIS	0
#define SYSCNTR_PCIM	1
#define SYSCNTR_CFG0	3
#define SYSCNTR_CFG1	4
#define SYSCNTR_CFG2	5
#define SYSCNTR_CFG3	16
#define SYSCNTR_BOOTEN	20
#define SYSCNTR_CPU_VPP	28
#define SYSCNTR_FL_VPP	29
#define SYSCNTR_FL_WP	30

#define GET_SYSCNTR_CFG(x)	(	\
	(GET_REG_BIT(x,SYSCNTR_CFG3)<<3)| \
	(GET_REG_BIT(x,SYSCNTR_CFG2)<<2)| \
	(GET_REG_BIT(x,SYSCNTR_CFG1)<<1)| \
	(GET_REG_BIT(x,SYSCNTR_CFG0)))


/***************************************************************
 * MISC Defines
 ***************************************************************/

#define PCI_VENDOR_ID_MPL	0x18E6
#define PCI_DEVICE_ID_PATI	0x00DA

#if defined(CONFIG_MIP405)
#define PATI_FIRMWARE_START_OFFSET	0x00300000
#define PATI_ISO_STRING  "MEV-10084-001"
#endif

#define PATI_ENDIAN_MODE	0x3E

/*******************************************
 * PATI Mapping:
 * -------------
 * PCI Map:
 * -------
 * All addreses are mapped into the memory area
 * (IO Area on some areas may also be possible)
 * - pci_cfg_mem_base: fixed address to the PLX config area size 512Bytes
 * - pci_space0_addr:  configurable
 * - pci_space1_addr	  configurable
 *
 * Local Map:
 * ----------
 * Local addresses (Remap)
 * - SDRAM      0x06000000 Size 16MByte mask 0xff000000
 * - EPLD CFG   0x07000000 Size 512Bytes
 * - FLASH      0x03000000 Size up to 8MByte
 * - CPU        0x01000000 Size 4MByte (only accessable if special configured)
 *
 * Implemention:
 * -------------
 * To prevent using large resources reservation on the host following
 * PCI mapping is choosed:
 * - pci_cfg_mem_base: fixed address to the PLX config area size 512Bytes
 * - pci_space0_addr:  configured to the EPLD Config Area size 256Bytes
 * - pci_space1_addr:  configured to the SDRAM Area size 1MBytes, this
 *                     space is used to switch between SDRAM, Flash and CPU
 *
 */

/* Attribute definitions */
#define PATI_BUS_SIZE_8		0
#define PATI_BUS_SIZE_16	1
#define PATI_BUS_SIZE_32	3

#define PATI_SPACE0_MASK	(0xFEFFFE00)  /* Mask Attributes */
#define PATI_SPACE1_MASK	(0x00000000)  /* Mask Attributes */

#define PATI_EXTRA_LONG_EEPROM	1

#define SPACE0_TA_ENABLE (1<<6)
#define SPACE1_TA_ENABLE (1<<6)

/* Config Area */
#define PATI_LOC_CFG_ADDR		0x07000000		/* Local Address */
#define PATI_LOC_CFG_MASK		0xFFFFFF00		/* 256 Bytes */
/* Attributes */
#define PATI_LOC_CFG_BUS_SIZE		PATI_BUS_SIZE_32	/* 32 Bit */
#define PATI_LOC_CFG_BURST		0			/* No Burst */
#define PATI_LOC_CFG_NO_PREFETCH	1			/* No Prefetch */
#define PATI_LOC_CFG_TA_ENABLE		1			/* Enable TA */

#define PATI_LOC_CFG_SPACE0_ATTR  ( \
		PATI_LOC_CFG_BUS_SIZE | \
		(PATI_LOC_CFG_TA_ENABLE << 6) | \
		(PATI_LOC_CFG_NO_PREFETCH << 8) | \
		(PATI_LOC_CFG_BURST << 24) | \
		(PATI_EXTRA_LONG_EEPROM << 25))

/* should never be used */
#define PATI_LOC_CFG_SPACE1_ATTR  ( \
		PATI_LOC_CFG_BUS_SIZE | \
		(PATI_LOC_CFG_TA_ENABLE << 6) | \
		(PATI_LOC_CFG_NO_PREFETCH << 9) | \
		(PATI_LOC_CFG_BURST << 8))


/* SDRAM Area */
#define PATI_LOC_SDRAM_ADDR		0x06000000		/* Local Address */
#define PATI_LOC_SDRAM_MASK		0xFFF00000		/* 1MByte */
/* Attributes */
#define PATI_LOC_SDRAM_BUS_SIZE		PATI_BUS_SIZE_32	/* 32 Bit */
#define PATI_LOC_SDRAM_BURST		0			/* No Burst */
#define PATI_LOC_SDRAM_NO_PREFETCH	0			/* Prefetch */
#define PATI_LOC_SDRAM_TA_ENABLE	1			/* Enable TA */

/* should never be used */
#define PATI_LOC_SDRAM_SPACE0_ATTR  ( \
		PATI_LOC_SDRAM_BUS_SIZE | \
		(PATI_LOC_SDRAM_TA_ENABLE << 6) | \
		(PATI_LOC_SDRAM_NO_PREFETCH << 8) | \
		(PATI_LOC_SDRAM_BURST << 24) | \
		(PATI_EXTRA_LONG_EEPROM << 25))

#define PATI_LOC_SDRAM_SPACE1_ATTR  ( \
		PATI_LOC_SDRAM_BUS_SIZE | \
		(PATI_LOC_SDRAM_TA_ENABLE << 6) | \
		(PATI_LOC_SDRAM_NO_PREFETCH << 9) | \
		(PATI_LOC_SDRAM_BURST << 8))


/* Flash Area */
#define PATI_LOC_FLASH_ADDR		0x03000000		/* Local Address */
#define PATI_LOC_FLASH_MASK		0xFFF00000		/* 1MByte */
/* Attributes */
#define PATI_LOC_FLASH_BUS_SIZE		PATI_BUS_SIZE_16	/* 16 Bit */
#define PATI_LOC_FLASH_BURST		0			/* No Burst */
#define PATI_LOC_FLASH_NO_PREFETCH	1			/* No Prefetch */
#define PATI_LOC_FLASH_TA_ENABLE	1			/* Enable TA */

/* should never be used */
#define PATI_LOC_FLASH_SPACE0_ATTR  ( \
		PATI_LOC_FLASH_BUS_SIZE | \
		(PATI_LOC_FLASH_TA_ENABLE << 6) | \
		(PATI_LOC_FLASH_NO_PREFETCH << 8) | \
		(PATI_LOC_FLASH_BURST << 24) | \
		(PATI_EXTRA_LONG_EEPROM << 25))

#define PATI_LOC_FLASH_SPACE1_ATTR  ( \
		PATI_LOC_FLASH_BUS_SIZE | \
		(PATI_LOC_FLASH_TA_ENABLE << 6) | \
		(PATI_LOC_FLASH_NO_PREFETCH << 9) | \
		(PATI_LOC_FLASH_BURST << 8))


/* CPU Area */
#define PATI_LOC_CPU_ADDR		0x01000000		/* Local Address */
#define PATI_LOC_CPU_MASK		0xFFF00000		/* 1Mbyte */
/* Attributes */
#define PATI_LOC_CPU_BUS_SIZE		PATI_BUS_SIZE_32	/* 32 Bit */
#define PATI_LOC_CPU_BURST		0			/* No Burst */
#define PATI_LOC_CPU_NO_PREFETCH	1			/* No Prefetch */
#define PATI_LOC_CPU_TA_ENABLE		1			/* Enable TA */

/* should never be used */
#define PATI_LOC_CPU_SPACE0_ATTR  ( \
		PATI_LOC_CPU_BUS_SIZE | \
		(PATI_LOC_CPU_TA_ENABLE << 6) | \
		(PATI_LOC_CPU_NO_PREFETCH << 8) | \
		(PATI_LOC_CPU_BURST << 24) | \
		(PATI_EXTRA_CPU_EEPROM << 25))

#define PATI_LOC_CPU_SPACE1_ATTR  ( \
		PATI_LOC_CPU_BUS_SIZE | \
		(PATI_LOC_CPU_TA_ENABLE << 6) | \
		(PATI_LOC_CPU_NO_PREFETCH << 9) | \
		(PATI_LOC_CPU_BURST << 8))

/***************************************************
 * Hardware Config word definition
 ***************************************************/
#define BOOT_EXT_FLASH		0x00000000
#define BOOT_INT_FLASH		0x00000004
#define BOOT_FROM_PCI		0x00000006
#define BOOT_FROM_SDRAM		0x00000005

#define ENABLE_INT_ARB		0x00000008

#define INITIAL_IRQ_PREF	0x00000010

#define INITIAL_MEM_0M		0x00000000
#define INITIAL_MEM_4M		0x00000080
#define INITIAL_MEM_8M		0x00000040
#define INITIAL_MEM_12M		0x000000C0
#define INITIAL_MEM_16M		0x00000020
#define INITIAL_MEM_20M		0x000000A0
#define INITIAL_MEM_24M		0x00000060
#define INITIAL_MEM_28M		0x000000E0
/* CONF */
#define INTERNAL_HWCONF		0x00000100
/* PRPM */
#define LOCAL_CPU_SLAVE		0x00000200
/* BDIS */
#define DISABLE_MEM_CNTR	0x00000400
/* PCIM */
#define PCI_MASTER_ONLY		0x00000800


#define PATI_HW_START		((BOOT_EXT_FLASH | INITIAL_MEM_28M | INITIAL_IRQ_PREF))
#define PATI_HW_PCI_ONLY	((BOOT_EXT_FLASH | INITIAL_MEM_28M | INITIAL_IRQ_PREF | PCI_MASTER_ONLY))
#define PATI_HW_CPU_ACC		((BOOT_EXT_FLASH | INITIAL_MEM_12M | INITIAL_IRQ_PREF | PCI_MASTER_ONLY))
#define PATI_HW_CPU_SLAVE	((BOOT_EXT_FLASH | INITIAL_MEM_12M | INITIAL_IRQ_PREF | PCI_MASTER_ONLY | LOCAL_CPU_SLAVE))

/***************************************************
 * Direct Master Config
 ***************************************************/
#define PATI_DMASTER_PCI_ADDR		0x01000000
#define PATI_BUS_MASTER 1


#define PATI_DMASTER_MASK		0xFFF00000  /* 1MByte */
#define PATI_DMASTER_ADDR		0x01000000  /* Local Address */

#define PATI_DMASTER_MEMORY_EN		0x00000001 /* 0x00000001 */
#define PATI_DMASTER_READ_AHEAD		0x00000004 /* 0x00000004 */
#define PATI_DMASTER_READ_NOT_AHEAD	0x00000000 /* 0x00000004 */
#define PATI_DMASTER_PRE_SIZE_CNTRL_0	0x00000000
#define PATI_DMASTER_PRE_SIZE_CNTRL_4	0x00000008
#define PATI_DMASTER_PRE_SIZE_CNTRL_8	0x00001000
#define PATI_DMASTER_PRE_SIZE_CNTRL_16	0x00001008
#define PATI_DMASTER_REL_PCI		0x00000000
#define PATI_DMASTER_NOT_REL_PCI	0x00000010
#define PATI_DMASTER_WR_INVAL		0x00000200
#define PATI_DMASTER_NOT_WR_INVAL	0x00000000
#define PATI_DMASTER_PRE_LIMIT		0x00000800
#define PATI_DMASTER_PRE_CONT		0x00000000
#define PATI_DMASTER_DELAY_WR_0		0x00000000
#define PATI_DMASTER_DELAY_WR_4		0x00004000
#define PATI_DMASTER_DELAY_WR_8		0x00008000
#define PATI_DMASTER_DELAY_WR_16	0x0000C000

#define PATI_DMASTER_PCI_ADDR_MASK	0xFFFF0000

#define PATI_DMASTER_ATTR	\
	PATI_DMASTER_MEMORY_EN | \
	PATI_DMASTER_READ_AHEAD | \
	PATI_DMASTER_PRE_SIZE_CNTRL_4 | \
	PATI_DMASTER_REL_PCI | \
	PATI_DMASTER_NOT_WR_INVAL | \
	PATI_DMASTER_PRE_LIMIT | \
	PATI_DMASTER_DELAY_WR_0


#endif /* #ifndef __PATI_H_ */
OpenPOWER on IntegriCloud