22
22
#define PA_TT_CTRL 0x1c08
23
23
#define PA_TGTID_CTRL 0x1c14
24
24
#define PA_SRCID_CTRL 0x1c18
25
+
26
+ /* H32 PA interrupt registers */
25
27
#define PA_INT_MASK 0x1c70
26
28
#define PA_INT_STATUS 0x1c78
27
29
#define PA_INT_CLEAR 0x1c7c
30
+
31
+ #define H60PA_INT_STATUS 0x1c70
32
+ #define H60PA_INT_MASK 0x1c74
33
+
28
34
#define PA_EVENT_TYPE0 0x1c80
29
35
#define PA_PMU_VERSION 0x1cf0
30
36
#define PA_EVENT_CNT0_L 0x1d00
@@ -46,6 +52,12 @@ HISI_PMU_EVENT_ATTR_EXTRACTOR(srcid_cmd, config1, 32, 22);
46
52
HISI_PMU_EVENT_ATTR_EXTRACTOR (srcid_msk , config1 , 43 , 33 );
47
53
HISI_PMU_EVENT_ATTR_EXTRACTOR (tracetag_en , config1 , 44 , 44 );
48
54
55
+ struct hisi_pa_pmu_int_regs {
56
+ u32 mask_offset ;
57
+ u32 clear_offset ;
58
+ u32 status_offset ;
59
+ };
60
+
49
61
static void hisi_pa_pmu_enable_tracetag (struct perf_event * event )
50
62
{
51
63
struct hisi_pmu * pa_pmu = to_hisi_pmu (event -> pmu );
@@ -219,40 +231,40 @@ static void hisi_pa_pmu_disable_counter(struct hisi_pmu *pa_pmu,
219
231
static void hisi_pa_pmu_enable_counter_int (struct hisi_pmu * pa_pmu ,
220
232
struct hw_perf_event * hwc )
221
233
{
234
+ struct hisi_pa_pmu_int_regs * regs = pa_pmu -> dev_info -> private ;
222
235
u32 val ;
223
236
224
237
/* Write 0 to enable interrupt */
225
- val = readl (pa_pmu -> base + PA_INT_MASK );
238
+ val = readl (pa_pmu -> base + regs -> mask_offset );
226
239
val &= ~(1 << hwc -> idx );
227
- writel (val , pa_pmu -> base + PA_INT_MASK );
240
+ writel (val , pa_pmu -> base + regs -> mask_offset );
228
241
}
229
242
230
243
static void hisi_pa_pmu_disable_counter_int (struct hisi_pmu * pa_pmu ,
231
244
struct hw_perf_event * hwc )
232
245
{
246
+ struct hisi_pa_pmu_int_regs * regs = pa_pmu -> dev_info -> private ;
233
247
u32 val ;
234
248
235
249
/* Write 1 to mask interrupt */
236
- val = readl (pa_pmu -> base + PA_INT_MASK );
250
+ val = readl (pa_pmu -> base + regs -> mask_offset );
237
251
val |= 1 << hwc -> idx ;
238
- writel (val , pa_pmu -> base + PA_INT_MASK );
252
+ writel (val , pa_pmu -> base + regs -> mask_offset );
239
253
}
240
254
241
255
static u32 hisi_pa_pmu_get_int_status (struct hisi_pmu * pa_pmu )
242
256
{
243
- return readl (pa_pmu -> base + PA_INT_STATUS );
257
+ struct hisi_pa_pmu_int_regs * regs = pa_pmu -> dev_info -> private ;
258
+
259
+ return readl (pa_pmu -> base + regs -> status_offset );
244
260
}
245
261
246
262
static void hisi_pa_pmu_clear_int_status (struct hisi_pmu * pa_pmu , int idx )
247
263
{
248
- writel (1 << idx , pa_pmu -> base + PA_INT_CLEAR );
249
- }
264
+ struct hisi_pa_pmu_int_regs * regs = pa_pmu -> dev_info -> private ;
250
265
251
- static const struct acpi_device_id hisi_pa_pmu_acpi_match [] = {
252
- { "HISI0273" , },
253
- {}
254
- };
255
- MODULE_DEVICE_TABLE (acpi , hisi_pa_pmu_acpi_match );
266
+ writel (1 << idx , pa_pmu -> base + regs -> clear_offset );
267
+ }
256
268
257
269
static int hisi_pa_pmu_init_data (struct platform_device * pdev ,
258
270
struct hisi_pmu * pa_pmu )
@@ -276,6 +288,10 @@ static int hisi_pa_pmu_init_data(struct platform_device *pdev,
276
288
pa_pmu -> ccl_id = -1 ;
277
289
pa_pmu -> sccl_id = -1 ;
278
290
291
+ pa_pmu -> dev_info = device_get_match_data (& pdev -> dev );
292
+ if (!pa_pmu -> dev_info )
293
+ return - ENODEV ;
294
+
279
295
pa_pmu -> base = devm_platform_ioremap_resource (pdev , 0 );
280
296
if (IS_ERR (pa_pmu -> base )) {
281
297
dev_err (& pdev -> dev , "ioremap failed for pa_pmu resource.\n" );
@@ -314,6 +330,32 @@ static const struct attribute_group hisi_pa_pmu_v2_events_group = {
314
330
.attrs = hisi_pa_pmu_v2_events_attr ,
315
331
};
316
332
333
+ static struct attribute * hisi_pa_pmu_v3_events_attr [] = {
334
+ HISI_PMU_EVENT_ATTR (tx_req , 0x0 ),
335
+ HISI_PMU_EVENT_ATTR (tx_dat , 0x1 ),
336
+ HISI_PMU_EVENT_ATTR (tx_snp , 0x2 ),
337
+ HISI_PMU_EVENT_ATTR (rx_req , 0x7 ),
338
+ HISI_PMU_EVENT_ATTR (rx_dat , 0x8 ),
339
+ HISI_PMU_EVENT_ATTR (rx_snp , 0x9 ),
340
+ NULL
341
+ };
342
+
343
+ static const struct attribute_group hisi_pa_pmu_v3_events_group = {
344
+ .name = "events" ,
345
+ .attrs = hisi_pa_pmu_v3_events_attr ,
346
+ };
347
+
348
+ static struct attribute * hisi_h60pa_pmu_events_attr [] = {
349
+ HISI_PMU_EVENT_ATTR (rx_flit , 0x50 ),
350
+ HISI_PMU_EVENT_ATTR (tx_flit , 0x65 ),
351
+ NULL
352
+ };
353
+
354
+ static const struct attribute_group hisi_h60pa_pmu_events_group = {
355
+ .name = "events" ,
356
+ .attrs = hisi_h60pa_pmu_events_attr ,
357
+ };
358
+
317
359
static DEVICE_ATTR (cpumask , 0444 , hisi_cpumask_sysfs_show , NULL) ;
318
360
319
361
static struct attribute * hisi_pa_pmu_cpumask_attrs [] = {
@@ -337,6 +379,12 @@ static const struct attribute_group hisi_pa_pmu_identifier_group = {
337
379
.attrs = hisi_pa_pmu_identifier_attrs ,
338
380
};
339
381
382
+ static struct hisi_pa_pmu_int_regs hisi_pa_pmu_regs = {
383
+ .mask_offset = PA_INT_MASK ,
384
+ .clear_offset = PA_INT_CLEAR ,
385
+ .status_offset = PA_INT_STATUS ,
386
+ };
387
+
340
388
static const struct attribute_group * hisi_pa_pmu_v2_attr_groups [] = {
341
389
& hisi_pa_pmu_v2_format_group ,
342
390
& hisi_pa_pmu_v2_events_group ,
@@ -345,6 +393,46 @@ static const struct attribute_group *hisi_pa_pmu_v2_attr_groups[] = {
345
393
NULL
346
394
};
347
395
396
+ static const struct hisi_pmu_dev_info hisi_h32pa_v2 = {
397
+ .name = "pa" ,
398
+ .attr_groups = hisi_pa_pmu_v2_attr_groups ,
399
+ .private = & hisi_pa_pmu_regs ,
400
+ };
401
+
402
+ static const struct attribute_group * hisi_pa_pmu_v3_attr_groups [] = {
403
+ & hisi_pa_pmu_v2_format_group ,
404
+ & hisi_pa_pmu_v3_events_group ,
405
+ & hisi_pa_pmu_cpumask_attr_group ,
406
+ & hisi_pa_pmu_identifier_group ,
407
+ NULL
408
+ };
409
+
410
+ static const struct hisi_pmu_dev_info hisi_h32pa_v3 = {
411
+ .name = "pa" ,
412
+ .attr_groups = hisi_pa_pmu_v3_attr_groups ,
413
+ .private = & hisi_pa_pmu_regs ,
414
+ };
415
+
416
+ static struct hisi_pa_pmu_int_regs hisi_h60pa_pmu_regs = {
417
+ .mask_offset = H60PA_INT_MASK ,
418
+ .clear_offset = H60PA_INT_STATUS , /* Clear on write */
419
+ .status_offset = H60PA_INT_STATUS ,
420
+ };
421
+
422
+ static const struct attribute_group * hisi_h60pa_pmu_attr_groups [] = {
423
+ & hisi_pa_pmu_v2_format_group ,
424
+ & hisi_h60pa_pmu_events_group ,
425
+ & hisi_pa_pmu_cpumask_attr_group ,
426
+ & hisi_pa_pmu_identifier_group ,
427
+ NULL
428
+ };
429
+
430
+ static const struct hisi_pmu_dev_info hisi_h60pa = {
431
+ .name = "h60pa" ,
432
+ .attr_groups = hisi_h60pa_pmu_attr_groups ,
433
+ .private = & hisi_h60pa_pmu_regs ,
434
+ };
435
+
348
436
static const struct hisi_uncore_ops hisi_uncore_pa_ops = {
349
437
.write_evtype = hisi_pa_pmu_write_evtype ,
350
438
.get_event_idx = hisi_uncore_pmu_get_event_idx ,
@@ -375,7 +463,7 @@ static int hisi_pa_pmu_dev_probe(struct platform_device *pdev,
375
463
if (ret )
376
464
return ret ;
377
465
378
- pa_pmu -> pmu_events .attr_groups = hisi_pa_pmu_v2_attr_groups ;
466
+ pa_pmu -> pmu_events .attr_groups = pa_pmu -> dev_info -> attr_groups ;
379
467
pa_pmu -> num_counters = PA_NR_COUNTERS ;
380
468
pa_pmu -> ops = & hisi_uncore_pa_ops ;
381
469
pa_pmu -> check_event = 0xB0 ;
@@ -400,8 +488,9 @@ static int hisi_pa_pmu_probe(struct platform_device *pdev)
400
488
if (ret )
401
489
return ret ;
402
490
403
- name = devm_kasprintf (& pdev -> dev , GFP_KERNEL , "hisi_sicl%u_pa%u" ,
404
- pa_pmu -> sicl_id , pa_pmu -> index_id );
491
+ name = devm_kasprintf (& pdev -> dev , GFP_KERNEL , "hisi_sicl%d_%s%u" ,
492
+ pa_pmu -> sicl_id , pa_pmu -> dev_info -> name ,
493
+ pa_pmu -> index_id );
405
494
if (!name )
406
495
return - ENOMEM ;
407
496
@@ -435,6 +524,14 @@ static int hisi_pa_pmu_remove(struct platform_device *pdev)
435
524
return 0 ;
436
525
}
437
526
527
+ static const struct acpi_device_id hisi_pa_pmu_acpi_match [] = {
528
+ { "HISI0273" , (kernel_ulong_t )& hisi_h32pa_v2 },
529
+ { "HISI0275" , (kernel_ulong_t )& hisi_h32pa_v3 },
530
+ { "HISI0274" , (kernel_ulong_t )& hisi_h60pa },
531
+ {}
532
+ };
533
+ MODULE_DEVICE_TABLE (acpi , hisi_pa_pmu_acpi_match );
534
+
438
535
static struct platform_driver hisi_pa_pmu_driver = {
439
536
.driver = {
440
537
.name = "hisi_pa_pmu" ,
0 commit comments