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/addrspace.h>
27 #include <asm/inca-ip.h>
30 extern uint incaip_get_cpuclk(void);
32 static ulong max_sdram_size(void)
34 /* The only supported SDRAM data width is 16bit.
38 /* The only supported number of SDRAM banks is 4.
42 ulong cfgpb0 = *INCA_IP_SDRAM_MC_CFGPB0;
43 int cols = cfgpb0 & 0xF;
44 int rows = (cfgpb0 & 0xF0) >> 4;
45 ulong size = (1 << (rows + cols)) * CFG_DW * CFG_NB;
51 * Check memory range for valid RAM. A simple memory test determines
52 * the actually available RAM size between addresses `base' and
53 * `base + maxsize'. Some (not all) hardware errors are detected:
54 * - short between address lines
55 * - short between data lines
58 static long int dram_size(long int *base, long int maxsize)
60 volatile long int *addr;
62 ulong save[32]; /* to make test non-destructive */
65 for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
66 addr = base + cnt; /* pointer arith! */
72 /* write 0 to base address */
77 /* check at base address */
78 if ((val = *addr) != 0) {
83 for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
84 addr = base + cnt; /* pointer arith! */
90 return (cnt * sizeof (long));
96 long int initdram(int board_type)
98 int rows, cols, best_val = *INCA_IP_SDRAM_MC_CFGPB0;
99 ulong size, max_size = 0;
102 asm volatile ("move %0, $25" : "=r" (our_address) :);
104 /* Can't probe for RAM size unless we are running from Flash.
106 if (PHYSADDR(our_address) < PHYSADDR(PHYS_FLASH_1))
108 return max_sdram_size();
111 for (cols = 0x8; cols <= 0xC; cols++)
113 for (rows = 0xB; rows <= 0xD; rows++)
115 *INCA_IP_SDRAM_MC_CFGPB0 = (0x14 << 8) |
117 size = dram_size((ulong *)CFG_SDRAM_BASE,
122 best_val = *INCA_IP_SDRAM_MC_CFGPB0;
128 *INCA_IP_SDRAM_MC_CFGPB0 = best_val;
132 int checkboard (void)
135 unsigned long chipid = *INCA_IP_WDT_CHIPID;
138 puts ("Board: INCA-IP ");
139 part_num = (chipid >> 12) & 0xffff;
142 printf ("Standard Version, ");
145 printf ("Basic Version, ");
148 printf ("Unknown Part Number 0x%x ", part_num);
152 printf ("Chip V1.%ld, ", (chipid >> 28));
154 printf("CPU Speed %d MHz\n", incaip_get_cpuclk()/1000000);