From: kettenis Date: Sun, 24 Dec 2017 19:42:51 +0000 (+0000) Subject: For systems where the cpu node in the device tree has a "clocks" property, X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=aa14cdcbe2bc7d27d33c51f5a619d57eb651844b;p=openbsd For systems where the cpu node in the device tree has a "clocks" property, implement hw.cpuspeed using the clock framework. ok patrick@ --- diff --git a/sys/arch/arm64/arm64/cpu.c b/sys/arch/arm64/arm64/cpu.c index d48ba78b52b..169a21f25ea 100644 --- a/sys/arch/arm64/arm64/cpu.c +++ b/sys/arch/arm64/arm64/cpu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.c,v 1.7 2017/08/20 04:22:57 jsg Exp $ */ +/* $OpenBSD: cpu.c,v 1.8 2017/12/24 19:42:51 kettenis Exp $ */ /* * Copyright (c) 2016 Dale Rahn @@ -20,9 +20,12 @@ #include #include #include +#include + #include #include +#include #include /* CPU Identification */ @@ -87,6 +90,7 @@ const struct implementers { }; char cpu_model[64]; +int cpu_node; int cpu_match(struct device *, void *, void *); void cpu_attach(struct device *, struct device *, void *); @@ -143,6 +147,8 @@ cpu_identify(struct cpu_info *ci) } } +int cpu_clockspeed(int *); + int cpu_match(struct device *parent, void *cfdata, void *aux) { @@ -172,9 +178,21 @@ cpu_attach(struct device *parent, struct device *dev, void *aux) printf(":"); cpu_identify(ci); + + if (OF_getproplen(faa->fa_node, "clocks") > 0) { + cpu_node = faa->fa_node; + cpu_cpuspeed = cpu_clockspeed; + } } else { printf(": not configured"); } printf("\n"); } + +int +cpu_clockspeed(int *freq) +{ + *freq = clock_get_frequency(cpu_node, NULL) / 1000000; + return 0; +}