]>
Commit | Line | Data |
---|---|---|
e2211743 WD |
1 | /*********************************************************************** |
2 | * | |
3 | M* Modul: lwmon.c | |
4 | M* | |
5 | M* Content: LWMON specific U-Boot commands. | |
6 | * | |
7 | * (C) Copyright 2001, 2002 | |
8 | * DENX Software Engineering | |
9 | * Wolfgang Denk, [email protected] | |
10 | * All rights reserved. | |
11 | * | |
12 | D* Design: [email protected] | |
13 | C* Coding: [email protected] | |
14 | V* Verification: [email protected] | |
15 | * | |
16 | * See file CREDITS for list of people who contributed to this | |
17 | * project. | |
18 | * | |
19 | * This program is free software; you can redistribute it and/or | |
20 | * modify it under the terms of the GNU General Public License as | |
21 | * published by the Free Software Foundation; either version 2 of | |
22 | * the License, or (at your option) any later version. | |
23 | * | |
24 | * This program is distributed in the hope that it will be useful, | |
25 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
26 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
27 | * GNU General Public License for more details. | |
28 | * | |
29 | * You should have received a copy of the GNU General Public License | |
30 | * along with this program; if not, write to the Free Software | |
31 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, | |
32 | * MA 02111-1307 USA | |
33 | ***********************************************************************/ | |
34 | ||
35 | /*---------------------------- Headerfiles ----------------------------*/ | |
36 | #include <common.h> | |
37 | #include <mpc8xx.h> | |
38 | #include <commproc.h> | |
39 | #include <i2c.h> | |
40 | #include <command.h> | |
e2211743 WD |
41 | #include <malloc.h> |
42 | #include <post.h> | |
281e00a3 | 43 | #include <serial.h> |
e2211743 WD |
44 | |
45 | #include <linux/types.h> | |
46 | #include <linux/string.h> /* for strdup */ | |
47 | ||
d87080b7 WD |
48 | DECLARE_GLOBAL_DATA_PTR; |
49 | ||
e2211743 WD |
50 | /*------------------------ Local prototypes ---------------------------*/ |
51 | static long int dram_size (long int, long int *, long int); | |
4532cb69 WD |
52 | static void kbd_init (void); |
53 | static int compare_magic (uchar *kbd_data, uchar *str); | |
e2211743 WD |
54 | |
55 | ||
56 | /*--------------------- Local macros and constants --------------------*/ | |
57 | #define _NOT_USED_ 0xFFFFFFFF | |
58 | ||
4532cb69 WD |
59 | #ifdef CONFIG_MODEM_SUPPORT |
60 | static int key_pressed(void); | |
61 | extern void disable_putc(void); | |
62 | #endif /* CONFIG_MODEM_SUPPORT */ | |
63 | ||
e2211743 WD |
64 | /* |
65 | * 66 MHz SDRAM access using UPM A | |
66 | */ | |
67 | const uint sdram_table[] = | |
68 | { | |
69 | #if defined(CFG_MEMORY_75) || defined(CFG_MEMORY_8E) | |
70 | /* | |
71 | * Single Read. (Offset 0 in UPM RAM) | |
72 | */ | |
73 | 0x1F0DFC04, 0xEEAFBC04, 0x11AF7C04, 0xEFBAFC00, | |
74 | 0x1FF5FC47, /* last */ | |
75 | /* | |
76 | * SDRAM Initialization (offset 5 in UPM RAM) | |
77 | * | |
8bde7f77 WD |
78 | * This is no UPM entry point. The following definition uses |
79 | * the remaining space to establish an initialization | |
80 | * sequence, which is executed by a RUN command. | |
e2211743 WD |
81 | * |
82 | */ | |
83 | 0x1FF5FC34, 0xEFEABC34, 0x1FB57C35, /* last */ | |
84 | /* | |
85 | * Burst Read. (Offset 8 in UPM RAM) | |
86 | */ | |
87 | 0x1F0DFC04, 0xEEAFBC04, 0x10AF7C04, 0xF0AFFC00, | |
88 | 0xF0AFFC00, 0xF1AFFC00, 0xEFBAFC00, 0x1FF5FC47, /* last */ | |
89 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, | |
90 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, | |
91 | /* | |
92 | * Single Write. (Offset 18 in UPM RAM) | |
93 | */ | |
94 | 0x1F2DFC04, 0xEEABBC00, 0x01B27C04, 0x1FF5FC47, /* last */ | |
95 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, | |
96 | /* | |
97 | * Burst Write. (Offset 20 in UPM RAM) | |
98 | */ | |
99 | 0x1F0DFC04, 0xEEABBC00, 0x10A77C00, 0xF0AFFC00, | |
100 | 0xF0AFFC00, 0xE1BAFC04, 0x01FF5FC47, /* last */ | |
101 | _NOT_USED_, | |
102 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, | |
103 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, | |
104 | /* | |
105 | * Refresh (Offset 30 in UPM RAM) | |
106 | */ | |
107 | 0x1FFD7C84, 0xFFFFFC04, 0xFFFFFC04, 0xFFFFFC04, | |
108 | 0xFFFFFC84, 0xFFFFFC07, /* last */ | |
109 | _NOT_USED_, _NOT_USED_, | |
110 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, | |
111 | /* | |
112 | * Exception. (Offset 3c in UPM RAM) | |
113 | */ | |
114 | 0x7FFFFC07, /* last */ | |
115 | 0xFFFFFCFF, 0xFFFFFCFF, 0xFFFFFCFF, | |
116 | #endif | |
117 | #ifdef CFG_MEMORY_7E | |
118 | /* | |
119 | * Single Read. (Offset 0 in UPM RAM) | |
120 | */ | |
121 | 0x0E2DBC04, 0x11AF7C04, 0xEFBAFC00, 0x1FF5FC47, /* last */ | |
122 | _NOT_USED_, | |
123 | /* | |
124 | * SDRAM Initialization (offset 5 in UPM RAM) | |
125 | * | |
8bde7f77 WD |
126 | * This is no UPM entry point. The following definition uses |
127 | * the remaining space to establish an initialization | |
128 | * sequence, which is executed by a RUN command. | |
e2211743 WD |
129 | * |
130 | */ | |
131 | 0x1FF5FC34, 0xEFEABC34, 0x1FB57C35, /* last */ | |
132 | /* | |
133 | * Burst Read. (Offset 8 in UPM RAM) | |
134 | */ | |
135 | 0x0E2DBC04, 0x10AF7C04, 0xF0AFFC00, 0xF0AFFC00, | |
136 | 0xF1AFFC00, 0xEFBAFC00, 0x1FF5FC47, /* last */ | |
8bde7f77 | 137 | _NOT_USED_, |
e2211743 WD |
138 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, |
139 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, | |
140 | /* | |
141 | * Single Write. (Offset 18 in UPM RAM) | |
142 | */ | |
143 | 0x0E29BC04, 0x01B27C04, 0x1FF5FC47, /* last */ | |
144 | _NOT_USED_, | |
145 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, | |
146 | /* | |
147 | * Burst Write. (Offset 20 in UPM RAM) | |
148 | */ | |
149 | 0x0E29BC04, 0x10A77C00, 0xF0AFFC00, 0xF0AFFC00, | |
150 | 0xE1BAFC04, 0x1FF5FC47, /* last */ | |
8bde7f77 | 151 | _NOT_USED_, _NOT_USED_, |
e2211743 WD |
152 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, |
153 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, | |
154 | /* | |
155 | * Refresh (Offset 30 in UPM RAM) | |
156 | */ | |
157 | 0x1FFD7C84, 0xFFFFFC04, 0xFFFFFC04, 0xFFFFFC04, | |
158 | 0xFFFFFC84, 0xFFFFFC07, /* last */ | |
159 | _NOT_USED_, _NOT_USED_, | |
160 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, | |
161 | /* | |
162 | * Exception. (Offset 3c in UPM RAM) | |
163 | */ | |
164 | 0x7FFFFC07, /* last */ | |
165 | 0xFFFFFCFF, 0xFFFFFCFF, 0xFFFFFCFF, | |
166 | #endif | |
167 | }; | |
168 | ||
169 | /* | |
170 | * Check Board Identity: | |
171 | * | |
172 | */ | |
173 | ||
174 | /*********************************************************************** | |
175 | F* Function: int checkboard (void) P*A*Z* | |
176 | * | |
177 | P* Parameters: none | |
178 | P* | |
179 | P* Returnvalue: int - 0 is always returned | |
180 | * | |
181 | Z* Intention: This function is the checkboard() method implementation | |
182 | Z* for the lwmon board. Only a standard message is printed. | |
183 | * | |
184 | D* Design: [email protected] | |
185 | C* Coding: [email protected] | |
186 | V* Verification: [email protected] | |
187 | ***********************************************************************/ | |
188 | int checkboard (void) | |
189 | { | |
ee073a55 | 190 | puts ("Board: LICCON Konsole LCD3\n"); |
e2211743 WD |
191 | return (0); |
192 | } | |
193 | ||
194 | /*********************************************************************** | |
195 | F* Function: long int initdram (int board_type) P*A*Z* | |
196 | * | |
197 | P* Parameters: int board_type | |
198 | P* - Usually type of the board - ignored here. | |
199 | P* | |
200 | P* Returnvalue: long int | |
201 | P* - Size of initialized memory | |
202 | * | |
203 | Z* Intention: This function is the initdram() method implementation | |
204 | Z* for the lwmon board. | |
205 | Z* The memory controller is initialized to access the | |
206 | Z* DRAM. | |
207 | * | |
208 | D* Design: [email protected] | |
209 | C* Coding: [email protected] | |
210 | V* Verification: [email protected] | |
211 | ***********************************************************************/ | |
212 | long int initdram (int board_type) | |
213 | { | |
214 | volatile immap_t *immr = (immap_t *) CFG_IMMR; | |
215 | volatile memctl8xx_t *memctl = &immr->im_memctl; | |
216 | long int size_b0; | |
217 | long int size8, size9; | |
218 | int i; | |
219 | ||
220 | /* | |
221 | * Configure UPMA for SDRAM | |
222 | */ | |
223 | upmconfig (UPMA, (uint *)sdram_table, sizeof(sdram_table)/sizeof(uint)); | |
224 | ||
225 | memctl->memc_mptpr = CFG_MPTPR; | |
226 | ||
227 | /* burst length=4, burst type=sequential, CAS latency=2 */ | |
228 | memctl->memc_mar = CFG_MAR; | |
229 | ||
230 | /* | |
231 | * Map controller bank 3 to the SDRAM bank at preliminary address. | |
232 | */ | |
233 | memctl->memc_or3 = CFG_OR3_PRELIM; | |
234 | memctl->memc_br3 = CFG_BR3_PRELIM; | |
235 | ||
236 | /* initialize memory address register */ | |
237 | memctl->memc_mamr = CFG_MAMR_8COL; /* refresh not enabled yet */ | |
238 | ||
239 | /* mode initialization (offset 5) */ | |
240 | udelay (200); /* 0x80006105 */ | |
241 | memctl->memc_mcr = MCR_OP_RUN | MCR_MB_CS3 | MCR_MLCF (1) | MCR_MAD (0x05); | |
242 | ||
243 | /* run 2 refresh sequence with 4-beat refresh burst (offset 0x30) */ | |
244 | udelay (1); /* 0x80006130 */ | |
245 | memctl->memc_mcr = MCR_OP_RUN | MCR_MB_CS3 | MCR_MLCF (1) | MCR_MAD (0x30); | |
246 | udelay (1); /* 0x80006130 */ | |
247 | memctl->memc_mcr = MCR_OP_RUN | MCR_MB_CS3 | MCR_MLCF (1) | MCR_MAD (0x30); | |
248 | ||
249 | udelay (1); /* 0x80006106 */ | |
250 | memctl->memc_mcr = MCR_OP_RUN | MCR_MB_CS3 | MCR_MLCF (1) | MCR_MAD (0x06); | |
251 | ||
2535d602 | 252 | memctl->memc_mamr |= MAMR_PTAE; /* refresh enabled */ |
e2211743 WD |
253 | |
254 | udelay (200); | |
255 | ||
256 | /* Need at least 10 DRAM accesses to stabilize */ | |
257 | for (i = 0; i < 10; ++i) { | |
258 | volatile unsigned long *addr = | |
259 | (volatile unsigned long *) SDRAM_BASE3_PRELIM; | |
260 | unsigned long val; | |
261 | ||
262 | val = *(addr + i); | |
263 | *(addr + i) = val; | |
264 | } | |
265 | ||
266 | /* | |
267 | * Check Bank 0 Memory Size for re-configuration | |
268 | * | |
269 | * try 8 column mode | |
270 | */ | |
77ddac94 | 271 | size8 = dram_size (CFG_MAMR_8COL, (long *)SDRAM_BASE3_PRELIM, SDRAM_MAX_SIZE); |
e2211743 WD |
272 | |
273 | udelay (1000); | |
274 | ||
275 | /* | |
276 | * try 9 column mode | |
277 | */ | |
77ddac94 | 278 | size9 = dram_size (CFG_MAMR_9COL, (long *)SDRAM_BASE3_PRELIM, SDRAM_MAX_SIZE); |
e2211743 WD |
279 | |
280 | if (size8 < size9) { /* leave configuration at 9 columns */ | |
281 | size_b0 = size9; | |
2535d602 | 282 | memctl->memc_mamr = CFG_MAMR_9COL | MAMR_PTAE; |
e2211743 WD |
283 | udelay (500); |
284 | } else { /* back to 8 columns */ | |
285 | size_b0 = size8; | |
2535d602 | 286 | memctl->memc_mamr = CFG_MAMR_8COL | MAMR_PTAE; |
e2211743 WD |
287 | udelay (500); |
288 | } | |
289 | ||
290 | /* | |
291 | * Final mapping: | |
292 | */ | |
293 | ||
294 | memctl->memc_or3 = ((-size_b0) & 0xFFFF0000) | | |
295 | OR_CSNT_SAM | OR_G5LS | SDRAM_TIMING; | |
296 | memctl->memc_br3 = (CFG_SDRAM_BASE & BR_BA_MSK) | BR_MS_UPMA | BR_V; | |
297 | udelay (1000); | |
298 | ||
299 | return (size_b0); | |
300 | } | |
301 | ||
302 | /*********************************************************************** | |
303 | F* Function: static long int dram_size (long int mamr_value, | |
304 | F* long int *base, | |
305 | F* long int maxsize) P*A*Z* | |
306 | * | |
307 | P* Parameters: long int mamr_value | |
308 | P* - Value for MAMR for the test | |
309 | P* long int *base | |
310 | P* - Base address for the test | |
311 | P* long int maxsize | |
312 | P* - Maximum size to test for | |
313 | P* | |
314 | P* Returnvalue: long int | |
315 | P* - Size of probed memory | |
316 | * | |
317 | Z* Intention: Check memory range for valid RAM. A simple memory test | |
318 | Z* determines the actually available RAM size between | |
319 | Z* addresses `base' and `base + maxsize'. Some (not all) | |
320 | Z* hardware errors are detected: | |
321 | Z* - short between address lines | |
322 | Z* - short between data lines | |
323 | * | |
324 | D* Design: [email protected] | |
325 | C* Coding: [email protected] | |
326 | V* Verification: [email protected] | |
327 | ***********************************************************************/ | |
328 | static long int dram_size (long int mamr_value, long int *base, long int maxsize) | |
329 | { | |
330 | volatile immap_t *immr = (immap_t *) CFG_IMMR; | |
331 | volatile memctl8xx_t *memctl = &immr->im_memctl; | |
e2211743 WD |
332 | |
333 | memctl->memc_mamr = mamr_value; | |
334 | ||
c83bf6a2 | 335 | return (get_ram_size(base, maxsize)); |
e2211743 WD |
336 | } |
337 | ||
338 | /* ------------------------------------------------------------------------- */ | |
339 | ||
340 | #ifndef PB_ENET_TENA | |
341 | # define PB_ENET_TENA ((uint)0x00002000) /* PB 18 */ | |
342 | #endif | |
343 | ||
344 | /*********************************************************************** | |
c837dcb1 | 345 | F* Function: int board_early_init_f (void) P*A*Z* |
e2211743 WD |
346 | * |
347 | P* Parameters: none | |
348 | P* | |
349 | P* Returnvalue: int | |
350 | P* - 0 is always returned. | |
351 | * | |
c837dcb1 | 352 | Z* Intention: This function is the board_early_init_f() method implementation |
e2211743 WD |
353 | Z* for the lwmon board. |
354 | Z* Disable Ethernet TENA on Port B. | |
355 | * | |
356 | D* Design: [email protected] | |
357 | C* Coding: [email protected] | |
358 | V* Verification: [email protected] | |
359 | ***********************************************************************/ | |
c837dcb1 | 360 | int board_early_init_f (void) |
e2211743 WD |
361 | { |
362 | volatile immap_t *immr = (immap_t *) CFG_IMMR; | |
363 | ||
364 | /* Disable Ethernet TENA on Port B | |
365 | * Necessary because of pull up in COM3 port. | |
366 | * | |
367 | * This is just a preliminary fix, intended to turn off TENA | |
368 | * as soon as possible to avoid noise on the network. Once | |
369 |