blob: 7578399cfb889d7603a46a8b4b1cbafa5e68903f [file] [log] [blame]
Saravana Kannanedad3012013-09-23 19:27:57 -07001/*
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 Kannanb93a2752015-06-11 16:04:23 -070024 * @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 Gupta4d1f4f42015-05-08 12:04:56 -070027 * @set_throttle_adj: Set throttle adjust field to the given value
28 * @get_throttle_adj: Get the value written to throttle adjust field
Saravana Kannanedad3012013-09-23 19:27:57 -070029 * @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 */
45struct bw_hwmon {
46 int (*start_hwmon)(struct bw_hwmon *hw, unsigned long mbps);
47 void (*stop_hwmon)(struct bw_hwmon *hw);
Saravana Kannancddae1b2014-08-07 19:38:02 -070048 int (*suspend_hwmon)(struct bw_hwmon *hw);
49 int (*resume_hwmon)(struct bw_hwmon *hw);
Saravana Kannanb93a2752015-06-11 16:04:23 -070050 unsigned long (*set_thres)(struct bw_hwmon *hw, unsigned long bytes);
Saravana Kannanf9d8fb12016-03-30 17:47:58 -070051 unsigned long (*set_hw_events)(struct bw_hwmon *hw,
52 unsigned int sample_ms);
Saravana Kannanb93a2752015-06-11 16:04:23 -070053 unsigned long (*get_bytes_and_clear)(struct bw_hwmon *hw);
Rohit Gupta4d1f4f42015-05-08 12:04:56 -070054 int (*set_throttle_adj)(struct bw_hwmon *hw, uint adj);
55 u32 (*get_throttle_adj)(struct bw_hwmon *hw);
Saravana Kannanedad3012013-09-23 19:27:57 -070056 struct device *dev;
57 struct device_node *of_node;
58 struct devfreq_governor *gov;
59
Saravana Kannanf9d8fb12016-03-30 17:47:58 -070060 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 Kannanedad3012013-09-23 19:27:57 -070065 struct devfreq *df;
66};
67
68#ifdef CONFIG_DEVFREQ_GOV_QCOM_BW_HWMON
69int register_bw_hwmon(struct device *dev, struct bw_hwmon *hwmon);
70int update_bw_hwmon(struct bw_hwmon *hwmon);
Saravana Kannanb93a2752015-06-11 16:04:23 -070071int bw_hwmon_sample_end(struct bw_hwmon *hwmon);
Saravana Kannanedad3012013-09-23 19:27:57 -070072#else
73static inline int register_bw_hwmon(struct device *dev,
74 struct bw_hwmon *hwmon)
75{
76 return 0;
77}
Saravana Kannanb93a2752015-06-11 16:04:23 -070078static inline int update_bw_hwmon(struct bw_hwmon *hwmon)
79{
80 return 0;
81}
82static inline int bw_hwmon_sample_end(struct bw_hwmon *hwmon)
Saravana Kannanedad3012013-09-23 19:27:57 -070083{
84 return 0;
85}
86#endif
87
88#endif /* _GOVERNOR_BW_HWMON_H */