Saravana Kannan | cedb32e | 2014-01-22 00:15:33 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2014, 2016, 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_CACHE_HWMON_H |
| 15 | #define _GOVERNOR_CACHE_HWMON_H |
| 16 | |
| 17 | #include <linux/kernel.h> |
| 18 | #include <linux/devfreq.h> |
| 19 | |
Junjie Wu | cd8a295 | 2014-10-30 12:13:03 -0700 | [diff] [blame] | 20 | enum request_group { |
| 21 | HIGH, |
| 22 | MED, |
| 23 | LOW, |
| 24 | MAX_NUM_GROUPS, |
| 25 | }; |
| 26 | |
Saravana Kannan | cedb32e | 2014-01-22 00:15:33 -0800 | [diff] [blame] | 27 | struct mrps_stats { |
Junjie Wu | cd8a295 | 2014-10-30 12:13:03 -0700 | [diff] [blame] | 28 | unsigned long mrps[MAX_NUM_GROUPS]; |
Saravana Kannan | cedb32e | 2014-01-22 00:15:33 -0800 | [diff] [blame] | 29 | unsigned int busy_percent; |
| 30 | }; |
| 31 | |
Junjie Wu | 211bbef | 2014-10-17 13:13:52 -0700 | [diff] [blame] | 32 | /** |
| 33 | * struct cache_hwmon - devfreq Cache HW monitor info |
| 34 | * @start_hwmon: Start the HW monitoring |
| 35 | * @stop_hwmon: Stop the HW monitoring |
Junjie Wu | 211bbef | 2014-10-17 13:13:52 -0700 | [diff] [blame] | 36 | * @meas_mrps_and_set_irq: Return the measured count and set up the |
| 37 | * IRQ to fire if usage exceeds current |
| 38 | * measurement by @tol percent. |
Junjie Wu | 211bbef | 2014-10-17 13:13:52 -0700 | [diff] [blame] | 39 | * @dev: device that this HW monitor can monitor. |
| 40 | * @of_node: OF node of device that this HW monitor can monitor. |
| 41 | * @df: Devfreq node that this HW montior is being used |
| 42 | * for. NULL when not actively in use, and non-NULL |
| 43 | * when in use. |
| 44 | */ |
Saravana Kannan | cedb32e | 2014-01-22 00:15:33 -0800 | [diff] [blame] | 45 | struct cache_hwmon { |
Junjie Wu | 211bbef | 2014-10-17 13:13:52 -0700 | [diff] [blame] | 46 | int (*start_hwmon)(struct cache_hwmon *hw, struct mrps_stats *mrps); |
| 47 | void (*stop_hwmon)(struct cache_hwmon *hw); |
Junjie Wu | 211bbef | 2014-10-17 13:13:52 -0700 | [diff] [blame] | 48 | unsigned long (*meas_mrps_and_set_irq)(struct cache_hwmon *hw, |
Saravana Kannan | cedb32e | 2014-01-22 00:15:33 -0800 | [diff] [blame] | 49 | unsigned int tol, unsigned int us, |
| 50 | struct mrps_stats *mrps); |
Junjie Wu | 211bbef | 2014-10-17 13:13:52 -0700 | [diff] [blame] | 51 | struct device *dev; |
| 52 | struct device_node *of_node; |
| 53 | struct devfreq *df; |
Saravana Kannan | cedb32e | 2014-01-22 00:15:33 -0800 | [diff] [blame] | 54 | }; |
| 55 | |
| 56 | #ifdef CONFIG_DEVFREQ_GOV_QCOM_CACHE_HWMON |
Junjie Wu | 211bbef | 2014-10-17 13:13:52 -0700 | [diff] [blame] | 57 | int register_cache_hwmon(struct device *dev, struct cache_hwmon *hwmon); |
Junjie Wu | 21d559a | 2014-10-20 15:47:07 -0700 | [diff] [blame] | 58 | int update_cache_hwmon(struct cache_hwmon *hwmon); |
Saravana Kannan | cedb32e | 2014-01-22 00:15:33 -0800 | [diff] [blame] | 59 | #else |
Junjie Wu | 211bbef | 2014-10-17 13:13:52 -0700 | [diff] [blame] | 60 | static inline int register_cache_hwmon(struct device *dev, |
| 61 | struct cache_hwmon *hwmon) |
Saravana Kannan | cedb32e | 2014-01-22 00:15:33 -0800 | [diff] [blame] | 62 | { |
| 63 | return 0; |
| 64 | } |
Junjie Wu | 21d559a | 2014-10-20 15:47:07 -0700 | [diff] [blame] | 65 | int update_cache_hwmon(struct cache_hwmon *hwmon) |
| 66 | { |
| 67 | return 0; |
| 68 | } |
Saravana Kannan | cedb32e | 2014-01-22 00:15:33 -0800 | [diff] [blame] | 69 | #endif |
| 70 | |
| 71 | #endif /* _GOVERNOR_CACHE_HWMON_H */ |