4 * The GENIETV is using the following physical memorymap (copied from
5 * the FADS configuration):
7 * ff020000 -> ff02ffff : pcmcia
8 * ff010000 -> ff01ffff : BCSR connected to CS1, setup by 8xxROM
9 * ff000000 -> ff00ffff : IMAP internal in the cpu
10 * 02800000 -> 0287ffff : flash connected to CS0
11 * 00000000 -> nnnnnnnn : sdram setup by U-Boot
13 * CS pins are connected as follows:
15 * CS0 -512Kb boot flash
20 * CS5 - LON (if present)
24 * Ports are configured as follows:
26 * PA7 - SDRAM banks enable
32 #define CFG_PA7 0x0100
34 /* ------------------------------------------------------------------------- */
36 static long int dram_size (long int, long int *, long int);
38 /* ------------------------------------------------------------------------- */
40 #define _NOT_USED_ 0xFFFFFFFF
42 const uint sdram_table[] = {
44 * Single Read. (Offset 0 in UPMB RAM)
46 0x1F0DFC04, 0xEEAFBC04, 0x11AF7C04, 0xEFBEEC00,
47 0x1FFDDC47, /* last */
49 * SDRAM Initialization (offset 5 in UPMB RAM)
51 * This is no UPM entry point. The following definition uses
52 * the remaining space to establish an initialization
53 * sequence, which is executed by a RUN command.
56 0x1FFDDC34, 0xEFEEAC34, 0x1FBD5C35, /* last */
58 * Burst Read. (Offset 8 in UPMB RAM)
60 0x1F0DFC04, 0xEEAFBC04, 0x10AF7C04, 0xF0AFFC00,
61 0xF0AFFC00, 0xF1AFFC00, 0xEFBEEC00, 0x1FFDDC47, /* last */
62 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
63 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
65 * Single Write. (Offset 18 in UPMB RAM)
67 0x1F2DFC04, 0xEEAFAC00, 0x01BE4C04, 0x1FFDDC47, /* last */
68 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
70 * Burst Write. (Offset 20 in UPMB RAM)
72 0x1F0DFC04, 0xEEAFAC00, 0x10AF5C00, 0xF0AFFC00,
73 0xF0AFFC00, 0xE1BEEC04, 0x1FFDDC47, /* last */
75 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
76 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
78 * Refresh (Offset 30 in UPMB RAM)
80 0x1FFD7C84, 0xFFFFFC04, 0xFFFFFC04, 0xFFFFFC04,
81 0xFFFFFC84, 0xFFFFFC07, /* last */
82 _NOT_USED_, _NOT_USED_,
83 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
85 * Exception. (Offset 3c in UPMB RAM)
87 0x7FFFFC07, /* last */
88 _NOT_USED_, _NOT_USED_, _NOT_USED_,
91 /* ------------------------------------------------------------------------- */
95 * Check Board Identity
100 puts ("Board: GenieTV\n");
105 static void PrintState (void)
107 volatile immap_t *im = (immap_t *) CFG_IMMR;
108 volatile memctl8xx_t *memctl = &im->im_memctl;
110 printf ("\n0 - FLASH: B=%08x O=%08x", memctl->memc_br0,
112 printf ("\n1 - SDRAM: B=%08x O=%08x", memctl->memc_br1,
114 printf ("\n2 - SDRAM: B=%08x O=%08x", memctl->memc_br2,
119 /* ------------------------------------------------------------------------- */
121 long int initdram (int board_type)
123 volatile immap_t *im = (immap_t *) CFG_IMMR;
124 volatile memctl8xx_t *memctl = &im->im_memctl;
125 long int size_b0, size_b1, size8;
129 /* Configuring PA7 for general purpouse output pin */
130 im->im_ioport.iop_papar &= ~CFG_PA7; /* 0 = general purpouse */
131 im->im_ioport.iop_padir |= CFG_PA7; /* 1 = output */
133 /* Enable SDRAM - PA7 = 1 */
134 im->im_ioport.iop_padat |= CFG_PA7; /* value of PA7 */
137 * Preliminary prescaler for refresh (depends on number of
138 * banks): This value is selected for four cycles every 62.4 us
139 * with two SDRAM banks or four cycles every 31.2 us with one
140 * bank. It will be adjusted after memory sizing.
142 memctl->memc_mptpr = CFG_MPTPR_2BK_4K;
144 memctl->memc_mbmr = CFG_MBMR_8COL;
146 upmconfig (UPMB, (uint *) sdram_table,
147 sizeof (sdram_table) / sizeof (uint));
150 * Map controller banks 1 and 2 to the SDRAM banks 1 and 2 at
151 * preliminary addresses - these have to be modified after the
152 * SDRAM size has been determined.
155 memctl->memc_or1 = 0xF0000000 | CFG_OR_TIMING_SDRAM;
157 ((SDRAM_BASE1_PRELIM & BR_BA_MSK) | BR_MS_UPMB | BR_V);
159 memctl->memc_or2 = 0xF0000000 | CFG_OR_TIMING_SDRAM;
161 ((SDRAM_BASE2_PRELIM & BR_BA_MSK) | BR_MS_UPMB | BR_V);
163 /* perform SDRAM initialization sequence */
164 memctl->memc_mar = 0x00000088;
166 memctl->memc_mcr = 0x80802105; /* SDRAM bank 0 */
168 memctl->memc_mcr = 0x80804105; /* SDRAM bank 1 */
170 /* Execute refresh 8 times */
171 memctl->memc_mbmr = (CFG_MBMR_8COL & ~MBMR_TLFB_MSK) | MBMR_TLFB_8X;
173 memctl->memc_mcr = 0x80802130; /* SDRAM bank 0 - execute twice */
175 memctl->memc_mcr = 0x80804130; /* SDRAM bank 1 - execute twice */
177 /* Execute refresh 4 times */
178 memctl->memc_mbmr = CFG_MBMR_8COL;
181 * Check Bank 0 Memory Size for re-configuration
189 /* printf ("\nChecking bank1..."); */
190 size8 = dram_size (CFG_MBMR_8COL, (long *) SDRAM_BASE1_PRELIM,
195 /* printf ("\nChecking bank2..."); */
197 dram_size (memctl->memc_mbmr, (long *) SDRAM_BASE2_PRELIM,
201 * Final mapping: map bigger bank first
204 memctl->memc_or1 = ((-size_b0) & 0xFFFF0000) | CFG_OR_TIMING_SDRAM;
205 memctl->memc_br1 = (CFG_SDRAM_BASE & BR_BA_MSK) | BR_MS_UPMB | BR_V;
209 * Position Bank 1 immediately above Bank 0
212 ((-size_b1) & 0xFFFF0000) | CFG_OR_TIMING_SDRAM;
214 ((CFG_SDRAM_BASE & BR_BA_MSK) | BR_MS_UPMB | BR_V) +
215 (size_b0 & BR_BA_MSK);
222 memctl->memc_br2 = 0;
223 /* adjust refresh rate depending on SDRAM type, one bank */
224 memctl->memc_mptpr = CFG_MPTPR_1BK_4K;
227 /* If no memory detected, disable SDRAM */
228 if ((size_b0 + size_b1) == 0) {
229 printf ("disabling SDRAM!\n");
230 /* Disable SDRAM - PA7 = 1 */
231 im->im_ioport.iop_padat &= ~CFG_PA7; /* value of PA7 */
234 /* printf("done! (%08lx)\n", size_b0 + size_b1); */
239 return (size_b0 + size_b1);
242 /* ------------------------------------------------------------------------- */
245 * Check memory range for valid RAM. A simple memory test determines
246 * the actually available RAM size between addresses `base' and
247 * `base + maxsize'. Some (not all) hardware errors are detected:
248 * - short between address lines
249 * - short between data lines
252 static long int dram_size (long int mbmr_value, long int *base,
257 /*memctl->memc_mbmr = mbmr_value; */
259 size = get_ram_size (base, maxsize);
262 /* printf("(%08lx)", size); */
270 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
272 #ifdef CFG_PCMCIA_MEM_ADDR
273 volatile unsigned char *pcmcia_mem = (unsigned char *) CFG_PCMCIA_MEM_ADDR;
276 int pcmcia_init (void)
278 volatile pcmconf8xx_t *pcmp;
279 uint v, slota, slotb;
282 ** Enable the PCMCIA for a Flash card.
284 pcmp = (pcmconf8xx_t *) (&(((immap_t *) CFG_IMMR)->im_pcmcia));
287 pcmp->pcmc_pbr0 = CFG_PCMCIA_MEM_ADDR;
288 pcmp->pcmc_por0 = 0xc00ff05d;
291 /* Set all slots to zero by default. */
292 pcmp->pcmc_pgcra = 0;
293 pcmp->pcmc_pgcrb = 0;
295 pcmp->pcmc_pgcra = 0x40;
298 pcmp->pcmc_pgcrb = 0x40;
301 /* Check if any PCMCIA card is luged in. */
302 slota = (pcmp->pcmc_pipr & 0x18000000) == 0;
303 slotb = (pcmp->pcmc_pipr & 0x00001800) == 0;
305 if (!(slota || slotb)) {
306 printf ("No card present\n");
308 pcmp->pcmc_pgcra = 0;
311 pcmp->pcmc_pgcrb = 0;
315 printf ("Unknown card (");
319 switch ((pcmp->pcmc_pipr >> 14) & 3) {
325 printf ("5V and 3V");
329 printf ("5V, 3V and x.xV");
336 printf ("; using 3V");
337 /* Enable 3 volt Vcc. */
342 printf ("; unknown voltage");
346 /* disable pcmcia reset after a while */
350 pcmp->pcmc_pgcrb = 0;
352 /* If you using a real hd you should give a short
354 #ifdef CONFIG_DISK_SPINUP_TIME
355 udelay (CONFIG_DISK_SPINUP_TIME);
360 #endif /* CFG_CMD_PCMCIA */