1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29#include <common.h>
30#include <i2c.h>
31#include <config.h>
32#include <mpc8xx.h>
33
34
35
36static long int dram_size (long int, long int *, long int);
37static unsigned char aschex_to_byte (unsigned char *cp);
38
39
40
41#define _NOT_USED_ 0xFFFFCC25
42
43const uint sdram_table[] =
44{
45
46
47
48 0xCFFFCC24, 0x0FFFCC04, 0X0CAFCC04, 0X03AFCC08,
49 0x3FBFCC27,
50 _NOT_USED_, _NOT_USED_, _NOT_USED_,
51
52
53
54
55 0xCFFFCC24, 0x0FFFCC04, 0x0CAFCC84, 0x03AFCC88,
56 0x3FBFCC27,
57 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
58 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
59 _NOT_USED_, _NOT_USED_, _NOT_USED_,
60
61
62
63
64 0xCFFFCC24, 0x0FFFCC04, 0x0CFFCC04, 0x03FFCC00,
65 0x3FFFCC27,
66 _NOT_USED_, _NOT_USED_, _NOT_USED_,
67
68
69
70
71 0xCFFFCC24, 0x0FFFCC04, 0x0CFFCC80, 0x03FFCC8C,
72 0x0CFFCC00, 0x33FFCC27,
73 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
74 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
75 _NOT_USED_, _NOT_USED_,
76
77
78
79
80 0xC0FFCC24, 0x03FFCC24, 0x0FFFCC24, 0x0FFFCC24,
81 0x3FFFCC27,
82 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
83 _NOT_USED_, _NOT_USED_, _NOT_USED_,
84
85
86
87
88 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_
89};
90
91
92
93
94
95
96
97
98int checkboard (void)
99{
100 puts ("Board: RPXClassic\n");
101 return (0);
102}
103
104
105
106
107
108void board_get_enetaddr (uchar * enet)
109{
110 int i;
111 char buff[256], *cp;
112
113
114 i2c_init (CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
115
116
117 i2c_read (0x54, 0, 1, (uchar *)buff, 128);
118 i2c_read (0x54, 128, 1, (uchar *)buff + 128, 128);
119
120
121 for (cp = buff;;) {
122 if (cp[0] == 'E' && cp[1] == 'A') {
123 cp += 3;
124
125 for (i = 0; i < 6; i++, cp += 2) {
126 enet[i] = aschex_to_byte ((unsigned char *)cp);
127 }
128 }
129
130 while ((*cp != '\n') && (*cp != (char)0xff)) {
131 cp++;
132 }
133
134 cp++;
135 if ((*cp == '\n') || (*cp == 0) || (*cp == (char)0xff))
136 break;
137 }
138
139#ifdef CONFIG_FEC_ENET
140
141
142 enet[3] |= 0x80;
143#endif
144
145 printf ("MAC address = %02x:%02x:%02x:%02x:%02x:%02x\n",
146 enet[0], enet[1], enet[2], enet[3], enet[4], enet[5]);
147
148}
149
150void rpxclassic_init (void)
151{
152
153 *((uchar *) BCSR0) |= BCSR0_ENNVRAM;
154
155#ifdef CONFIG_FEC_ENET
156
157
158 *((volatile uchar *) BCSR2) &= ~BCSR2_MIICTL;
159 *((volatile uchar *) BCSR2) &= ~BCSR2_MIIPWRDWN;
160 *((volatile uchar *) BCSR2) |= BCSR2_MIIRST;
161 *((volatile uchar *) BCSR2) |= BCSR2_MIIPWRDWN;
162#endif
163
164}
165
166
167
168phys_size_t initdram (int board_type)
169{
170 volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
171 volatile memctl8xx_t *memctl = &immap->im_memctl;
172 long int size10;
173
174 upmconfig (UPMA, (uint *) sdram_table,
175 sizeof (sdram_table) / sizeof (uint));
176
177
178 memctl->memc_mptpr = CONFIG_SYS_MPTPR;
179
180 memctl->memc_mar = 0x00000000;
181
182
183 memctl->memc_or1 = CONFIG_SYS_OR1_PRELIM;
184 memctl->memc_br1 = CONFIG_SYS_BR1_PRELIM;
185
186 memctl->memc_mamr = CONFIG_SYS_MAMR_10COL & (~(MAMR_PTAE));
187
188 udelay (200);
189
190
191
192 memctl->memc_mcr = 0x80002230;
193 udelay (1);
194
195 memctl->memc_mamr |= MAMR_PTAE;
196
197 udelay (1000);
198
199
200
201
202
203 size10 = dram_size (CONFIG_SYS_MAMR_10COL, SDRAM_BASE_PRELIM,
204 SDRAM_MAX_SIZE);
205
206 return (size10);
207}
208
209
210
211
212
213
214
215
216
217
218
219static long int dram_size (long int mamr_value, long int *base, long int maxsize)
220{
221 volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
222 volatile memctl8xx_t *memctl = &immap->im_memctl;
223
224 memctl->memc_mamr = mamr_value;
225
226 return (get_ram_size(base, maxsize));
227}
228
229
230
231
232static unsigned char aschex_to_byte (unsigned char *cp)
233{
234 u_char byte, c;
235
236 c = *cp++;
237
238 if ((c >= 'A') && (c <= 'F')) {
239 c -= 'A';
240 c += 10;
241 } else if ((c >= 'a') && (c <= 'f')) {
242 c -= 'a';
243 c += 10;
244 } else {
245 c -= '0';
246 }
247
248 byte = c * 16;
249
250 c = *cp;
251
252 if ((c >= 'A') && (c <= 'F')) {
253 c -= 'A';
254 c += 10;
255 } else if ((c >= 'a') && (c <= 'f')) {
256 c -= 'a';
257 c += 10;
258 } else {
259 c -= '0';
260 }
261
262 byte += c;
263
264 return (byte);
265}
266