Subject: port-powerpc/13803: print cpu clock frequency on powerpc
To: None <gnats-bugs@gnats.netbsd.org>
From: None <hamajima@nagoya.ydc.co.jp>
List: netbsd-bugs
Date: 08/28/2001 10:52:39
>Number: 13803
>Category: port-powerpc
>Synopsis: print cpu clock frequency on powerpc
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: port-powerpc-maintainer
>State: open
>Class: change-request
>Submitter-Id: net
>Arrival-Date: Mon Aug 27 18:48:01 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator: Katsuomi Hamajima
>Release: NetBSD 1.5X
>Organization:
>Environment:
sys/arch/powerpc/mpc6xx/cpu_subr.c:1.1
System: NetBSD ppc 1.5X NetBSD 1.5X (8500) #39: Mon Aug 27 21:34:49 JST 2001 hamajima@ppc:/usr/src/sys/arch/macppc/compile/8500 macppc
>Description:
Print cpu clock frequency in boot time.
This code copied from sys/arch/powerpc/powerpc/cpu.c of OpenBSD.
>How-To-Repeat:
>Fix:
one part of dmesg
cpu0 at mainbus0: 750 195MHz (Revision 201), ID 0 (primary)
--- cpu_subr.c.orig Sun Aug 26 11:47:39 2001
+++ cpu_subr.c Mon Aug 27 21:31:41 2001
@@ -43,6 +43,7 @@
#include <uvm/uvm_extern.h>
#include <powerpc/mpc6xx/hid.h>
#include <powerpc/spr.h>
+#include <dev/ofw/openfirm.h>
static void cpu_config_l2cr(int);
@@ -239,6 +240,9 @@
{
u_int pvr, vers, rev;
const struct cputab *cp;
+ char name[32];
+ int qhandle, phandle;
+ unsigned int clock_freq = 0;
asm ("mfpvr %0" : "=r"(pvr));
vers = pvr >> 16;
@@ -250,6 +254,23 @@
cp++;
}
+ for (qhandle = OF_peer(0); qhandle; qhandle = phandle) {
+ if (OF_getprop(qhandle, "device_type", name, sizeof name) >= 0
+ && !strcmp(name, "cpu")
+ && OF_getprop(qhandle, "clock-frequency",
+ &clock_freq , sizeof clock_freq ) >= 0)
+ {
+ break;
+ }
+ if ((phandle = OF_child(qhandle)))
+ continue;
+ while (qhandle) {
+ if ((phandle = OF_peer(qhandle)))
+ break;
+ qhandle = OF_parent(qhandle);
+ }
+ }
+
if (str == NULL) {
str = cpu_model;
len = sizeof(cpu_model);
@@ -257,7 +278,11 @@
}
if (cp->name != NULL) {
- snprintf(str, len, "%s (Revision %x)", cp->name, rev);
+ if (clock_freq != 0)
+ snprintf(str, len, "%s %dMHz (Revision %x)",
+ cp->name, clock_freq/1000000, rev);
+ else
+ snprintf(str, len, "%s (Revision %x)", cp->name, rev);
} else {
snprintf(str, len, "Version %x (Revision %x)", vers, rev);
}
>Release-Note:
>Audit-Trail:
>Unformatted: