blob: eb6eaea27857c908f9bc173d8886968a2c777543 [file] [log] [blame]
wdenkc0218802003-03-27 12:09:35 +00001/*
2 * (C) Copyright 2003
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4 *
5 * See file CREDITS for list of people who contributed to this
6 * project.
7 *
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.
12 *
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.
17 *
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,
21 * MA 02111-1307 USA
22 */
23
24#include <common.h>
25#include <command.h>
26#include <asm/addrspace.h>
27#include <asm/inca-ip.h>
28
29
wdenk85ec0bc2003-03-31 16:34:49 +000030extern uint incaip_get_cpuclk(void);
31
wdenkc0218802003-03-27 12:09:35 +000032static ulong max_sdram_size(void)
33{
34 /* The only supported SDRAM data width is 16bit.
35 */
36#define CFG_DW 2
37
38 /* The only supported number of SDRAM banks is 4.
39 */
40#define CFG_NB 4
41
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;
46
47 return size;
48}
49
wdenkc0218802003-03-27 12:09:35 +000050long int initdram(int board_type)
51{
52 int rows, cols, best_val = *INCA_IP_SDRAM_MC_CFGPB0;
53 ulong size, max_size = 0;
54 ulong our_address;
55
56 asm volatile ("move %0, $25" : "=r" (our_address) :);
57
58 /* Can't probe for RAM size unless we are running from Flash.
59 */
60 if (PHYSADDR(our_address) < PHYSADDR(PHYS_FLASH_1))
61 {
62 return max_sdram_size();
63 }
64
65 for (cols = 0x8; cols <= 0xC; cols++)
66 {
67 for (rows = 0xB; rows <= 0xD; rows++)
68 {
69 *INCA_IP_SDRAM_MC_CFGPB0 = (0x14 << 8) |
70 (rows << 4) | cols;
wdenkc83bf6a2004-01-06 22:38:14 +000071 size = get_ram_size((ulong *)CFG_SDRAM_BASE,
wdenkc0218802003-03-27 12:09:35 +000072 max_sdram_size());
73
74 if (size > max_size)
75 {
76 best_val = *INCA_IP_SDRAM_MC_CFGPB0;
77 max_size = size;
78 }
79 }
80 }
81
82 *INCA_IP_SDRAM_MC_CFGPB0 = best_val;
83 return max_size;
84}
85
wdenk85ec0bc2003-03-31 16:34:49 +000086int checkboard (void)
87{
88
89 unsigned long chipid = *INCA_IP_WDT_CHIPID;
90 int part_num;
91
92 puts ("Board: INCA-IP ");
93 part_num = (chipid >> 12) & 0xffff;
94 switch (part_num) {
95 case 0xc0:
96 printf ("Standard Version, ");
97 break;
98 case 0xc1:
99 printf ("Basic Version, ");
100 break;
101 default:
102 printf ("Unknown Part Number 0x%x ", part_num);
103 break;
104 }
105
106 printf ("Chip V1.%ld, ", (chipid >> 28));
107
108 printf("CPU Speed %d MHz\n", incaip_get_cpuclk()/1000000);
109
110 return 0;
111}