From patchwork Thu Oct 22 09:42:16 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sekhar Nori X-Patchwork-Id: 55283 Received: from devils.ext.ti.com (devils.ext.ti.com [198.47.26.153]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n9M9jRXN009291 for ; Thu, 22 Oct 2009 09:45:28 GMT Received: from dlep34.itg.ti.com ([157.170.170.115]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id n9M9hK47001287 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 22 Oct 2009 04:43:20 -0500 Received: from linux.omap.com (localhost [127.0.0.1]) by dlep34.itg.ti.com (8.13.7/8.13.7) with ESMTP id n9M9hJCS016195; Thu, 22 Oct 2009 04:43:19 -0500 (CDT) Received: from linux.omap.com (localhost [127.0.0.1]) by linux.omap.com (Postfix) with ESMTP id 70EA380639; Thu, 22 Oct 2009 04:43:01 -0500 (CDT) X-Original-To: davinci-linux-open-source@linux.davincidsp.com Delivered-To: davinci-linux-open-source@linux.davincidsp.com Received: from dbdp31.itg.ti.com (dbdp31.itg.ti.com [172.24.170.98]) by linux.omap.com (Postfix) with ESMTP id B73548062C for ; Thu, 22 Oct 2009 04:42:21 -0500 (CDT) Received: from psplinux051.india.ti.com (localhost [127.0.0.1]) by dbdp31.itg.ti.com (8.13.8/8.13.8) with ESMTP id n9M9gJod018921; Thu, 22 Oct 2009 15:12:20 +0530 (IST) Received: from psplinux051.india.ti.com (localhost [127.0.0.1]) by psplinux051.india.ti.com (8.13.1/8.13.1) with ESMTP id n9M9gJ8M022280; Thu, 22 Oct 2009 15:12:19 +0530 Received: (from a0875516@localhost) by psplinux051.india.ti.com (8.13.1/8.13.1/Submit) id n9M9gJps022277; Thu, 22 Oct 2009 15:12:19 +0530 From: Sekhar Nori To: davinci-linux-open-source@linux.davincidsp.com Date: Thu, 22 Oct 2009 15:12:16 +0530 Message-Id: <1256204538-20794-4-git-send-email-nsekhar@ti.com> X-Mailer: git-send-email 1.6.2.4 In-Reply-To: <1256204538-20794-3-git-send-email-nsekhar@ti.com> References: <1256204538-20794-1-git-send-email-nsekhar@ti.com> <1256204538-20794-2-git-send-email-nsekhar@ti.com> <1256204538-20794-3-git-send-email-nsekhar@ti.com> Cc: Subject: [PATCH 4/6] davinci: DA850/OMAP-L138: avoid using separate initcall for initializing regulator X-BeenThere: davinci-linux-open-source@linux.davincidsp.com X-Mailman-Version: 2.1.4 Precedence: list List-Id: davinci-linux-open-source.linux.davincidsp.com List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: davinci-linux-open-source-bounces@linux.davincidsp.com Errors-To: davinci-linux-open-source-bounces@linux.davincidsp.com diff --git a/arch/arm/mach-davinci/cpufreq.c b/arch/arm/mach-davinci/cpufreq.c index 8c8c07b..d3fa6de 100644 --- a/arch/arm/mach-davinci/cpufreq.c +++ b/arch/arm/mach-davinci/cpufreq.c @@ -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) { diff --git a/arch/arm/mach-davinci/da850.c b/arch/arm/mach-davinci/da850.c index a13a6c4..c2d2724 100644 --- a/arch/arm/mach-davinci/da850.c +++ b/arch/arm/mach-davinci/da850.c @@ -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 __init 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, diff --git a/arch/arm/mach-davinci/include/mach/cpufreq.h b/arch/arm/mach-davinci/include/mach/cpufreq.h index 442bdea..3c089cf 100644 --- a/arch/arm/mach-davinci/include/mach/cpufreq.h +++ b/arch/arm/mach-davinci/include/mach/cpufreq.h @@ -20,6 +20,7 @@ struct davinci_cpufreq_config { struct cpufreq_frequency_table *freq_table; int (*set_voltage) (unsigned int index); + int (*init) (void); }; #endif