bcu_vrip.c revision 1.10.2.3 1 1.10.2.3 jdolecek /* $NetBSD: bcu_vrip.c,v 1.10.2.3 2002/02/11 20:08:12 jdolecek Exp $ */
2 1.1 takemura
3 1.1 takemura /*-
4 1.7 sato * Copyright (c) 1999-2001 SATO Kazumi. All rights reserved.
5 1.1 takemura * Copyright (c) 1999 PocketBSD Project. All rights reserved.
6 1.1 takemura *
7 1.1 takemura * Redistribution and use in source and binary forms, with or without
8 1.1 takemura * modification, are permitted provided that the following conditions
9 1.1 takemura * are met:
10 1.1 takemura * 1. Redistributions of source code must retain the above copyright
11 1.1 takemura * notice, this list of conditions and the following disclaimer.
12 1.1 takemura * 2. Redistributions in binary form must reproduce the above copyright
13 1.1 takemura * notice, this list of conditions and the following disclaimer in the
14 1.1 takemura * documentation and/or other materials provided with the distribution.
15 1.1 takemura * 3. All advertising materials mentioning features or use of this software
16 1.1 takemura * must display the following acknowledgement:
17 1.1 takemura * This product includes software developed by the PocketBSD project
18 1.1 takemura * and its contributors.
19 1.1 takemura * 4. Neither the name of the project nor the names of its contributors
20 1.1 takemura * may be used to endorse or promote products derived from this software
21 1.1 takemura * without specific prior written permission.
22 1.1 takemura *
23 1.1 takemura * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 1.1 takemura * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 1.1 takemura * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 1.1 takemura * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 1.1 takemura * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 1.1 takemura * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 1.1 takemura * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 1.1 takemura * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 1.1 takemura * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 1.1 takemura * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 1.1 takemura * SUCH DAMAGE.
34 1.1 takemura *
35 1.1 takemura */
36 1.1 takemura
37 1.1 takemura #include <sys/param.h>
38 1.1 takemura #include <sys/systm.h>
39 1.1 takemura #include <sys/device.h>
40 1.1 takemura #include <sys/reboot.h>
41 1.1 takemura
42 1.1 takemura #include <machine/bus.h>
43 1.10.2.3 jdolecek #include <machine/debug.h>
44 1.1 takemura
45 1.1 takemura #include <mips/cpuregs.h>
46 1.1 takemura
47 1.7 sato #include "opt_vr41xx.h"
48 1.1 takemura #include <hpcmips/vr/vr.h>
49 1.7 sato #include <hpcmips/vr/vrcpudef.h>
50 1.10.2.3 jdolecek #include <hpcmips/vr/vripif.h>
51 1.1 takemura #include <hpcmips/vr/vripvar.h>
52 1.1 takemura #include <hpcmips/vr/vripreg.h>
53 1.1 takemura #include <hpcmips/vr/bcureg.h>
54 1.1 takemura #include <hpcmips/vr/bcuvar.h>
55 1.1 takemura
56 1.10.2.2 thorpej static int vrbcu_match(struct device *, struct cfdata *, void *);
57 1.10.2.2 thorpej static void vrbcu_attach(struct device *, struct device *, void *);
58 1.1 takemura
59 1.10.2.2 thorpej static void vrbcu_write(struct vrbcu_softc *, int, unsigned short);
60 1.10.2.2 thorpej static unsigned short vrbcu_read(struct vrbcu_softc *, int);
61 1.2 sato
62 1.10.2.2 thorpej static void vrbcu_dump_regs(void);
63 1.5 sato
64 1.2 sato char *vr_cpuname=NULL;
65 1.2 sato int vr_major=-1;
66 1.2 sato int vr_minor=-1;
67 1.2 sato int vr_cpuid=-1;
68 1.1 takemura
69 1.1 takemura struct cfattach vrbcu_ca = {
70 1.3 sato sizeof(struct vrbcu_softc), vrbcu_match, vrbcu_attach
71 1.1 takemura };
72 1.1 takemura
73 1.3 sato struct vrbcu_softc *the_bcu_sc = NULL;
74 1.3 sato
75 1.3 sato static inline void
76 1.10.2.2 thorpej vrbcu_write(struct vrbcu_softc *sc, int port, unsigned short val)
77 1.3 sato {
78 1.10.2.2 thorpej
79 1.3 sato bus_space_write_2(sc->sc_iot, sc->sc_ioh, port, val);
80 1.3 sato }
81 1.3 sato
82 1.3 sato static inline unsigned short
83 1.10.2.2 thorpej vrbcu_read(struct vrbcu_softc *sc, int port)
84 1.3 sato {
85 1.10.2.2 thorpej
86 1.10.2.2 thorpej return (bus_space_read_2(sc->sc_iot, sc->sc_ioh, port));
87 1.3 sato }
88 1.3 sato
89 1.1 takemura static int
90 1.10.2.2 thorpej vrbcu_match(struct device *parent, struct cfdata *cf, void *aux)
91 1.1 takemura {
92 1.10.2.2 thorpej
93 1.10.2.2 thorpej return (2);
94 1.1 takemura }
95 1.1 takemura
96 1.1 takemura static void
97 1.10.2.2 thorpej vrbcu_attach(struct device *parent, struct device *self, void *aux)
98 1.1 takemura {
99 1.1 takemura struct vrip_attach_args *va = aux;
100 1.3 sato struct vrbcu_softc *sc = (struct vrbcu_softc *)self;
101 1.1 takemura
102 1.3 sato sc->sc_iot = va->va_iot;
103 1.3 sato bus_space_map(sc->sc_iot, va->va_addr, va->va_size,
104 1.10.2.2 thorpej 0, /* no flags */
105 1.10.2.2 thorpej &sc->sc_ioh);
106 1.1 takemura
107 1.1 takemura printf("\n");
108 1.3 sato the_bcu_sc = sc;
109 1.5 sato vrbcu_dump_regs();
110 1.5 sato }
111 1.5 sato
112 1.5 sato static void
113 1.5 sato vrbcu_dump_regs()
114 1.5 sato {
115 1.5 sato struct vrbcu_softc *sc = the_bcu_sc;
116 1.7 sato int cpuclock = 0, tclock = 0, vtclock = 0, cpuid;
117 1.8 sato #if !defined(ONLY_VR4102)
118 1.7 sato int spdreg;
119 1.7 sato #endif
120 1.7 sato #ifdef VRBCUDEBUG
121 1.5 sato int reg;
122 1.7 sato #endif /* VRBCUDEBUG */
123 1.5 sato
124 1.7 sato cpuid = vrbcu_vrip_getcpuid();
125 1.8 sato #if !defined(ONLY_VR4181) && !defined(ONLY_VR4102)
126 1.7 sato if (cpuid != BCUREVID_FIXRID_4181
127 1.10.2.2 thorpej && cpuid <= BCUREVID_RID_4131
128 1.10.2.2 thorpej && cpuid >= BCUREVID_RID_4111) {
129 1.7 sato spdreg = vrbcu_read(sc, BCUCLKSPEED_REG_W);
130 1.5 sato #ifdef VRBCUDEBUG
131 1.7 sato printf("vrbcu: CLKSPEED %x: \n", spdreg);
132 1.7 sato #endif /* VRBCUDEBUG */
133 1.7 sato }
134 1.7 sato #endif
135 1.8 sato #if defined VR4181
136 1.8 sato if (cpuid == BCUREVID_FIXRID_4181){
137 1.8 sato spdreg = vrbcu_read(sc, BCU81CLKSPEED_REG_W);
138 1.8 sato #ifdef VRBCUDEBUG
139 1.8 sato printf("vrbcu: CLKSPEED %x: \n", spdreg);
140 1.8 sato #endif /* VRBCUDEBUG */
141 1.8 sato }
142 1.8 sato #endif
143 1.7 sato
144 1.5 sato cpuclock = vrbcu_vrip_getcpuclock();
145 1.5 sato
146 1.5 sato switch (cpuid) {
147 1.8 sato #if defined VR4181
148 1.7 sato case BCUREVID_FIXRID_4181:
149 1.10.2.2 thorpej switch ((spdreg & BCU81CLKSPEED_DIVTMASK) >>
150 1.10.2.2 thorpej BCU81CLKSPEED_DIVTSHFT){
151 1.8 sato case BCU81CLKSPEED_DIVT1:
152 1.8 sato vtclock = tclock = cpuclock;
153 1.8 sato break;
154 1.8 sato case BCU81CLKSPEED_DIVT2:
155 1.8 sato vtclock = tclock = cpuclock/2;
156 1.8 sato break;
157 1.8 sato case BCU81CLKSPEED_DIVT3:
158 1.8 sato vtclock = tclock = cpuclock/3;
159 1.8 sato break;
160 1.8 sato case BCU81CLKSPEED_DIVT4:
161 1.8 sato vtclock = tclock = cpuclock/4;
162 1.8 sato break;
163 1.8 sato default:
164 1.8 sato vtclock = tclock = 0;
165 1.8 sato }
166 1.8 sato break;
167 1.8 sato #endif /* VR4181 */
168 1.5 sato case BCUREVID_RID_4101:
169 1.5 sato case BCUREVID_RID_4102:
170 1.5 sato vtclock = tclock = cpuclock/2;
171 1.5 sato break;
172 1.7 sato #if defined VR4111
173 1.5 sato case BCUREVID_RID_4111:
174 1.7 sato if ((spdreg&BCUCLKSPEED_DIVT2B) == 0)
175 1.5 sato vtclock = tclock = cpuclock/2;
176 1.7 sato else if ((spdreg&BCUCLKSPEED_DIVT3B) == 0)
177 1.5 sato vtclock = tclock = cpuclock/3;
178 1.7 sato else if ((spdreg&BCUCLKSPEED_DIVT4B) == 0)
179 1.5 sato vtclock = tclock = cpuclock/4;
180 1.5 sato else
181 1.5 sato vtclock = tclock = 0; /* XXX */
182 1.5 sato break;
183 1.7 sato #endif /* VR4111 */
184 1.7 sato #if defined VR4121
185 1.5 sato case BCUREVID_RID_4121:
186 1.10.2.2 thorpej {
187 1.10.2.2 thorpej int vt;
188 1.10.2.2 thorpej tclock = cpuclock / ((spdreg & BCUCLKSPEED_DIVTMASK) >>
189 1.10.2.2 thorpej BCUCLKSPEED_DIVTSHFT);
190 1.10.2.2 thorpej vt = ((spdreg & BCUCLKSPEED_DIVVTMASK) >>
191 1.10.2.2 thorpej BCUCLKSPEED_DIVVTSHFT);
192 1.10.2.2 thorpej if (vt == 0)
193 1.10.2.2 thorpej vtclock = 0; /* XXX */
194 1.10.2.2 thorpej else if (vt < 0x9)
195 1.10.2.2 thorpej vtclock = cpuclock / vt;
196 1.10.2.2 thorpej else
197 1.10.2.2 thorpej vtclock = cpuclock / ((vt - 8)*2+1) * 2;
198 1.10.2.2 thorpej }
199 1.10.2.2 thorpej break;
200 1.7 sato #endif /* VR4121 */
201 1.10.2.1 thorpej #if defined VR4122 || defined VR4131
202 1.9 enami case BCUREVID_RID_4122:
203 1.10.2.1 thorpej case BCUREVID_RID_4131:
204 1.10.2.2 thorpej {
205 1.10.2.2 thorpej int vtdiv;
206 1.9 enami
207 1.10.2.2 thorpej vtdiv = ((spdreg & BCUCLKSPEED_VTDIVMODE) >>
208 1.10.2.2 thorpej BCUCLKSPEED_VTDIVSHFT);
209 1.10.2.2 thorpej if (vtdiv == 0 || vtdiv > BCUCLKSPEED_VTDIV6)
210 1.10.2.2 thorpej vtclock = 0; /* XXX */
211 1.10.2.2 thorpej else
212 1.10.2.2 thorpej vtclock = cpuclock / vtdiv;
213 1.10.2.2 thorpej tclock = vtclock /
214 1.10.2.2 thorpej (((spdreg & BCUCLKSPEED_TDIVMODE) >>
215 1.10.2.2 thorpej BCUCLKSPEED_TDIVSHFT) ? 4 : 2);
216 1.10.2.2 thorpej }
217 1.10.2.2 thorpej break;
218 1.10.2.1 thorpej #endif /* VR4122 || VR4131 */
219 1.5 sato default:
220 1.5 sato break;
221 1.5 sato }
222 1.7 sato if (tclock)
223 1.7 sato printf("%s: cpu %d.%03dMHz, bus %d.%03dMHz, ram %d.%03dMHz\n",
224 1.10.2.2 thorpej sc->sc_dev.dv_xname,
225 1.10.2.2 thorpej cpuclock/1000000, (cpuclock%1000000)/1000,
226 1.10.2.2 thorpej tclock/1000000, (tclock%1000000)/1000,
227 1.10.2.2 thorpej vtclock/1000000, (vtclock%1000000)/1000);
228 1.7 sato else {
229 1.7 sato printf("%s: cpu %d.%03dMHz\n",
230 1.10.2.2 thorpej sc->sc_dev.dv_xname,
231 1.10.2.2 thorpej cpuclock/1000000, (cpuclock%1000000)/1000);
232 1.10.2.2 thorpej printf("%s: UNKNOWN BUS CLOCK SPEED:"
233 1.10.2.2 thorpej " CPU is UNKNOWN or NOT CONFIGURED\n",
234 1.10.2.2 thorpej sc->sc_dev.dv_xname);
235 1.7 sato }
236 1.5 sato #ifdef VRBCUDEBUG
237 1.7 sato reg = vrbcu_read(sc, BCUCNT1_REG_W);
238 1.7 sato printf("vrbcu: CNT1 %x: ", reg);
239 1.10.2.3 jdolecek dbg_bit_print(reg);
240 1.7 sato #if !defined(ONLY_VR4181)
241 1.7 sato if (cpuid != BCUREVID_FIXRID_4181
242 1.10.2.2 thorpej && cpuid <= BCUREVID_RID_4121
243 1.10.2.2 thorpej && cpuid >= BCUREVID_RID_4102) {
244 1.7 sato reg = vrbcu_read(sc, BCUCNT2_REG_W);
245 1.7 sato printf("vrbcu: CNT2 %x: ", reg);
246 1.10.2.3 jdolecek dbg_bit_print(reg);
247 1.7 sato }
248 1.7 sato #endif /* !defined ONLY_VR4181 */
249 1.10.2.1 thorpej #if !defined(ONLY_VR4181) || !defined(ONLY_VR4122_4131)
250 1.7 sato if (cpuid != BCUREVID_FIXRID_4181
251 1.10.2.2 thorpej && cpuid <= BCUREVID_RID_4121
252 1.10.2.2 thorpej && cpuid >= BCUREVID_RID_4102) {
253 1.7 sato reg = vrbcu_read(sc, BCUSPEED_REG_W);
254 1.7 sato printf("vrbcu: SPEED %x: ", reg);
255 1.10.2.3 jdolecek dbg_bit_print(reg);
256 1.7 sato reg = vrbcu_read(sc, BCUERRST_REG_W);
257 1.7 sato printf("vrbcu: ERRST %x: ", reg);
258 1.10.2.3 jdolecek dbg_bit_print(reg);
259 1.7 sato reg = vrbcu_read(sc, BCURFCNT_REG_W);
260 1.7 sato printf("vrbcu: RFCNT %x\n", reg);
261 1.7 sato reg = vrbcu_read(sc, BCUREFCOUNT_REG_W);
262 1.7 sato printf("vrbcu: RFCOUNT %x\n", reg);
263 1.7 sato }
264 1.10.2.1 thorpej #endif /* !defined(ONLY_VR4181) || !defined(ONLY_VR4122_4131) */
265 1.7 sato #if !defined(ONLY_VR4181)
266 1.7 sato if (cpuid != BCUREVID_FIXRID_4181
267 1.10.2.2 thorpej && cpuid <= BCUREVID_RID_4131
268 1.10.2.2 thorpej && cpuid >= BCUREVID_RID_4111)
269 1.7 sato {
270 1.5 sato reg = vrbcu_read(sc, BCUCNT3_REG_W);
271 1.5 sato printf("vrbcu: CNT3 %x: ", reg);
272 1.10.2.3 jdolecek dbg_bit_print(reg);
273 1.5 sato }
274 1.7 sato #endif /* !defined ONLY_VR4181 */
275 1.5 sato #endif /* VRBCUDEBUG */
276 1.5 sato
277 1.1 takemura }
278 1.1 takemura
279 1.1 takemura static char *cpuname[] = {
280 1.7 sato "VR4101", /* 0 */
281 1.7 sato "VR4102", /* 1 */
282 1.7 sato "VR4111", /* 2 */
283 1.7 sato "VR4121", /* 3 */
284 1.7 sato "VR4122", /* 4 */
285 1.10.2.1 thorpej "VR4131", /* 5 */
286 1.7 sato "UNKNOWN",
287 1.7 sato "UNKNOWN",
288 1.1 takemura "UNKNOWN",
289 1.1 takemura "UNKNOWN",
290 1.1 takemura "UNKNOWN",
291 1.7 sato "UNKNOWN",
292 1.7 sato "UNKNOWN",
293 1.7 sato "UNKNOWN",
294 1.7 sato "UNKNOWN",
295 1.7 sato "UNKNOWN",
296 1.7 sato "VR4181", /* 0x10 + 0 */
297 1.7 sato };
298 1.1 takemura
299 1.2 sato int
300 1.2 sato vrbcu_vrip_getcpuid(void)
301 1.2 sato {
302 1.2 sato volatile u_int16_t *revreg;
303 1.2 sato
304 1.2 sato if (vr_cpuid != -1)
305 1.10.2.2 thorpej return (vr_cpuid);
306 1.2 sato
307 1.2 sato if (vr_cpuid == -1) {
308 1.8 sato if (VRIP_BCU_ADDR == VR4181_BCU_ADDR)
309 1.10.2.2 thorpej revreg = (u_int16_t *)MIPS_PHYS_TO_KSEG1
310 1.10.2.2 thorpej ((VRIP_BCU_ADDR+BCU81REVID_REG_W));
311 1.8 sato else
312 1.10.2.2 thorpej revreg = (u_int16_t *)MIPS_PHYS_TO_KSEG1
313 1.10.2.2 thorpej ((VRIP_BCU_ADDR+BCUREVID_REG_W));
314 1.2 sato
315 1.2 sato vr_cpuid = *revreg;
316 1.2 sato vr_cpuid = (vr_cpuid&BCUREVID_RIDMASK)>>BCUREVID_RIDSHFT;
317 1.8 sato if (VRIP_BCU_ADDR == VR4181_BCU_ADDR
318 1.8 sato && vr_cpuid == BCUREVID_RID_4181) /* conflict vr4101 */
319 1.7 sato vr_cpuid = BCUREVID_FIXRID_4181;
320 1.2 sato }
321 1.10.2.2 thorpej return (vr_cpuid);
322 1.2 sato }
323 1.2 sato
324 1.1 takemura char *
325 1.1 takemura vrbcu_vrip_getcpuname(void)
326 1.1 takemura {
327 1.2 sato int cpuid;
328 1.1 takemura
329 1.2 sato if (vr_cpuname != NULL)
330 1.10.2.2 thorpej return (vr_cpuname);
331 1.1 takemura
332 1.2 sato cpuid = vrbcu_vrip_getcpuid();
333 1.2 sato vr_cpuname = cpuname[cpuid];
334 1.10.2.2 thorpej
335 1.10.2.2 thorpej return (vr_cpuname);
336 1.1 takemura }
337 1.1 takemura
338 1.2 sato
339 1.1 takemura int
340 1.1 takemura vrbcu_vrip_getcpumajor(void)
341 1.1 takemura {
342 1.1 takemura volatile u_int16_t *revreg;
343 1.2 sato
344 1.2 sato if (vr_major != -1)
345 1.10.2.2 thorpej return (vr_major);
346 1.1 takemura
347 1.10.2.2 thorpej revreg = (u_int16_t *)MIPS_PHYS_TO_KSEG1
348 1.10.2.2 thorpej ((VRIP_BCU_ADDR+BCUREVID_REG_W));
349 1.1 takemura
350 1.2 sato vr_major = *revreg;
351 1.2 sato vr_major = (vr_major&BCUREVID_MJREVMASK)>>BCUREVID_MJREVSHFT;
352 1.10.2.2 thorpej
353 1.10.2.2 thorpej return (vr_major);
354 1.1 takemura }
355 1.1 takemura
356 1.1 takemura int
357 1.1 takemura vrbcu_vrip_getcpuminor(void)
358 1.1 takemura {
359 1.1 takemura volatile u_int16_t *revreg;
360 1.2 sato
361 1.2 sato if (vr_minor != -1)
362 1.10.2.2 thorpej return (vr_minor);
363 1.1 takemura
364 1.10.2.2 thorpej revreg = (u_int16_t *)MIPS_PHYS_TO_KSEG1
365 1.10.2.2 thorpej ((VRIP_BCU_ADDR+BCUREVID_REG_W));
366 1.1 takemura
367 1.2 sato vr_minor = *revreg;
368 1.2 sato vr_minor = (vr_minor&BCUREVID_MNREVMASK)>>BCUREVID_MNREVSHFT;
369 1.10.2.2 thorpej
370 1.10.2.2 thorpej return (vr_minor);
371 1.1 takemura }
372 1.4 shin
373 1.4 shin #define CLKX 18432000 /* CLKX1,CLKX2: 18.432MHz */
374 1.4 shin #define MHZ 1000000
375 1.4 shin
376 1.4 shin int
377 1.4 shin vrbcu_vrip_getcpuclock(void)
378 1.4 shin {
379 1.4 shin u_int16_t clksp;
380 1.4 shin int cpuid, cpuclock;
381 1.4 shin
382 1.4 shin cpuid = vrbcu_vrip_getcpuid();
383 1.7 sato if (cpuid != BCUREVID_FIXRID_4181 && cpuid >= BCUREVID_RID_4111) {
384 1.10.2.2 thorpej clksp = *(u_int16_t *)MIPS_PHYS_TO_KSEG1
385 1.10.2.2 thorpej ((VRIP_BCU_ADDR+BCUCLKSPEED_REG_W)) &
386 1.10.2.2 thorpej BCUCLKSPEED_CLKSPMASK;
387 1.8 sato } else if (cpuid == BCUREVID_FIXRID_4181) {
388 1.10.2.2 thorpej clksp = *(u_int16_t *)MIPS_PHYS_TO_KSEG1
389 1.10.2.2 thorpej ((VRIP_BCU_ADDR+BCU81CLKSPEED_REG_W)) &
390 1.10.2.2 thorpej BCUCLKSPEED_CLKSPMASK;
391 1.7 sato }
392 1.4 shin
393 1.4 shin switch (cpuid) {
394 1.7 sato case BCUREVID_FIXRID_4181:
395 1.8 sato cpuclock = CLKX / clksp * 64;
396 1.7 sato /* branch delay is 1 clock; 2 clock/loop */
397 1.7 sato cpuspeed = (cpuclock / 2 + MHZ / 2) / MHZ;
398 1.7 sato break;
399 1.4 shin case BCUREVID_RID_4101:
400 1.4 shin /* assume 33MHz */
401 1.4 shin cpuclock = 33000000;
402 1.4 shin /* branch delay is 1 clock; 2 clock/loop */
403 1.4 shin cpuspeed = (cpuclock / 2 + MHZ / 2) / MHZ;
404 1.4 shin break;
405 1.4 shin case BCUREVID_RID_4102:
406 1.4 shin cpuclock = CLKX / clksp * 32;
407 1.4 shin /* branch delay is 1 clock; 2 clock/loop */
408 1.4 shin cpuspeed = (cpuclock / 2 + MHZ / 2) / MHZ;
409 1.4 shin break;
410 1.4 shin case BCUREVID_RID_4111:
411 1.4 shin cpuclock = CLKX / clksp * 64;
412 1.4 shin /* branch delay is 1 clock; 2 clock/loop */
413 1.4 shin cpuspeed = (cpuclock / 2 + MHZ / 2) / MHZ;
414 1.4 shin break;
415 1.4 shin case BCUREVID_RID_4121:
416 1.4 shin cpuclock = CLKX / clksp * 64;
417 1.9 enami /* branch delay is 2 clock; 3 clock/loop */
418 1.9 enami cpuspeed = (cpuclock / 3 + MHZ / 2) / MHZ;
419 1.9 enami break;
420 1.9 enami case BCUREVID_RID_4122:
421 1.10.2.1 thorpej cpuclock = CLKX / clksp * 98;
422 1.10.2.1 thorpej /* branch delay is 2 clock; 3 clock/loop */
423 1.10.2.1 thorpej cpuspeed = (cpuclock / 3 + MHZ / 2) / MHZ;
424 1.10.2.1 thorpej break;
425 1.10.2.1 thorpej case BCUREVID_RID_4131:
426 1.9 enami cpuclock = CLKX / clksp * 98;
427 1.4 shin /* branch delay is 2 clock; 3 clock/loop */
428 1.4 shin cpuspeed = (cpuclock / 3 + MHZ / 2) / MHZ;
429 1.4 shin break;
430 1.4 shin default:
431 1.4 shin panic("unknown CPU type %d\n", cpuid);
432 1.4 shin break;
433 1.4 shin }
434 1.10.2.2 thorpej
435 1.10.2.2 thorpej return (cpuclock);
436 1.4 shin }
437