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