blob: 8c533ee6db70aa7866998e52899298f50c1f200c [file] [log] [blame]
Rohit Gupta5e4358c2014-07-18 16:16:02 -07001/*
Santosh Mardi19f4e0d2017-05-25 18:11:42 +05302 * Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
Rohit Gupta5e4358c2014-07-18 16:16:02 -07003 *
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
Santosh Mardi19f4e0d2017-05-25 18:11:42 +053014#ifndef _GOVERNOR_MEMLAT_H
15#define _GOVERNOR_MEMLAT_H
Rohit Gupta5e4358c2014-07-18 16:16:02 -070016
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
Rohit Gupta870b1802016-04-13 16:55:04 -070034struct core_dev_map {
35 unsigned int core_mhz;
36 unsigned int target_freq;
37};
38
Rohit Gupta5e4358c2014-07-18 16:16:02 -070039/**
40 * struct memlat_hwmon - Memory Latency HW monitor info
41 * @start_hwmon: Start the HW monitoring
42 * @stop_hwmon: Stop the HW monitoring
43 * @get_cnt: Return the number of intructions executed,
44 * memory accesses and effective frequency
45 * @dev: Pointer to device that this HW monitor can
46 * monitor.
47 * @of_node: OF node of device that this HW monitor can
48 * monitor.
49 * @df: Devfreq node that this HW monitor is being
50 * used for. NULL when not actively in use and
51 * non-NULL when in use.
52 * @num_cores: Number of cores that are monitored by the
53 * hardware monitor.
54 * @core_stats: Array containing instruction count, memory
55 * accesses and effective frequency for each core.
56 *
57 * One of dev or of_node needs to be specified for a successful registration.
58 *
59 */
60struct memlat_hwmon {
61 int (*start_hwmon)(struct memlat_hwmon *hw);
62 void (*stop_hwmon)(struct memlat_hwmon *hw);
63 unsigned long (*get_cnt)(struct memlat_hwmon *hw);
64 struct device *dev;
65 struct device_node *of_node;
66
67 unsigned int num_cores;
68 struct dev_stats *core_stats;
69
70 struct devfreq *df;
Rohit Gupta870b1802016-04-13 16:55:04 -070071 struct core_dev_map *freq_map;
Rohit Gupta5e4358c2014-07-18 16:16:02 -070072};
73
74#ifdef CONFIG_DEVFREQ_GOV_MEMLAT
75int register_memlat(struct device *dev, struct memlat_hwmon *hw);
76int update_memlat(struct memlat_hwmon *hw);
77#else
78static inline int register_memlat(struct device *dev,
79 struct memlat_hwmon *hw)
80{
81 return 0;
82}
83static inline int update_memlat(struct memlat_hwmon *hw)
84{
85 return 0;
86}
87#endif
88
89#endif /* _GOVERNOR_BW_HWMON_H */