blob: 01b5a7556eac38282be36530f699a39686d75eee [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
Junjie Wucd8a2952014-10-30 12:13:03 -070020enum request_group {
21 HIGH,
22 MED,
23 LOW,
24 MAX_NUM_GROUPS,
25};
26
Saravana Kannancedb32e2014-01-22 00:15:33 -080027struct mrps_stats {
Junjie Wucd8a2952014-10-30 12:13:03 -070028 unsigned long mrps[MAX_NUM_GROUPS];
Saravana Kannancedb32e2014-01-22 00:15:33 -080029 unsigned int busy_percent;
30};
31
Junjie Wu211bbef2014-10-17 13:13:52 -070032/**
33 * struct cache_hwmon - devfreq Cache HW monitor info
34 * @start_hwmon: Start the HW monitoring
35 * @stop_hwmon: Stop the HW monitoring
Junjie Wu211bbef2014-10-17 13:13:52 -070036 * @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 Wu211bbef2014-10-17 13:13:52 -070039 * @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 Kannancedb32e2014-01-22 00:15:33 -080045struct cache_hwmon {
Junjie Wu211bbef2014-10-17 13:13:52 -070046 int (*start_hwmon)(struct cache_hwmon *hw, struct mrps_stats *mrps);
47 void (*stop_hwmon)(struct cache_hwmon *hw);
Junjie Wu211bbef2014-10-17 13:13:52 -070048 unsigned long (*meas_mrps_and_set_irq)(struct cache_hwmon *hw,
Saravana Kannancedb32e2014-01-22 00:15:33 -080049 unsigned int tol, unsigned int us,
50 struct mrps_stats *mrps);
Junjie Wu211bbef2014-10-17 13:13:52 -070051 struct device *dev;
52 struct device_node *of_node;
53 struct devfreq *df;
Saravana Kannancedb32e2014-01-22 00:15:33 -080054};
55
56#ifdef CONFIG_DEVFREQ_GOV_QCOM_CACHE_HWMON
Junjie Wu211bbef2014-10-17 13:13:52 -070057int register_cache_hwmon(struct device *dev, struct cache_hwmon *hwmon);
Junjie Wu21d559a2014-10-20 15:47:07 -070058int update_cache_hwmon(struct cache_hwmon *hwmon);
Saravana Kannancedb32e2014-01-22 00:15:33 -080059#else
Junjie Wu211bbef2014-10-17 13:13:52 -070060static inline int register_cache_hwmon(struct device *dev,
61 struct cache_hwmon *hwmon)
Saravana Kannancedb32e2014-01-22 00:15:33 -080062{
63 return 0;
64}
Junjie Wu21d559a2014-10-20 15:47:07 -070065int update_cache_hwmon(struct cache_hwmon *hwmon)
66{
67 return 0;
68}
Saravana Kannancedb32e2014-01-22 00:15:33 -080069#endif
70
71#endif /* _GOVERNOR_CACHE_HWMON_H */