Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F159955585
D48149.id149089.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
D48149.id149089.diff
View Options
diff --git a/sys/dev/ofw/ofw_cpu.c b/sys/dev/ofw/ofw_cpu.c
--- a/sys/dev/ofw/ofw_cpu.c
+++ b/sys/dev/ofw/ofw_cpu.c
@@ -44,6 +44,7 @@
#if defined(__arm__) || defined(__arm64__) || defined(__riscv)
#include <dev/clk/clk.h>
+#define HAS_CLK
#endif
static int ofw_cpulist_probe(device_t);
@@ -198,6 +199,30 @@
return (0);
}
+static int
+get_freq_from_clk(device_t dev, struct ofw_cpu_softc *sc)
+{
+#ifdef HAS_CLK
+ clk_t cpuclk;
+ uint64_t freq;
+ int rv;
+
+ rv = clk_get_by_ofw_index(dev, 0, 0, &cpuclk);
+ if (rv == 0) {
+ rv = clk_get_freq(cpuclk, &freq);
+ if (rv != 0 && bootverbose)
+ device_printf(dev,
+ "Cannot get freq of property clocks\n");
+ else
+ sc->sc_nominal_mhz = freq / 1000000;
+ }
+
+ return (rv);
+#else
+ return (ENODEV);
+#endif
+}
+
static int
ofw_cpu_attach(device_t dev)
{
@@ -206,10 +231,6 @@
phandle_t node;
pcell_t cell;
int rv;
-#if defined(__arm__) || defined(__arm64__) || defined(__riscv)
- clk_t cpuclk;
- uint64_t freq;
-#endif
sc = device_get_softc(dev);
psc = device_get_softc(device_get_parent(dev));
@@ -276,18 +297,7 @@
sc->sc_cpu_pcpu = pcpu_find(device_get_unit(dev));
if (OF_getencprop(node, "clock-frequency", &cell, sizeof(cell)) < 0) {
-#if defined(__arm__) || defined(__arm64__) || defined(__riscv)
- rv = clk_get_by_ofw_index(dev, 0, 0, &cpuclk);
- if (rv == 0) {
- rv = clk_get_freq(cpuclk, &freq);
- if (rv != 0 && bootverbose)
- device_printf(dev,
- "Cannot get freq of property clocks\n");
- else
- sc->sc_nominal_mhz = freq / 1000000;
- } else
-#endif
- {
+ if (get_freq_from_clk(dev, sc) != 0) {
if (bootverbose)
device_printf(dev,
"missing 'clock-frequency' property\n");
@@ -298,6 +308,7 @@
if (sc->sc_nominal_mhz != 0 && bootverbose)
device_printf(dev, "Nominal frequency %dMhz\n",
sc->sc_nominal_mhz);
+
bus_identify_children(dev);
bus_attach_children(dev);
return (0);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Jun 20, 9:59 PM (14 h, 42 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
34130473
Default Alt Text
D48149.id149089.diff (1 KB)
Attached To
Mode
D48149: ofw_cpu: collapse some #ifdef code
Attached
Detach File
Event Timeline
Log In to Comment