blob: 0c214ebe66833b215d28b03d535cdf4879cb1061 [file] [log] [blame]
rjw1f884582022-01-06 17:20:42 +08001/*
2 * Copyright (C) 2019 MediaTek Inc.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 */
13
14#include <asm/cpu.h>
15#include "met_kernel_symbol.h"
16#include "cpu_dsu.h"
17
18//dsu support 6 event
19#define DSU_EVENT_MAX_CNT 6
20
21static int armv8_dsu_hw_check_event(struct met_dsu *pmu, int idx, int event)
22{
23 int i;
24
25 /* Check if event is duplicate */
26 for (i = 0; i < idx; i++) {
27 if (pmu[i].event == event)
28 break;
29 }
30 if (i < idx) {
31 /* pr_debug("++++++ found duplicate event 0x%02x i=%d\n", event, i); */
32 return -1;
33 }
34 return 0;
35}
36
37
38static struct met_dsu pmus[MXNR_DSU_EVENTS];
39
40struct cpu_dsu_hw armv8_dsu = {
41 .name = "armv8_dsu",
42 .check_event = armv8_dsu_hw_check_event,
43};
44
45static void init_dsu(void)
46{
47 armv8_dsu.event_count = DSU_EVENT_MAX_CNT;
48}
49
50struct cpu_dsu_hw *cpu_dsu_hw_init(void)
51{
52
53 init_dsu();
54 armv8_dsu.pmu = pmus;
55 return &armv8_dsu;
56}