ofw_cpu: Add support for getting cpu clock via clock property
Nominal Mhz is either expressed via the clock-frequency property or can be get via the clock property that holds the cpu clock. Add support for the later. Reviewed by: nwhitehorn Differential Revision: https://reviews.freebsd.org/D16346
This commit is contained in:
parent
409735e6b1
commit
d214656dca
@ -45,6 +45,10 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include <dev/ofw/ofw_bus_subr.h>
|
#include <dev/ofw/ofw_bus_subr.h>
|
||||||
#include <dev/ofw/ofw_cpu.h>
|
#include <dev/ofw/ofw_cpu.h>
|
||||||
|
|
||||||
|
#ifdef EXT_RESOURCES
|
||||||
|
#include <dev/extres/clk/clk.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
static int ofw_cpulist_probe(device_t);
|
static int ofw_cpulist_probe(device_t);
|
||||||
static int ofw_cpulist_attach(device_t);
|
static int ofw_cpulist_attach(device_t);
|
||||||
static const struct ofw_bus_devinfo *ofw_cpulist_get_devinfo(device_t dev,
|
static const struct ofw_bus_devinfo *ofw_cpulist_get_devinfo(device_t dev,
|
||||||
@ -203,6 +207,10 @@ ofw_cpu_attach(device_t dev)
|
|||||||
phandle_t node;
|
phandle_t node;
|
||||||
pcell_t cell;
|
pcell_t cell;
|
||||||
int rv;
|
int rv;
|
||||||
|
#ifdef EXT_RESOURCES
|
||||||
|
clk_t cpuclk;
|
||||||
|
uint64_t freq;
|
||||||
|
#endif
|
||||||
|
|
||||||
sc = device_get_softc(dev);
|
sc = device_get_softc(dev);
|
||||||
psc = device_get_softc(device_get_parent(dev));
|
psc = device_get_softc(device_get_parent(dev));
|
||||||
@ -269,12 +277,28 @@ ofw_cpu_attach(device_t dev)
|
|||||||
sc->sc_cpu_pcpu = pcpu_find(device_get_unit(dev));
|
sc->sc_cpu_pcpu = pcpu_find(device_get_unit(dev));
|
||||||
|
|
||||||
if (OF_getencprop(node, "clock-frequency", &cell, sizeof(cell)) < 0) {
|
if (OF_getencprop(node, "clock-frequency", &cell, sizeof(cell)) < 0) {
|
||||||
if (bootverbose)
|
#ifdef EXT_RESOURCES
|
||||||
device_printf(dev,
|
rv = clk_get_by_ofw_index(dev, 0, 0, &cpuclk);
|
||||||
"missing 'clock-frequency' property\n");
|
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 (bootverbose)
|
||||||
|
device_printf(dev,
|
||||||
|
"missing 'clock-frequency' property\n");
|
||||||
|
}
|
||||||
} else
|
} else
|
||||||
sc->sc_nominal_mhz = cell / 1000000; /* convert to MHz */
|
sc->sc_nominal_mhz = cell / 1000000; /* convert to MHz */
|
||||||
|
|
||||||
|
if (sc->sc_nominal_mhz != 0 && bootverbose)
|
||||||
|
device_printf(dev, "Nominal frequency %dMhz\n",
|
||||||
|
sc->sc_nominal_mhz);
|
||||||
bus_generic_probe(dev);
|
bus_generic_probe(dev);
|
||||||
return (bus_generic_attach(dev));
|
return (bus_generic_attach(dev));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user