blob: 36da7774eaf4f47132b53a6752ea008a8e9a7bac [file] [log] [blame]
Jon Loeligerdebb7352006-04-26 17:58:56 -05001/*
2 * Copyright 2004 Freescale Semiconductor
3 * Jeff Brown (jeffrey@freescale.com)
4 * Srikanth Srinivasan (srikanth.srinivasan@freescale.com)
5 *
6 * See file CREDITS for list of people who contributed to this
7 * project.
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation; either version 2 of
12 * the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
22 * MA 02111-1307 USA
23 */
24
25#include <common.h>
26#include <watchdog.h>
27#include <command.h>
28#include <asm/cache.h>
29#include <mpc86xx.h>
30
31#if defined(CONFIG_OF_FLAT_TREE)
32#include <ft_build.h>
33#endif
34
Jon Loeliger5c9efb32006-04-27 10:15:16 -050035extern unsigned long get_board_sys_clk(ulong dummy);
Jon Loeligerdebb7352006-04-26 17:58:56 -050036
Jon Loeligerdebb7352006-04-26 17:58:56 -050037
38static __inline__ unsigned long get_dbat3u (void)
39{
Jon Loeliger5c9efb32006-04-27 10:15:16 -050040 unsigned long dbat3u;
41 asm volatile("mfspr %0, 542" : "=r" (dbat3u) :);
42 return dbat3u;
Jon Loeligerdebb7352006-04-26 17:58:56 -050043}
44
45static __inline__ unsigned long get_dbat3l (void)
46{
Jon Loeliger5c9efb32006-04-27 10:15:16 -050047 unsigned long dbat3l;
48 asm volatile("mfspr %0, 543" : "=r" (dbat3l) :);
49 return dbat3l;
Jon Loeligerdebb7352006-04-26 17:58:56 -050050}
51
52static __inline__ unsigned long get_msr (void)
53{
Jon Loeliger5c9efb32006-04-27 10:15:16 -050054 unsigned long msr;
55 asm volatile("mfmsr %0" : "=r" (msr) :);
56 return msr;
Jon Loeligerdebb7352006-04-26 17:58:56 -050057}
58
Jon Loeligerdebb7352006-04-26 17:58:56 -050059
60int checkcpu (void)
61{
62 sys_info_t sysinfo;
63 uint pvr, svr;
64 uint ver;
65 uint major, minor;
66 uint lcrr; /* local bus clock ratio register */
67 uint clkdiv; /* clock divider portion of lcrr */
Jon Loeliger5c9efb32006-04-27 10:15:16 -050068
Jon Loeligerdebb7352006-04-26 17:58:56 -050069 puts("Freescale PowerPC\n");
70
71 pvr = get_pvr();
72 ver = PVR_VER(pvr);
73 major = PVR_MAJ(pvr);
74 minor = PVR_MIN(pvr);
75
Jon Loeliger5c9efb32006-04-27 10:15:16 -050076 puts("CPU:\n");
Jon Loeligerdebb7352006-04-26 17:58:56 -050077
78 printf(" Core: ");
Jon Loeliger5c9efb32006-04-27 10:15:16 -050079
Jon Loeligerdebb7352006-04-26 17:58:56 -050080 switch (ver) {
81 case PVR_VER(PVR_86xx):
82 puts("E600");
83 break;
84 default:
85 puts("Unknown");
86 break;
87 }
88 printf(", Version: %d.%d, (0x%08x)\n", major, minor, pvr);
89
90 svr = get_svr();
91 ver = SVR_VER(svr);
92 major = SVR_MAJ(svr);
93 minor = SVR_MIN(svr);
94
95 puts(" System: ");
Jon Loeliger5c9efb32006-04-27 10:15:16 -050096 switch (ver) {
Jon Loeligerdebb7352006-04-26 17:58:56 -050097 case SVR_8641:
98 puts("8641");
99 break;
100 case SVR_8641D:
101 puts("8641D");
102 break;
103 default:
104 puts("Unknown");
105 break;
106 }
107 printf(", Version: %d.%d, (0x%08x)\n", major, minor, svr);
108
109 get_sys_info(&sysinfo);
110
111 puts(" Clocks: ");
112 printf("CPU:%4lu MHz, ", sysinfo.freqProcessor / 1000000);
113 printf("MPX:%4lu MHz, ", sysinfo.freqSystemBus / 1000000);
114 printf("DDR:%4lu MHz, ", sysinfo.freqSystemBus / 2000000);
Jon Loeliger5c9efb32006-04-27 10:15:16 -0500115
Jon Loeligerdebb7352006-04-26 17:58:56 -0500116#if defined(CFG_LBC_LCRR)
117 lcrr = CFG_LBC_LCRR;
118#else
119 {
120 volatile immap_t *immap = (immap_t *)CFG_IMMR;
121 volatile ccsr_lbc_t *lbc= &immap->im_lbc;
122
123 lcrr = lbc->lcrr;
124 }
125#endif
126 clkdiv = lcrr & 0x0f;
127 if (clkdiv == 2 || clkdiv == 4 || clkdiv == 8) {
128 printf("LBC:%4lu MHz\n",
129 sysinfo.freqSystemBus / 1000000 / clkdiv);
130 } else {
131 printf(" LBC: unknown (lcrr: 0x%08x)\n", lcrr);
132 }
133
134 printf(" L2: ");
135 if (get_l2cr() & 0x80000000)
Jon Loeliger5c9efb32006-04-27 10:15:16 -0500136 printf("Enabled\n");
Jon Loeligerdebb7352006-04-26 17:58:56 -0500137 else
Jon Loeliger5c9efb32006-04-27 10:15:16 -0500138 printf("Disabled\n");
139
140 return 0;
Jon Loeligerdebb7352006-04-26 17:58:56 -0500141}
142
143
144/* -------------------------------------------------------------------- */
145
146static inline void
147soft_restart(unsigned long addr)
148{
149
150#ifndef CONFIG_MPC8641HPCN
Jon Loeliger5c9efb32006-04-27 10:15:16 -0500151
Jon Loeligerdebb7352006-04-26 17:58:56 -0500152 /* SRR0 has system reset vector, SRR1 has default MSR value */
153 /* rfi restores MSR from SRR1 and sets the PC to the SRR0 value */
154
155 __asm__ __volatile__ ("mtspr 26, %0" :: "r" (addr));
156 __asm__ __volatile__ ("li 4, (1 << 6)" ::: "r4");
157 __asm__ __volatile__ ("mtspr 27, 4");
158 __asm__ __volatile__ ("rfi");
159
160#else /* CONFIG_MPC8641HPCN */
161 out8(PIXIS_BASE+PIXIS_RST,0);
162#endif /* !CONFIG_MPC8641HPCN */
163 while(1); /* not reached */
164}
165
166
167
168#ifdef CONFIG_MPC8641HPCN
169
170int set_px_sysclk(ulong sysclk)
171{
172 u8 sysclk_s, sysclk_r, sysclk_v, vclkh, vclkl, sysclk_aux,tmp;
173
174 /* Per table 27, page 58 of MPC8641HPCN spec*/
175 switch(sysclk)
176 {
177 case 33:
178 sysclk_s = 0x04;
179 sysclk_r = 0x04;
180 sysclk_v = 0x07;
181 sysclk_aux = 0x00;
182 break;
183 case 40:
184 sysclk_s = 0x01;
185 sysclk_r = 0x1F;
186 sysclk_v = 0x20;
187 sysclk_aux = 0x01;
188 break;
189 case 50:
190 sysclk_s = 0x01;
191 sysclk_r = 0x1F;
192 sysclk_v = 0x2A;
193 sysclk_aux = 0x02;
194 break;
195 case 66:
196 sysclk_s = 0x01;
197 sysclk_r = 0x04;
198 sysclk_v = 0x04;
199 sysclk_aux = 0x03;
200 break;
201 case 83:
202 sysclk_s = 0x01;
203 sysclk_r = 0x1F;
204 sysclk_v = 0x4B;
205 sysclk_aux = 0x04;
206 break;
207 case 100:
208 sysclk_s = 0x01;
209 sysclk_r = 0x1F;
210 sysclk_v = 0x5C;
211 sysclk_aux = 0x05;
212 break;
213 case 134:
214 sysclk_s = 0x06;
215 sysclk_r = 0x1F;
216 sysclk_v = 0x3B;
Jon Loeliger5c9efb32006-04-27 10:15:16 -0500217 sysclk_aux = 0x06;
Jon Loeligerdebb7352006-04-26 17:58:56 -0500218 break;
219 case 166:
220 sysclk_s = 0x06;
221 sysclk_r = 0x1F;
222 sysclk_v = 0x4B;
223 sysclk_aux = 0x07;
224 break;
225 default:
226 printf("Unsupported SYSCLK frequency.\n");
227 return 0;
228 }
Jon Loeliger5c9efb32006-04-27 10:15:16 -0500229
Jon Loeligerdebb7352006-04-26 17:58:56 -0500230 vclkh = (sysclk_s << 5) | sysclk_r ;
231 vclkl = sysclk_v;
232 out8(PIXIS_BASE+PIXIS_VCLKH,vclkh);
233 out8(PIXIS_BASE+PIXIS_VCLKL,vclkl);
234
235 out8(PIXIS_BASE+PIXIS_AUX,sysclk_aux);
Jon Loeliger5c9efb32006-04-27 10:15:16 -0500236
Jon Loeligerdebb7352006-04-26 17:58:56 -0500237 return 1;
238}
239
240int set_px_mpxpll(ulong mpxpll)
241{
242 u8 tmp;
243 u8 val;
244 switch(mpxpll)
245 {
246 case 2:
247 case 4:
248 case 6:
249 case 8:
250 case 10:
251 case 12:
252 case 14:
253 case 16:
254 val = (u8)mpxpll;
255 break;
256 default:
257 printf("Unsupported MPXPLL ratio.\n");
258 return 0;
259 }
260
261 tmp = in8(PIXIS_BASE+PIXIS_VSPEED1);
262 tmp = (tmp & 0xF0) | (val & 0x0F);
263 out8(PIXIS_BASE+PIXIS_VSPEED1,tmp);
Jon Loeliger5c9efb32006-04-27 10:15:16 -0500264
Jon Loeligerdebb7352006-04-26 17:58:56 -0500265 return 1;
266}
267
268int set_px_corepll(ulong corepll)
269{
270 u8 tmp;
271 u8 val;
Jon Loeliger5c9efb32006-04-27 10:15:16 -0500272
273 switch ((int)corepll) {
Jon Loeligerdebb7352006-04-26 17:58:56 -0500274 case 20:
275 val = 0x08;
276 break;
277 case 25:
278 val = 0x0C;
279 break;
280 case 30:
281 val = 0x10;
282 break;
283 case 35:
284 val = 0x1C;
285 break;
286 case 40:
287 val = 0x14;
288 break;
289 case 45:
290 val = 0x0E;
291 break;
292 default:
293 printf("Unsupported COREPLL ratio.\n");
294 return 0;
295 }
Jon Loeliger5c9efb32006-04-27 10:15:16 -0500296
Jon Loeligerdebb7352006-04-26 17:58:56 -0500297 tmp = in8(PIXIS_BASE+PIXIS_VSPEED0);
298 tmp = (tmp & 0xE0) | (val & 0x1F);
299 out8(PIXIS_BASE+PIXIS_VSPEED0,tmp);
Jon Loeliger5c9efb32006-04-27 10:15:16 -0500300
Jon Loeligerdebb7352006-04-26 17:58:56 -0500301 return 1;
302}
303
304void read_from_px_regs(int set)
305{
306 u8 tmp, mask = 0x1C;
307 tmp = in8(PIXIS_BASE+PIXIS_VCFGEN0);
308 if (set)
309 tmp = tmp | mask;
310 else
311 tmp = tmp & ~mask;
Jon Loeliger5c9efb32006-04-27 10:15:16 -0500312 out8(PIXIS_BASE+PIXIS_VCFGEN0,tmp);
Jon Loeligerdebb7352006-04-26 17:58:56 -0500313}
314
315void read_from_px_regs_altbank(int set)
316{
317 u8 tmp, mask = 0x04;
318 tmp = in8(PIXIS_BASE+PIXIS_VCFGEN1);
319 if (set)
320 tmp = tmp | mask;
321 else
322 tmp = tmp & ~mask;
Jon Loeliger5c9efb32006-04-27 10:15:16 -0500323 out8(PIXIS_BASE+PIXIS_VCFGEN1,tmp);
Jon Loeligerdebb7352006-04-26 17:58:56 -0500324}
325
326void set_altbank(void)
327{
328 u8 tmp;
329 tmp = in8(PIXIS_BASE+PIXIS_VBOOT);
330 tmp ^= 0x40;
331 out8(PIXIS_BASE+PIXIS_VBOOT,tmp);
332 }
333
334
335void set_px_go(void)
336{
337 u8 tmp;
338 tmp = in8(PIXIS_BASE+PIXIS_VCTL);
339 tmp = tmp & 0x1E;
340 out8(PIXIS_BASE+PIXIS_VCTL,tmp);
341 tmp = in8(PIXIS_BASE+PIXIS_VCTL);
342 tmp = tmp | 0x01;
Jon Loeliger5c9efb32006-04-27 10:15:16 -0500343 out8(PIXIS_BASE+PIXIS_VCTL,tmp);
Jon Loeligerdebb7352006-04-26 17:58:56 -0500344}
345
346void set_px_go_with_watchdog(void)
347{
348 u8 tmp;
349 tmp = in8(PIXIS_BASE+PIXIS_VCTL);
350 tmp = tmp & 0x1E;
351 out8(PIXIS_BASE+PIXIS_VCTL,tmp);
352 tmp = in8(PIXIS_BASE+PIXIS_VCTL);
353 tmp = tmp | 0x09;
Jon Loeliger5c9efb32006-04-27 10:15:16 -0500354 out8(PIXIS_BASE+PIXIS_VCTL,tmp);
Jon Loeligerdebb7352006-04-26 17:58:56 -0500355}
356
357/* This function takes the non-integral cpu:mpx pll ratio
358 * and converts it to an integer that can be used to assign
359 * FPGA register values.
360 * input: strptr i.e. argv[2]
361*/
362
363ulong strfractoint(uchar *strptr)
364{
365 int i,j,retval,intarr_len=0, decarr_len=0, mulconst, no_dec=0;
366 ulong intval =0, decval=0;
367 uchar intarr[3], decarr[3];
368
369 /* Assign the integer part to intarr[]
370 * If there is no decimal point i.e.
371 * if the ratio is an integral value
372 * simply create the intarr.
373 */
374 i=0;
375 while(strptr[i] != 46)
376 {
377 if(strptr[i] == 0)
378 {
379 no_dec = 1;
380 break; /* Break from loop once the end of string is reached */
381 }
Jon Loeliger5c9efb32006-04-27 10:15:16 -0500382
Jon Loeligerdebb7352006-04-26 17:58:56 -0500383 intarr[i] = strptr[i];
384 i++;
385 }
Jon Loeliger5c9efb32006-04-27 10:15:16 -0500386
Jon Loeligerdebb7352006-04-26 17:58:56 -0500387 intarr_len = i; /* Assign length of integer part to intarr_len*/
388 intarr[i] = '\0'; /* */
389
390 if(no_dec)
391 {
392 mulconst=10; /* Currently needed only for single digit corepll ratios */
393 decval = 0;
394 }
395 else
396 {
397 j=0;
398 i++; /* Skipping the decimal point */
399 while ((strptr[i] > 47) && (strptr[i] < 58))
400 {
401 decarr[j] = strptr[i];
402 i++;
403 j++;
404 }
Jon Loeliger5c9efb32006-04-27 10:15:16 -0500405
Jon Loeligerdebb7352006-04-26 17:58:56 -0500406 decarr_len = j;
407 decarr[j] = '\0';
Jon Loeliger5c9efb32006-04-27 10:15:16 -0500408
Jon Loeligerdebb7352006-04-26 17:58:56 -0500409 mulconst=1;
410 for(i=0; i<decarr_len;i++)
411 mulconst = mulconst*10;
Jon Loeliger5c9efb32006-04-27 10:15:16 -0500412 decval = simple_strtoul(decarr,NULL,10);
Jon Loeligerdebb7352006-04-26 17:58:56 -0500413 }
414
415 intval = simple_strtoul(intarr,NULL,10);
416 intval = intval*mulconst;
417
418 retval = intval+decval;
419
420 return retval;
421
422}
Jon Loeligerdebb7352006-04-26 17:58:56 -0500423
Jon Loeliger5c9efb32006-04-27 10:15:16 -0500424
425#endif /* CONFIG_MPC8641HPCN */
Jon Loeligerdebb7352006-04-26 17:58:56 -0500426
427
428/* no generic way to do board reset. simply call soft_reset. */
429void
430do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
431{
432 char cmd;
433 ulong addr, val;
434 ulong corepll;
Jon Loeligerdebb7352006-04-26 17:58:56 -0500435
436#ifdef CFG_RESET_ADDRESS
437 addr = CFG_RESET_ADDRESS;
438#else
439 /*
440 * note: when CFG_MONITOR_BASE points to a RAM address,
441 * CFG_MONITOR_BASE - sizeof (ulong) is usually a valid
442 * address. Better pick an address known to be invalid on your
443 * system and assign it to CFG_RESET_ADDRESS.
444 */
445 addr = CFG_MONITOR_BASE - sizeof (ulong);
446#endif
447
448#ifndef CONFIG_MPC8641HPCN
449
Jon Loeliger5c9efb32006-04-27 10:15:16 -0500450 /* flush and disable I/D cache */
Jon Loeligerdebb7352006-04-26 17:58:56 -0500451 __asm__ __volatile__ ("mfspr 3, 1008" ::: "r3");
452 __asm__ __volatile__ ("ori 5, 5, 0xcc00" ::: "r5");
453 __asm__ __volatile__ ("ori 4, 3, 0xc00" ::: "r4");
454 __asm__ __volatile__ ("andc 5, 3, 5" ::: "r5");
455 __asm__ __volatile__ ("sync");
456 __asm__ __volatile__ ("mtspr 1008, 4");
457 __asm__ __volatile__ ("isync");
458 __asm__ __volatile__ ("sync");
459 __asm__ __volatile__ ("mtspr 1008, 5");
460 __asm__ __volatile__ ("isync");
461 __asm__ __volatile__ ("sync");
462
463 soft_restart(addr);
464
465#else /* CONFIG_MPC8641HPCN */
Jon Loeligerdebb7352006-04-26 17:58:56 -0500466
Jon Loeliger5c9efb32006-04-27 10:15:16 -0500467 if (argc > 1) {
468 cmd = argv[1][1];
469 switch(cmd) {
470 case 'f': /* reset with frequency changed */
471 if (argc < 5)
472 goto my_usage;
473 read_from_px_regs(0);
Jon Loeligerdebb7352006-04-26 17:58:56 -0500474
Jon Loeliger5c9efb32006-04-27 10:15:16 -0500475 val = set_px_sysclk(simple_strtoul(argv[2],NULL,10));
476
477 corepll = strfractoint(argv[3]);
478 val = val + set_px_corepll(corepll);
479 val = val + set_px_mpxpll(simple_strtoul(argv[4],
480 NULL, 10));
481 if (val == 3) {
482 printf("Setting registers VCFGEN0 and VCTL\n");
483 read_from_px_regs(1);
484 printf("Resetting board with values from VSPEED0, VSPEED1, VCLKH, and VCLKL ....\n");
485 set_px_go();
486 } else
487 goto my_usage;
488
489 while (1); /* Not reached */
490
491 case 'l':
492 if (argv[2][1] == 'f') {
493 read_from_px_regs(0);
494 read_from_px_regs_altbank(0);
495 /* reset with frequency changed */
496 val = set_px_sysclk(simple_strtoul(argv[3],NULL,10));
497
498 corepll = strfractoint(argv[4]);
499 val = val + set_px_corepll(corepll);
500 val = val + set_px_mpxpll(simple_strtoul(argv[5],NULL,10));
501 if (val == 3) {
502 printf("Setting registers VCFGEN0, VCFGEN1, VBOOT, and VCTL\n");
503 set_altbank();
504 read_from_px_regs(1);
505 read_from_px_regs_altbank(1);
506 printf("Enabling watchdog timer on the FPGA and resetting board with values from VSPEED0, VSPEED1, VCLKH, and VCLKL to boot from the other bank ....\n");
507 set_px_go_with_watchdog();
508 } else
509 goto my_usage;
510
511 while(1); /* Not reached */
512 } else {
513 /* Reset from next bank without changing frequencies */
514 read_from_px_regs(0);
515 read_from_px_regs_altbank(0);
516 if(argc > 2)
517 goto my_usage;
518 printf("Setting registers VCFGEN1, VBOOT, and VCTL\n");
519 set_altbank();
520 read_from_px_regs_altbank(1);
521 printf("Enabling watchdog timer on the FPGA and resetting board to boot from the other bank....\n");
522 set_px_go_with_watchdog();
523 while(1); /* Not reached */
524 }
525
526 default:
527 goto my_usage;
528 }
529
Jon Loeligerdebb7352006-04-26 17:58:56 -0500530my_usage:
Jon Loeliger5c9efb32006-04-27 10:15:16 -0500531 printf("\nUsage: reset cf <SYSCLK freq> <COREPLL ratio> <MPXPLL ratio>\n");
532 printf(" reset altbank [cf <SYSCLK freq> <COREPLL ratio> <MPXPLL ratio>]\n");
533 printf("For example: reset cf 40 2.5 10\n");
534 printf("See MPC8641HPCN Design Workbook for valid values of command line parameters.\n");
535 return;
536 } else
537 out8(PIXIS_BASE+PIXIS_RST,0);
538
Jon Loeligerdebb7352006-04-26 17:58:56 -0500539#endif /* !CONFIG_MPC8641HPCN */
Jon Loeliger5c9efb32006-04-27 10:15:16 -0500540
Jon Loeligerdebb7352006-04-26 17:58:56 -0500541 while(1); /* not reached */
542}
543
544
Jon Loeligerdebb7352006-04-26 17:58:56 -0500545/*
546 * Get timebase clock frequency
547 */
548unsigned long get_tbclk(void)
549{
550 sys_info_t sys_info;
551
552 get_sys_info(&sys_info);
Jon Loeliger5c9efb32006-04-27 10:15:16 -0500553 return (sys_info.freqSystemBus + 3L) / 4L;
Jon Loeligerdebb7352006-04-26 17:58:56 -0500554}
555
Jon Loeligerdebb7352006-04-26 17:58:56 -0500556
557#if defined(CONFIG_WATCHDOG)
558void
559watchdog_reset(void)
560{
Jon Loeligerdebb7352006-04-26 17:58:56 -0500561}
562#endif /* CONFIG_WATCHDOG */
563
Jon Loeligerdebb7352006-04-26 17:58:56 -0500564
565#if defined(CONFIG_DDR_ECC)
Jon Loeliger5c9efb32006-04-27 10:15:16 -0500566void dma_init(void)
567{
Jon Loeligerdebb7352006-04-26 17:58:56 -0500568 volatile immap_t *immap = (immap_t *)CFG_IMMR;
569 volatile ccsr_dma_t *dma = &immap->im_dma;
570
571 dma->satr0 = 0x00040000;
572 dma->datr0 = 0x00040000;
573 asm("sync; isync");
574 return;
575}
576
Jon Loeliger5c9efb32006-04-27 10:15:16 -0500577uint dma_check(void)
578{
Jon Loeligerdebb7352006-04-26 17:58:56 -0500579 volatile immap_t *immap = (immap_t *)CFG_IMMR;
580 volatile ccsr_dma_t *dma = &immap->im_dma;
581 volatile uint status = dma->sr0;
582
583 /* While the channel is busy, spin */
584 while((status & 4) == 4) {
585 status = dma->sr0;
586 }
587
588 if (status != 0) {
589 printf ("DMA Error: status = %x\n", status);
590 }
591 return status;
592}
593
Jon Loeliger5c9efb32006-04-27 10:15:16 -0500594int dma_xfer(void *dest, uint count, void *src)
595{
Jon Loeligerdebb7352006-04-26 17:58:56 -0500596 volatile immap_t *immap = (immap_t *)CFG_IMMR;
597 volatile ccsr_dma_t *dma = &immap->im_dma;
598
599 dma->dar0 = (uint) dest;
600 dma->sar0 = (uint) src;
601 dma->bcr0 = count;
602 dma->mr0 = 0xf000004;
603 asm("sync;isync");
604 dma->mr0 = 0xf000005;
605 asm("sync;isync");
606 return dma_check();
607}
Jon Loeliger5c9efb32006-04-27 10:15:16 -0500608
Jon Loeligerdebb7352006-04-26 17:58:56 -0500609#endif /* CONFIG_DDR_ECC */
610
611
612#ifdef CONFIG_OF_FLAT_TREE
613void ft_cpu_setup(void *blob, bd_t *bd)
614{
615 u32 *p;
616 ulong clock;
617 int len;
Jon Loeliger5c9efb32006-04-27 10:15:16 -0500618
Jon Loeligerdebb7352006-04-26 17:58:56 -0500619 clock = bd->bi_busfreq;
620 p = ft_get_prop(blob, "/cpus/" OF_CPU "/bus-frequency", &len);
621 if (p != NULL)
622 *p = cpu_to_be32(clock);
623
624 p = ft_get_prop(blob, "/" OF_SOC "/serial@4500/clock-frequency", &len);
625 if (p != NULL)
626 *p = cpu_to_be32(clock);
627
628 p = ft_get_prop(blob, "/" OF_SOC "/serial@4600/clock-frequency", &len);
629 if (p != NULL)
630 *p = cpu_to_be32(clock);
631
632#if defined(CONFIG_MPC86XX_TSEC1)
633 p = ft_get_prop(blob, "/" OF_SOC "/ethernet@24000/address", &len);
634 memcpy(p, bd->bi_enetaddr, 6);
635#endif
Jon Loeliger5c9efb32006-04-27 10:15:16 -0500636
Jon Loeligerdebb7352006-04-26 17:58:56 -0500637#if defined(CONFIG_MPC86XX_TSEC2)
638 p = ft_get_prop(blob, "/" OF_SOC "/ethernet@25000/address", &len);
639 memcpy(p, bd->bi_enet1addr, 6);
640#endif
641
642#if defined(CONFIG_MPC86XX_TSEC3)
643 p = ft_get_prop(blob, "/" OF_SOC "/ethernet@26000/address", &len);
644 memcpy(p, bd->bi_enet2addr, 6);
645#endif
646
647#if defined(CONFIG_MPC86XX_TSEC4)
648 p = ft_get_prop(blob, "/" OF_SOC "/ethernet@27000/address", &len);
649 memcpy(p, bd->bi_enet3addr, 6);
650#endif
651
652}
653#endif