@@ -37,6 +37,14 @@ struct tad_pmu {
3737 DECLARE_BITMAP (counters_map , TAD_MAX_COUNTERS );
3838};
3939
40+ enum mrvl_tad_pmu_version {
41+ TAD_PMU_V1 = 1 ,
42+ };
43+
44+ struct tad_pmu_data {
45+ int id ;
46+ };
47+
4048static int tad_pmu_cpuhp_state ;
4149
4250static void tad_pmu_event_counter_read (struct perf_event * event )
@@ -254,13 +262,15 @@ static const struct attribute_group *tad_pmu_attr_groups[] = {
254262
255263static int tad_pmu_probe (struct platform_device * pdev )
256264{
265+ const struct tad_pmu_data * dev_data ;
257266 struct device * dev = & pdev -> dev ;
258267 struct tad_region * regions ;
259268 struct tad_pmu * tad_pmu ;
260269 struct resource * res ;
261270 u32 tad_pmu_page_size ;
262271 u32 tad_page_size ;
263272 u32 tad_cnt ;
273+ int version ;
264274 int i , ret ;
265275 char * name ;
266276
@@ -270,6 +280,13 @@ static int tad_pmu_probe(struct platform_device *pdev)
270280
271281 platform_set_drvdata (pdev , tad_pmu );
272282
283+ dev_data = device_get_match_data (& pdev -> dev );
284+ if (!dev_data ) {
285+ dev_err (& pdev -> dev , "Error: No device match data found\n" );
286+ return - ENODEV ;
287+ }
288+ version = dev_data -> id ;
289+
273290 res = platform_get_resource (pdev , IORESOURCE_MEM , 0 );
274291 if (!res ) {
275292 dev_err (& pdev -> dev , "Mem resource not found\n" );
@@ -319,7 +336,6 @@ static int tad_pmu_probe(struct platform_device *pdev)
319336 tad_pmu -> pmu = (struct pmu ) {
320337
321338 .module = THIS_MODULE ,
322- .attr_groups = tad_pmu_attr_groups ,
323339 .capabilities = PERF_PMU_CAP_NO_EXCLUDE |
324340 PERF_PMU_CAP_NO_INTERRUPT ,
325341 .task_ctx_nr = perf_invalid_context ,
@@ -332,6 +348,9 @@ static int tad_pmu_probe(struct platform_device *pdev)
332348 .read = tad_pmu_event_counter_read ,
333349 };
334350
351+ if (version == TAD_PMU_V1 )
352+ tad_pmu -> pmu .attr_groups = tad_pmu_attr_groups ;
353+
335354 tad_pmu -> cpu = raw_smp_processor_id ();
336355
337356 /* Register pmu instance for cpu hotplug */
@@ -360,16 +379,22 @@ static void tad_pmu_remove(struct platform_device *pdev)
360379 perf_pmu_unregister (& pmu -> pmu );
361380}
362381
382+ #if defined(CONFIG_OF ) || defined(CONFIG_ACPI )
383+ static const struct tad_pmu_data tad_pmu_data = {
384+ .id = TAD_PMU_V1 ,
385+ };
386+ #endif
387+
363388#ifdef CONFIG_OF
364389static const struct of_device_id tad_pmu_of_match [] = {
365- { .compatible = "marvell,cn10k-tad-pmu" , },
390+ { .compatible = "marvell,cn10k-tad-pmu" , . data = & tad_pmu_data },
366391 {},
367392};
368393#endif
369394
370395#ifdef CONFIG_ACPI
371396static const struct acpi_device_id tad_pmu_acpi_match [] = {
372- {"MRVL000B" , 0 },
397+ {"MRVL000B" , ( kernel_ulong_t ) & tad_pmu_data },
373398 {},
374399};
375400MODULE_DEVICE_TABLE (acpi , tad_pmu_acpi_match );
0 commit comments