blob: 19a35009a4a0c7350b99a0558363f99600d8083d [file] [log] [blame]
Rohit Gupta5e4358c2014-07-18 16:16:02 -07001/*
2 * Copyright (c) 2015, The Linux Foundation. All rights reserved.
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 and
6 * only version 2 as 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 _GOVERNOR_BW_HWMON_H
15#define _GOVERNOR_BW_HWMON_H
16
17#include <linux/kernel.h>
18#include <linux/devfreq.h>
19
20/**
21 * struct dev_stats - Device stats
22 * @inst_count: Number of instructions executed.
23 * @mem_count: Number of memory accesses made.
24 * @freq: Effective frequency of the device in the
25 * last interval.
26 */
27struct dev_stats {
28 int id;
29 unsigned long inst_count;
30 unsigned long mem_count;
31 unsigned long freq;
32};
33
34/**
35 * struct memlat_hwmon - Memory Latency HW monitor info
36 * @start_hwmon: Start the HW monitoring
37 * @stop_hwmon: Stop the HW monitoring
38 * @get_cnt: Return the number of intructions executed,
39 * memory accesses and effective frequency
40 * @dev: Pointer to device that this HW monitor can
41 * monitor.
42 * @of_node: OF node of device that this HW monitor can
43 * monitor.
44 * @df: Devfreq node that this HW monitor is being
45 * used for. NULL when not actively in use and
46 * non-NULL when in use.
47 * @num_cores: Number of cores that are monitored by the
48 * hardware monitor.
49 * @core_stats: Array containing instruction count, memory
50 * accesses and effective frequency for each core.
51 *
52 * One of dev or of_node needs to be specified for a successful registration.
53 *
54 */
55struct memlat_hwmon {
56 int (*start_hwmon)(struct memlat_hwmon *hw);
57 void (*stop_hwmon)(struct memlat_hwmon *hw);
58 unsigned long (*get_cnt)(struct memlat_hwmon *hw);
59 struct device *dev;
60 struct device_node *of_node;
61
62 unsigned int num_cores;
63 struct dev_stats *core_stats;
64
65 struct devfreq *df;
66};
67
68#ifdef CONFIG_DEVFREQ_GOV_MEMLAT
69int register_memlat(struct device *dev, struct memlat_hwmon *hw);
70int update_memlat(struct memlat_hwmon *hw);
71#else
72static inline int register_memlat(struct device *dev,
73 struct memlat_hwmon *hw)
74{
75 return 0;
76}
77static inline int update_memlat(struct memlat_hwmon *hw)
78{
79 return 0;
80}
81#endif
82
83#endif /* _GOVERNOR_BW_HWMON_H */