blob: c6baf6ea21057697eef86ecf4ae3448b7d4655b6 [file] [log] [blame]
Saravana Kannancedb32e2014-01-22 00:15:33 -08001/*
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
20struct mrps_stats {
21 unsigned long high;
22 unsigned long med;
23 unsigned long low;
24 unsigned int busy_percent;
25};
26
Junjie Wu211bbef2014-10-17 13:13:52 -070027/**
28 * struct cache_hwmon - devfreq Cache HW monitor info
29 * @start_hwmon: Start the HW monitoring
30 * @stop_hwmon: Stop the HW monitoring
Junjie Wu211bbef2014-10-17 13:13:52 -070031 * @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 Wu211bbef2014-10-17 13:13:52 -070034 * @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 Kannancedb32e2014-01-22 00:15:33 -080040struct cache_hwmon {
Junjie Wu211bbef2014-10-17 13:13:52 -070041 int (*start_hwmon)(struct cache_hwmon *hw, struct mrps_stats *mrps);
42 void (*stop_hwmon)(struct cache_hwmon *hw);
Junjie Wu211bbef2014-10-17 13:13:52 -070043 unsigned long (*meas_mrps_and_set_irq)(struct cache_hwmon *hw,
Saravana Kannancedb32e2014-01-22 00:15:33 -080044 unsigned int tol, unsigned int us,
45 struct mrps_stats *mrps);
Junjie Wu211bbef2014-10-17 13:13:52 -070046 struct device *dev;
47 struct device_node *of_node;
48 struct devfreq *df;
Saravana Kannancedb32e2014-01-22 00:15:33 -080049};
50
51#ifdef CONFIG_DEVFREQ_GOV_QCOM_CACHE_HWMON
Junjie Wu211bbef2014-10-17 13:13:52 -070052int register_cache_hwmon(struct device *dev, struct cache_hwmon *hwmon);
Junjie Wu21d559a2014-10-20 15:47:07 -070053int update_cache_hwmon(struct cache_hwmon *hwmon);
Saravana Kannancedb32e2014-01-22 00:15:33 -080054#else
Junjie Wu211bbef2014-10-17 13:13:52 -070055static inline int register_cache_hwmon(struct device *dev,
56 struct cache_hwmon *hwmon)
Saravana Kannancedb32e2014-01-22 00:15:33 -080057{
58 return 0;
59}
Junjie Wu21d559a2014-10-20 15:47:07 -070060int update_cache_hwmon(struct cache_hwmon *hwmon)
61{
62 return 0;
63}
Saravana Kannancedb32e2014-01-22 00:15:33 -080064#endif
65
66#endif /* _GOVERNOR_CACHE_HWMON_H */