From patchwork Fri Oct 29 15:38:20 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 290662 X-Patchwork-Delegate: khilman@deeprootsystems.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id o9TFcsuB013054 for ; Fri, 29 Oct 2010 15:38:55 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934076Ab0J2Piy (ORCPT ); Fri, 29 Oct 2010 11:38:54 -0400 Received: from arroyo.ext.ti.com ([192.94.94.40]:51561 "EHLO arroyo.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932789Ab0J2Pik (ORCPT ); Fri, 29 Oct 2010 11:38:40 -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 o9TFcaRX009025 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 29 Oct 2010 10:38:38 -0500 Received: from localhost.localdomain (localhost [127.0.0.1]) by dbdp31.itg.ti.com (8.13.8/8.13.8) with ESMTP id o9TFcTYq012648; Fri, 29 Oct 2010 21:08:33 +0530 (IST) From: Thara Gopinath To: linux-omap@vger.kernel.org Cc: paul@pwsan.com, khilman@deeprootsystems.com, b-cousson@ti.com, vishwanath.bs@ti.com, sawant@ti.com, Thara Gopinath Subject: [PATCH v2 06/14] OMAP: Voltage layer changes to support DVFS. Date: Fri, 29 Oct 2010 21:08:20 +0530 Message-Id: <1288366708-32302-7-git-send-email-thara@ti.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1288366708-32302-1-git-send-email-thara@ti.com> References: <1288366708-32302-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 (demeter1.kernel.org [140.211.167.41]); Fri, 29 Oct 2010 15:38:55 +0000 (UTC) diff --git a/arch/arm/mach-omap2/voltage.c b/arch/arm/mach-omap2/voltage.c index 6c2e4ef..458f8c1 100644 --- a/arch/arm/mach-omap2/voltage.c +++ b/arch/arm/mach-omap2/voltage.c @@ -27,9 +27,11 @@ #include #include #include +#include #include #include +#include #include "prm-regbits-34xx.h" #include "prm44xx.h" @@ -1678,6 +1680,76 @@ struct voltagedomain *omap_voltage_domain_lookup(char *name) } /** + * omap_voltage_scale : API to scale the devices associated with a + * voltage domain vdd voltage. + * @volt_domain : the voltage domain to be scaled + * @volt : the new voltage for the voltage domain + * + * This API runs through the list of devices associated with the + * voltage domain and scales the device rates to those corresponding + * to the new voltage of the voltage domain. This API also scales + * the voltage domain voltage to the new value. Returns 0 on success + * else the error value. + */ +int omap_voltage_scale(struct voltagedomain *voltdm, unsigned long volt) +{ + unsigned long curr_volt; + int is_volt_scaled = 0; + struct omap_vdd_info *vdd; + struct omap_vdd_dev_list *temp_dev; + + if (!voltdm || IS_ERR(voltdm)) { + pr_warning("%s: VDD specified does not exist!\n", __func__); + return -EINVAL; + } + + vdd = container_of(voltdm, struct omap_vdd_info, voltdm); + + mutex_lock(&vdd->scaling_mutex); + + curr_volt = omap_voltage_get_nom_volt(voltdm); + + if (curr_volt == volt) { + is_volt_scaled = 1; + } else if (curr_volt < volt) { + omap_voltage_scale_vdd(voltdm, volt); + is_volt_scaled = 1; + } + + list_for_each_entry(temp_dev, &vdd->dev_list, node) { + struct device *dev; + struct opp *opp; + unsigned long freq; + + dev = temp_dev->dev; + + opp = opp_find_voltage(dev, volt); + if (IS_ERR(opp)) { + dev_err(dev, "%s: Unable to find OPP for" + "volt%ld\n", __func__, volt); + continue; + } + + freq = opp_get_freq(opp); + + if (freq == omap_device_get_rate(dev)) { + dev_warn(dev, "%s: Already at the requested" + "rate %ld\n", __func__, freq); + continue; + } + + omap_device_set_rate(dev, freq); + } + + if (!is_volt_scaled) + omap_voltage_scale_vdd(voltdm, volt); + + mutex_unlock(&vdd->scaling_mutex); + + return 0; +} + +/** * omap_voltage_init : Volatage init API which does VP and VC init. */ static int __init omap_voltage_init(void) diff --git a/arch/arm/plat-omap/include/plat/voltage.h b/arch/arm/plat-omap/include/plat/voltage.h index dc64a9a..54d50e2 100644 --- a/arch/arm/plat-omap/include/plat/voltage.h +++ b/arch/arm/plat-omap/include/plat/voltage.h @@ -153,6 +153,7 @@ void omap_change_voltscale_method(int voltscale_method); int omap_voltage_add_request(struct voltagedomain *voltdm, struct device *dev, unsigned long *volt); int omap_voltage_add_dev(struct voltagedomain *voltdm, struct device *dev); +int omap_voltage_scale(struct voltagedomain *voltdm, unsigned long volt); #else static inline void omap_voltage_register_pmic (struct omap_volt_pmic_info *pmic_info) {} @@ -169,6 +170,12 @@ static inline int omap_voltage_add_dev(struct voltagedomain *voltdm, { return -EINVAL; } + +static inline int omap_voltage_scale(struct voltagedomain *voltdm, + unsigned long volt) +{ + return -EINVAL; +} #endif #endif