cpufreq: dt: Support governor tunables per policy
authorViresh Kumar <viresh.kumar@linaro.org>
Fri, 9 Sep 2016 11:18:08 +0000 (16:48 +0530)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Tue, 13 Sep 2016 00:39:12 +0000 (02:39 +0200)
The cpufreq-dt driver is also used for systems with multiple
clock/voltage domains for CPUs, i.e. multiple cpufreq policies in a
system.

And in such cases the platform users may want to enable "governor
tunables per policy". Support that via platform data, as not all users
of the driver would want that behavior.

Reported-by: Juri Lelli <Juri.Lelli@arm.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/cpufreq/cpufreq-dt-platdev.c
drivers/cpufreq/cpufreq-dt.c
drivers/cpufreq/cpufreq-dt.h [new file with mode: 0644]

index 276378a..d2637e1 100644 (file)
@@ -11,6 +11,8 @@
 #include <linux/of.h>
 #include <linux/platform_device.h>
 
+#include "cpufreq-dt.h"
+
 static const struct of_device_id machines[] __initconst = {
        { .compatible = "allwinner,sun4i-a10", },
        { .compatible = "allwinner,sun5i-a10s", },
@@ -93,7 +95,8 @@ static int __init cpufreq_dt_platdev_init(void)
        if (!match)
                return -ENODEV;
 
-       return PTR_ERR_OR_ZERO(platform_device_register_simple("cpufreq-dt", -1,
-                                                              NULL, 0));
+       return PTR_ERR_OR_ZERO(platform_device_register_data(NULL, "cpufreq-dt",
+                              -1, match->data,
+                              sizeof(struct cpufreq_dt_platform_data)));
 }
 device_initcall(cpufreq_dt_platdev_init);
index 2bd2053..5c07ae0 100644 (file)
@@ -25,6 +25,8 @@
 #include <linux/slab.h>
 #include <linux/thermal.h>
 
+#include "cpufreq-dt.h"
+
 struct private_data {
        struct device *cpu_dev;
        struct thermal_cooling_device *cdev;
@@ -353,6 +355,7 @@ static struct cpufreq_driver dt_cpufreq_driver = {
 
 static int dt_cpufreq_probe(struct platform_device *pdev)
 {
+       struct cpufreq_dt_platform_data *data = dev_get_platdata(&pdev->dev);
        int ret;
 
        /*
@@ -366,6 +369,9 @@ static int dt_cpufreq_probe(struct platform_device *pdev)
        if (ret)
                return ret;
 
+       if (data && data->have_governor_per_policy)
+               dt_cpufreq_driver.flags |= CPUFREQ_HAVE_GOVERNOR_PER_POLICY;
+
        ret = cpufreq_register_driver(&dt_cpufreq_driver);
        if (ret)
                dev_err(&pdev->dev, "failed register driver: %d\n", ret);
diff --git a/drivers/cpufreq/cpufreq-dt.h b/drivers/cpufreq/cpufreq-dt.h
new file mode 100644 (file)
index 0000000..54d774e
--- /dev/null
@@ -0,0 +1,19 @@
+/*
+ * Copyright (C) 2016 Linaro
+ * Viresh Kumar <viresh.kumar@linaro.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef __CPUFREQ_DT_H__
+#define __CPUFREQ_DT_H__
+
+#include <linux/types.h>
+
+struct cpufreq_dt_platform_data {
+       bool have_governor_per_policy;
+};
+
+#endif /* __CPUFREQ_DT_H__ */