-/* $OpenBSD: cpu.c,v 1.41 2017/08/20 04:22:57 jsg Exp $ */
+/* $OpenBSD: cpu.c,v 1.42 2017/12/24 19:43:51 kettenis Exp $ */
/* $NetBSD: cpu.c,v 1.56 2004/04/14 04:01:49 bsh Exp $ */
#include <sys/proc.h>
#include <sys/conf.h>
#include <sys/sched.h>
+#include <sys/sysctl.h>
+
#include <uvm/uvm_extern.h>
+
#include <machine/cpu.h>
#include <machine/intr.h>
#include <machine/fdt.h>
#include <arm/undefined.h>
#include <dev/ofw/openfirm.h>
+#include <dev/ofw/ofw_clock.h>
#include <dev/ofw/fdt.h>
char cpu_model[256];
+int cpu_node;
int cpu_match(struct device *, void *, void *);
void cpu_attach(struct device *, struct device *, void *);
NULL, "cpu", DV_DULL
};
-void identify_arm_cpu(struct device *dv, struct cpu_info *);
+void identify_arm_cpu(struct device *, struct cpu_info *);
+int cpu_clockspeed(int *);
int
cpu_match(struct device *parent, void *cfdata, void *aux)
void
cpu_attach(struct device *parent, struct device *dev, void *aux)
{
+ struct fdt_attach_args *faa = aux;
struct cpu_info *ci;
if (dev->dv_unit == 0) {
ci->ci_arm_cpuid & CPU_ID_REVISION_MASK;
identify_arm_cpu(dev, ci);
+
+ if (OF_getproplen(faa->fa_node, "clocks") > 0) {
+ cpu_node = faa->fa_node;
+ cpu_cpuspeed = cpu_clockspeed;
+ }
} else {
printf(": not configured");
}
}
}
+int
+cpu_clockspeed(int *freq)
+{
+ *freq = clock_get_frequency(cpu_node, NULL) / 1000000;
+ return 0;
+}
+
#ifdef MULTIPROCESSOR
int
cpu_alloc_idle_pcb(struct cpu_info *ci)