From patchwork Fri Jul 2 10:18:25 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 109852 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.4/8.14.3) with ESMTP id o62AIpv4014491 for ; Fri, 2 Jul 2010 10:18:52 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754635Ab0GBKSt (ORCPT ); Fri, 2 Jul 2010 06:18:49 -0400 Received: from devils.ext.ti.com ([198.47.26.153]:38687 "EHLO devils.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753344Ab0GBKSk (ORCPT ); Fri, 2 Jul 2010 06:18:40 -0400 Received: from dbdp31.itg.ti.com ([172.24.170.98]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id o62AIZV1032659 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 2 Jul 2010 05:18:38 -0500 Received: from linfarm488.india.ti.com (localhost [127.0.0.1]) by dbdp31.itg.ti.com (8.13.8/8.13.8) with ESMTP id o62AIVql017719; Fri, 2 Jul 2010 15:48:31 +0530 (IST) Received: from linfarm488.india.ti.com (localhost [127.0.0.1]) by linfarm488.india.ti.com (8.12.11/8.12.11) with ESMTP id o62AIVrf032230; Fri, 2 Jul 2010 15:48:31 +0530 Received: (from a0393109@localhost) by linfarm488.india.ti.com (8.12.11/8.12.11/Submit) id o62AIUUF032228; Fri, 2 Jul 2010 15:48:30 +0530 From: Thara Gopinath To: linux-omap@vger.kernel.org Cc: khilman@deeprootsystems.com, paul@pwsan.com, b-cousson@ti.com, vishwanath.bs@ti.com, sawant@ti.com, p-basak2@ti.com, Thara Gopinath Subject: [RFC 3/7] OMAP: Introduce voltage domain pointer and device specific set rate and get rate in device opp structures. Date: Fri, 2 Jul 2010 15:48:25 +0530 Message-Id: <1278065909-32148-4-git-send-email-thara@ti.com> X-Mailer: git-send-email 1.5.6.6 In-Reply-To: <1278065909-32148-3-git-send-email-thara@ti.com> References: <1278065909-32148-1-git-send-email-thara@ti.com> <1278065909-32148-2-git-send-email-thara@ti.com> <1278065909-32148-3-git-send-email-thara@ti.com> Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Fri, 02 Jul 2010 10:18:52 +0000 (UTC) diff --git a/arch/arm/plat-omap/include/plat/opp.h b/arch/arm/plat-omap/include/plat/opp.h index 893731f..15e1e70 100644 --- a/arch/arm/plat-omap/include/plat/opp.h +++ b/arch/arm/plat-omap/include/plat/opp.h @@ -16,6 +16,7 @@ #include #include +#include #include @@ -38,21 +39,45 @@ */ struct omap_opp_def { char *hwmod_name; + char *vdd_name; unsigned long freq; unsigned long u_volt; + int (*set_rate)(struct device *dev, unsigned long rate); + unsigned long (*get_rate) (struct device *dev); + bool enabled; }; +struct device_opp { + struct list_head node; + char *vdd_name; + + struct omap_hwmod *oh; + struct device *dev; + struct omap_volt_domain *volt_domain; + + struct list_head opp_list; + u32 opp_count; + u32 enabled_opp_count; + + int (*set_rate)(struct device *dev, unsigned long rate); + unsigned long (*get_rate) (struct device *dev); +}; + /* * Initialization wrapper used to define an OPP. * To point at the end of a terminator of a list of OPPs, * use OMAP_OPP_DEF(0, 0, 0) */ -#define OMAP_OPP_DEF(_hwmod_name, _enabled, _freq, _uv) \ +#define OMAP_OPP_DEF(_hwmod_name, _vdd_name, _set_rate, _get_rate, \ + _enabled, _freq, _uv) \ { \ .hwmod_name = _hwmod_name, \ + .vdd_name = _vdd_name, \ + .set_rate = _set_rate, \ + .get_rate = _get_rate, \ .enabled = _enabled, \ .freq = _freq, \ .u_volt = _uv, \ @@ -77,6 +102,8 @@ struct omap_opp *opp_find_freq_ceil(struct device *dev, unsigned long *freq); struct omap_opp *opp_find_voltage(struct device *dev, unsigned long volt); +struct device_opp *opp_find_dev_opp(struct device *dev); + int opp_add(const struct omap_opp_def *opp_def); int opp_enable(struct omap_opp *opp); @@ -89,6 +116,9 @@ u8 __deprecated opp_get_opp_id(struct omap_opp *opp); void opp_init_cpufreq_table(struct device *dev, struct cpufreq_frequency_table **table); + +struct device **opp_init_voltage_params(struct omap_volt_domain *volt_domain, + int *dev_count); #else static inline unsigned long opp_get_voltage(const struct omap_opp *opp) { @@ -124,6 +154,11 @@ static inline struct omap_opp *opp_find_freq_ceil(struct omap_opp *oppl, return ERR_PTR(-EINVAL); } +static inline struct device_opp *opp_find_dev_opp(struct device *dev) +{ + return ERR_PTR(-EINVAL); +} + static inline struct omap_opp *opp_add(struct omap_opp *oppl, const struct omap_opp_def *opp_def) { diff --git a/arch/arm/plat-omap/opp.c b/arch/arm/plat-omap/opp.c index 070ff5b..9bc53e8 100644 --- a/arch/arm/plat-omap/opp.c +++ b/arch/arm/plat-omap/opp.c @@ -22,6 +22,7 @@ #include #include #include +#include /** * struct omap_opp - OMAP OPP description structure @@ -43,17 +44,6 @@ struct omap_opp { struct device_opp *dev_opp; /* containing device_opp struct */ }; -struct device_opp { - struct list_head node; - - struct omap_hwmod *oh; - struct device *dev; - - struct list_head opp_list; - u32 opp_count; - u32 enabled_opp_count; -}; - static LIST_HEAD(dev_opp_list); /** @@ -330,6 +320,11 @@ struct omap_opp *opp_find_voltage(struct device *dev, unsigned long volt) return opp; } +struct device_opp *opp_find_dev_opp(struct device *dev) +{ + return find_device_opp(dev); +} + /* wrapper to reuse converting opp_def to opp struct */ static void omap_opp_populate(struct omap_opp *opp, const struct omap_opp_def *opp_def) @@ -385,6 +380,11 @@ int opp_add(const struct omap_opp_def *opp_def) dev_opp->oh = oh; dev_opp->dev = &oh->od->pdev.dev; + dev_opp->vdd_name = kzalloc(strlen(opp_def->vdd_name) + 1, + GFP_KERNEL); + strcpy(dev_opp->vdd_name, opp_def->vdd_name); + dev_opp->set_rate = opp_def->set_rate; + dev_opp->get_rate = opp_def->get_rate; INIT_LIST_HEAD(&dev_opp->opp_list); list_add(&dev_opp->node, &dev_opp_list); @@ -511,3 +511,28 @@ void opp_init_cpufreq_table(struct device *dev, *table = &freq_table[0]; } + +struct device **opp_init_voltage_params(struct omap_volt_domain *volt_domain, + int *dev_count) +{ + struct device_opp *dev_opp; + struct device **dev_list; + int count = 0, i = 0; + + list_for_each_entry(dev_opp, &dev_opp_list, node) { + if (!strcmp(dev_opp->vdd_name, volt_domain->name)) { + dev_opp->volt_domain = volt_domain; + count++; + } + } + + dev_list = kzalloc(sizeof(struct device *) * count, GFP_KERNEL); + + list_for_each_entry(dev_opp, &dev_opp_list, node) { + if (dev_opp->volt_domain == volt_domain) + dev_list[i++] = dev_opp->dev; + } + + *dev_count = count; + return dev_list; +}