]> bbs.cooldavid.org Git - net-next-2.6.git/commitdiff
davinci: DA850/OMAP-L138: avoid using separate initcall for initializing regulator
authorSekhar Nori <nsekhar@ti.com>
Thu, 22 Oct 2009 09:42:16 +0000 (15:12 +0530)
committerKevin Hilman <khilman@deeprootsystems.com>
Wed, 25 Nov 2009 18:21:37 +0000 (10:21 -0800)
Using a device_initcall() for initializing the voltage regulator
on DA850 is not such a good idea because it gets called for all
platforms - even those who do not have a regulator implemented.
This leads to a big fat warning message during boot-up when
regulator cannot be found.

Instead, tie initialization of voltage regulator to cpufreq init.
Define a platform specific init call which in case of DA850 gets
used for initializing the regulator. On other future platforms it
can be used for other purposes.

Signed-off-by: Sekhar Nori <nsekhar@ti.com>
Signed-off-by: Kevin Hilman <khilman@deeprootsystems.com>
arch/arm/mach-davinci/cpufreq.c
arch/arm/mach-davinci/da850.c
arch/arm/mach-davinci/include/mach/cpufreq.h

index 8c8c07b12d87383957cdca520748ac02934c4373..d3fa6de1e20f6d5cb85d4e8424e26a6c9d5889b4 100644 (file)
@@ -127,6 +127,13 @@ static int __init davinci_cpu_init(struct cpufreq_policy *policy)
        if (policy->cpu != 0)
                return -EINVAL;
 
+       /* Finish platform specific initialization */
+       if (pdata->init) {
+               result = pdata->init();
+               if (result)
+                       return result;
+       }
+
        policy->cur = policy->min = policy->max = davinci_getspeed(0);
 
        if (freq_table) {
index 0f27c93545bfc3d83d8d71de1e55242f01267bea..717806c6cef942c3fdc5f65172d1643b2d706cfc 100644 (file)
@@ -907,8 +907,39 @@ static struct cpufreq_frequency_table da850_freq_table[] = {
        },
 };
 
+#ifdef CONFIG_REGULATOR
+static struct regulator *cvdd;
+
+static int da850_set_voltage(unsigned int index)
+{
+       struct da850_opp *opp;
+
+       if (!cvdd)
+               return -ENODEV;
+
+       opp = (struct da850_opp *) da850_freq_table[index].index;
+
+       return regulator_set_voltage(cvdd, opp->cvdd_min, opp->cvdd_max);
+}
+
+static int da850_regulator_init(void)
+{
+       cvdd = regulator_get(NULL, "cvdd");
+       if (WARN(IS_ERR(cvdd), "Unable to obtain voltage regulator for CVDD;"
+                                       " voltage scaling unsupported\n")) {
+               return PTR_ERR(cvdd);
+       }
+
+       return 0;
+}
+#endif
+
 static struct davinci_cpufreq_config cpufreq_info = {
        .freq_table = &da850_freq_table[0],
+#ifdef CONFIG_REGULATOR
+       .init = da850_regulator_init,
+       .set_voltage = da850_set_voltage,
+#endif
 };
 
 static struct platform_device da850_cpufreq_device = {
@@ -997,39 +1028,6 @@ static int da850_round_armrate(struct clk *clk, unsigned long rate)
 }
 #endif
 
-#ifdef CONFIG_REGULATOR
-static struct regulator *cvdd;
-
-static int da850_set_voltage(unsigned int index)
-{
-       struct da850_opp *opp;
-
-       if (!cvdd)
-               return -ENODEV;
-
-       opp = (struct da850_opp *) da850_freq_table[index].index;
-
-       return regulator_set_voltage(cvdd, opp->cvdd_min, opp->cvdd_max);
-}
-
-static int __init da850_regulator_init(void)
-{
-       int ret = 0;
-
-       cvdd = regulator_get(NULL, "cvdd");
-       if (WARN(IS_ERR(cvdd), "Unable to obtain voltage regulator for CVDD;"
-                                       " voltage scaling unsupported\n")) {
-               ret = PTR_ERR(cvdd);
-               goto out;
-       }
-
-       cpufreq_info.set_voltage = da850_set_voltage;
-
-out:
-       return ret;
-}
-device_initcall(da850_regulator_init);
-#endif
 
 static struct davinci_soc_info davinci_soc_info_da850 = {
        .io_desc                = da850_io_desc,
index 442bdea4463229e06c1891a3fdee309b56719fcb..3c089cfb6cd63152ad14465ff6dd5392a415ad0f 100644 (file)
@@ -20,6 +20,7 @@
 struct davinci_cpufreq_config {
        struct cpufreq_frequency_table *freq_table;
        int (*set_voltage) (unsigned int index);
+       int (*init) (void);
 };
 
 #endif