Date: Thu, 28 Nov 2013 21:57:18 +0000 (UTC) From: Andreas Tobler <andreast@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r258722 - head/sys/powerpc/powerpc Message-ID: <201311282157.rASLvImF021401@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: andreast Date: Thu Nov 28 21:57:17 2013 New Revision: 258722 URL: http://svnweb.freebsd.org/changeset/base/258722 Log: 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 Modified: head/sys/powerpc/powerpc/cpu.c Modified: head/sys/powerpc/powerpc/cpu.c ============================================================================== --- head/sys/powerpc/powerpc/cpu.c Thu Nov 28 19:55:07 2013 (r258721) +++ head/sys/powerpc/powerpc/cpu.c Thu Nov 28 21:57:17 2013 (r258722) @@ -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 * { 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 * 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);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201311282157.rASLvImF021401>