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. Tested under qemu and real hardware: cpu0: IBM POWER5+ revision 2.0, 1898.10 MHz
This commit is contained in:
parent
be3d0087dc
commit
a07c08cea5
@ -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,10 @@ cpu_est_clockrate(int cpu_id, uint64_t *cps)
|
||||
{
|
||||
uint16_t vers;
|
||||
register_t msr;
|
||||
phandle_t cpu, dev, root;
|
||||
uint32_t freq[2];
|
||||
int res = 0;
|
||||
char buf[8];
|
||||
|
||||
vers = mfpvr() >> 16;
|
||||
msr = mfmsr();
|
||||
@ -316,6 +322,41 @@ cpu_est_clockrate(int cpu_id, uint64_t *cps)
|
||||
|
||||
mtmsr(msr);
|
||||
return (0);
|
||||
|
||||
case IBMPOWER5:
|
||||
case IBMPOWER5PLUS:
|
||||
case IBMPOWER6:
|
||||
case IBMPOWER7:
|
||||
case IBMPOWER7PLUS:
|
||||
case IBMPOWER8:
|
||||
root = OF_peer(0);
|
||||
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, "clock-frequency", &freq[0],
|
||||
sizeof(freq[0])))
|
||||
*cps = freq[0];
|
||||
else if (OF_getprop(cpu, "ibm,extended-clock-frequency",
|
||||
&freq, sizeof(freq)))
|
||||
*cps = freq[1];
|
||||
else
|
||||
*cps = 0;
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
return (ENXIO);
|
||||
|
Loading…
Reference in New Issue
Block a user