blob: 08575a4930cf437df4e03ee8f7d79b146b54a3d2 [file] [log] [blame]
wdenk5b1d7132002-11-03 00:07:02 +00001/*
2 * (C) Copyright 2000
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4 *
Wolfgang Denk1a459662013-07-08 09:37:19 +02005 * SPDX-License-Identifier: GPL-2.0+
wdenk5b1d7132002-11-03 00:07:02 +00006 */
7
8/*
9 * Yoo. Jonghoon, IPone, yooth@ipone.co.kr
10 * U-Boot port on RPXlite board
11 *
12 * DRAM related UPMA register values are modified.
13 * See RPXLite engineering note : 50MHz/60ns - UPM RAM WORDS
14 */
15
16#include <common.h>
17#include <mpc8xx.h>
18
19/* ------------------------------------------------------------------------- */
20
21static long int dram_size (long int, long int *, long int);
22
23/* ------------------------------------------------------------------------- */
24
25#define _NOT_USED_ 0xFFFFCC25
26
wdenkc83bf6a2004-01-06 22:38:14 +000027const uint sdram_table[] = {
wdenk5b1d7132002-11-03 00:07:02 +000028 /*
29 * Single Read. (Offset 00h in UPMA RAM)
30 */
31 0xCFFFCC24, 0x0FFFCC04, 0X0CAFCC04, 0X03AFCC08,
wdenkc83bf6a2004-01-06 22:38:14 +000032 0x3FBFCC27, /* last */
wdenk5b1d7132002-11-03 00:07:02 +000033 _NOT_USED_, _NOT_USED_, _NOT_USED_,
34
35 /*
36 * Burst Read. (Offset 08h in UPMA RAM)
37 */
38 0xCFFFCC24, 0x0FFFCC04, 0x0CAFCC84, 0x03AFCC88,
wdenkc83bf6a2004-01-06 22:38:14 +000039 0x3FBFCC27, /* last */
wdenk5b1d7132002-11-03 00:07:02 +000040 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
41 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
42 _NOT_USED_, _NOT_USED_, _NOT_USED_,
43
44 /*
45 * Single Write. (Offset 18h in UPMA RAM)
46 */
47 0xCFFFCC24, 0x0FFFCC04, 0x0CFFCC04, 0x03FFCC00,
wdenkc83bf6a2004-01-06 22:38:14 +000048 0x3FFFCC27, /* last */
wdenk5b1d7132002-11-03 00:07:02 +000049 _NOT_USED_, _NOT_USED_, _NOT_USED_,
50
51 /*
52 * Burst Write. (Offset 20h in UPMA RAM)
53 */
54 0xCFFFCC24, 0x0FFFCC04, 0x0CFFCC80, 0x03FFCC8C,
wdenkc83bf6a2004-01-06 22:38:14 +000055 0x0CFFCC00, 0x33FFCC27, /* last */
wdenk5b1d7132002-11-03 00:07:02 +000056 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
57 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
58 _NOT_USED_, _NOT_USED_,
59
60 /*
61 * Refresh. (Offset 30h in UPMA RAM)
62 */
63 0xC0FFCC24, 0x03FFCC24, 0x0FFFCC24, 0x0FFFCC24,
wdenkc83bf6a2004-01-06 22:38:14 +000064 0x3FFFCC27, /* last */
wdenk5b1d7132002-11-03 00:07:02 +000065 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
66 _NOT_USED_, _NOT_USED_, _NOT_USED_,
67
68 /*
69 * Exception. (Offset 3Ch in UPMA RAM)
70 */
71 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_
72};
73
74/* ------------------------------------------------------------------------- */
75
76
77/*
78 * Check Board Identity:
79 */
80
81int checkboard (void)
82{
wdenkc83bf6a2004-01-06 22:38:14 +000083 puts ("Board: RPXlite\n");
84 return (0);
wdenk5b1d7132002-11-03 00:07:02 +000085}
86
87/* ------------------------------------------------------------------------- */
88
Becky Bruce9973e3c2008-06-09 16:03:40 -050089phys_size_t initdram (int board_type)
wdenk5b1d7132002-11-03 00:07:02 +000090{
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020091 volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
wdenkc83bf6a2004-01-06 22:38:14 +000092 volatile memctl8xx_t *memctl = &immap->im_memctl;
93 long int size10;
wdenk5b1d7132002-11-03 00:07:02 +000094
wdenkc83bf6a2004-01-06 22:38:14 +000095 upmconfig (UPMA, (uint *) sdram_table,
96 sizeof (sdram_table) / sizeof (uint));
wdenk5b1d7132002-11-03 00:07:02 +000097
98 /* Refresh clock prescalar */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020099 memctl->memc_mptpr = CONFIG_SYS_MPTPR;
wdenk5b1d7132002-11-03 00:07:02 +0000100
wdenkc83bf6a2004-01-06 22:38:14 +0000101 memctl->memc_mar = 0x00000000;
wdenk5b1d7132002-11-03 00:07:02 +0000102
103 /* Map controller banks 1 to the SDRAM bank */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200104 memctl->memc_or1 = CONFIG_SYS_OR1_PRELIM;
105 memctl->memc_br1 = CONFIG_SYS_BR1_PRELIM;
wdenk5b1d7132002-11-03 00:07:02 +0000106
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200107 memctl->memc_mamr = CONFIG_SYS_MAMR_10COL & (~(MAMR_PTAE)); /* no refresh yet */
wdenk5b1d7132002-11-03 00:07:02 +0000108
wdenkc83bf6a2004-01-06 22:38:14 +0000109 udelay (200);
wdenk5b1d7132002-11-03 00:07:02 +0000110
wdenkc83bf6a2004-01-06 22:38:14 +0000111 /* perform SDRAM initializsation sequence */
wdenk5b1d7132002-11-03 00:07:02 +0000112
wdenkc83bf6a2004-01-06 22:38:14 +0000113 memctl->memc_mcr = 0x80002230; /* SDRAM bank 0 - refresh twice */
114 udelay (1);
wdenk5b1d7132002-11-03 00:07:02 +0000115
wdenkc83bf6a2004-01-06 22:38:14 +0000116 memctl->memc_mamr |= MAMR_PTAE; /* enable refresh */
wdenk5b1d7132002-11-03 00:07:02 +0000117
wdenkc83bf6a2004-01-06 22:38:14 +0000118 udelay (1000);
wdenk5b1d7132002-11-03 00:07:02 +0000119
120 /* Check Bank 0 Memory Size
121 * try 10 column mode
122 */
123
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200124 size10 = dram_size (CONFIG_SYS_MAMR_10COL, SDRAM_BASE_PRELIM,
wdenkc83bf6a2004-01-06 22:38:14 +0000125 SDRAM_MAX_SIZE);
wdenk5b1d7132002-11-03 00:07:02 +0000126
wdenkc83bf6a2004-01-06 22:38:14 +0000127 return (size10);
wdenk5b1d7132002-11-03 00:07:02 +0000128}
129
130/* ------------------------------------------------------------------------- */
131
132/*
133 * Check memory range for valid RAM. A simple memory test determines
134 * the actually available RAM size between addresses `base' and
135 * `base + maxsize'. Some (not all) hardware errors are detected:
136 * - short between address lines
137 * - short between data lines
138 */
139
wdenkc83bf6a2004-01-06 22:38:14 +0000140static long int dram_size (long int mamr_value, long int *base,
141 long int maxsize)
wdenk5b1d7132002-11-03 00:07:02 +0000142{
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200143 volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
wdenkc83bf6a2004-01-06 22:38:14 +0000144 volatile memctl8xx_t *memctl = &immap->im_memctl;
wdenk5b1d7132002-11-03 00:07:02 +0000145
wdenkc83bf6a2004-01-06 22:38:14 +0000146 memctl->memc_mamr = mamr_value;
wdenk5b1d7132002-11-03 00:07:02 +0000147
wdenkc83bf6a2004-01-06 22:38:14 +0000148 return (get_ram_size (base, maxsize));
wdenk5b1d7132002-11-03 00:07:02 +0000149}