1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24#include <common.h>
25#include <mpc8xx.h>
26#include <net.h>
27#include "atm.h"
28#include <i2c.h>
29
30
31
32static long int dram_size (long int, long int *, long int);
33
34
35
36
37# define PLD_GCR1_REG (unsigned char *) (0x10000000 + 0)
38# define PLD_EXT_RES (unsigned char *) (0x10000000 + 10)
39# define PLD_EXT_FETH (unsigned char *) (0x10000000 + 11)
40# define PLD_EXT_LED (unsigned char *) (0x10000000 + 12)
41# define PLD_EXT_X21 (unsigned char *) (0x10000000 + 13)
42
43#define _NOT_USED_ 0xFFFFFFFF
44
45const uint sdram_table[] = {
46
47
48
49 0xFE2DB004, 0xF0AA7004, 0xF0A5F400, 0xF3AFFC47,
50 _NOT_USED_,
51
52
53
54
55
56
57
58
59 0xFFFAF834, 0xFFE5B435,
60 _NOT_USED_,
61
62
63
64 0xFE2DB004, 0xF0AF7404, 0xF0AFFC00, 0xF0AFFC00,
65 0xF0AFFC00, 0xF0AAF800, 0xF1A5E447,
66 _NOT_USED_,
67 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
68 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
69
70
71
72 0xFE29B300, 0xF1A27304, 0xFFA5F747,
73 _NOT_USED_,
74 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
75
76
77
78 0x1F0DFC04, 0xEEABBC00, 0x10A77C00, 0xF0AFFC00,
79 0xF1AAF804, 0xFFA5F447,
80 _NOT_USED_, _NOT_USED_,
81 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
82 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
83
84
85
86 0xFFAC3884, 0xFFAC3404, 0xFFAFFC04, 0xFFAFFC84,
87 0xFFAFFC07,
88 _NOT_USED_, _NOT_USED_, _NOT_USED_,
89
90
91
92 0xFFAAB834, 0xFFA57434, 0xFFAFFC05,
93 _NOT_USED_,
94
95
96
97 0xFFAFFC04, 0xFFAFFC05,
98 _NOT_USED_, _NOT_USED_,
99};
100
101
102
103
104phys_size_t initdram (int board_type)
105{
106 volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
107 volatile memctl8xx_t *memctl = &immap->im_memctl;
108 volatile iop8xx_t *iop = &immap->im_ioport;
109 volatile fec_t *fecp = &immap->im_cpm.cp_fec;
110 long int size;
111
112 upmconfig (UPMA, (uint *) sdram_table,
113 sizeof (sdram_table) / sizeof (uint));
114
115
116
117
118
119
120
121 memctl->memc_mptpr = CONFIG_SYS_MPTPR;
122
123 memctl->memc_mar = 0x00000088;
124
125
126
127
128
129
130 memctl->memc_or2 = CONFIG_SYS_OR2_PRELIM;
131 memctl->memc_br2 = CONFIG_SYS_BR2_PRELIM;
132
133 memctl->memc_mamr = CONFIG_SYS_MAMR & (~(MAMR_PTAE));
134
135 udelay (200);
136
137
138
139 memctl->memc_mcr = 0x80004105;
140 udelay (1);
141 memctl->memc_mcr = 0x80004230;
142 udelay (1);
143
144 memctl->memc_mcr = 0x80004105;
145 udelay (1);
146 memctl->memc_mcr = 0x80004030;
147 udelay (1);
148 memctl->memc_mcr = 0x80004138;
149 udelay (1);
150
151 memctl->memc_mamr |= MAMR_PTAE;
152
153 udelay (1000);
154
155
156
157
158
159 size = dram_size (CONFIG_SYS_MAMR, (long *) SDRAM_BASE_PRELIM,
160 SDRAM_MAX_SIZE);
161
162 udelay (1000);
163
164
165 memctl->memc_mamr = CONFIG_SYS_MAMR;
166 udelay (1000);
167
168
169
170
171 memctl->memc_or2 = ((-size) & 0xFFFF0000) | CONFIG_SYS_OR2_PRELIM;
172 memctl->memc_br2 = ((CONFIG_SYS_SDRAM_BASE & BR_BA_MSK) | BR_MS_UPMA | BR_V);
173
174 udelay (10000);
175
176
177
178 atmLoad ();
179 fecp->fec_ecntrl = 0x00000004;
180 iop->iop_pdpar |= 0x0080;
181
182
183 return (size);
184}
185
186
187
188
189
190
191
192
193
194
195
196static long int dram_size (long int mamr_value, long int *base,
197 long int maxsize)
198{
199 volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
200 volatile memctl8xx_t *memctl = &immap->im_memctl;
201
202 memctl->memc_mamr = mamr_value;
203
204 return (get_ram_size (base, maxsize));
205}
206
207
208
209
210
211int checkboard (void)
212{
213 return (0);
214}
215
216void board_serial_init (void)
217{
218 ;
219}
220
221void board_ether_init (void)
222{
223 volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
224 volatile iop8xx_t *iop = &immap->im_ioport;
225 volatile fec_t *fecp = &immap->im_cpm.cp_fec;
226
227 atmLoad ();
228 fecp->fec_ecntrl = 0x00000004;
229 iop->iop_pdpar |= 0x0080;
230}
231
232int board_early_init_f (void)
233{
234 volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
235 volatile cpmtimer8xx_t *timers = &immap->im_cpmtimer;
236 volatile memctl8xx_t *memctl = &immap->im_memctl;
237 volatile iop8xx_t *iop = &immap->im_ioport;
238
239
240 iop->iop_papar = 0x0800;
241 iop->iop_padir = 0x0800;
242
243
244 timers->cpmt_tmr2 = 0xff2c;
245 timers->cpmt_trr2 = 0x000003d0;
246 timers->cpmt_tgcr = 0x00000810;
247
248
249 memctl->memc_br6 = 0x10000401;
250 memctl->memc_or6 = 0xFC000908;
251
252
253
254 *PLD_GCR1_REG = 0x06;
255 *PLD_EXT_RES = 0xC0;
256 *PLD_EXT_FETH = 0x40;
257 *PLD_EXT_LED = 0xFF;
258 *PLD_EXT_X21 = 0x04;
259 return 0;
260}
261
262static void board_get_enetaddr(uchar *addr)
263{
264 int i;
265 volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
266 volatile cpm8xx_t *cpm = &immap->im_cpm;
267 unsigned int rccrtmp;
268
269 char default_mac_addr[] = { 0x00, 0x08, 0x01, 0x02, 0x03, 0x04 };
270
271 for (i = 0; i < 6; i++)
272 addr[i] = default_mac_addr[i];
273
274 printf ("There is an error in the i2c driver .. /n");
275 printf ("You need to fix it first....../n");
276
277 rccrtmp = cpm->cp_rccr;
278 cpm->cp_rccr |= 0x0020;
279
280 i2c_reg_read (0xa0, 0);
281 printf ("seep = '-%c-%c-%c-%c-%c-%c-'\n",
282 i2c_reg_read (0xa0, 0), i2c_reg_read (0xa0, 0),
283 i2c_reg_read (0xa0, 0), i2c_reg_read (0xa0, 0),
284 i2c_reg_read (0xa0, 0), i2c_reg_read (0xa0, 0));
285
286 cpm->cp_rccr = rccrtmp;
287}
288
289int misc_init_r(void)
290{
291 uchar enetaddr[6];
292
293 if (!eth_getenv_enetaddr("ethaddr", enetaddr)) {
294 board_get_enetaddr(enetaddr);
295 eth_setenv_enetaddr("ethaddr", enetaddr);
296 }
297
298 return 0;
299}
300