Commit cfdad299 authored by Mark Rutland's avatar Mark Rutland Committed by Will Deacon

arm: perf: share arm_pmu_device_probe

Enable the probe function to be shared with other drivers, which will
inject the appropriate of_device_id and pmu_probe_info tables.
Signed-off-by: default avatarMark Rutland <mark.rutland@arm.com>
Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
parent ed61f985
...@@ -145,6 +145,10 @@ struct pmu_probe_info { ...@@ -145,6 +145,10 @@ struct pmu_probe_info {
#define XSCALE_PMU_PROBE(_version, _fn) \ #define XSCALE_PMU_PROBE(_version, _fn) \
PMU_PROBE(ARM_CPU_IMP_INTEL << 24 | _version, ARM_PMU_XSCALE_MASK, _fn) PMU_PROBE(ARM_CPU_IMP_INTEL << 24 | _version, ARM_PMU_XSCALE_MASK, _fn)
int arm_pmu_device_probe(struct platform_device *pdev,
const struct of_device_id *of_table,
const struct pmu_probe_info *probe_table);
#endif /* CONFIG_HW_PERF_EVENTS */ #endif /* CONFIG_HW_PERF_EVENTS */
#endif /* __ARM_PMU_H__ */ #endif /* __ARM_PMU_H__ */
...@@ -286,16 +286,16 @@ static const struct pmu_probe_info pmu_probe_table[] = { ...@@ -286,16 +286,16 @@ static const struct pmu_probe_info pmu_probe_table[] = {
/* /*
* CPU PMU identification and probing. * CPU PMU identification and probing.
*/ */
static int probe_current_pmu(struct arm_pmu *pmu) static int probe_current_pmu(struct arm_pmu *pmu,
const struct pmu_probe_info *info)
{ {
int cpu = get_cpu(); int cpu = get_cpu();
unsigned int cpuid = read_cpuid_id(); unsigned int cpuid = read_cpuid_id();
int ret = -ENODEV; int ret = -ENODEV;
const struct pmu_probe_info *info;
pr_info("probing PMU on CPU %d\n", cpu); pr_info("probing PMU on CPU %d\n", cpu);
for (info = pmu_probe_table; info->init != NULL; info++) { for (; info->init != NULL; info++) {
if ((cpuid & info->mask) != info->cpuid) if ((cpuid & info->mask) != info->cpuid)
continue; continue;
ret = info->init(pmu); ret = info->init(pmu);
...@@ -352,7 +352,9 @@ static int of_pmu_irq_cfg(struct arm_pmu *pmu) ...@@ -352,7 +352,9 @@ static int of_pmu_irq_cfg(struct arm_pmu *pmu)
return 0; return 0;
} }
static int cpu_pmu_device_probe(struct platform_device *pdev) int arm_pmu_device_probe(struct platform_device *pdev,
const struct of_device_id *of_table,
const struct pmu_probe_info *probe_table)
{ {
const struct of_device_id *of_id; const struct of_device_id *of_id;
const int (*init_fn)(struct arm_pmu *); const int (*init_fn)(struct arm_pmu *);
...@@ -371,14 +373,14 @@ static int cpu_pmu_device_probe(struct platform_device *pdev) ...@@ -371,14 +373,14 @@ static int cpu_pmu_device_probe(struct platform_device *pdev)
pmu->plat_device = pdev; pmu->plat_device = pdev;
if (node && (of_id = of_match_node(cpu_pmu_of_device_ids, pdev->dev.of_node))) { if (node && (of_id = of_match_node(of_table, pdev->dev.of_node))) {
init_fn = of_id->data; init_fn = of_id->data;
ret = of_pmu_irq_cfg(pmu); ret = of_pmu_irq_cfg(pmu);
if (!ret) if (!ret)
ret = init_fn(pmu); ret = init_fn(pmu);
} else { } else {
ret = probe_current_pmu(pmu); ret = probe_current_pmu(pmu, probe_table);
cpumask_setall(&pmu->supported_cpus); cpumask_setall(&pmu->supported_cpus);
} }
...@@ -405,6 +407,12 @@ static int cpu_pmu_device_probe(struct platform_device *pdev) ...@@ -405,6 +407,12 @@ static int cpu_pmu_device_probe(struct platform_device *pdev)
return ret; return ret;
} }
static int cpu_pmu_device_probe(struct platform_device *pdev)
{
return arm_pmu_device_probe(pdev, cpu_pmu_of_device_ids,
pmu_probe_table);
}
static struct platform_driver cpu_pmu_driver = { static struct platform_driver cpu_pmu_driver = {
.driver = { .driver = {
.name = "arm-pmu", .name = "arm-pmu",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment