cpufreq: scmi: Set transition_delay_us
[sfrench/cifs-2.6.git] / drivers / cpufreq / scmi-cpufreq.c
index 4ee23f4ebf4a40bacf10c493c88b247dd1dff09e..0b483bd0d3ca6c5ca1668c6d87d431888ca26df1 100644 (file)
@@ -144,6 +144,29 @@ scmi_get_cpu_power(struct device *cpu_dev, unsigned long *power,
        return 0;
 }
 
+static int
+scmi_get_rate_limit(u32 domain, bool has_fast_switch)
+{
+       int ret, rate_limit;
+
+       if (has_fast_switch) {
+               /*
+                * Fast channels are used whenever available,
+                * so use their rate_limit value if populated.
+                */
+               ret = perf_ops->fast_switch_rate_limit(ph, domain,
+                                                      &rate_limit);
+               if (!ret && rate_limit)
+                       return rate_limit;
+       }
+
+       ret = perf_ops->rate_limit_get(ph, domain, &rate_limit);
+       if (ret)
+               return 0;
+
+       return rate_limit;
+}
+
 static int scmi_cpufreq_init(struct cpufreq_policy *policy)
 {
        int ret, nr_opp, domain;
@@ -250,6 +273,9 @@ static int scmi_cpufreq_init(struct cpufreq_policy *policy)
        policy->fast_switch_possible =
                perf_ops->fast_switch_possible(ph, domain);
 
+       policy->transition_delay_us =
+               scmi_get_rate_limit(domain, policy->fast_switch_possible);
+
        return 0;
 
 out_free_opp: