Saravana Kannan | edad301 | 2013-09-23 19:27:57 -0700 | [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_BW_HWMON_H |
| 15 | #define _GOVERNOR_BW_HWMON_H |
| 16 | |
| 17 | #include <linux/kernel.h> |
| 18 | #include <linux/devfreq.h> |
| 19 | |
| 20 | /** |
| 21 | * struct bw_hwmon - dev BW HW monitor info |
| 22 | * @start_hwmon: Start the HW monitoring of the dev BW |
| 23 | * @stop_hwmon: Stop the HW monitoring of dev BW |
Saravana Kannan | b93a275 | 2015-06-11 16:04:23 -0700 | [diff] [blame] | 24 | * @set_thres: Set the count threshold to generate an IRQ |
| 25 | * @get_bytes_and_clear: Get the bytes transferred since the last call |
| 26 | * and reset the counter to start over. |
Rohit Gupta | 4d1f4f4 | 2015-05-08 12:04:56 -0700 | [diff] [blame] | 27 | * @set_throttle_adj: Set throttle adjust field to the given value |
| 28 | * @get_throttle_adj: Get the value written to throttle adjust field |
Saravana Kannan | edad301 | 2013-09-23 19:27:57 -0700 | [diff] [blame] | 29 | * @dev: Pointer to device that this HW monitor can |
| 30 | * monitor. |
| 31 | * @of_node: OF node of device that this HW monitor can |
| 32 | * monitor. |
| 33 | * @gov: devfreq_governor struct that should be used |
| 34 | * when registering this HW monitor with devfreq. |
| 35 | * Only the name field is expected to be |
| 36 | * initialized. |
| 37 | * @df: Devfreq node that this HW monitor is being |
| 38 | * used for. NULL when not actively in use and |
| 39 | * non-NULL when in use. |
| 40 | * |
| 41 | * One of dev, of_node or governor_name needs to be specified for a |
| 42 | * successful registration. |
| 43 | * |
| 44 | */ |
| 45 | struct bw_hwmon { |
| 46 | int (*start_hwmon)(struct bw_hwmon *hw, unsigned long mbps); |
| 47 | void (*stop_hwmon)(struct bw_hwmon *hw); |
Saravana Kannan | cddae1b | 2014-08-07 19:38:02 -0700 | [diff] [blame] | 48 | int (*suspend_hwmon)(struct bw_hwmon *hw); |
| 49 | int (*resume_hwmon)(struct bw_hwmon *hw); |
Saravana Kannan | b93a275 | 2015-06-11 16:04:23 -0700 | [diff] [blame] | 50 | unsigned long (*set_thres)(struct bw_hwmon *hw, unsigned long bytes); |
Saravana Kannan | f9d8fb1 | 2016-03-30 17:47:58 -0700 | [diff] [blame] | 51 | unsigned long (*set_hw_events)(struct bw_hwmon *hw, |
| 52 | unsigned int sample_ms); |
Saravana Kannan | b93a275 | 2015-06-11 16:04:23 -0700 | [diff] [blame] | 53 | unsigned long (*get_bytes_and_clear)(struct bw_hwmon *hw); |
Rohit Gupta | 4d1f4f4 | 2015-05-08 12:04:56 -0700 | [diff] [blame] | 54 | int (*set_throttle_adj)(struct bw_hwmon *hw, uint adj); |
| 55 | u32 (*get_throttle_adj)(struct bw_hwmon *hw); |
Saravana Kannan | edad301 | 2013-09-23 19:27:57 -0700 | [diff] [blame] | 56 | struct device *dev; |
| 57 | struct device_node *of_node; |
| 58 | struct devfreq_governor *gov; |
| 59 | |
Saravana Kannan | f9d8fb1 | 2016-03-30 17:47:58 -0700 | [diff] [blame] | 60 | unsigned long up_wake_mbps; |
| 61 | unsigned long undo_over_req_mbps; |
| 62 | unsigned long down_wake_mbps; |
| 63 | unsigned int down_cnt; |
| 64 | |
Saravana Kannan | edad301 | 2013-09-23 19:27:57 -0700 | [diff] [blame] | 65 | struct devfreq *df; |
| 66 | }; |
| 67 | |
| 68 | #ifdef CONFIG_DEVFREQ_GOV_QCOM_BW_HWMON |
| 69 | int register_bw_hwmon(struct device *dev, struct bw_hwmon *hwmon); |
| 70 | int update_bw_hwmon(struct bw_hwmon *hwmon); |
Saravana Kannan | b93a275 | 2015-06-11 16:04:23 -0700 | [diff] [blame] | 71 | int bw_hwmon_sample_end(struct bw_hwmon *hwmon); |
Saravana Kannan | edad301 | 2013-09-23 19:27:57 -0700 | [diff] [blame] | 72 | #else |
| 73 | static inline int register_bw_hwmon(struct device *dev, |
| 74 | struct bw_hwmon *hwmon) |
| 75 | { |
| 76 | return 0; |
| 77 | } |
Saravana Kannan | b93a275 | 2015-06-11 16:04:23 -0700 | [diff] [blame] | 78 | static inline int update_bw_hwmon(struct bw_hwmon *hwmon) |
| 79 | { |
| 80 | return 0; |
| 81 | } |
| 82 | static inline int bw_hwmon_sample_end(struct bw_hwmon *hwmon) |
Saravana Kannan | edad301 | 2013-09-23 19:27:57 -0700 | [diff] [blame] | 83 | { |
| 84 | return 0; |
| 85 | } |
| 86 | #endif |
| 87 | |
| 88 | #endif /* _GOVERNOR_BW_HWMON_H */ |