Rohit Gupta | 5e4358c | 2014-07-18 16:16:02 -0700 | [diff] [blame] | 1 | /* |
Santosh Mardi | 19f4e0d | 2017-05-25 18:11:42 +0530 | [diff] [blame] | 2 | * Copyright (c) 2015-2017, The Linux Foundation. All rights reserved. |
Rohit Gupta | 5e4358c | 2014-07-18 16:16:02 -0700 | [diff] [blame] | 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 | |
Santosh Mardi | 19f4e0d | 2017-05-25 18:11:42 +0530 | [diff] [blame] | 14 | #ifndef _GOVERNOR_MEMLAT_H |
| 15 | #define _GOVERNOR_MEMLAT_H |
Rohit Gupta | 5e4358c | 2014-07-18 16:16:02 -0700 | [diff] [blame] | 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 | */ |
| 27 | struct dev_stats { |
| 28 | int id; |
| 29 | unsigned long inst_count; |
| 30 | unsigned long mem_count; |
| 31 | unsigned long freq; |
| 32 | }; |
| 33 | |
Rohit Gupta | 870b180 | 2016-04-13 16:55:04 -0700 | [diff] [blame] | 34 | struct core_dev_map { |
| 35 | unsigned int core_mhz; |
| 36 | unsigned int target_freq; |
| 37 | }; |
| 38 | |
Rohit Gupta | 5e4358c | 2014-07-18 16:16:02 -0700 | [diff] [blame] | 39 | /** |
| 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 | */ |
| 60 | struct 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 Gupta | 870b180 | 2016-04-13 16:55:04 -0700 | [diff] [blame] | 71 | struct core_dev_map *freq_map; |
Rohit Gupta | 5e4358c | 2014-07-18 16:16:02 -0700 | [diff] [blame] | 72 | }; |
| 73 | |
| 74 | #ifdef CONFIG_DEVFREQ_GOV_MEMLAT |
| 75 | int register_memlat(struct device *dev, struct memlat_hwmon *hw); |
| 76 | int update_memlat(struct memlat_hwmon *hw); |
| 77 | #else |
| 78 | static inline int register_memlat(struct device *dev, |
| 79 | struct memlat_hwmon *hw) |
| 80 | { |
| 81 | return 0; |
| 82 | } |
| 83 | static inline int update_memlat(struct memlat_hwmon *hw) |
| 84 | { |
| 85 | return 0; |
| 86 | } |
| 87 | #endif |
| 88 | |
| 89 | #endif /* _GOVERNOR_BW_HWMON_H */ |