Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F137050007
D19727.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D19727.id.diff
View Options
Index: head/sys/riscv/riscv/timer.c
===================================================================
--- head/sys/riscv/riscv/timer.c
+++ head/sys/riscv/riscv/timer.c
@@ -61,7 +61,10 @@
#include <machine/trap.h>
#include <machine/sbi.h>
-#define DEFAULT_FREQ 10000000
+#include <dev/fdt/fdt_common.h>
+#include <dev/ofw/ofw_bus.h>
+#include <dev/ofw/ofw_bus_subr.h>
+#include <dev/ofw/openfirm.h>
#define TIMER_COUNTS 0x00
#define TIMER_MTIMECMP(cpu) (cpu * 8)
@@ -157,6 +160,32 @@
}
static int
+riscv_timer_get_timebase(device_t dev, uint32_t *freq)
+{
+ phandle_t node;
+ int len;
+
+ node = OF_finddevice("/cpus");
+ if (node == -1) {
+ if (bootverbose)
+ device_printf(dev, "Can't find cpus node.\n");
+ return (ENXIO);
+ }
+
+ len = OF_getproplen(node, "timebase-frequency");
+ if (len != 4) {
+ if (bootverbose)
+ device_printf(dev,
+ "Can't find timebase-frequency property.\n");
+ return (ENXIO);
+ }
+
+ OF_getencprop(node, "timebase-frequency", freq, len);
+
+ return (0);
+}
+
+static int
riscv_timer_probe(device_t dev)
{
@@ -176,10 +205,9 @@
return (ENXIO);
if (device_get_unit(dev) != 0)
- return ENXIO;
+ return (ENXIO);
- sc->clkfreq = DEFAULT_FREQ;
- if (sc->clkfreq == 0) {
+ if (riscv_timer_get_timebase(dev, &sc->clkfreq) != 0) {
device_printf(dev, "No clock frequency specified\n");
return (ENXIO);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 22, 1:27 AM (10 h, 25 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
25858946
Default Alt Text
D19727.id.diff (1 KB)
Attached To
Mode
D19727: Fix timer frequency
Attached
Detach File
Event Timeline
Log In to Comment