blob: 013a063263fba47d64148afc5f07cd2b9297062a [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_H_
15#define _PMU_H_
16
17#include <linux/device.h>
18
19#define MODE_DISABLED 0
20#define MODE_INTERRUPT 1
21#define MODE_POLLING 2
22
23#define MXSIZE_PMU_DESC 32
24#define MXNR_CPU 16
25
26struct met_pmu {
27 unsigned char mode;
28 unsigned short event;
29 unsigned long freq;
30 struct kobject *kobj_cpu_pmu;
31};
32
33struct cpu_pmu_hw {
34 const char *name;
35 const char *cpu_name;
36 int nr_cnt;
37 int (*get_event_desc)(int idx, int event, char *event_desc);
38 int (*check_event)(struct met_pmu *pmu, int idx, int event);
39 void (*start)(struct met_pmu *pmu, int count);
40 void (*stop)(int count);
41 unsigned int (*polling)(struct met_pmu *pmu, int count, unsigned int *pmu_value);
42 struct met_pmu *pmu;
43};
44
45struct pmu_desc {
46 unsigned int event;
47 char name[MXSIZE_PMU_DESC];
48};
49
50struct cpu_pmu_hw *cpu_pmu_hw_init(void);
51
52extern struct cpu_pmu_hw *cpu_pmu;
53extern noinline void mp_cpu(unsigned char cnt, unsigned int *value);
54
55extern void met_perf_cpupmu_start(void);
56extern void met_perf_cpupmu_stop(void);
57extern void met_perf_cpupmu_online(unsigned int cpu);
58extern void met_perf_cpupmu_down(void *cpu);
59extern void cpupmu_polling(unsigned long long stamp, int cpu);
60
61#endif /* _PMU_H_ */