aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Rutland <mark.rutland@arm.com>2011-06-22 10:34:56 -0400
committerRussell King <rmk+kernel@arm.linux.org.uk>2011-06-29 05:27:09 -0400
commite4b6381009d740bd3a97e6b841d8efe7fc70c1b7 (patch)
treeb461d1c8c6f442658106aba9fdf05138578c0eaf
parente73c34c3d522a60d9f7b38a7683076362bad98f5 (diff)
ARM: 6977/1: pmu: add platform_device_id table support
This patch adds support for platform_device_id tables, allowing new PMU types to be registered with the correct type, without requiring new platform_driver shims to provide the type. An single entry for existing devices is provided. Macros matching functionality of the of_device_id table macros are provided for convenience. Signed-off-by: Mark Rutland <mark.rutland@arm.com> Acked-by: Jamie Iles <jamie@jamieiles.com> Cc: Rob Herring <rob.herring@calxeda.com> Cc: Will Deacon <will.deacon@arm.com> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
-rw-r--r--arch/arm/kernel/pmu.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/arch/arm/kernel/pmu.c b/arch/arm/kernel/pmu.c
index 2ce00be697ea..2b70709376c3 100644
--- a/arch/arm/kernel/pmu.c
+++ b/arch/arm/kernel/pmu.c
@@ -61,9 +61,22 @@ static struct of_device_id armpmu_of_device_ids[] = {
61 {}, 61 {},
62}; 62};
63 63
64#define PLAT_MATCH_PMU(_name, _type) { \
65 .name = _name, \
66 .driver_data = _type, \
67}
68
69#define PLAT_MATCH_CPU(_name) PLAT_MATCH_PMU(_name, ARM_PMU_DEVICE_CPU)
70
71static struct platform_device_id armpmu_plat_device_ids[] = {
72 PLAT_MATCH_CPU("arm-pmu"),
73 {},
74};
75
64enum arm_pmu_type armpmu_device_type(struct platform_device *pdev) 76enum arm_pmu_type armpmu_device_type(struct platform_device *pdev)
65{ 77{
66 const struct of_device_id *of_id; 78 const struct of_device_id *of_id;
79 const struct platform_device_id *pdev_id;
67 80
68 /* provided by of_device_id table */ 81 /* provided by of_device_id table */
69 if (pdev->dev.of_node) { 82 if (pdev->dev.of_node) {
@@ -72,8 +85,10 @@ enum arm_pmu_type armpmu_device_type(struct platform_device *pdev)
72 return (enum arm_pmu_type)of_id->data; 85 return (enum arm_pmu_type)of_id->data;
73 } 86 }
74 87
75 /* Provided by a 'legacy' platform_device */ 88 /* Provided by platform_device_id table */
76 return ARM_PMU_DEVICE_CPU; 89 pdev_id = platform_get_device_id(pdev);
90 BUG_ON(!pdev_id);
91 return pdev_id->driver_data;
77} 92}
78 93
79static int __devinit armpmu_device_probe(struct platform_device *pdev) 94static int __devinit armpmu_device_probe(struct platform_device *pdev)
@@ -87,6 +102,7 @@ static struct platform_driver armpmu_driver = {
87 .of_match_table = armpmu_of_device_ids, 102 .of_match_table = armpmu_of_device_ids,
88 }, 103 },
89 .probe = armpmu_device_probe, 104 .probe = armpmu_device_probe,
105 .id_table = armpmu_plat_device_ids,
90}; 106};
91 107
92static int __init register_pmu_driver(void) 108static int __init register_pmu_driver(void)