cpufreq: BOOST: Adjust setting of BOOST frequency just before first valid freq
authorLukasz Majewski <l.majewski@samsung.com>
Thu, 17 Jul 2014 14:50:55 +0000 (16:50 +0200)
committerChanho Park <chanho61.park@samsung.com>
Tue, 18 Nov 2014 03:00:07 +0000 (12:00 +0900)
Before this change the BOOST frequency was always hardcoded to be the
highest one. This worked for M0 and Proxima, but failed when support for
odroid U3 has been added.

Since odroid U3 supports three more freqs, higher than the boost for M0,
it is necessary to adjust setting of boost frequency. Without that on M0
cpufreq sets frequencies reserved for odroid, which is dangerous.

Change-Id: I70b19453d5853b6c0139f2c59c98dd5ad65da01e
Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
drivers/cpufreq/exynos-cpufreq.c

index 0ecb7c9..0bd56da 100644 (file)
@@ -293,7 +293,7 @@ int exynos_of_parse_boost(struct exynos_dvfs_info *info,
 {
        struct cpufreq_frequency_table *ft = info->freq_table;
        struct device_node *node = info->dev->of_node;
-       unsigned int boost_freq;
+       unsigned int boost_freq, i;
 
        if (of_property_read_u32(node, property_name, &boost_freq)) {
                pr_err("%s: Property: %s not found\n", __func__,
@@ -310,10 +310,19 @@ int exynos_of_parse_boost(struct exynos_dvfs_info *info,
         * frequency table is required.
         */
 
-       ft[0].index = CPUFREQ_BOOST_FREQ;
-       ft[0].frequency = boost_freq;
+       for (i = 0; ft[i].frequency != CPUFREQ_TABLE_END; i++)
+               if (ft[i].frequency != CPUFREQ_ENTRY_INVALID)
+                       break;
+
+       if (--i >= 0) {
+               ft[i].index = CPUFREQ_BOOST_FREQ;
+               ft[i].frequency = boost_freq;
+       } else {
+               pr_err("%s: BOOST index: %d out of range\n", __func__, i);
+               return -EINVAL;
+       }
 
-       pr_debug("%s: BOOST frequency: %d\n", __func__, ft[0].frequency);
+       pr_debug("%s: BOOST frequency: %d\n", __func__, ft[i].frequency);
 
        return 0;
 }