[RFC PATCH] ARM: pmu: add OF match support

Subsystems: arm port, the rest

STALE5654d

2 messages, 2 authors, 2011-02-09 · open the first message on its own page

[RFC PATCH] ARM: pmu: add OF match support

From: Rob Herring <hidden>
Date: 2011-02-09 03:53:37

From: Rob Herring <redacted>

Add OF match table to enable OF style driver binding. The dts entry is like
this:

pmu {
	compatible = "arm,pmu";
	interrupts = <100 101>;
};

The use of pdev->id as an index breaks with OF device binding. Change to use
a counter instead. If more than 1 pmu device is ever really supported, a
better solution to match users with particular pmu is probably needed.

Signed-off-by: Rob Herring <redacted>
---
 arch/arm/kernel/pmu.c |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/arch/arm/kernel/pmu.c b/arch/arm/kernel/pmu.c
index b8af96e..7084057 100644
--- a/arch/arm/kernel/pmu.c
+++ b/arch/arm/kernel/pmu.c
@@ -24,30 +24,37 @@
 static volatile long pmu_lock;
 
 static struct platform_device *pmu_devices[ARM_NUM_PMU_DEVICES];
+static int pmu_device_count;
 
 static int __devinit pmu_device_probe(struct platform_device *pdev)
 {
 
-	if (pdev->id < 0 || pdev->id >= ARM_NUM_PMU_DEVICES) {
+	if (pmu_device_count >= ARM_NUM_PMU_DEVICES) {
 		pr_warning("received registration request for unknown "
 				"device %d\n", pdev->id);
 		return -EINVAL;
 	}
 
-	if (pmu_devices[pdev->id])
+	if (pmu_devices[pmu_device_count])
 		pr_warning("registering new PMU device type %d overwrites "
 				"previous registration!\n", pdev->id);
 	else
 		pr_info("registered new PMU device of type %d\n",
 				pdev->id);
 
-	pmu_devices[pdev->id] = pdev;
+	pmu_devices[pmu_device_count++] = pdev;
 	return 0;
 }
 
+static struct of_device_id pmu_device_ids[] = {
+	{ .compatible = "arm,pmu" },
+	{},
+};
+
 static struct platform_driver pmu_driver = {
 	.driver		= {
 		.name	= "arm-pmu",
+		.of_match_table = pmu_device_ids,
 	},
 	.probe		= pmu_device_probe,
 };
-- 
1.7.1

[RFC PATCH] ARM: pmu: add OF match support

From: Will Deacon <hidden>
Date: 2011-02-09 09:51:27

Hi Rob,
Add OF match table to enable OF style driver binding. The dts entry is like
this:

pmu {
	compatible = "arm,pmu";
	interrupts = <100 101>;
};

The use of pdev->id as an index breaks with OF device binding. Change to use
a counter instead. If more than 1 pmu device is ever really supported, a
better solution to match users with particular pmu is probably needed.
We will want to support multiple PMU devices in the near future but
this is currently blocked on userspace issues. One such device would
be the event counters on the PL310, which could be used to complement
the CPU PMU on the Cortex-A9.

I don't like the idea of a counter as it forces platforms to register
their devices in a specific order. Is it possible to separate different
types of PMU in the device tree and then have pmu.c work out what to do
with them?

Will
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help