@@ -37,6 +37,14 @@ struct tad_pmu {
37
37
DECLARE_BITMAP (counters_map , TAD_MAX_COUNTERS );
38
38
};
39
39
40
+ enum mrvl_tad_pmu_version {
41
+ TAD_PMU_V1 = 1 ,
42
+ };
43
+
44
+ struct tad_pmu_data {
45
+ int id ;
46
+ };
47
+
40
48
static int tad_pmu_cpuhp_state ;
41
49
42
50
static void tad_pmu_event_counter_read (struct perf_event * event )
@@ -254,13 +262,15 @@ static const struct attribute_group *tad_pmu_attr_groups[] = {
254
262
255
263
static int tad_pmu_probe (struct platform_device * pdev )
256
264
{
265
+ const struct tad_pmu_data * dev_data ;
257
266
struct device * dev = & pdev -> dev ;
258
267
struct tad_region * regions ;
259
268
struct tad_pmu * tad_pmu ;
260
269
struct resource * res ;
261
270
u32 tad_pmu_page_size ;
262
271
u32 tad_page_size ;
263
272
u32 tad_cnt ;
273
+ int version ;
264
274
int i , ret ;
265
275
char * name ;
266
276
@@ -270,6 +280,13 @@ static int tad_pmu_probe(struct platform_device *pdev)
270
280
271
281
platform_set_drvdata (pdev , tad_pmu );
272
282
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
+
273
290
res = platform_get_resource (pdev , IORESOURCE_MEM , 0 );
274
291
if (!res ) {
275
292
dev_err (& pdev -> dev , "Mem resource not found\n" );
@@ -319,7 +336,6 @@ static int tad_pmu_probe(struct platform_device *pdev)
319
336
tad_pmu -> pmu = (struct pmu ) {
320
337
321
338
.module = THIS_MODULE ,
322
- .attr_groups = tad_pmu_attr_groups ,
323
339
.capabilities = PERF_PMU_CAP_NO_EXCLUDE |
324
340
PERF_PMU_CAP_NO_INTERRUPT ,
325
341
.task_ctx_nr = perf_invalid_context ,
@@ -332,6 +348,9 @@ static int tad_pmu_probe(struct platform_device *pdev)
332
348
.read = tad_pmu_event_counter_read ,
333
349
};
334
350
351
+ if (version == TAD_PMU_V1 )
352
+ tad_pmu -> pmu .attr_groups = tad_pmu_attr_groups ;
353
+
335
354
tad_pmu -> cpu = raw_smp_processor_id ();
336
355
337
356
/* Register pmu instance for cpu hotplug */
@@ -360,16 +379,22 @@ static void tad_pmu_remove(struct platform_device *pdev)
360
379
perf_pmu_unregister (& pmu -> pmu );
361
380
}
362
381
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
+
363
388
#ifdef CONFIG_OF
364
389
static 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 },
366
391
{},
367
392
};
368
393
#endif
369
394
370
395
#ifdef CONFIG_ACPI
371
396
static const struct acpi_device_id tad_pmu_acpi_match [] = {
372
- {"MRVL000B" , 0 },
397
+ {"MRVL000B" , ( kernel_ulong_t ) & tad_pmu_data },
373
398
{},
374
399
};
375
400
MODULE_DEVICE_TABLE (acpi , tad_pmu_acpi_match );
0 commit comments