blob: 438117e60c0097b5fc6be79546c05c2647857032 [file] [log] [blame]
wdenk608c9142003-01-13 23:54:46 +00001/*
2 * (C) Copyright 2003
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4 *
Wolfgang Denk1a459662013-07-08 09:37:19 +02005 * SPDX-License-Identifier: GPL-2.0+
wdenk608c9142003-01-13 23:54:46 +00006 */
7
8/*
9 * Yoo. Jonghoon, IPone, yooth@ipone.co.kr
wdenk3bac3512003-03-12 10:41:04 +000010 * U-Boot port on RPXlite board
wdenk608c9142003-01-13 23:54:46 +000011 *
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 (void);
22
23/* ------------------------------------------------------------------------- */
24
Wolfgang Denk53677ef2008-05-20 16:00:29 +020025#define MBYTE (1024*1024)
26#define DRAM_DELAY 0x00000379 /* DRAM delay count */
wdenk608c9142003-01-13 23:54:46 +000027#define _NOT_USED_ 0xFFFFCC25
28
29const uint sdram_table[] =
30{
wdenk8bde7f72003-06-27 21:31:46 +000031 /* single read. (offset 0 in upm RAM) */
32 0x1F07D004, 0xEEAEE004, 0x11ADD004, 0xEFBBA000,
33 0x1FF75447, 0x1FF77C34, 0xEFEABC34, 0x1FB57C35,
wdenk608c9142003-01-13 23:54:46 +000034
wdenk8bde7f72003-06-27 21:31:46 +000035 /* burst read. (Offset 8 in upm RAM) */
36 0x1F07D004, 0xEEAEE004, 0x00ADC004, 0x00AFC000,
37 0x00AFC000, 0x01AFC000, 0x0FBB8000, 0x1FF75447,
38 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
39 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
wdenk608c9142003-01-13 23:54:46 +000040
wdenk8bde7f72003-06-27 21:31:46 +000041 /* single write. (Offset 0x18 in upm RAM) */
42 0x1F27D004, 0xEEAEA000, 0x01B90004, 0x1FF75447,
43 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
wdenk608c9142003-01-13 23:54:46 +000044
wdenk8bde7f72003-06-27 21:31:46 +000045 /* burst write. (Offset 0x20 in upm RAM) */
46 0x1F07D004, 0xEEAEA000, 0x00AD4000, 0x00AFC000,
47 0x00AFC000, 0x01BB8004, 0x1FF75447, 0xFFFFFFFF,
48 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
49 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
wdenk608c9142003-01-13 23:54:46 +000050
wdenk8bde7f72003-06-27 21:31:46 +000051 /* Refresh cycle, offset 0x30 */
52 0x1FF5DC84, 0xFFFFFC04, 0xFFFFFC04, 0xFFFFFC04,
53 0xFFFFFC84, 0xFFFFFC07, 0xFFFFFFFF, 0xFFFFFFFF,
54 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
wdenk608c9142003-01-13 23:54:46 +000055
wdenk8bde7f72003-06-27 21:31:46 +000056 /* Exception, 0ffset 0x3C */
57 0x7FFFFC07, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
wdenk608c9142003-01-13 23:54:46 +000058};
59/* ------------------------------------------------------------------------- */
60
61
62/*
63 * Check Board Identity:
64 *
65 * Return 1 for now.
66 *
67 */
68
69int checkboard (void)
70{
71 printf("Marel V37\n") ;
72 return (0) ;
73}
74
75/* ------------------------------------------------------------------------- */
76
Becky Bruce9973e3c2008-06-09 16:03:40 -050077phys_size_t initdram (int board_type)
wdenk608c9142003-01-13 23:54:46 +000078{
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020079 volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
wdenk608c9142003-01-13 23:54:46 +000080 volatile memctl8xx_t *memctl = &immap->im_memctl;
81 unsigned long temp;
82 volatile int delay_cnt;
83 long int ramsize;
84
85 ramsize = dram_size();
86
87 /* Refresh clock prescalar */
88 memctl->memc_mptpr = 0x400 ;
89
90 if( ramsize == 32*MBYTE )
91 temp = 0xd0904110;
92 else /* 16MB */
93 temp = 0xd0802110;
94
95 memctl->memc_mbmr = temp;
96
97 upmconfig(UPMB, (uint *)sdram_table, sizeof(sdram_table)/sizeof(uint));
98
99 /* Map controller banks 2 to the SDRAM bank */
100 memctl->memc_or2 = 0xA00 | (0 - ramsize);
101 memctl->memc_br2 = 0xC1;
102
103 memctl->memc_mbmr = temp | 0x08;
104 memctl->memc_mcr = 0x80804130;
105
106 delay_cnt = 0;
107 while( delay_cnt++ < DRAM_DELAY )
wdenk8bde7f72003-06-27 21:31:46 +0000108 ;
wdenk608c9142003-01-13 23:54:46 +0000109
110 /* Run MRS command in location 5-8 of UPMB */
111
112 memctl->memc_mbmr = temp | 0x04;
113 memctl->memc_mar = 0x88;
114
115 memctl->memc_mcr = 0x80804105;
116
117 delay_cnt = 0;
118 while( delay_cnt++ < DRAM_DELAY )
wdenk8bde7f72003-06-27 21:31:46 +0000119 ;
wdenk608c9142003-01-13 23:54:46 +0000120
121#ifdef CONFIG_CAN_DRIVER
122 /* Initialize OR3 / BR3 */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200123 memctl->memc_or3 = CONFIG_SYS_OR3_CAN;
124 memctl->memc_br3 = CONFIG_SYS_BR3_CAN;
wdenk608c9142003-01-13 23:54:46 +0000125
126 /* Initialize MBMR */
wdenk2535d602003-07-17 23:16:40 +0000127 memctl->memc_mamr = MAMR_GPL_A4DIS; /* GPL_A4 ouput line Disable */
wdenk608c9142003-01-13 23:54:46 +0000128
129 /* Initialize UPMB for CAN: single read */
130 memctl->memc_mdr = 0xFFFFC004;
131 memctl->memc_mcr = 0x0100 | UPMA;
132
133 memctl->memc_mdr = 0x0FFFD004;
134 memctl->memc_mcr = 0x0101 | UPMA;
135
136 memctl->memc_mdr = 0x0FFFC000;
137 memctl->memc_mcr = 0x0102 | UPMA;
138
139 memctl->memc_mdr = 0x3FFFC004;
140 memctl->memc_mcr = 0x0103 | UPMA;
141
142 memctl->memc_mdr = 0xFFFFDC05;
143 memctl->memc_mcr = 0x0104 | UPMA;
144
145 /* Initialize UPMB for CAN: single write */
146 memctl->memc_mdr = 0xFFFCC004;
147 memctl->memc_mcr = 0x0118 | UPMA;
148
149 memctl->memc_mdr = 0xCFFCD004;
150 memctl->memc_mcr = 0x0119 | UPMA;
151
152 memctl->memc_mdr = 0x0FFCC000;
153 memctl->memc_mcr = 0x011A | UPMA;
154
155 memctl->memc_mdr = 0x7FFCC004;
156 memctl->memc_mcr = 0x011B | UPMA;
157
158 memctl->memc_mdr = 0xFFFDCC05;
159 memctl->memc_mcr = 0x011C | UPMA;
160#endif /* CONFIG_CAN_DRIVER */
161
162 return (dram_size());
163}
164
165/* ------------------------------------------------------------------------- */
166
167/*
168 * Find size of RAM from configuration pins.
169 * The input pins that contain the memory size are also the debug port
170 * pins. Normally they are configured as debug port pins. To be able
171 * to read the memory configuration, we must deactivate the debug port
172 * and enable the pcmcia input pins. Then return the register to
173 * previous state.
174 */
175
176static long int dram_size ()
177{
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200178 volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
wdenk608c9142003-01-13 23:54:46 +0000179 volatile sysconf8xx_t *siu = &immap->im_siu_conf;
180 volatile pcmconf8xx_t *pcm = &immap->im_pcmcia;
181 long int i, memory=1;
182 unsigned long siu_mcr;
183
184 siu_mcr = siu->sc_siumcr;
185 siu->sc_siumcr = siu_mcr & 0xFF9FFFFF;
186 for(i=0; i<10; i++) i = i;
187
188 memory = (pcm->pcmc_pipr>>12) & 0x3;
189
190 siu->sc_siumcr = siu_mcr;
191
192 switch( memory )
193 {
wdenk8bde7f72003-06-27 21:31:46 +0000194 case 1:
195 return( 32*MBYTE );
196 case 2:
197 return( 64*MBYTE );
198 default:
199 break;
wdenk608c9142003-01-13 23:54:46 +0000200 }
201 return( 16*MBYTE );
202}