@@ -14,6 +14,7 @@
#include <linux/devfreq-event.h>
#include <linux/device.h>
#include <linux/export.h>
+#include <linux/jiffies.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/pm_opp.h>
@@ -31,6 +32,7 @@ struct exynos_bus {
struct mutex lock;
unsigned long curr_freq;
+ unsigned long prev_time;
struct opp_table *opp_table;
struct clk *clk;
@@ -57,7 +59,22 @@ static int exynos_bus_##ops(struct exynos_bus *bus) \
}
exynos_bus_ops_edev(enable_edev);
exynos_bus_ops_edev(disable_edev);
-exynos_bus_ops_edev(set_event);
+
+static int exynos_bus_set_event(struct exynos_bus *bus)
+{
+ int i, ret;
+
+ bus->prev_time = jiffies;
+ for (i = 0; i < bus->edev_count; i++) {
+ if (!bus->edev[i])
+ continue;
+ ret = devfreq_event_set_event(bus->edev[i]);
+ if (ret < 0)
+ return ret;
+ }
+
+ return 0;
+}
static int exynos_bus_get_event(struct exynos_bus *bus,
struct devfreq_event_data *edata)
@@ -66,6 +83,8 @@ static int exynos_bus_get_event(struct exynos_bus *bus,
unsigned long load_count = 0, total_count = 0;
int i, ret = 0;
+ event_data.curr_freq = bus->curr_freq;
+ event_data.prev_time = bus->prev_time;
for (i = 0; i < bus->edev_count; i++) {
if (!bus->edev[i])
continue;
@@ -41,12 +41,16 @@ struct devfreq_event_dev {
* each count may represent a clock cycle, a time unit
* (ns/us/...), or anything the device driver wants.
* Generally, utilization is load_count / total_count.
+ * @prev_time : jiffies for interval calculations with polling.
+ * @curr_freq : current frequency for calculating max bandwidth.
*
* This structure contains the data of devfreq-event device for polling period.
*/
struct devfreq_event_data {
unsigned long load_count;
unsigned long total_count;
+ unsigned long prev_time;
+ unsigned long curr_freq;
};
/**
Add time to struct exynos_bus and time and current frequency to struct devfreq_event_data. This will allow to calculate load and max bandwidth in exynos-nocp driver. Signed-off-by: Kamil Konieczny <k.konieczny@samsung.com> --- drivers/devfreq/exynos-bus.c | 21 ++++++++++++++++++++- include/linux/devfreq-event.h | 4 ++++ 2 files changed, 24 insertions(+), 1 deletion(-)