OpenCores
URL https://opencores.org/ocsvn/or1k_soc_on_altera_embedded_dev_kit/or1k_soc_on_altera_embedded_dev_kit/trunk

Subversion Repositories or1k_soc_on_altera_embedded_dev_kit

[/] [or1k_soc_on_altera_embedded_dev_kit/] [trunk/] [linux-2.6/] [linux-2.6.24/] [include/] [asm-or32/] [mc2.h] - Blame information for rev 7

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 7 xianfeng
#ifndef _OR32_MC2_H
2
#define _OR32_MC2_H 
3
 
4
#if CONFIG_OR32_MC_VERSION==2
5
#ifdef CONFIG_OR32_HIGHLAND_DEFAULT_MEMORY_TIMINGS
6
//#  define CONFIG_OR32_FLASH_INTEL_J3
7
#  define CONFIG_OR32_FLASH_BENDER_2
8
#  define CONFIG_OR32_SDRAM_MICRON_MT48LC16M16A2_TC_75D
9
#elif CONFIG_OR32_GENERIC_MEMORY_TIMINGS
10
/* FLASH timings: worst cases in ns, from data sheets */
11
#  define FLASH_WA_TIME           CONFIG_OR32_FLASH_WA_TIME
12
#  define FLASH_WE_DELAY          CONFIG_OR32_FLASH_WE_DELAY
13
#  define FLASH_WH_TIME           CONFIG_OR32_FLASH_WH_TIME
14
#  define FLASH_RA_TIME           CONFIG_OR32_FLASH_RA_TIME
15
#  define FLASH_PRA_TIME          CONFIG_OR32_FLASH_PRA_TIME
16
#  define FLASH_RT_TIME           CONFIG_OR32_FLASH_RT_TIME
17
 
18
/* SDRAM timings: worst cases in ns, from data sheets */
19
#  define SDRAM_tRCD              CONFIG_OR32_SDRAM_tRCD
20
#  define SDRAM_tWR               CONFIG_OR32_SDRAM_tWR
21
#  define SDRAM_tRC               CONFIG_OR32_SDRAM_tRC
22
#  define SDRAM_tRFC              CONFIG_OR32_SDRAM_tRFC
23
#  define SDRAM_tRAS              CONFIG_OR32_SDRAM_tRAS
24
#  define SDRAM_tRP               CONFIG_OR32_SDRAM_tRP
25
#  define SDRAM_tRRD              CONFIG_OR32_SDRAM_tRRD
26
#  define SDRAM_tREF              CONFIG_OR32_SDRAM_tREF
27
#else
28
#  error "no timings defined"
29
#endif
30
#endif
31
 
32
/* ----------------------------------------------------[ memory timings ]--- */
33
 
34
/* FLASH timings: worst cases in ns, from data sheets */
35
#ifdef CONFIG_OR32_FLASH_INTEL_J3
36
#  define FLASH_WA_TIME           150+10 /* write access*/
37
#  define FLASH_WE_DELAY          0   /* write enable*/
38
#  define FLASH_WH_TIME           0   /* write hold */
39
#  define FLASH_RA_TIME           120+10 /* read access*/
40
#  define FLASH_PRA_TIME          25  /* page read access time */
41
#  define FLASH_RT_TIME           15  /* read turnaround time */
42
#endif /* CONFIG_OR32_FLASH_INTEL_J3 */
43
 
44
#ifdef CONFIG_OR32_FLASH_BENDER_2
45
#  define FLASH_WA_TIME           50  /* write access*/
46
#  define FLASH_WE_DELAY          0   /* write enable*/
47
#  define FLASH_WH_TIME           0   /* write hold */
48
#  define FLASH_RA_TIME           95  /* read access*/
49
#  define FLASH_PRA_TIME          25  /* page read access time */
50
#  define FLASH_RT_TIME           24  /* read turnaround time */
51
#endif /* CONFIG_OR32_FLASH_BENDER_2 */
52
 
53
/* SDRAM timings: worst cases in ns, from data sheets */
54
#ifdef CONFIG_OR32_SDRAM_MICRON_MT48LC16M16A2_TC_75D
55
#  define SDRAM_tRCD              20
56
#  define SDRAM_tWR               15 /* ?? */
57
#  define SDRAM_tRC               66
58
#  define SDRAM_tRFC              66 /* sometimes the same as tRC */
59
#  define SDRAM_tRAS              44 /* use the worst case minimal value */
60
#  define SDRAM_tRP               20
61
#  define SDRAM_tRRD              15
62
#  define SDRAM_tREF              ((64000000/8192)+1)
63
#endif /* CONFIG_OR32_SDRAM_MICRON_MT48LC16M16A2_TC_75D */
64
 
65
#ifdef CONFIG_OR32_SDRAM_BENDER_2
66
#  define SDRAM_tRCD              23
67
#  define SDRAM_tWR               20
68
#  define SDRAM_tRC               60
69
#  define SDRAM_tRFC              60 /* sometimes the same as tRC */
70
#  define SDRAM_tRAS              50 /* use the worst case minimal value */
71
#  define SDRAM_tRP               23
72
#  define SDRAM_tRRD              15
73
#  define SDRAM_tREF              ((64000000/8192)+1)
74
#endif /* CONFIG_OR32_SDRAM_BENDER_2 */
75
 
76
/* -------------------------------------------------------[ calculation ]--- */
77
 
78
#if CONFIG_OR32_MC_VERSION==1
79
/* Memory controller initialize values */
80
#  if CONFIG_OR32_SYS_CLK==25
81
#    define MC_CSR_VAL      0x0B000300
82
#    define MC_MASK_VAL     0x000003f0
83
#    define FLASH_TMS_VAL   0x00000103
84
#    define SDRAM_BASE_ADD  0x00000000
85
#    define SDRAM_TMS_VAL   0x19220057
86
#  elif CONFIG_OR32_SYS_CLK==48
87
#    warning Timings for 48Mhz are taken the same as for 25MHz
88
#    define MC_CSR_VAL      0x0B000300
89
#    define MC_MASK_VAL     0x000003f0
90
#    define FLASH_TMS_VAL   0x00000103
91
#    define SDRAM_BASE_ADD  0x00000000
92
#    define SDRAM_TMS_VAL   0x19220057
93
 
94
#  elif CONFIG_OR32_SYS_CLK==100
95
#    define MC_CSR_VAL      0x0B000300
96
#    define MC_MASK_VAL     0x000003f0
97
#    define FLASH_TMS_VAL   0x0000010c
98
#    define SDRAM_BASE_ADD  0x00000000
99
#    define SDRAM_TMS_VAL   0x2a5a0300
100
#  elif CONFIG_OR32_SYS_CLK==120
101
     /* Sandi guarantees timings are ok */
102
#    define MC_CSR_VAL      0x0B000300
103
#    define MC_MASK_VAL     0x000003f0
104
#    define FLASH_TMS_VAL   0x0000010c
105
#    define SDRAM_BASE_ADD  0x00000000
106
#    define SDRAM_TMS_VAL   0x2a5a0300
107
#  else
108
#    error  No MC ver. 1 initialization values for this frequency
109
#  endif
110
#elif CONFIG_OR32_MC_VERSION==2
111
 
112
#  define FLASH_BAR_VAL   FLASH_BASE_ADD
113
#  define FLASH_AMR_VAL   0xf0000000     /* address mask register */
114
#  define SDRAM_BASE_ADDR 0x00000000
115
#  define SDRAM_SIZE      0x02000000
116
#  define SDRAM_BAR_VAL   SDRAM_BASE_ADDR
117
#  define SDRAM_AMR_VAL   (~(SDRAM_SIZE-1))
118
 
119
/* independant from flash properties, always 0 ;)   */
120
#  define FLASH_OE_DELAY  0              /* output enable */
121
 
122
// define FLASH_WTR_VAL   0x00011009 /* write timings */
123
#  define FLASH_WTR_VAL   ((0x000003ff & (FLASH_WA_TIME /SYS_CLK_PERIOD)) | \
124
                           (0x0000f000 & (FLASH_WE_DELAY/SYS_CLK_PERIOD)<<12) | \
125
                           (0x001f0000 & (FLASH_WH_TIME /SYS_CLK_PERIOD)<<16))
126
 
127
// define FLASH_RTR_VAL   0x01002009 /* read timings */
128
#  define FLASH_RTR_VAL   ((0x000003ff & (FLASH_RA_TIME /SYS_CLK_PERIOD)) | \
129
                           (0x0000f000 & (FLASH_OE_DELAY/SYS_CLK_PERIOD)<<12) | \
130
                           (0x001f0000 & (FLASH_PRA_TIME/SYS_CLK_PERIOD)<<16) | \
131
                           (0x1f000000 & (FLASH_RT_TIME /SYS_CLK_PERIOD)<<24))
132
 
133
/* round this value down:
134
 * if it's 30 / 10 -> we want 2, so it's ok, 31 / 10 -> we want 3
135
 *
136
 * define SDRAM_RCDR_VAL  0x00000002
137
 */
138
#  define SDRAM_RCDR_VAL  ((SDRAM_tRCD-1)/SYS_CLK_PERIOD)
139
 
140
// prviously undefined
141
#  define SDRAM_WRTR_VAL  (((SDRAM_tWR+(SYS_CLK_PERIOD-1))/SYS_CLK_PERIOD)-1)
142
#  if SDRAM_WRTR_VAL<0
143
#    undef  SDRAM_WRTR_VAL
144
#    define SDRAM_WRTR_VAL 0
145
#  endif
146
 
147
// define SDRAM_RCTR_VAL  0x00000006
148
#  define SDRAM_RCTR_VAL  (((SDRAM_tRC+(SYS_CLK_PERIOD-1))/SYS_CLK_PERIOD)-1)
149
#  if SDRAM_RCTR_VAL<0
150
#    undef  SDRAM_RCTR_VAL
151
#    define SDRAM_RCTR_VAL 0
152
#  endif
153
 
154
// define SDRAM_REFCTR_VAL 0x00000006
155
#  define SDRAM_REFCTR_VAL (((SDRAM_tRFC+(SYS_CLK_PERIOD-1))/SYS_CLK_PERIOD)-1)
156
#  if SDRAM_REFCTR_VAL<0
157
#    undef  SDRAM_REFCTR_VAL
158
#    define SDRAM_REFCTR_VAL 0
159
#  endif
160
 
161
// define SDRAM_RATR_VAL  0x00000006
162
#  define SDRAM_RATR_VAL  (((SDRAM_tRAS+(SYS_CLK_PERIOD-1))/SYS_CLK_PERIOD)-1)
163
#  if SDRAM_RATR_VAL<0
164
#    undef  SDRAM_RATR_VAL
165
#    define SDRAM_RATR_VAL 0
166
#  endif
167
 
168
// define SDRAM_PTR_VAL   0x00000001
169
#  define SDRAM_PTR_VAL   (((SDRAM_tRP+(SYS_CLK_PERIOD-1))/SYS_CLK_PERIOD)-1)
170
#  if SDRAM_PTR_VAL<0
171
#    undef  SDRAM_PTR_VAL
172
#    define SDRAM_PTR_VAL 0
173
#  endif
174
 
175
// define SDRAM_RRDR_VAL  0x00000000
176
#  define SDRAM_RRDR_VAL  (((SDRAM_tRRD+(SYS_CLK_PERIOD-1))/SYS_CLK_PERIOD)-1)
177
#  if SDRAM_RRDR_VAL<0
178
#    undef  SDRAM_RRDR_VAL
179
#    define SDRAM_RRDR_VAL 0
180
#  endif
181
 
182
/*
183
 * we don't want to go to the edge with refresh delays
184
 * define SDRAM_RIR_VAL   0x00000300
185
 */
186
#  define SDRAM_RIR_VAL   ((SDRAM_tREF/SYS_CLK_PERIOD)-((SDRAM_tREF/SYS_CLK_PERIOD)+10)/10)
187
 
188
/* ------------------------------------------------------[ MC registers ]--- */
189
 
190
 
191
#  define MC_BAR_0        (0x00)
192
#  define MC_AMR_0        (0x04)
193
#  define MC_BAR_1        (0x08)
194
#  define MC_AMR_1        (0x0c)
195
#  define MC_BAR_2        (0x10)
196
#  define MC_AMR_2        (0x14)
197
#  define MC_BAR_3        (0x18)
198
#  define MC_AMR_3        (0x1c)
199
#  define MC_CCR_0        (0x20)
200
#  define MC_CCR_1        (0x24)
201
#  define MC_CCR_2        (0x28)
202
#  define MC_CCR_3        (0x2c)
203
#  define MC_WTR_0        (0x30)
204
#  define MC_RTR_0        (0x34)
205
#  define MC_WTR_1        (0x38)
206
#  define MC_RTR_1        (0x3c)
207
#  define MC_WTR_2        (0x40)
208
#  define MC_RTR_2        (0x44)
209
#  define MC_WTR_3        (0x48)
210
#  define MC_RTR_3        (0x4c)
211
 
212
#  define MC_BAR_4        (0x80)
213
#  define MC_AMR_4        (0x84)
214
#  define MC_BAR_5        (0x88)
215
#  define MC_AMR_5        (0x8c)
216
#  define MC_BAR_6        (0x90)
217
#  define MC_AMR_6        (0x94)
218
#  define MC_BAR_7        (0x98)
219
#  define MC_AMR_7        (0x9c)
220
#  define MC_CCR_4        (0xa0)
221
#  define MC_CCR_5        (0xa4)
222
#  define MC_CCR_6        (0xa8)
223
#  define MC_CCR_7        (0xac)
224
 
225
#  define MC_RATR         (0xb0)  /* row active time register  */
226
#  define MC_RCTR         (0xb4)
227
#  define MC_RRDR         (0xb8)
228
#  define MC_PTR          (0xbc)
229
#  define MC_WRTR         (0xc0)
230
#  define MC_REFCTR       (0xc4)
231
#  define MC_RCDR         (0xc8)
232
#  define MC_RIR          (0xcc)
233
#  define MC_SMBOR        (0xe0)
234
#  define MC_ORR          (0xe4)
235
#  define MC_OSR          (0xe8)
236
#  define MC_PCR          (0xec)
237
#  define MC_IIR          (0xf0)
238
 
239
/* POC register field definition */
240
#  define MC_POC_EN_BW_OFFSET             0
241
#  define MC_POC_EN_BW_WIDTH              2
242
#  define MC_POC_EN_MEMTYPE_OFFSET        2
243
#  define MC_POC_EN_MEMTYPE_WIDTH         2
244
 
245
/* CSC register field definition */
246
#  define MC_CSC_EN_OFFSET                0
247
#  define MC_CSC_MEMTYPE_OFFSET           1
248
#  define MC_CSC_MEMTYPE_WIDTH            2
249
#  define MC_CSC_BW_OFFSET                4
250
#  define MC_CSC_BW_WIDTH                 2
251
#  define MC_CSC_MS_OFFSET                6
252
#  define MC_CSC_MS_WIDTH                 2
253
#  define MC_CSC_WP_OFFSET                8
254
#  define MC_CSC_BAS_OFFSET               9
255
#  define MC_CSC_KRO_OFFSET               10
256
#  define MC_CSC_PEN_OFFSET               11
257
#  define MC_CSC_SEL_OFFSET               16
258
#  define MC_CSC_SEL_WIDTH                8
259
 
260
#  define MC_CSC_MEMTYPE_SDRAM            0
261
#  define MC_CSC_MEMTYPE_SSRAM            1
262
#  define MC_CSC_MEMTYPE_ASYNC            2
263
#  define MC_CSC_MEMTYPE_SYNC             3
264
 
265
#  define MC_CSR_VALID                    0xFF000703LU
266
#  define MC_POC_VALID                    0x0000000FLU
267
#  define MC_BA_MASK_VALID                0x000003FFLU
268
#  define MC_CSC_VALID                    0x00FF0FFFLU
269
#  define MC_TMS_SDRAM_VALID              0x0FFF83FFLU
270
#  define MC_TMS_SSRAM_VALID              0x00000000LU
271
#  define MC_TMS_ASYNC_VALID              0x03FFFFFFLU
272
#  define MC_TMS_SYNC_VALID               0x01FFFFFFLU
273
#  define MC_TMS_VALID                    0xFFFFFFFFLU /* reg test compat. */
274
 
275
/* TMS register field definition SDRAM */
276
#  define MC_TMS_SDRAM_TRFC_OFFSET        24
277
#  define MC_TMS_SDRAM_TRFC_WIDTH         4
278
#  define MC_TMS_SDRAM_TRP_OFFSET         20
279
#  define MC_TMS_SDRAM_TRP_WIDTH          4
280
#  define MC_TMS_SDRAM_TRCD_OFFSET        17
281
#  define MC_TMS_SDRAM_TRCD_WIDTH         4
282
#  define MC_TMS_SDRAM_TWR_OFFSET         15
283
#  define MC_TMS_SDRAM_TWR_WIDTH          2
284
#  define MC_TMS_SDRAM_WBL_OFFSET         9
285
#  define MC_TMS_SDRAM_OM_OFFSET          7
286
#  define MC_TMS_SDRAM_OM_WIDTH           2
287
#  define MC_TMS_SDRAM_CL_OFFSET          4
288
#  define MC_TMS_SDRAM_CL_WIDTH           3
289
#  define MC_TMS_SDRAM_BT_OFFSET          3
290
#  define MC_TMS_SDRAM_BL_OFFSET          0
291
#  define MC_TMS_SDRAM_BL_WIDTH           3
292
 
293
/* TMS register field definition ASYNC */
294
#  define MC_TMS_ASYNC_TWWD_OFFSET        20
295
#  define MC_TMS_ASYNC_TWWD_WIDTH         6
296
#  define MC_TMS_ASYNC_TWD_OFFSET         16
297
#  define MC_TMS_ASYNC_TWD_WIDTH          4
298
#  define MC_TMS_ASYNC_TWPW_OFFSET        12
299
#  define MC_TMS_ASYNC_TWPW_WIDTH         4
300
#  define MC_TMS_ASYNC_TRDZ_OFFSET        8
301
#  define MC_TMS_ASYNC_TRDZ_WIDTH         4
302
#  define MC_TMS_ASYNC_TRDV_OFFSET        0
303
#  define MC_TMS_ASYNC_TRDV_WIDTH         8
304
 
305
/* TMS register field definition SYNC  */
306
#  define MC_TMS_SYNC_TTO_OFFSET          16
307
#  define MC_TMS_SYNC_TTO_WIDTH           9
308
#  define MC_TMS_SYNC_TWR_OFFSET          12
309
#  define MC_TMS_SYNC_TWR_WIDTH           4
310
#  define MC_TMS_SYNC_TRDZ_OFFSET         8
311
#  define MC_TMS_SYNC_TRDZ_WIDTH          4
312
#  define MC_TMS_SYNC_TRDV_OFFSET         0
313
#  define MC_TMS_SYNC_TRDV_WIDTH          8
314
 
315
#else
316
#  error "no memory controler specified"
317
#endif
318
 
319
#endif
320
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.