blob: b54c61412a4d4146075d5e1049905ba222380221 [file] [log] [blame]
wdenk16f21702002-08-26 21:58:50 +00001/*
2 * (C) Copyright 2000
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4 *
Wolfgang Denkd79de1d2013-07-08 09:37:19 +02005 * SPDX-License-Identifier: GPL-2.0+
wdenk16f21702002-08-26 21:58:50 +00006 *
7 * Modified By Conn Clark to work with Esteem 192E 7/31/00
wdenk16f21702002-08-26 21:58:50 +00008 */
9
10#include <common.h>
11#include <mpc8xx.h>
12
13/* ------------------------------------------------------------------------- */
14
wdenk16f21702002-08-26 21:58:50 +000015#define _NOT_USED_ 0xFFFFFFFF
16
wdenk87249ba2004-01-06 22:38:14 +000017const uint sdram_table[] = {
wdenk16f21702002-08-26 21:58:50 +000018 /*
19 * Single Read. (Offset 0 in UPMA RAM)
20 *
21 * active, NOP, read, precharge, NOP */
22 0x0F27CC04, 0x0EAECC04, 0x00B98C04, 0x00F74C00,
wdenk87249ba2004-01-06 22:38:14 +000023 0x11FFCC05, /* last */
wdenk16f21702002-08-26 21:58:50 +000024 /*
25 * SDRAM Initialization (offset 5 in UPMA RAM)
26 *
wdenk57b2d802003-06-27 21:31:46 +000027 * This is no UPM entry point. The following definition uses
28 * the remaining space to establish an initialization
29 * sequence, which is executed by a RUN command.
wdenk16f21702002-08-26 21:58:50 +000030 * NOP, Program
31 */
wdenk87249ba2004-01-06 22:38:14 +000032 0x0F0A8C34, 0x1F354C37, /* last */
wdenk16f21702002-08-26 21:58:50 +000033
wdenk87249ba2004-01-06 22:38:14 +000034 _NOT_USED_, /* Not used */
wdenk16f21702002-08-26 21:58:50 +000035
36 /*
37 * Burst Read. (Offset 8 in UPMA RAM)
38 * active, NOP, read, NOP, NOP, NOP, NOP, NOP */
39 0x0F37CC04, 0x0EFECC04, 0x00FDCC04, 0x00FFCC00,
wdenk87249ba2004-01-06 22:38:14 +000040 0x00FFCC00, 0x01FFCC00, 0x0FFFCC00, 0x1FFFCC05, /* last */
wdenk16f21702002-08-26 21:58:50 +000041 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
42 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
43 /*
44 * Single Write. (Offset 18 in UPMA RAM)
45 * active, NOP, write, NOP, precharge, NOP */
46 0x0F27CC04, 0x0EAE8C00, 0x01BD4C04, 0x0FFB8C04,
wdenk87249ba2004-01-06 22:38:14 +000047 0x0FF74C04, 0x1FFFCC05, /* last */
wdenk16f21702002-08-26 21:58:50 +000048 _NOT_USED_, _NOT_USED_,
49 /*
50 * Burst Write. (Offset 20 in UPMA RAM)
51 * active, NOP, write, NOP, NOP, NOP, NOP, NOP */
52 0x0F37CC04, 0x0EFE8C00, 0x00FD4C00, 0x00FFCC00,
wdenk87249ba2004-01-06 22:38:14 +000053 0x00FFCC00, 0x01FFCC04, 0x0FFFCC04, 0x1FFFCC05, /* last */
wdenk16f21702002-08-26 21:58:50 +000054 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
55 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
56 /*
57 * Refresh (Offset 30 in UPMA RAM)
58 * precharge, NOP, auto_ref, NOP, NOP, NOP */
59 0x0FF74C34, 0x0FFACCB4, 0x0FF5CC34, 0x0FFFCC34,
wdenk87249ba2004-01-06 22:38:14 +000060 0x0FFFCCB4, 0x1FFFCC35, /* last */
61 _NOT_USED_, _NOT_USED_,
wdenk16f21702002-08-26 21:58:50 +000062 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
63 /*
64 * Exception. (Offset 3c in UPMA RAM)
65 */
wdenk87249ba2004-01-06 22:38:14 +000066 0x0FFB8C00, 0x1FF74C03, /* last */
67 _NOT_USED_, _NOT_USED_
wdenk16f21702002-08-26 21:58:50 +000068};
69
70/* ------------------------------------------------------------------------- */
71
72
73/*
74 * Check Board Identity:
75 */
76
77int checkboard (void)
78{
wdenk87249ba2004-01-06 22:38:14 +000079 puts ("Board: Esteem 192E\n");
80 return (0);
wdenk16f21702002-08-26 21:58:50 +000081}
82
83/* ------------------------------------------------------------------------- */
84
85
Becky Brucebd99ae72008-06-09 16:03:40 -050086phys_size_t initdram (int board_type)
wdenk16f21702002-08-26 21:58:50 +000087{
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020088 volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
wdenk87249ba2004-01-06 22:38:14 +000089 volatile memctl8xx_t *memctl = &immap->im_memctl;
90 long int size_b0, size_b1;
wdenk16f21702002-08-26 21:58:50 +000091
wdenk87249ba2004-01-06 22:38:14 +000092 /*
93 * Explain frequency of refresh here
94 */
wdenk16f21702002-08-26 21:58:50 +000095
wdenk87249ba2004-01-06 22:38:14 +000096 memctl->memc_mptpr = 0x0200; /* divide by 32 */
wdenk16f21702002-08-26 21:58:50 +000097
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020098 memctl->memc_mamr = 0x18003112; /*CONFIG_SYS_MAMR_8COL; */ /* 0x18005112 TODO: explain here */
wdenk16f21702002-08-26 21:58:50 +000099
wdenk87249ba2004-01-06 22:38:14 +0000100 upmconfig (UPMA, (uint *) sdram_table,
101 sizeof (sdram_table) / sizeof (uint));
wdenk16f21702002-08-26 21:58:50 +0000102
wdenk87249ba2004-01-06 22:38:14 +0000103 /*
104 * Map cs 2 and 3 to the SDRAM banks 0 and 1 at
105 * preliminary addresses - these have to be modified after the
106 * SDRAM size has been determined.
107 */
wdenk16f21702002-08-26 21:58:50 +0000108
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200109 memctl->memc_or2 = CONFIG_SYS_OR2_PRELIM; /* not defined yet */
110 memctl->memc_br2 = CONFIG_SYS_BR2_PRELIM;
wdenk16f21702002-08-26 21:58:50 +0000111
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200112 memctl->memc_or3 = CONFIG_SYS_OR3_PRELIM;
113 memctl->memc_br3 = CONFIG_SYS_BR3_PRELIM;
wdenk16f21702002-08-26 21:58:50 +0000114
wdenk16f21702002-08-26 21:58:50 +0000115
wdenk87249ba2004-01-06 22:38:14 +0000116 /* perform SDRAM initializsation sequence */
117 memctl->memc_mar = 0x00000088;
118 memctl->memc_mcr = 0x80004830; /* SDRAM bank 0 execute 8 refresh */
119 memctl->memc_mcr = 0x80004105; /* SDRAM bank 0 */
wdenk16f21702002-08-26 21:58:50 +0000120
wdenk87249ba2004-01-06 22:38:14 +0000121 memctl->memc_mcr = 0x80006830; /* SDRAM bank 1 execute 8 refresh */
122 memctl->memc_mcr = 0x80006105; /* SDRAM bank 1 */
wdenk16f21702002-08-26 21:58:50 +0000123
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200124 memctl->memc_mamr = CONFIG_SYS_MAMR_8COL; /* 0x18803112 start refresh timer TODO: explain here */
wdenk16f21702002-08-26 21:58:50 +0000125
126/* printf ("banks 0 and 1 are programed\n"); */
127
wdenk87249ba2004-01-06 22:38:14 +0000128 /*
129 * Check Bank 0 Memory Size for re-configuration
130 *
131 */
Wolfgang Denk7fb52662005-10-13 16:45:02 +0200132 size_b0 = get_ram_size ( (long *)SDRAM_BASE2_PRELIM, SDRAM_MAX_SIZE);
133 size_b1 = get_ram_size ( (long *)SDRAM_BASE3_PRELIM, SDRAM_MAX_SIZE);
wdenk16f21702002-08-26 21:58:50 +0000134
wdenk87249ba2004-01-06 22:38:14 +0000135 printf ("\nbank 0 size %lu\nbank 1 size %lu\n", size_b0, size_b1);
wdenk16f21702002-08-26 21:58:50 +0000136
137/* printf ("bank 1 size %u\n",size_b1); */
138
wdenk87249ba2004-01-06 22:38:14 +0000139 if (size_b1 == 0) {
140 /*
141 * Adjust refresh rate if bank 0 isn't stuffed
142 */
143 memctl->memc_mptpr = 0x0400; /* divide by 64 */
144 memctl->memc_br3 &= 0x0FFFFFFFE;
wdenk16f21702002-08-26 21:58:50 +0000145
wdenk87249ba2004-01-06 22:38:14 +0000146 /*
147 * Adjust OR2 for size of bank 0
148 */
149 memctl->memc_or2 |= 7 * size_b0;
150 } else {
151 if (size_b0 < size_b1) {
152 memctl->memc_br2 &= 0x00007FFE;
153 memctl->memc_br3 &= 0x00007FFF;
wdenk16f21702002-08-26 21:58:50 +0000154
wdenk87249ba2004-01-06 22:38:14 +0000155 /*
156 * Adjust OR3 for size of bank 1
157 */
158 memctl->memc_or3 |= 15 * size_b1;
wdenk16f21702002-08-26 21:58:50 +0000159
wdenk87249ba2004-01-06 22:38:14 +0000160 /*
161 * Adjust OR2 for size of bank 0
162 */
163 memctl->memc_or2 |= 15 * size_b0;
164 memctl->memc_br2 += (size_b1 + 1);
165 } else {
166 memctl->memc_br3 &= 0x00007FFE;
wdenk16f21702002-08-26 21:58:50 +0000167
wdenk87249ba2004-01-06 22:38:14 +0000168 /*
169 * Adjust OR2 for size of bank 0
170 */
171 memctl->memc_or2 |= 15 * size_b0;
wdenk16f21702002-08-26 21:58:50 +0000172
wdenk87249ba2004-01-06 22:38:14 +0000173 /*
174 * Adjust OR3 for size of bank 1
175 */
176 memctl->memc_or3 |= 15 * size_b1;
177 memctl->memc_br3 += (size_b0 + 1);
178 }
179 }
wdenk16f21702002-08-26 21:58:50 +0000180
wdenk87249ba2004-01-06 22:38:14 +0000181 /* before leaving set all unused i/o pins to outputs */
wdenk16f21702002-08-26 21:58:50 +0000182
wdenk87249ba2004-01-06 22:38:14 +0000183 /*
184 * --*Unused Pin List*--
185 *
186 * group/port bit number
187 * IP_B 0,1,3,4,5 Taken care of in pcmcia-cs-x.x.xx
188 * PA 5,7,8,9,14,15
189 * PB 22,23,31
190 * PC 4,5,6,7,10,11,12,13,14,15
191 * PD 5,6,7
192 *
193 */
wdenk16f21702002-08-26 21:58:50 +0000194
wdenk87249ba2004-01-06 22:38:14 +0000195 /*
196 * --*Pin Used for I/O List*--
197 *
198 * port input bit number output bit number either
199 * PB 18,26,27
200 * PD 3,4 8,9,10,11,12,13,14,15
201 *
202 */
wdenk16f21702002-08-26 21:58:50 +0000203
wdenk87249ba2004-01-06 22:38:14 +0000204 immap->im_ioport.iop_papar &= ~0x05C3; /* set pins as io */
205 immap->im_ioport.iop_padir |= 0x05C3; /* set pins as output */
206 immap->im_ioport.iop_paodr &= 0x0008; /* config pins 9 & 14 as normal outputs */
207 immap->im_ioport.iop_padat |= 0x05C3; /* set unused pins as high */
wdenk16f21702002-08-26 21:58:50 +0000208
wdenk87249ba2004-01-06 22:38:14 +0000209 immap->im_cpm.cp_pbpar &= ~0x00001331; /* set unused port b pins as io */
210 immap->im_cpm.cp_pbdir |= 0x00001331; /* set unused port b pins as output */
211 immap->im_cpm.cp_pbodr &= ~0x00001331; /* config bits 18,22,23,26,27 & 31 as normal outputs */
212 immap->im_cpm.cp_pbdat |= 0x00001331; /* set T/E LED, /NV_CS, & /POWER_ADJ_CS and the rest to a high */
wdenk16f21702002-08-26 21:58:50 +0000213
wdenk87249ba2004-01-06 22:38:14 +0000214 immap->im_ioport.iop_pcpar &= ~0x0F3F; /* set unused port c pins as io */
215 immap->im_ioport.iop_pcdir |= 0x0F3F; /* set unused port c pins as output */
216 immap->im_ioport.iop_pcso &= ~0x0F3F; /* clear special purpose bit for unused port c pins for clarity */
217 immap->im_ioport.iop_pcdat |= 0x0F3F; /* set unused port c pins high */
wdenk16f21702002-08-26 21:58:50 +0000218
wdenk87249ba2004-01-06 22:38:14 +0000219 immap->im_ioport.iop_pdpar &= 0xE000; /* set pins as io */
220 immap->im_ioport.iop_pddir &= 0xE000; /* set bit 3 & 4 as inputs */
221 immap->im_ioport.iop_pddir |= 0x07FF; /* set bits 5 - 15 as outputs */
222 immap->im_ioport.iop_pddat = 0x0055; /* set alternating pattern on test port */
wdenk16f21702002-08-26 21:58:50 +0000223
wdenk87249ba2004-01-06 22:38:14 +0000224 return (size_b0 + size_b1);
wdenk16f21702002-08-26 21:58:50 +0000225}