blob: dbf0ecc5af3d1d56bfbd9b16c18a2ea27c16ce94 [file] [log] [blame]
wdenkbb1b8262003-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>
Jean-Christophe PLAGNIOL-VILLARD089dbb72007-11-13 09:11:05 +010028#include <asm/io.h>
wdenkbb1b8262003-03-27 12:09:35 +000029
wdenk8dba0502003-03-31 16:34:49 +000030extern uint incaip_get_cpuclk(void);
31
wdenkbb1b8262003-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
wdenkbb1b8262003-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;
Wolfgang Denkf6a692b2005-12-04 00:40:34 +010071 size = get_ram_size((long *)CFG_SDRAM_BASE,
wdenkbb1b8262003-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
wdenk8dba0502003-03-31 16:34:49 +000086int checkboard (void)
87{
wdenk8dba0502003-03-31 16:34:49 +000088 unsigned long chipid = *INCA_IP_WDT_CHIPID;
89 int part_num;
90
91 puts ("Board: INCA-IP ");
92 part_num = (chipid >> 12) & 0xffff;
93 switch (part_num) {
94 case 0xc0:
95 printf ("Standard Version, ");
96 break;
97 case 0xc1:
98 printf ("Basic Version, ");
99 break;
100 default:
101 printf ("Unknown Part Number 0x%x ", part_num);
102 break;
103 }
104
105 printf ("Chip V1.%ld, ", (chipid >> 28));
106
107 printf("CPU Speed %d MHz\n", incaip_get_cpuclk()/1000000);
108
Jean-Christophe PLAGNIOL-VILLARD089dbb72007-11-13 09:11:05 +0100109 set_io_port_base(0);
110
wdenk8dba0502003-03-31 16:34:49 +0000111 return 0;
112}