]>
git.ipfire.org Git - u-boot.git/blob - board/purple/purple.c
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);
54 static void sdram_timing_init (ulong size
)
59 register uint p0
, p1
, p2
, p3
, p4
;
62 #define WRITE_MC_IOGP_1 *(uint *)0xbf800800 = (p1<<14)+(p2<<13)+(p4<<8)+(p0<<4)+p3;
63 #define WRITE_MC_IOGP_2 *(uint *)0xbf800800 = (p1<<14)+(p2<<13)+((p4-16)<<8)+(p0<<4)+p3;
67 while (p0
< 4 && done
== 0) {
69 while (p1
< 2 && done
== 0) {
71 while (p2
< 2 && done
== 0) {
73 while (p3
< 16 && done
== 0) {
76 while (p4
< 32 && done
== 0) {
79 for (addr
= KSEG1
+ 0x4000;
80 addr
< KSEG1ADDR (size
);
82 *(uint
*) addr
= 0xaa55aa55;
87 for (addr
= KSEG1
+ 0x4000;
88 addr
< KSEG1ADDR (size
) && pass
== 1;
90 if (*(uint
*) addr
!= 0xaa55aa55)
118 long int initdram(int board_type
)
120 /* The only supported number of SDRAM banks is 4.
124 ulong cfgpb0
= *INCA_IP_SDRAM_MC_CFGPB0
;
125 ulong cfgdw
= *INCA_IP_SDRAM_MC_CFGDW
;
126 int cols
= cfgpb0
& 0xF;
127 int rows
= (cfgpb0
& 0xF0) >> 4;
128 int dw
= cfgdw
& 0xF;
129 ulong size
= (1 << (rows
+ cols
)) * (1 << (dw
- 1)) * CFG_NB
;
130 void (* sdram_init
) (ulong
);
132 sdram_init
= (void (*)(ulong
)) KSEG0ADDR(&sdram_timing_init
);
139 int checkboard (void)
142 unsigned long chipid
= *(unsigned long *)0xB800C800;
144 printf ("Board: Purple PLB 2800 chip version %ld, ", chipid
& 0xF);
146 printf("CPU Speed %d MHz\n", CPU_CLOCK_RATE
/1000000);
151 int misc_init_r (void)
155 sconsole_putc
= asc_serial_putc
;
156 sconsole_puts
= asc_serial_puts
;
157 sconsole_getc
= asc_serial_getc
;
158 sconsole_tstc
= asc_serial_tstc
;
159 sconsole_setbrg
= asc_serial_setbrg
;
165 /*******************************************************************************
167 * copydwords - copy one buffer to another a long at a time
169 * This routine copies the first <nlongs> longs from <source> to <destination>.
171 static void copydwords (ulong
*source
, ulong
*destination
, ulong nlongs
)
174 ulong
*dstend
= destination
+ nlongs
;
176 while (destination
< dstend
)
179 /* dummy read from sdram */
180 temp1
= *(ulong
*)0xa0000000;
181 /* avoid optimization from compliler */
182 *(ulong
*)0xbf0081f8 = temp1
+ temp
;
183 *destination
++ = temp
;
188 /*******************************************************************************
190 * copyLongs - copy one buffer to another a long at a time
192 * This routine copies the first <nlongs> longs from <source> to <destination>.
194 static void copyLongs (ulong
*source
, ulong
*destination
, ulong nlongs
)
198 absEntry
= (FUNCPTR
)(0xbf008000+((ulong
)copydwords
& 0x7));
199 absEntry(source
, destination
, nlongs
);
202 /*******************************************************************************
204 * programLoad - load program into ram
206 * This routine load copydwords into ram
209 static void programLoad(void)
214 src
= (ulong
*)(TEXT_BASE
+ 0x428);
215 dst
= (ulong
*)0xbf0081d0;
217 absEntry
= (FUNCPTR
)(TEXT_BASE
+ 0x400);
218 absEntry(src
,dst
,0x6);
220 src
= (ulong
*)((ulong
)copydwords
& 0xfffffff8);
221 dst
= (ulong
*)0xbf008000;
223 absEntry(src
,dst
,0x38);
226 /*******************************************************************************
228 * copy_code - copy u-boot image from flash to RAM
230 * This routine is needed to solve flash problems on this board
233 void copy_code (ulong dest_addr
)
235 extern long uboot_end_data
;
239 /* load copydwords into ram
245 copyLongs((ulong
*)CFG_MONITOR_BASE
,
247 ((ulong
)&uboot_end_data
- CFG_MONITOR_BASE
+ 3) / 4);
254 end
= start
+ CFG_DCACHE_SIZE
;
256 cache_unroll(start
,Index_Writeback_Inv_D
);
257 start
+= CFG_CACHELINE_SIZE
;
261 end
= start
+ CFG_ICACHE_SIZE
;
263 cache_unroll(start
,Index_Invalidate_I
);
264 start
+= CFG_CACHELINE_SIZE
;