blob: 7ff99459b7ad480a2c59d7bce9cc3707909367b2 [file] [log] [blame]
wdenk174e0e52003-12-07 22:27:15 +00001/*
2 * (C) Copyright 2003
3 * MuLogic B.V.
4 *
5 * (C) Copyright 2002
6 * Simple Network Magic Corporation, dnevil@snmc.com
7 *
8 * (C) Copyright 2000
9 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
10 *
Wolfgang Denkd79de1d2013-07-08 09:37:19 +020011 * SPDX-License-Identifier: GPL-2.0+
wdenk174e0e52003-12-07 22:27:15 +000012 */
13
14#include <common.h>
15#include <asm/u-boot.h>
16#include <commproc.h>
17#include "mpc8xx.h"
18
19/* ------------------------------------------------------------------------- */
20
21static long int dram_size (long int, long int *, long int);
22
23/* ------------------------------------------------------------------------- */
24
25const uint sdram_table[] =
26{
27 /*
28 * Single Read. (Offset 0 in UPMA RAM)
29 */
30 0x1F07FC04, 0xEEAEFC04, 0x11ADFC04, 0xEFBBBC00,
31 0x1FF77C47, 0x1FF77C35, 0xEFEABC34, 0x1FB57C35,
32 /*
33 * Burst Read. (Offset 8 in UPMA RAM)
34 */
35 0x1F07FC04, 0xEEAEFC04, 0x10ADFC04, 0xF0AFFC00,
36 0xF0AFFC00, 0xF1AFFC00, 0xEFBBBC00, 0x1FF77C47,
37 0xFFFFEC04, 0xFFFFEC04, 0xFFFFEC04, 0xFFFFEC04,
38 0xFFFFEC04, 0xFFFFEC04, 0xFFFFEC04, 0xFFFFEC04,
39 /*
40 * Single Write. (Offset 18 in UPMA RAM)
41 */
42 0x1F27FC04, 0xEEAEBC00, 0x01B93C04, 0x1FF77C47,
43 0xFFFFEC04, 0xFFFFEC04, 0xFFFFEC04, 0xFFFFEC04,
44 /*
45 * Burst Write. (Offset 20 in UPMA RAM)
46 */
47 0x1F07FC04, 0xEEAEBC00, 0x10AD7C00, 0xF0AFFC00,
48 0xF0AFFC00, 0xE1BBBC04, 0x1FF77C47, 0xFFFFEC04,
49 0xFFFFEC04, 0xFFFFEC04, 0xFFFFEC04, 0xFFFFEC04,
50 0xFFFFEC04, 0xFFFFEC04, 0xFFFFEC04, 0xFFFFEC04,
51 /*
52 * Refresh (Offset 30 in UPMA RAM)
53 */
54 0x1FF5FC84, 0xFFFFFC04, 0xFFFFFC04, 0xFFFFFC04,
55 0xFFFFFC84, 0xFFFFFC07, 0xFFFFEC04, 0xFFFFEC04,
56 0xFFFFEC04, 0xFFFFEC04, 0xFFFFEC04, 0xFFFFEC04,
57 /*
58 * Exception. (Offset 3c in UPMA RAM)
59 */
60 0x7FFFFC07, 0xFFFFEC04, 0xFFFFEC04, 0xFFFFEC04
61};
62
63/* ------------------------------------------------------------------------- */
64
65
66/*
67 * Check Board Identity:
68 *
69 * Test ID string (QS860T...)
70 *
71 * Always return 1
72 */
73
74int checkboard (void)
75{
Wolfgang Denk7fb52662005-10-13 16:45:02 +020076 char *s, *e;
77 char buf[64];
wdenk174e0e52003-12-07 22:27:15 +000078 int i;
79
Wolfgang Denk76af2782010-07-24 21:55:43 +020080 i = getenv_f("serial#", buf, sizeof(buf));
wdenk174e0e52003-12-07 22:27:15 +000081 s = (i>0) ? buf : NULL;
82
83 if (!s || strncmp(s, "QS860T", 6)) {
84 puts ("### No HW ID - assuming QS860T");
85 } else {
86 for (e=s; *e; ++e) {
87 if (*e == ' ')
88 break;
89 }
90
91 for ( ; s<e; ++s) {
92 putc (*s);
93 }
94 }
95 putc ('\n');
96
97 return (0);
98}
99
100/* ------------------------------------------------------------------------- */
101
Becky Brucebd99ae72008-06-09 16:03:40 -0500102phys_size_t initdram (int board_type)
wdenk174e0e52003-12-07 22:27:15 +0000103{
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200104 volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
wdenk174e0e52003-12-07 22:27:15 +0000105 volatile memctl8xx_t *memctl = &immap->im_memctl;
106 long int size;
107
108 upmconfig(UPMB, (uint *)sdram_table, sizeof(sdram_table)/sizeof(uint));
109
110 /*
111 * Prescaler for refresh
112 */
113 memctl->memc_mptpr = 0x0400;
114
115 /*
116 * Map controller bank 2 to the SDRAM address
117 */
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200118 memctl->memc_or2 = CONFIG_SYS_OR2;
119 memctl->memc_br2 = CONFIG_SYS_BR2;
wdenk174e0e52003-12-07 22:27:15 +0000120 udelay(200);
121
122 /* perform SDRAM initialization sequence */
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200123 memctl->memc_mbmr = CONFIG_SYS_16M_MBMR;
wdenk174e0e52003-12-07 22:27:15 +0000124 udelay(100);
125
126 memctl->memc_mar = 0x00000088;
127 memctl->memc_mcr = 0x80804105; /* run precharge pattern */
128 udelay(1);
129
130 /* Run two refresh cycles on SDRAM */
131 memctl->memc_mbmr = 0x18802118;
132 memctl->memc_mcr = 0x80804130;
133 memctl->memc_mbmr = 0x18802114;
134 memctl->memc_mcr = 0x80804106;
135
136 udelay (1000);
137
138#if 0
139 /*
140 * Check for 64M SDRAM Memory Size
141 */
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200142 size = dram_size (CONFIG_SYS_64M_MBMR, (ulong *)SDRAM_BASE, SDRAM_64M_MAX_SIZE);
wdenk174e0e52003-12-07 22:27:15 +0000143 udelay (1000);
144
145 /*
146 * Check for 16M SDRAM Memory Size
147 */
148 if (size != SDRAM_64M_MAX_SIZE) {
149#endif
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200150 size = dram_size (CONFIG_SYS_16M_MBMR, (long *)SDRAM_BASE, SDRAM_16M_MAX_SIZE);
wdenk174e0e52003-12-07 22:27:15 +0000151 udelay (1000);
152#if 0
153 }
154
155 memctl->memc_or2 = ((-size) & 0xFFFF0000) | SDRAM_TIMING;
156#endif
157
158
159 udelay(10000);
160
161
162#if 0
163
164 /*
165 * Also, map other memory to correct position
166 */
167
168 /*
169 * Map the 8M Intel Flash device to chip select 1
170 */
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200171 memctl->memc_or1 = CONFIG_SYS_OR1;
172 memctl->memc_br1 = CONFIG_SYS_BR1;
wdenk174e0e52003-12-07 22:27:15 +0000173
174
175 /*
176 * Map 64K NVRAM, Sipex Device, NAND Ctl Reg, and LED Ctl Reg
177 * to chip select 3
178 */
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200179 memctl->memc_or3 = CONFIG_SYS_OR3;
180 memctl->memc_br3 = CONFIG_SYS_BR3;
wdenk174e0e52003-12-07 22:27:15 +0000181
182 /*
183 * Map chip selects 4, 5, 6, & 7 for external expansion connector
184 */
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200185 memctl->memc_or4 = CONFIG_SYS_OR4;
186 memctl->memc_br4 = CONFIG_SYS_BR4;
wdenk174e0e52003-12-07 22:27:15 +0000187
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200188 memctl->memc_or5 = CONFIG_SYS_OR5;
189 memctl->memc_br5 = CONFIG_SYS_BR5;
wdenk174e0e52003-12-07 22:27:15 +0000190
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200191 memctl->memc_or6 = CONFIG_SYS_OR6;
192 memctl->memc_br6 = CONFIG_SYS_BR6;
wdenk174e0e52003-12-07 22:27:15 +0000193
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200194 memctl->memc_or7 = CONFIG_SYS_OR7;
195 memctl->memc_br7 = CONFIG_SYS_BR7;
wdenk174e0e52003-12-07 22:27:15 +0000196
197#endif
198
199 return (size);
200}
201
202/* ------------------------------------------------------------------------- */
203
204/*
205 * Check memory range for valid RAM. A simple memory test determines
206 * the actually available RAM size between addresses `base' and
207 * `base + maxsize'. Some (not all) hardware errors are detected:
208 * - short between address lines
209 * - short between data lines
210 */
211
212static long int dram_size (long int mbmr_value, long int *base, long int maxsize)
213{
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200214 volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
wdenk174e0e52003-12-07 22:27:15 +0000215 volatile memctl8xx_t *memctl = &immap->im_memctl;
wdenk174e0e52003-12-07 22:27:15 +0000216
217 memctl->memc_mbmr = mbmr_value;
218
wdenk87249ba2004-01-06 22:38:14 +0000219 return (get_ram_size(base, maxsize));
wdenk174e0e52003-12-07 22:27:15 +0000220}