2 * (C) Copyright 2000-2004
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5 * Modified by, Yuli Barcohen, Arabella Software Ltd., yuli@arabellasw.com
7 * See file CREDITS for list of people who contributed to this
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License as
12 * published by the Free Software Foundation; either version 2 of
13 * the License, or (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
31 #define _NOT_USED_ 0xFFFFFFFF
32 /* #define debug(fmt,args...) printf (fmt ,##args) */
34 static long int dram_size (long int, long int *, long int);
36 const uint sdram_table[] = {
38 * Single Read. (Offset 0 in UPMB RAM)
40 0x1F07FC04, 0xEEAEFC04, 0x11ADFC04, 0xEFBBBC00,
41 0x1FF77C47, /* last */
43 * SDRAM Initialization (offset 5 in UPMB RAM)
45 * This is no UPM entry point. The following definition uses
46 * the remaining space to establish an initialization
47 * sequence, which is executed by a RUN command.
50 0x1FF77C34, 0xEFEABC34, 0x1FB57C35, /* last */
52 * Burst Read. (Offset 8 in UPMB RAM)
54 0x1F07FC04, 0xEEAEFC04, 0x10ADFC04, 0xF0AFFC00,
55 0xF0AFFC00, 0xF1AFFC00, 0xEFBBBC00, 0x1FF77C47, /* last */
56 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
57 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
59 * Single Write. (Offset 18 in UPMB RAM)
61 0x1F07FC04, 0xEEAEBC00, 0x01B93C04, 0x1FF77C47, /* last */
62 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
64 * Burst Write. (Offset 20 in UPMB RAM)
66 0x1F07FC04, 0xEEAEBC00, 0x10AD7C00, 0xF0AFFC00,
67 0xF0AFFC00, 0xE1BBBC04, 0x1FF77C47, /* last */
69 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
70 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
72 * Refresh (Offset 30 in UPMB RAM)
74 0x1FF5FC84, 0xFFFFFC04, 0xFFFFFC04, 0xFFFFFC04,
75 0xFFFFFC84, 0xFFFFFC07, /* last */
76 _NOT_USED_, _NOT_USED_,
77 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
79 * Exception. (Offset 3c in UPMB RAM)
81 0x7FFFFC07, /* last */
82 _NOT_USED_, _NOT_USED_, _NOT_USED_,
85 long int initdram (int board_type)
87 volatile immap_t *immr = (immap_t *) CFG_IMMR;
88 volatile memctl8xx_t *memctl = &immr->im_memctl;
89 /* volatile spc1920_pld_t *pld = (spc1920_pld_t *) CFG_SPC1920_PLD_BASE; */
92 long int size8, size9;
96 * Configure UPMB for SDRAM
98 upmconfig (UPMB, (uint *)sdram_table, sizeof(sdram_table)/sizeof(uint));
102 memctl->memc_mptpr = CFG_MPTPR;
104 /* burst length=4, burst type=sequential, CAS latency=2 */
105 memctl->memc_mar = CFG_MAR;
108 * Map controller bank 1 to the SDRAM bank at preliminary address.
110 memctl->memc_or1 = CFG_OR1_PRELIM;
111 memctl->memc_br1 = CFG_BR1_PRELIM;
113 /* initialize memory address register */
114 memctl->memc_mbmr = CFG_MBMR_8COL; /* refresh not enabled yet */
116 /* mode initialization (offset 5) */
117 udelay (200); /* 0x80006105 */
118 memctl->memc_mcr = MCR_OP_RUN | MCR_UPM_B | MCR_MB_CS1 | MCR_MLCF (1) | MCR_MAD (0x05);
120 /* run 2 refresh sequence with 4-beat refresh burst (offset 0x30) */
121 udelay (1); /* 0x80006130 */
122 memctl->memc_mcr = MCR_OP_RUN | MCR_UPM_B | MCR_MB_CS1 | MCR_MLCF (1) | MCR_MAD (0x30);
123 udelay (1); /* 0x80006130 */
124 memctl->memc_mcr = MCR_OP_RUN | MCR_UPM_B | MCR_MB_CS1 | MCR_MLCF (1) | MCR_MAD (0x30);
125 udelay (1); /* 0x80006106 */
126 memctl->memc_mcr = MCR_OP_RUN | MCR_UPM_B | MCR_MB_CS1 | MCR_MLCF (1) | MCR_MAD (0x06);
128 memctl->memc_mbmr |= MBMR_PTBE; /* refresh enabled */
132 /* Need at least 10 DRAM accesses to stabilize */
133 for (i = 0; i < 10; ++i) {
134 volatile unsigned long *addr =
135 (volatile unsigned long *) CFG_SDRAM_BASE;
143 * Check Bank 0 Memory Size for re-configuration
147 size8 = dram_size (CFG_MBMR_8COL, (long *)CFG_SDRAM_BASE, SDRAM_MAX_SIZE);
154 size9 = dram_size (CFG_MBMR_9COL, (long *)CFG_SDRAM_BASE, SDRAM_MAX_SIZE);
156 if (size8 < size9) { /* leave configuration at 9 columns */
158 memctl->memc_mbmr = CFG_MBMR_9COL | MBMR_PTBE;
160 } else { /* back to 8 columns */
162 memctl->memc_mbmr = CFG_MBMR_8COL | MBMR_PTBE;
170 memctl->memc_or1 = ((-size_b0) & 0xFFFF0000) |
171 OR_CSNT_SAM | OR_G5LS | SDRAM_TIMING;
172 memctl->memc_br1 = (CFG_SDRAM_BASE & BR_BA_MSK) | BR_MS_UPMB | BR_V;
177 memctl->memc_or5 = CFG_OR5_PRELIM;
178 memctl->memc_br5 = CFG_BR5_PRELIM;
185 * Check memory range for valid RAM. A simple memory test determines
186 * the actually available RAM size between addresses `base' and
187 * `base + maxsize'. Some (not all) hardware errors are detected:
188 * - short between address lines
189 * - short between data lines
191 static long int dram_size (long int mbmr_value, long int *base,
194 volatile immap_t *immap = (immap_t *) CFG_IMMR;
195 volatile memctl8xx_t *memctl = &immap->im_memctl;
197 memctl->memc_mbmr = mbmr_value;
199 return (get_ram_size (base, maxsize));
203 /************* other stuff ******************/
206 int board_early_init_f(void)
208 volatile immap_t *immap = (immap_t *) CFG_IMMR;
211 /* Turn on LED PD9 */
212 immap->im_ioport.iop_pdpar &= ~(0x0040);
213 immap->im_ioport.iop_pddir |= 0x0040;
214 immap->im_ioport.iop_pddat |= 0x0040;
216 /* Enable PD10 (COM2_EN) */
217 immap->im_ioport.iop_pdpar &= ~0x0020;
218 immap->im_ioport.iop_pddir &= ~0x4000;
219 immap->im_ioport.iop_pddir |= 0x0020;
220 immap->im_ioport.iop_pddat |= 0x0020;
223 #ifdef CFG_SMC1_PLD_CLK4 /* SMC1 uses CLK4 from PLD */
224 immap->im_cpm.cp_simode |= 0x7000;
225 immap->im_cpm.cp_simode &= ~(0x8000);
232 int checkboard (void)
234 puts("Board: SPC1920\n");