summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOctav Zlatior <octav.zlatior@theobroma-systems.com>2015-05-27 18:02:27 +0200
committerKlaus Goger <klaus.goger@theobroma-systems.com>2015-07-30 18:53:01 +0200
commitd9619b4709496273d3b1f73ea72ead643c744374 (patch)
treea38f7d949f6a46436d2559a372bc89014b6c5a35
parentb3bc3244ea87a85a097830529811858f00c6bfa5 (diff)
cpufreq: adds custom sampling-rate support in dt
This allows the setting of a sampling-rate property for a cpu in the device-tree; if set, this will override the defaut sampling rate calculation Signed-off-by: Octav Zlatior <octav.zlatior@theobroma-systems.com> Signed-off-by: Christoph Muellner <christoph.muellner@theobroma-systems.com>
-rw-r--r--Documentation/devicetree/bindings/cpufreq/cpufreq-dt.txt6
-rw-r--r--drivers/cpufreq/cpufreq-dt.c5
-rw-r--r--drivers/cpufreq/cpufreq_governor.c7
-rw-r--r--include/linux/cpufreq.h3
4 files changed, 20 insertions, 1 deletions
diff --git a/Documentation/devicetree/bindings/cpufreq/cpufreq-dt.txt b/Documentation/devicetree/bindings/cpufreq/cpufreq-dt.txt
index e41c98ffbcc..eb492a9a0e1 100644
--- a/Documentation/devicetree/bindings/cpufreq/cpufreq-dt.txt
+++ b/Documentation/devicetree/bindings/cpufreq/cpufreq-dt.txt
@@ -21,6 +21,11 @@ Optional properties:
- cooling-min-level:
- cooling-max-level:
Please refer to Documentation/devicetree/bindings/thermal/thermal.txt.
+- sampling-rate: Override the default sample rate (calculated from transition
+ latency, please refer to Documentation/cpu-freq/governors.txt) with a
+ user-specified value (in microseconds); if the value is zero, the default
+ (calculated) value will be used; if the value is a non-zero integer smaller
+ than sampling_rate_min, sampling_rate_min will be used
Examples:
@@ -39,6 +44,7 @@ cpus {
198000 850000
>;
clock-latency = <61036>; /* two CLK32 periods */
+ sampling-rate = <160000>; /* 160 milliseconds */
#cooling-cells = <2>;
cooling-min-level = <0>;
cooling-max-level = <2>;
diff --git a/drivers/cpufreq/cpufreq-dt.c b/drivers/cpufreq/cpufreq-dt.c
index bab67db54b7..88812437e8a 100644
--- a/drivers/cpufreq/cpufreq-dt.c
+++ b/drivers/cpufreq/cpufreq-dt.c
@@ -193,6 +193,7 @@ static int cpufreq_init(struct cpufreq_policy *policy)
struct clk *cpu_clk;
unsigned long min_uV = ~0, max_uV = 0;
unsigned int transition_latency;
+ unsigned int sampling_rate = 0;
int ret;
ret = allocate_resources(policy->cpu, &cpu_dev, &cpu_reg, &cpu_clk);
@@ -230,6 +231,9 @@ static int cpufreq_init(struct cpufreq_policy *policy)
of_property_read_u32(np, "voltage-tolerance", &priv->voltage_tolerance);
+ if (of_property_read_u32(np, "sampling-rate", &sampling_rate))
+ sampling_rate = 0;
+
if (of_property_read_u32(np, "clock-latency", &transition_latency))
transition_latency = CPUFREQ_ETERNAL;
@@ -292,6 +296,7 @@ static int cpufreq_init(struct cpufreq_policy *policy)
}
policy->cpuinfo.transition_latency = transition_latency;
+ policy->cpuinfo.sampling_rate = sampling_rate;
pd = cpufreq_get_driver_data();
if (!pd || !pd->independent_clocks)
diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c
index 1b44496b2d2..53d06df8631 100644
--- a/drivers/cpufreq/cpufreq_governor.c
+++ b/drivers/cpufreq/cpufreq_governor.c
@@ -303,11 +303,16 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
if (latency == 0)
latency = 1;
+ sampling_rate = policy->cpuinfo.sampling_rate;
+
+ if (sampling_rate == 0)
+ sampling_rate = latency * LATENCY_MULTIPLIER;
+
/* Bring kernel and HW constraints together */
dbs_data->min_sampling_rate = max(dbs_data->min_sampling_rate,
MIN_LATENCY_MULTIPLIER * latency);
set_sampling_rate(dbs_data, max(dbs_data->min_sampling_rate,
- latency * LATENCY_MULTIPLIER));
+ sampling_rate));
if ((cdata->governor == GOV_CONSERVATIVE) &&
(!policy->governor->initialized)) {
diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
index 2ee4888c1f4..61f05a1ba13 100644
--- a/include/linux/cpufreq.h
+++ b/include/linux/cpufreq.h
@@ -49,6 +49,9 @@ struct cpufreq_cpuinfo {
/* in 10^(-9) s = nanoseconds */
unsigned int transition_latency;
+
+ /* in 10^(-9) s = nanoseconds */
+ unsigned int sampling_rate;
};
struct cpufreq_real_policy {