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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
|
#include "u.h"
#include "lib.h"
#include "mem.h"
#include "dat.h"
#include "fns.h"
#include "io.h"
#include "archfads.h"
/*
* board-specific support for the 8xxFADS (including 860/21 development system)
*/
enum {
USESDRAM = 0, /* set to 1 if kernel is to use SDRAM as well as DRAM */
/* sccr */
RTSEL = IBIT(8), /* =0, select main oscillator (OSCM); =1, select external crystal (EXTCLK) */
RTDIV = IBIT(7), /* =0, divide by 4; =1, divide by 512 */
CRQEN = IBIT(9), /* =1, switch to high frequency when CPM active */
PRQEN = IBIT(10), /* =1, switch to high frequency when interrupt pending */
/* plprcr */
CSRC = IBIT(21), /* =0, clock is DFNH; =1, clock is DFNL */
};
/*
* called early in main.c, after machinit:
* using board and architecture specific registers, initialise
* 8xx registers that need it and complete initialisation of the Mach structure.
*/
void
archinit(void)
{
IMM *io;
int mf, isfads, sysmhz, t;
ulong v;
v = getimmr() & 0xFFFF;
isfads = 0; /* assume it's the 860/821 board */
sysmhz = 40;
switch(v>>8){
case 0x00: t = 0x86000; break;
case 0x20: t = 0x82300; isfads = 1; break;
case 0x21: t = 0x823a0; isfads = 1; break;
default: t = 0; break;
}
m->cputype = t;
m->bcsr = KADDR(BCSRMEM);
m->bcsr[1] |= DisableRS232a | DisableIR | DisableEther | DisablePCMCIA | DisableRS232b;
m->bcsr[1] &= ~(DisableDRAM|DisableFlash);
if(isfads){
sysmhz = 50;
m->bcsr[1] &= ~EnableSDRAM;
m->bcsr[4] &= ~(EnableVideoClock|EnableVideoPort);
m->bcsr[4] |= DisableVideoLamp;
}
io = m->iomem;
if(1 || io->sccr & IBIT(7)){ /* RTDIV=1 */
/* oscillator frequency can't be determined independently: check a switch */
if((m->bcsr[2]>>19)&(1<<2))
m->clockgen = 5*MHz;
else
m->clockgen = 4*MHz;
} else
m->clockgen = 32768;
mf = (sysmhz*MHz)/m->clockgen;
m->cpuhz = m->clockgen*mf;
io->plprcrk = KEEP_ALIVE_KEY;
io->plprcr &= ~IBIT(21); /* general system clock is DFNH */
io->plprcr = (io->plprcr & ((1<<20)-1)) | ((mf-1)<<20);
io->mptpr = 0x0400; /* memory prescaler = 16 for refresh */
io->plprcrk = ~KEEP_ALIVE_KEY;
if(isfads){
m->bcsr[1] |= EnableSDRAM;
sdraminit(SDRAMMEM);
if(!USESDRAM)
m->bcsr[1] &= ~EnableSDRAM; /* tells kernel not to map it */
}
}
static void
archidprint(void)
{
int f, i;
ulong v;
/* 8xx and FADS specific */
print("IMMR: ");
v = getimmr() & 0xFFFF;
switch(v>>8){
case 0x00: print("MPC860/821"); break;
case 0x20: print("MPC823"); break;
case 0x21: print("MPC823A"); break;
default: print("Type #%lux", v>>8); break;
}
print(", mask #%lux\n", v&0xFF);
v = m->bcsr[3]>>16;
print("MPC8xxFADS rev %lud, DB: ", ((v>>4)&8)|((v>>1)&4)|(v&3));
f = (v>>8)&0x3F;
switch(f){
default: print("ID#%x", f); break;
case 0x00: print("MPC860/821"); break;
case 0x01: print("MPC813"); break;
case 0x02: print("MPC821"); break;
case 0x03: print("MPC823"); break;
case 0x20: print("MPC801"); break;
case 0x21: print("MPC850"); break;
case 0x22: print("MPC860"); break;
case 0x23: print("MPC860SAR"); break;
case 0x24: print("MPC860T"); break;
}
print("ADS, rev #%lux\n", (m->bcsr[2]>>16)&7);
for(i=0; i<=4; i++)
print("BCSR%d: %8.8lux\n", i, m->bcsr[i]);
v = m->bcsr[2];
f = (v>>28)&0xF;
switch(f){
default: print("Unknown"); break;
case 4: print("SM732A2000/SM73228 - 8M SIMM"); break;
case 5: print("SM732A1000A/SM73218 - 4M SIMM"); break;
case 6: print("MCM29080 - 8M SIMM"); break;
case 7: print("MCM29040 - 4M SIMM"); break;
case 8: print("MCM29020 - 2M SIMM"); break;
}
switch((m->bcsr[3]>>20)&7){
default: i = 0; break;
case 1: i = 150; break;
case 2: i = 120; break;
case 3: i = 90; break;
}
print(" flash, %dns\n", i);
f = (v>>23)&0xF;
switch(f&3){
case 0: i = 4; break;
case 1: i = 32; break;
case 2: i = 16; break;
case 3: i = 8; break;
}
print("%dM SIMM, ", i);
switch(f>>2){
default: i = 0; break;
case 2: i = 70; break;
case 3: i = 60; break;
}
print("%dns\n", i);
print("options: #%lux\n", (m->bcsr[2]>>19)&0xF);
print("plprcr=%8.8lux sccr=%8.8lux\n", m->iomem->plprcr, m->iomem->sccr);
}
void
cpuidprint(void)
{
int t;
print("PVR: ");
t = getpvr()>>16;
switch(t){
case 0x01: print("MPC601"); break;
case 0x03: print("MPC603"); break;
case 0x04: print("MPC604"); break;
case 0x06: print("MPC603e"); break;
case 0x07: print("MPC603e-v7"); break;
case 0x50: print("MPC8xx"); break;
default: print("PowerPC version #%x", t); break;
}
print(", revision #%lux\n", getpvr()&0xffff);
archidprint();
print("%lud MHz system\n", m->cpuhz/MHz);
print("\n");
}
static char* defplan9ini[2] = {
/* 860/821 */
"ether0=type=SCC port=1 ea=00108bf12900\r\n"
"vgasize=640x480x8\r\n"
"kernelpercent=40\r\n"
"console=0 lcd\r\nbaud=9600\r\n",
/* 823 */
"ether0=type=SCC port=2 ea=00108bf12900\r\n"
"vgasize=640x480x8\r\n"
"kernelpercent=40\r\n"
"console=0 lcd\r\nbaud=9600\r\n",
};
char *
archconfig(void)
{
print("Using default configuration\n");
return defplan9ini[MPCMODEL(m->cputype) == 0x823];
}
/*
* provide value for #r/switch (devrtc.c)
*/
int
archoptionsw(void)
{
return (m->bcsr[2]>>19)&0xF; /* value of switch DS1 */
}
/*
* invoked by clock.c:/^clockintr
*/
static void
twinkle(void)
{
if(m->ticks%MS2TK(1000) == 0)
m->bcsr[4] ^= DisableLamp;
}
void (*archclocktick)(void) = twinkle;
/*
* for flash.c:/^flashreset
* retrieve flash type, virtual base and length and return 0;
* return -1 on error (no flash)
*/
int
archflashreset(char *type, void **addr, long *length)
{
char *t;
int mbyte;
if((m->iomem->memc[0].base & 1) == 0)
return -1; /* shouldn't happen */
switch((m->bcsr[2]>>28)&0xF){
default: return -1; /* unknown or not there */
case 4: mbyte=8; t = "SM732x8"; break;
case 5: mbyte=4; t = "SM732x8"; break;
case 6: mbyte=8; t = "AMD29F0x0"; break;
case 7: mbyte=4; t = "AMD29F0x0"; break;
case 8: mbyte=2; t = "AMD29F0x0"; break;
}
strcpy(type, t);
*addr = KADDR(FLASHMEM);
*length = mbyte*1024*1024;
return 0;
}
/*
* enable the clocks for the given SCC ether and reveal them to the caller.
* do anything else required to prepare the transceiver (eg, set full-duplex, reset loopback).
*/
int
archetherenable(int cpmid, int *rcs, int *tcs)
{
IMM *io;
switch(cpmid){
default:
/* no other SCCs are wired on the FADS board */
return -1;
case SCC2ID: /* assume 8xxFADS board with 823DABS */
io = ioplock();
m->bcsr[1] |= DisableIR|DisableRS232b;
m->bcsr[1] &= ~DisableEther;
io->papar |= SIBIT(6)|SIBIT(5); /* enable CLK2 and CLK3 */
io->padir &= ~(SIBIT(6)|SIBIT(5));
/* ETHLOOP etc set in BCSR elsewhere */
*rcs = CLK2;
*tcs = CLK3;
iopunlock();
break;
case SCC1ID: /* assume 860/21 development board */
io = ioplock();
m->bcsr[1] |= DisableIR|DisableRS232b; /* TO DO: might not be shared with RS232b */
m->bcsr[1] &= ~DisableEther;
io->papar |= SIBIT(6)|SIBIT(7); /* enable CLK2 and CLK1 */
io->padir &= ~(SIBIT(6)|SIBIT(7));
/* settings peculiar to 860/821 development board */
io->pcpar &= ~(SIBIT(4)|SIBIT(5)|SIBIT(6)); /* ETHLOOP, TPFULDL~, TPSQEL~ */
io->pcdir |= SIBIT(4)|SIBIT(5)|SIBIT(6);
io->pcdat &= ~SIBIT(4);
io->pcdat |= SIBIT(5)|SIBIT(6);
*rcs = CLK2;
*tcs = CLK1;
iopunlock();
break;
}
return 0;
}
void
archetherdisable(int id)
{
USED(id);
m->bcsr[1] |= DisableEther|DisableIR|DisableRS232b;
}
/*
* do anything extra required to enable the UART on the given CPM port
*/
void
archenableuart(int id, int irda)
{
switch(id){
case SMC1ID:
m->bcsr[1] &= ~DisableRS232a;
break;
case SCC2ID:
m->bcsr[1] |= DisableEther|DisableIR|DisableRS232b;
if(irda)
m->bcsr[1] &= ~DisableIR;
else
m->bcsr[1] &= ~DisableRS232b;
break;
default:
/* nothing special */
break;
}
}
/*
* do anything extra required to disable the UART on the given CPM port
*/
void
archdisableuart(int id)
{
switch(id){
case SMC1ID:
m->bcsr[1] |= DisableRS232a;
break;
case SCC2ID:
m->bcsr[1] |= DisableIR|DisableRS232b;
break;
default:
/* nothing special */
break;
}
}
/*
* enable/disable the LCD panel's backlight via
* York touch panel interface (does no harm without it)
*/
void
archbacklight(int on)
{
IMM *io;
delay(2);
io = ioplock();
io->papar &= ~SIBIT(4);
io->padir |= SIBIT(4);
if(on)
io->padat |= SIBIT(4);
else
io->padat &= ~SIBIT(4);
iopunlock();
}
|