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,
27 #include <asm/inca-ip.h>
28 #include <asm/regdef.h>
29 #include <asm/mipsregs.h>
31 #include <asm/addrspace.h>
32 #include <asm/cacheops.h>
33 #include <asm/reboot.h>
37 #define cache_unroll(base,op) \
38 __asm__ __volatile__(" \
48 typedef void (*FUNCPTR
)(ulong
*source
, ulong
*destination
, ulong nlongs
);
50 extern void asc_serial_init (void);
51 extern void asc_serial_putc (char);
52 extern void asc_serial_puts (const char *);
53 extern int asc_serial_getc (void);
54 extern int asc_serial_tstc (void);
55 extern void asc_serial_setbrg (void);
57 void _machine_restart(void)
59 void (*f
)(void) = (void *) 0xbfc00000;
64 static void sdram_timing_init (ulong size
)
69 register uint p0
, p1
, p2
, p3
, p4
;
72 #define WRITE_MC_IOGP_1 *(uint *)0xbf800800 = (p1<<14)+(p2<<13)+(p4<<8)+(p0<<4)+p3;
73 #define WRITE_MC_IOGP_2 *(uint *)0xbf800800 = (p1<<14)+(p2<<13)+((p4-16)<<8)+(p0<<4)+p3;
77 while (p0
< 4 && done
== 0) {
79 while (p1
< 2 && done
== 0) {
81 while (p2
< 2 && done
== 0) {
83 while (p3
< 16 && done
== 0) {
86 while (p4
< 32 && done
== 0) {
89 for (addr
= CKSEG1
+ 0x4000;
90 addr
< CKSEG1ADDR (size
);
92 *(uint
*) addr
= 0xaa55aa55;
97 for (addr
= CKSEG1
+ 0x4000;
98 addr
< CKSEG1ADDR (size
) && pass
== 1;
100 if (*(uint
*) addr
!= 0xaa55aa55)
128 phys_size_t
initdram(int board_type
)
130 /* The only supported number of SDRAM banks is 4.
132 #define CONFIG_SYS_NB 4
134 ulong cfgpb0
= *INCA_IP_SDRAM_MC_CFGPB0
;
135 ulong cfgdw
= *INCA_IP_SDRAM_MC_CFGDW
;
136 int cols
= cfgpb0
& 0xF;
137 int rows
= (cfgpb0
& 0xF0) >> 4;
138 int dw
= cfgdw
& 0xF;
139 ulong size
= (1 << (rows
+ cols
)) * (1 << (dw
- 1)) * CONFIG_SYS_NB
;
140 void (* sdram_init
) (ulong
);
142 sdram_init
= (void (*)(ulong
)) CKSEG0ADDR(&sdram_timing_init
);
149 int checkboard (void)
152 unsigned long chipid
= *(unsigned long *)0xB800C800;
154 printf ("Board: Purple PLB 2800 chip version %ld, ", chipid
& 0xF);
156 printf("CPU Speed %d MHz\n", CPU_CLOCK_RATE
/1000000);
163 int misc_init_r (void)
167 sconsole_putc
= asc_serial_putc
;
168 sconsole_puts
= asc_serial_puts
;
169 sconsole_getc
= asc_serial_getc
;
170 sconsole_tstc
= asc_serial_tstc
;
171 sconsole_setbrg
= asc_serial_setbrg
;
177 /*******************************************************************************
179 * copydwords - copy one buffer to another a long at a time
181 * This routine copies the first <nlongs> longs from <source> to <destination>.
183 static void copydwords (ulong
*source
, ulong
*destination
, ulong nlongs
)
186 ulong
*dstend
= destination
+ nlongs
;
188 while (destination
< dstend
) {
190 /* dummy read from sdram */
191 temp1
= *(ulong
*)0xa0000000;
192 /* avoid optimization from compliler */
193 *(ulong
*)0xbf0081f8 = temp1
+ temp
;
194 *destination
++ = temp
;
199 /*******************************************************************************
201 * copyLongs - copy one buffer to another a long at a time
203 * This routine copies the first <nlongs> longs from <source> to <destination>.
205 static void copyLongs (ulong
*source
, ulong
*destination
, ulong nlongs
)
209 absEntry
= (FUNCPTR
)(0xbf008000+((ulong
)copydwords
& 0x7));
210 absEntry(source
, destination
, nlongs
);
213 /*******************************************************************************
215 * programLoad - load program into ram
217 * This routine load copydwords into ram
220 static void programLoad(void)
225 src
= (ulong
*)(TEXT_BASE
+ 0x428);
226 dst
= (ulong
*)0xbf0081d0;
228 absEntry
= (FUNCPTR
)(TEXT_BASE
+ 0x400);
229 absEntry(src
,dst
,0x6);
231 src
= (ulong
*)((ulong
)copydwords
& 0xfffffff8);
232 dst
= (ulong
*)0xbf008000;
234 absEntry(src
,dst
,0x38);
237 /*******************************************************************************
239 * copy_code - copy u-boot image from flash to RAM
241 * This routine is needed to solve flash problems on this board
244 void copy_code (ulong dest_addr
)
246 extern long uboot_end_data
;
250 /* load copydwords into ram
256 copyLongs((ulong
*)CONFIG_SYS_MONITOR_BASE
,
258 ((ulong
)&uboot_end_data
- CONFIG_SYS_MONITOR_BASE
+ 3) / 4);
265 end
= start
+ CONFIG_SYS_DCACHE_SIZE
;
267 cache_unroll(start
,Index_Writeback_Inv_D
);
268 start
+= CONFIG_SYS_CACHELINE_SIZE
;
272 end
= start
+ CONFIG_SYS_ICACHE_SIZE
;
274 cache_unroll(start
,Index_Invalidate_I
);
275 start
+= CONFIG_SYS_CACHELINE_SIZE
;
279 #ifdef CONFIG_PLB2800_ETHER
280 int board_eth_init(bd_t
*bis
)
282 return plb2800_eth_initialize(bis
);