Split out the FDT parts of the pmu driver to make way for adding ACPI

support.

Obtained from:	ABT Systems Ltd
Sponsored by:	The FreeBSD Foundation
This commit is contained in:
Andrew Turner 2016-11-22 09:39:31 +00:00
parent 8624bb0572
commit f1568d1e03

View File

@ -36,6 +36,7 @@
__FBSDID("$FreeBSD$");
#include "opt_hwpmc_hooks.h"
#include "opt_platform.h"
#include <sys/param.h>
#include <sys/systm.h>
@ -49,9 +50,11 @@ __FBSDID("$FreeBSD$");
#include <sys/pmc.h>
#include <sys/pmckern.h>
#ifdef FDT
#include <dev/ofw/openfirm.h>
#include <dev/ofw/ofw_bus.h>
#include <dev/ofw/ofw_bus_subr.h>
#endif
#include <machine/bus.h>
#include <machine/cpu.h>
@ -69,22 +72,6 @@ struct pmu_softc {
void *ih[MAX_RLEN];
};
static struct ofw_compat_data compat_data[] = {
{"arm,armv8-pmuv3", 1},
{"arm,cortex-a17-pmu", 1},
{"arm,cortex-a15-pmu", 1},
{"arm,cortex-a12-pmu", 1},
{"arm,cortex-a9-pmu", 1},
{"arm,cortex-a8-pmu", 1},
{"arm,cortex-a7-pmu", 1},
{"arm,cortex-a5-pmu", 1},
{"arm,arm11mpcore-pmu", 1},
{"arm,arm1176-pmu", 1},
{"arm,arm1136-pmu", 1},
{"qcom,krait-pmu", 1},
{NULL, 0}
};
static struct resource_spec pmu_spec[] = {
{ SYS_RES_IRQ, 0, RF_ACTIVE },
/* We don't currently handle pmu events, other than on cpu 0 */
@ -143,21 +130,6 @@ pmu_intr(void *arg)
return (FILTER_HANDLED);
}
static int
pmu_probe(device_t dev)
{
if (!ofw_bus_status_okay(dev))
return (ENXIO);
if (ofw_bus_search_compatible(dev, compat_data)->ocd_data != 0) {
device_set_desc(dev, "Performance Monitoring Unit");
return (BUS_PROBE_DEFAULT);
}
return (ENXIO);
}
static int
pmu_attach(device_t dev)
{
@ -206,18 +178,51 @@ pmu_attach(device_t dev)
return (0);
}
static device_method_t pmu_methods[] = {
DEVMETHOD(device_probe, pmu_probe),
#ifdef FDT
static struct ofw_compat_data compat_data[] = {
{"arm,armv8-pmuv3", 1},
{"arm,cortex-a17-pmu", 1},
{"arm,cortex-a15-pmu", 1},
{"arm,cortex-a12-pmu", 1},
{"arm,cortex-a9-pmu", 1},
{"arm,cortex-a8-pmu", 1},
{"arm,cortex-a7-pmu", 1},
{"arm,cortex-a5-pmu", 1},
{"arm,arm11mpcore-pmu", 1},
{"arm,arm1176-pmu", 1},
{"arm,arm1136-pmu", 1},
{"qcom,krait-pmu", 1},
{NULL, 0}
};
static int
pmu_fdt_probe(device_t dev)
{
if (!ofw_bus_status_okay(dev))
return (ENXIO);
if (ofw_bus_search_compatible(dev, compat_data)->ocd_data != 0) {
device_set_desc(dev, "Performance Monitoring Unit");
return (BUS_PROBE_DEFAULT);
}
return (ENXIO);
}
static device_method_t pmu_fdt_methods[] = {
DEVMETHOD(device_probe, pmu_fdt_probe),
DEVMETHOD(device_attach, pmu_attach),
{ 0, 0 }
};
static driver_t pmu_driver = {
static driver_t pmu_fdt_driver = {
"pmu",
pmu_methods,
pmu_fdt_methods,
sizeof(struct pmu_softc),
};
static devclass_t pmu_devclass;
static devclass_t pmu_fdt_devclass;
DRIVER_MODULE(pmu, simplebus, pmu_driver, pmu_devclass, 0, 0);
DRIVER_MODULE(pmu, simplebus, pmu_fdt_driver, pmu_fdt_devclass, 0, 0);
#endif