1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24#include <common.h>
25#include <mpc8xx.h>
26
27
28
29static long int dram_size (long int, long int *, long int);
30
31
32
33#define _NOT_USED_ 0xFFFFFFFF
34
35const uint sdram_table[] =
36{
37
38
39
40 0x1F07FC04, 0xEEAEFC04, 0x11ADFC04, 0xEFBBBC00,
41 0x1FF77C47,
42
43
44
45
46
47
48
49
50 0x1FF77C34, 0xEFEABC34, 0x1FB57C35,
51
52
53
54 0x1F07FC04, 0xEEAEFC04, 0x10ADFC04, 0xF0AFFC00,
55 0xF0AFFC00, 0xF1AFFC00, 0xEFBBBC00, 0x1FF77C47,
56 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
57 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
58
59
60
61 0x1F07FC04, 0xEEAEBC00, 0x01B93C04, 0x1FF77C47,
62 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
63
64
65
66 0x1F07FC04, 0xEEAEBC00, 0x10AD7C00, 0xF0AFFC00,
67 0xF0AFFC00, 0xE1BBBC04, 0x1FF77C47,
68 _NOT_USED_,
69 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
70 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
71
72
73
74 0x1FF5FC84, 0xFFFFFC04, 0xFFFFFC04, 0xFFFFFC04,
75 0xFFFFFC84, 0xFFFFFC07,
76 _NOT_USED_, _NOT_USED_,
77 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
78
79
80
81 0x7FFFFC07,
82 _NOT_USED_, _NOT_USED_, _NOT_USED_,
83};
84
85
86
87
88
89
90
91
92int checkboard (void)
93{
94 unsigned char *s = (unsigned char *)getenv ("serial#");
95
96 puts ("Board: TTTech C2MON ");
97
98 for (; s && *s; ++s) {
99 if (*s == ' ')
100 break;
101 putc (*s);
102 }
103
104 putc ('\n');
105
106 return (0);
107}
108
109
110
111phys_size_t initdram (int board_type)
112{
113 volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
114 volatile memctl8xx_t *memctl = &immap->im_memctl;
115 unsigned long reg;
116 long int size8, size9;
117 long int size = 0;
118
119 upmconfig (UPMA, (uint *)sdram_table, sizeof(sdram_table) / sizeof(uint));
120
121
122
123
124
125
126
127 memctl->memc_mptpr = CONFIG_SYS_MPTPR_2BK_8K;
128
129 memctl->memc_mar = 0x00000088;
130
131
132
133
134 memctl->memc_or2 = CONFIG_SYS_OR2_PRELIM;
135 memctl->memc_br2 = CONFIG_SYS_BR2_PRELIM;
136
137 memctl->memc_mamr = CONFIG_SYS_MAMR_8COL & (~(MAMR_PTAE));
138
139 udelay (200);
140
141
142
143 memctl->memc_mcr = 0x80004105;
144 udelay (1);
145 memctl->memc_mcr = 0x80004230;
146 udelay (1);
147
148 memctl->memc_mamr |= MAMR_PTAE;
149
150 udelay (1000);
151
152
153
154
155
156
157 size8 = dram_size (CONFIG_SYS_MAMR_8COL,
158 SDRAM_BASE2_PRELIM,
159 SDRAM_MAX_SIZE);
160
161 udelay (1000);
162
163
164
165
166 size9 = dram_size (CONFIG_SYS_MAMR_9COL,
167 SDRAM_BASE2_PRELIM,
168 SDRAM_MAX_SIZE);
169
170 if (size8 < size9) {
171 size = size9;
172
173 } else {
174 size = size8;
175 memctl->memc_mamr = CONFIG_SYS_MAMR_8COL;
176 udelay (500);
177
178 }
179
180 udelay (1000);
181
182
183
184
185
186 if (size < 0x02000000) {
187
188 memctl->memc_mptpr = CONFIG_SYS_MPTPR_2BK_4K;
189 udelay (1000);
190 }
191
192
193
194
195 memctl->memc_or2 = ((-size) & 0xFFFF0000) | CONFIG_SYS_OR_TIMING_SDRAM;
196 memctl->memc_br2 = (CONFIG_SYS_SDRAM_BASE & BR_BA_MSK) | BR_MS_UPMA | BR_V;
197
198
199
200
201
202
203 memctl->memc_br3 = 0;
204
205
206 reg = memctl->memc_mptpr;
207 reg >>= 1;
208 memctl->memc_mptpr = reg;
209
210 udelay (10000);
211
212 return (size);
213}
214
215
216
217
218
219
220
221
222
223
224
225static long int dram_size (long int mamr_value, long int *base,
226 long int maxsize)
227{
228 volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
229 volatile memctl8xx_t *memctl = &immap->im_memctl;
230
231 memctl->memc_mamr = mamr_value;
232
233 return (get_ram_size(base, maxsize));
234}
235