3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5 * See file CREDITS for list of people who contributed to this
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
26 #include <asm/inca-ip.h>
27 #include <asm/regdef.h>
28 #include <asm/mipsregs.h>
29 #include <asm/addrspace.h>
30 #include <asm/cacheops.h>
34 #define cache_unroll(base,op) \
35 __asm__ __volatile__(" \
45 typedef void (*FUNCPTR)(ulong *source, ulong *destination, ulong nlongs);
47 extern void asc_serial_init (void);
48 extern void asc_serial_putc (char);
49 extern void asc_serial_puts (const char *);
50 extern int asc_serial_getc (void);
51 extern int asc_serial_tstc (void);
52 extern void asc_serial_setbrg (void);
55 long int initdram(int board_type)
57 /* The only supported number of SDRAM banks is 4.
61 ulong cfgpb0 = *INCA_IP_SDRAM_MC_CFGPB0;
62 ulong cfgdw = *INCA_IP_SDRAM_MC_CFGDW;
63 int cols = cfgpb0 & 0xF;
64 int rows = (cfgpb0 & 0xF0) >> 4;
66 ulong size = (1 << (rows + cols)) * (1 << (dw - 1)) * CFG_NB;
74 unsigned long chipid = *(unsigned long *)0xB800C800;
76 printf ("Board: Purple PLB 2800 chip version %ld, ", chipid & 0xF);
78 printf("CPU Speed %d MHz\n", CPU_CLOCK_RATE/1000000);
83 int misc_init_r (void)
87 sconsole_putc = asc_serial_putc;
88 sconsole_puts = asc_serial_puts;
89 sconsole_getc = asc_serial_getc;
90 sconsole_tstc = asc_serial_tstc;
91 sconsole_setbrg = asc_serial_setbrg;
97 /*******************************************************************************
99 * copydwords - copy one buffer to another a long at a time
101 * This routine copies the first <nlongs> longs from <source> to <destination>.
103 static void copydwords (ulong *source, ulong *destination, ulong nlongs)
106 ulong *dstend = destination + nlongs;
108 while (destination < dstend)
111 /* dummy read from sdram */
112 temp1 = *(ulong *)0xa0000000;
113 /* avoid optimization from compliler */
114 *(ulong *)0xbf0081f8 = temp1 + temp;
115 *destination++ = temp;
120 /*******************************************************************************
122 * copyLongs - copy one buffer to another a long at a time
124 * This routine copies the first <nlongs> longs from <source> to <destination>.
126 static void copyLongs (ulong *source, ulong *destination, ulong nlongs)
130 absEntry = (FUNCPTR)(0xbf008000+((ulong)copydwords & 0x7));
131 absEntry(source, destination, nlongs);
134 /*******************************************************************************
136 * programLoad - load program into ram
138 * This routine load copydwords into ram
141 static void programLoad(void)
146 src = (ulong *)(TEXT_BASE + 0x428);
147 dst = (ulong *)0xbf0081d0;
149 absEntry = (FUNCPTR)(TEXT_BASE + 0x400);
150 absEntry(src,dst,0x6);
152 src = (ulong *)((ulong)copydwords & 0xfffffff8);
153 dst = (ulong *)0xbf008000;
155 absEntry(src,dst,0x38);
158 /*******************************************************************************
160 * copy_code - copy u-boot image from flash to RAM
162 * This routine is needed to solve flash problems on this board
165 void copy_code (ulong dest_addr)
170 /* load copydwords into ram
176 copyLongs((ulong *)CFG_MONITOR_BASE,
178 (CFG_MONITOR_LEN + 3) / 4);
185 end = start + CFG_DCACHE_SIZE;
187 cache_unroll(start,Index_Writeback_Inv_D);
188 start += CFG_CACHELINE_SIZE;
192 end = start + CFG_ICACHE_SIZE;
194 cache_unroll(start,Index_Invalidate_I);
195 start += CFG_CACHELINE_SIZE;