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#include <commproc.h>
27#include <command.h>
28
29
30
31static long int dram_size (long int, long int *, long int);
32void can_driver_enable (void);
33void can_driver_disable (void);
34
35int fpga_init(void);
36
37
38
39#define _NOT_USED_ 0xFFFFFFFF
40
41const uint sdram_table[] =
42{
43
44
45
46 0x1F0DFC04, 0xEEAFBC04, 0x11AF7C04, 0xEFBAFC00,
47 0x1FF5FC47,
48
49
50
51
52
53
54
55
56 0x1FF5FC34, 0xEFEABC34, 0x1FB57C35,
57
58
59
60 0x1F0DFC04, 0xEEAFBC04, 0x10AF7C04, 0xF0AFFC00,
61 0xF0AFFC00, 0xF1AFFC00, 0xEFBAFC00, 0x1FF5FC47,
62 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
63 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
64
65
66
67 0x1F0DFC04, 0xEEABBC00, 0x01B27C04, 0x1FF5FC47,
68 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
69
70
71
72 0x1F0DFC04, 0xEEABBC00, 0x10A77C00, 0xF0AFFC00,
73 0xF0AFFC00, 0xE1BAFC04, 0x1FF5FC47,
74 _NOT_USED_,
75 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
76 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
77
78
79
80 0x1FFD7C84, 0xFFFFFC04, 0xFFFFFC04, 0xFFFFFC04,
81 0xFFFFFC84, 0xFFFFFC07,
82 _NOT_USED_, _NOT_USED_,
83 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
84
85
86
87 0x7FFFFC07,
88 _NOT_USED_, _NOT_USED_, _NOT_USED_,
89};
90
91
92
93
94
95
96
97
98
99
100int checkboard (void)
101{
102 unsigned char *s;
103 unsigned char buf[64];
104
105 s = (getenv_f("serial#", (char *)&buf, sizeof(buf)) > 0) ? buf : NULL;
106
107 puts ("Board: Siemens CCM");
108
109 if (s) {
110 puts (" (");
111
112 for (; *s; ++s) {
113 if (*s == ' ')
114 break;
115 putc (*s);
116 }
117 putc (')');
118 }
119
120 putc ('\n');
121
122 return (0);
123}
124
125
126
127
128
129
130
131#define RSR_CSRS 0x08000000
132
133int power_on_reset(void)
134{
135
136 return ((volatile immap_t *)CONFIG_SYS_IMMR)->im_clkrst.car_rsr & RSR_CSRS ? 0:1;
137}
138
139#define PB_LED_GREEN 0x10000
140#define PB_LED_RED 0x20000
141#define PB_LEDS (PB_LED_GREEN | PB_LED_RED);
142
143static void init_leds (void)
144{
145 volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
146
147 immap->im_cpm.cp_pbpar &= ~PB_LEDS;
148 immap->im_cpm.cp_pbodr &= ~PB_LEDS;
149 immap->im_cpm.cp_pbdir |= PB_LEDS;
150
151 if (power_on_reset()) {
152 immap->im_cpm.cp_pbdat &= ~PB_LEDS;
153 }
154}
155
156
157
158phys_size_t initdram (int board_type)
159{
160 volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
161 volatile memctl8xx_t *memctl = &immap->im_memctl;
162 long int size8, size9;
163 long int size = 0;
164 unsigned long reg;
165
166 upmconfig(UPMA, (uint *)sdram_table, sizeof(sdram_table)/sizeof(uint));
167
168
169
170
171
172
173
174 memctl->memc_mptpr = CONFIG_SYS_MPTPR_2BK_8K;
175
176 memctl->memc_mar = 0x00000088;
177
178
179
180
181
182
183 memctl->memc_or2 = CONFIG_SYS_OR2_PRELIM;
184 memctl->memc_br2 = CONFIG_SYS_BR2_PRELIM;
185
186 memctl->memc_mamr = CONFIG_SYS_MAMR_8COL & (~(MAMR_PTAE));
187
188 udelay(200);
189
190
191
192 memctl->memc_mcr = 0x80004105;
193 udelay(1);
194 memctl->memc_mcr = 0x80004230;
195 udelay(1);
196
197 memctl->memc_mamr |= MAMR_PTAE;
198
199 udelay (1000);
200
201
202
203
204
205
206 size8 = dram_size (CONFIG_SYS_MAMR_8COL, SDRAM_BASE2_PRELIM, SDRAM_MAX_SIZE);
207
208 udelay (1000);
209
210
211
212
213 size9 = dram_size (CONFIG_SYS_MAMR_9COL, SDRAM_BASE2_PRELIM, SDRAM_MAX_SIZE);
214
215 if (size8 < size9) {
216 size = size9;
217
218 } else {
219 size = size8;
220 memctl->memc_mamr = CONFIG_SYS_MAMR_8COL;
221 udelay(500);
222
223 }
224
225 udelay (1000);
226
227
228
229
230
231 if (size < 0x02000000) {
232
233 memctl->memc_mptpr = CONFIG_SYS_MPTPR_2BK_4K;
234 udelay(1000);
235 }
236
237
238
239
240
241 memctl->memc_or2 = ((-size) & 0xFFFF0000) | CONFIG_SYS_OR_TIMING_SDRAM;
242 memctl->memc_br2 = (CONFIG_SYS_SDRAM_BASE & BR_BA_MSK) | BR_MS_UPMA | BR_V;
243
244
245
246 reg = memctl->memc_mptpr;
247 reg >>= 1;
248 memctl->memc_mptpr = reg;
249
250 can_driver_enable ();
251 init_leds ();
252
253 udelay(10000);
254
255 return (size);
256}
257
258
259
260
261
262
263
264void can_driver_enable (void)
265{
266 volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
267 volatile memctl8xx_t *memctl = &immap->im_memctl;
268
269
270 memctl->memc_mbmr = MBMR_GPL_B4DIS;
271
272
273 memctl->memc_mdr = 0xFFFFC004;
274 memctl->memc_mcr = 0x0100 | UPMB;
275
276 memctl->memc_mdr = 0x0FFFD004;
277 memctl->memc_mcr = 0x0101 | UPMB;
278
279 memctl->memc_mdr = 0x0FFFC000;
280 memctl->memc_mcr = 0x0102 | UPMB;
281
282 memctl->memc_mdr = 0x3FFFC004;
283 memctl->memc_mcr = 0x0103 | UPMB;
284
285 memctl->memc_mdr = 0xFFFFDC05;
286 memctl->memc_mcr = 0x0104 | UPMB;
287
288
289 memctl->memc_mdr = 0xFFFCC004;
290 memctl->memc_mcr = 0x0118 | UPMB;
291
292 memctl->memc_mdr = 0xCFFCD004;
293 memctl->memc_mcr = 0x0119 | UPMB;
294
295 memctl->memc_mdr = 0x0FFCC000;
296 memctl->memc_mcr = 0x011A | UPMB;
297
298 memctl->memc_mdr = 0x7FFCC004;
299 memctl->memc_mcr = 0x011B | UPMB;
300
301 memctl->memc_mdr = 0xFFFDCC05;
302 memctl->memc_mcr = 0x011C | UPMB;
303
304
305 memctl->memc_or3 = CONFIG_SYS_OR3_CAN;
306 memctl->memc_br3 = CONFIG_SYS_BR3_CAN;
307}
308
309void can_driver_disable (void)
310{
311 volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
312 volatile memctl8xx_t *memctl = &immap->im_memctl;
313
314
315 memctl->memc_br3 = 0;
316 memctl->memc_or3 = 0;
317
318 memctl->memc_mbmr = 0;
319}
320
321
322
323
324
325
326
327
328
329
330
331
332static long int dram_size (long int mamr_value, long int *base, long int maxsize)
333{
334 volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
335 volatile memctl8xx_t *memctl = &immap->im_memctl;
336
337 memctl->memc_mamr = mamr_value;
338
339 return (get_ram_size(base, maxsize));
340}
341
342
343
344#define ETH_CFG_BITS (CONFIG_SYS_PB_ETH_CFG1 | CONFIG_SYS_PB_ETH_CFG2 | CONFIG_SYS_PB_ETH_CFG3 )
345
346#define ETH_ALL_BITS (ETH_CFG_BITS | CONFIG_SYS_PB_ETH_POWERDOWN)
347
348void reset_phy(void)
349{
350 immap_t *immr = (immap_t *)CONFIG_SYS_IMMR;
351 ulong value;
352
353
354#ifdef CONFIG_SYS_ETH_MDDIS_VALUE
355 immr->im_ioport.iop_padat |= CONFIG_SYS_PA_ETH_MDDIS;
356#else
357 immr->im_ioport.iop_padat &= ~(CONFIG_SYS_PA_ETH_MDDIS | CONFIG_SYS_PA_ETH_RESET);
358#endif
359 immr->im_ioport.iop_papar &= ~(CONFIG_SYS_PA_ETH_MDDIS | CONFIG_SYS_PA_ETH_RESET);
360 immr->im_ioport.iop_paodr &= ~(CONFIG_SYS_PA_ETH_MDDIS | CONFIG_SYS_PA_ETH_RESET);
361 immr->im_ioport.iop_padir |= CONFIG_SYS_PA_ETH_MDDIS | CONFIG_SYS_PA_ETH_RESET;
362
363 immr->im_cpm.cp_pbpar &= ~(ETH_ALL_BITS);
364 immr->im_cpm.cp_pbodr &= ~(ETH_ALL_BITS);
365
366 value = immr->im_cpm.cp_pbdat;
367
368
369 value |= CONFIG_SYS_PB_ETH_POWERDOWN;
370
371
372#ifdef CONFIG_SYS_ETH_CFG1_VALUE
373 value |= CONFIG_SYS_PB_ETH_CFG1;
374#else
375 value &= ~(CONFIG_SYS_PB_ETH_CFG1);
376#endif
377#ifdef CONFIG_SYS_ETH_CFG2_VALUE
378 value |= CONFIG_SYS_PB_ETH_CFG2;
379#else
380 value &= ~(CONFIG_SYS_PB_ETH_CFG2);
381#endif
382#ifdef CONFIG_SYS_ETH_CFG3_VALUE
383 value |= CONFIG_SYS_PB_ETH_CFG3;
384#else
385 value &= ~(CONFIG_SYS_PB_ETH_CFG3);
386#endif
387
388
389 immr->im_cpm.cp_pbdat = value;
390 immr->im_cpm.cp_pbdir |= ETH_ALL_BITS;
391 udelay (10000);
392
393
394 immr->im_cpm.cp_pbdat &= ~(CONFIG_SYS_PB_ETH_POWERDOWN);
395 udelay (10000);
396
397
398 immr->im_ioport.iop_padat |= CONFIG_SYS_PA_ETH_RESET;
399 udelay (1000);
400}
401
402
403int misc_init_r (void)
404{
405 fpga_init();
406 return (0);
407}
408
409