From patchwork Wed Aug 18 11:20:01 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 120138 X-Patchwork-Delegate: khilman@deeprootsystems.com 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 o7IBKWwN019617 for ; Wed, 18 Aug 2010 11:20:33 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752815Ab0HRLU1 (ORCPT ); Wed, 18 Aug 2010 07:20:27 -0400 Received: from arroyo.ext.ti.com ([192.94.94.40]:41227 "EHLO arroyo.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752790Ab0HRLUY (ORCPT ); Wed, 18 Aug 2010 07:20:24 -0400 Received: from dbdp31.itg.ti.com ([172.24.170.98]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id o7IBKJYI020704 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 18 Aug 2010 06:20:22 -0500 Received: from localhost.localdomain (localhost [127.0.0.1]) by dbdp31.itg.ti.com (8.13.8/8.13.8) with ESMTP id o7IBKGp8022576; Wed, 18 Aug 2010 16:50:17 +0530 (IST) From: Thara Gopinath To: linux-omap@vger.kernel.org Cc: khilman@deeprootsystems.com, paul@pwsan.com, vishwanath.bs@ti.com, sawant@ti.com, b-cousson@ti.com, Thara Gopinath Subject: [PATCH 02/13] OMAP: Introduce API in the OPP layer to find the opp entry corresponding to a voltage. Date: Wed, 18 Aug 2010 16:50:01 +0530 Message-Id: <1282130412-12027-3-git-send-email-thara@ti.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1282130412-12027-1-git-send-email-thara@ti.com> References: <1282130412-12027-1-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]); Wed, 18 Aug 2010 11:20:33 +0000 (UTC) diff --git a/arch/arm/plat-omap/include/plat/opp.h b/arch/arm/plat-omap/include/plat/opp.h index 997b56e..0e580ed 100644 --- a/arch/arm/plat-omap/include/plat/opp.h +++ b/arch/arm/plat-omap/include/plat/opp.h @@ -76,6 +76,8 @@ struct omap_opp *opp_find_freq_floor(struct device *dev, unsigned long *freq); 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); + int opp_add(const struct omap_opp_def *opp_def); int opp_enable(struct omap_opp *opp); @@ -119,6 +121,12 @@ static inline struct omap_opp *opp_find_freq_ceil(struct omap_opp *oppl, return ERR_PTR(-EINVAL); } +static inline struct omap_opp *opp_find_voltage(struct device *dev, + unsigned long volt) +{ + 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 5a86bdd..a3dea82 100644 --- a/arch/arm/plat-omap/opp.c +++ b/arch/arm/plat-omap/opp.c @@ -290,6 +290,34 @@ struct omap_opp *opp_find_freq_floor(struct device *dev, unsigned long *freq) return opp; } +/** + * opp_find_voltage() - search for an exact voltage + * @dev: device pointer associated with the opp type + * @volt: voltage to search for + * + * Searches for exact match in the opp list and returns handle to the matching + * opp if found, else returns ERR_PTR in case of error and should be handled + * using IS_ERR. + */ +struct omap_opp *opp_find_voltage(struct device *dev, unsigned long volt) +{ + struct device_opp *dev_opp; + struct omap_opp *temp_opp, *opp = ERR_PTR(-ENODEV); + + dev_opp = find_device_opp(dev); + if (IS_ERR(dev_opp)) + return opp; + + list_for_each_entry(temp_opp, &dev_opp->opp_list, node) { + if (temp_opp->enabled && temp_opp->u_volt == volt) { + opp = temp_opp; + break; + } + } + + return opp; +} + /* 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)