blob: 6af56bb2bbf591d4d1aec4e9dbd068af402537b1 [file] [log] [blame]
rjw1f884582022-01-06 17:20:42 +08001/*
2 * Copyright (C) 2018 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#ifndef _PMU_V2_H_
15#define _PMU_V2_H_
16
17#include <linux/device.h>
18#include <linux/threads.h> /* NR_CPUS */
19
20#define MODE_DISABLED 0
21#define MODE_INTERRUPT 1
22#define MODE_POLLING 2
23#define MXSIZE_PMU_DESC 32
24#define MXNR_CPU_V2 NR_CPUS
25
26
27/*******************************************************************************
28* Type Define
29*******************************************************************************/
30struct met_pmu_v2 {
31 unsigned char mode;
32 unsigned short event;
33 struct kobject *kobj_cpu_pmu;
34 const char *cpu_name;
35};
36
37enum ARM_TYPE_v2 {
38 CORTEX_A53 = 0xD03,
39 CORTEX_A35 = 0xD04,
40 CORTEX_A57 = 0xD07,
41 CORTEX_A72 = 0xD08,
42 CORTEX_A73 = 0xD09,
43 CHIP_UNKNOWN = 0xFFF
44};
45
46struct pmu_desc_v2 {
47 unsigned int event;
48 char name[MXSIZE_PMU_DESC];
49};
50
51struct chip_pmu_v2 {
52 enum ARM_TYPE_v2 type;
53 struct pmu_desc_v2 *desc;
54 unsigned int pmu_count;
55 unsigned int hw_count;
56 const char *cpu_name;
57};
58
59struct cpu_pmu_hw_v2 {
60 const char *name;
61 int max_hw_count;
62 int (*get_event_desc)(int event, char *event_desc);
63 int (*check_event)(struct met_pmu_v2 *pmu, int idx, int event);
64 void (*start)(struct met_pmu_v2 *pmu, int count);
65 void (*stop)(int count);
66 unsigned int (*polling)(struct met_pmu_v2 *pmu, int count, unsigned int *pmu_value);
67 struct met_pmu_v2 *met_pmu[MXNR_CPU_V2];
68 struct chip_pmu_v2 *chip_pmu[MXNR_CPU_V2];
69};
70
71
72extern struct cpu_pmu_hw_v2 *cpu_pmu_hw_v2;
73
74
75/*******************************************************************************
76* Fuction Pototypes
77*******************************************************************************/
78extern noinline void mp_cpu_v2(unsigned char cnt, unsigned int *value);
79extern void met_perf_cpupmu_online_v2(unsigned int cpu);
80extern void met_perf_cpupmu_down_v2(void *cpu);
81extern void met_perf_cpupmu_start_v2(void);
82extern void met_perf_cpupmu_stop_v2(void);
83extern void cpupmu_polling_v2(unsigned long long stamp, int cpu);
84
85#endif /* _PMU_V2_H_ */