summaryrefslogtreecommitdiffstats
path: root/sys/powerpc
diff options
context:
space:
mode:
authorandreast <andreast@FreeBSD.org>2013-12-12 12:29:35 +0000
committerandreast <andreast@FreeBSD.org>2013-12-12 12:29:35 +0000
commit14be275758a03b869f8d32806e726b95cbdd119d (patch)
tree5f46d63b85608898d0f23ec6fee77657d1bedb7f /sys/powerpc
parent8843b343e66ad85232a61eb3687ce898616adb6f (diff)
downloadFreeBSD-src-14be275758a03b869f8d32806e726b95cbdd119d.zip
FreeBSD-src-14be275758a03b869f8d32806e726b95cbdd119d.tar.gz
MFC: r258722, r258757
r258722: Give some output about the CPU clock on IBMPOWER machines, currently read from OF. Linux does it similar, means they also read the OF values and display them. r258757: Use the Open Firmware-based CPU frequency determination as a generic fallback if we can't measure CPU frequency. This is also useful on a variety of embedded systems using FDT.
Diffstat (limited to 'sys/powerpc')
-rw-r--r--sys/powerpc/powerpc/cpu.c40
1 files changed, 38 insertions, 2 deletions
diff --git a/sys/powerpc/powerpc/cpu.c b/sys/powerpc/powerpc/cpu.c
index d7f8e2d..99c8ca1 100644
--- a/sys/powerpc/powerpc/cpu.c
+++ b/sys/powerpc/powerpc/cpu.c
@@ -74,6 +74,8 @@
#include <machine/smp.h>
#include <machine/spr.h>
+#include <dev/ofw/openfirm.h>
+
static void cpu_6xx_setup(int cpuid, uint16_t vers);
static void cpu_970_setup(int cpuid, uint16_t vers);
static void cpu_booke_setup(int cpuid, uint16_t vers);
@@ -273,6 +275,9 @@ cpu_est_clockrate(int cpu_id, uint64_t *cps)
{
uint16_t vers;
register_t msr;
+ phandle_t cpu, dev, root;
+ int res = 0;
+ char buf[8];
vers = mfpvr() >> 16;
msr = mfmsr();
@@ -316,9 +321,40 @@ cpu_est_clockrate(int cpu_id, uint64_t *cps)
mtmsr(msr);
return (0);
+
+ default:
+ root = OF_peer(0);
+ if (root == 0)
+ return (ENXIO);
+
+ dev = OF_child(root);
+ while (dev != 0) {
+ res = OF_getprop(dev, "name", buf, sizeof(buf));
+ if (res > 0 && strcmp(buf, "cpus") == 0)
+ break;
+ dev = OF_peer(dev);
+ }
+ cpu = OF_child(dev);
+ while (cpu != 0) {
+ res = OF_getprop(cpu, "device_type", buf,
+ sizeof(buf));
+ if (res > 0 && strcmp(buf, "cpu") == 0)
+ break;
+ cpu = OF_peer(cpu);
+ }
+ if (cpu == 0)
+ return (ENOENT);
+ if (OF_getprop(cpu, "ibm,extended-clock-frequency",
+ cps, sizeof(*cps)) >= 0) {
+ return (0);
+ } else if (OF_getprop(cpu, "clock-frequency", cps,
+ sizeof(cell_t)) >= 0) {
+ *cps >>= 32;
+ return (0);
+ } else {
+ return (ENOENT);
+ }
}
-
- return (ENXIO);
}
void
OpenPOWER on IntegriCloud