From patchwork Sat Feb 19 12:01:46 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nishanth Menon X-Patchwork-Id: 574741 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 p1JC2BhA013921 for ; Sat, 19 Feb 2011 12:03:06 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754231Ab1BSMDG (ORCPT ); Sat, 19 Feb 2011 07:03:06 -0500 Received: from na3sys009aog107.obsmtp.com ([74.125.149.197]:44205 "EHLO na3sys009aog107.obsmtp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751556Ab1BSMDF (ORCPT ); Sat, 19 Feb 2011 07:03:05 -0500 Received: from source ([209.85.160.175]) (using TLSv1) by na3sys009aob107.postini.com ([74.125.148.12]) with SMTP ID DSNKTV+xd3w6729IMrAx0+l/b2tnLW/YStK/@postini.com; Sat, 19 Feb 2011 04:03:04 PST Received: by gyd8 with SMTP id 8so1941940gyd.34 for ; Sat, 19 Feb 2011 04:03:03 -0800 (PST) Received: by 10.150.195.4 with SMTP id s4mr2350827ybf.249.1298116983007; Sat, 19 Feb 2011 04:03:03 -0800 (PST) Received: from localhost (dragon.ti.com [192.94.94.33]) by mx.google.com with ESMTPS id 8sm1986796yhl.44.2011.02.19.04.02.59 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 19 Feb 2011 04:03:02 -0800 (PST) From: Nishanth Menon To: linux-omap Cc: Tony Lindgren , Kevin Hilman , Nishanth Menon Subject: [PATCH 07/19] omap3+: voltage: add transdone apis Date: Sat, 19 Feb 2011 17:31:46 +0530 Message-Id: <1298116918-30744-8-git-send-email-nm@ti.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1298116918-30744-1-git-send-email-nm@ti.com> References: <1298116918-30744-1-git-send-email-nm@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.6 (demeter1.kernel.org [140.211.167.41]); Sat, 19 Feb 2011 12:03:22 +0000 (UTC) diff --git a/arch/arm/mach-omap2/voltage.c b/arch/arm/mach-omap2/voltage.c index 08f0abf..77cb0cd 100644 --- a/arch/arm/mach-omap2/voltage.c +++ b/arch/arm/mach-omap2/voltage.c @@ -639,8 +639,8 @@ static int vp_forceupdate_scale_voltage(struct omap_vdd_info *vdd, struct omap_volt_data *target_volt) { u32 vpconfig; - u16 mod, ocp_mod; - u8 target_vsel, current_vsel, prm_irqst_reg; + u16 mod; + u8 target_vsel, current_vsel; int ret, timeout = 0; ret = _pre_volt_scale(vdd, target_volt, &target_vsel, ¤t_vsel); @@ -648,18 +648,13 @@ static int vp_forceupdate_scale_voltage(struct omap_vdd_info *vdd, return ret; mod = vdd->vp_reg.prm_mod; - ocp_mod = vdd->ocp_mod; - prm_irqst_reg = vdd->prm_irqst_reg; - /* * Clear all pending TransactionDone interrupt/status. Typical latency * is <3us */ while (timeout++ < VP_TRANXDONE_TIMEOUT) { - vdd->write_reg(vdd->vp_reg.tranxdone_status, - ocp_mod, prm_irqst_reg); - if (!(vdd->read_reg(ocp_mod, prm_irqst_reg) & - vdd->vp_reg.tranxdone_status)) + omap_vp_clear_transdone(&vdd->voltdm); + if (!omap_vp_is_transdone(&vdd->voltdm)) break; udelay(1); } @@ -691,7 +686,7 @@ static int vp_forceupdate_scale_voltage(struct omap_vdd_info *vdd, * Depends on SMPSWAITTIMEMIN/MAX and voltage change */ timeout = 0; - omap_test_timeout((vdd->read_reg(ocp_mod, prm_irqst_reg) & + omap_test_timeout((vdd->read_reg(vdd->ocp_mod, vdd->prm_irqst_reg) & vdd->vp_reg.tranxdone_status), VP_TRANXDONE_TIMEOUT, timeout); if (timeout >= VP_TRANXDONE_TIMEOUT) @@ -707,11 +702,9 @@ static int vp_forceupdate_scale_voltage(struct omap_vdd_info *vdd, */ timeout = 0; while (timeout++ < VP_TRANXDONE_TIMEOUT) { - vdd->write_reg(vdd->vp_reg.tranxdone_status, - ocp_mod, prm_irqst_reg); - if (!(vdd->read_reg(ocp_mod, prm_irqst_reg) & - vdd->vp_reg.tranxdone_status)) - break; + omap_vp_clear_transdone(&vdd->voltdm); + if (!omap_vp_is_transdone(&vdd->voltdm)) + break; udelay(1); } @@ -1269,6 +1262,47 @@ void omap_vp_disable(struct voltagedomain *voltdm) } /** + * omap_vp_is_transdone() - is voltage transfer done on vp? + * @voltdm: pointer to the VDD which is to be scaled. + * + * VP's transdone bit is the only way to ensure that the transfer + * of the voltage value has actually been send over to the PMIC + * This is hence useful for all users of voltage domain to precisely + * identify once the PMIC voltage has been set by the voltage processor + */ +bool omap_vp_is_transdone(struct voltagedomain *voltdm) +{ + struct omap_vdd_info *vdd; + + if (IS_ERR_OR_NULL(voltdm)) { + pr_warning("%s: Bad Params vdm=%p\n", __func__, voltdm); + return false; + } + + vdd = container_of(voltdm, struct omap_vdd_info, voltdm); + return (vdd->read_reg(vdd->ocp_mod, vdd->prm_irqst_reg) & + vdd->vp_reg.tranxdone_status) ? true : false; +} + +/** + * omap_vp_clear_transdone() - clear voltage transfer done status on vp + * @voltdm: pointer to the VDD which is to be scaled. + */ +bool omap_vp_clear_transdone(struct voltagedomain *voltdm) +{ + struct omap_vdd_info *vdd; + + if (IS_ERR_OR_NULL(voltdm)) { + pr_warning("%s: Bad Params vdm=%p\n", __func__, voltdm); + return false; + } + + vdd = container_of(voltdm, struct omap_vdd_info, voltdm); + vdd->write_reg(vdd->vp_reg.tranxdone_status, + vdd->ocp_mod, vdd->prm_irqst_reg); + return true; +} +/** * omap_voltage_scale_vdd() - API to scale voltage of a particular * voltage domain. * @voltdm: pointer to the VDD which is to be scaled. diff --git a/arch/arm/plat-omap/include/plat/voltage.h b/arch/arm/plat-omap/include/plat/voltage.h index 52df49f..332c581 100644 --- a/arch/arm/plat-omap/include/plat/voltage.h +++ b/arch/arm/plat-omap/include/plat/voltage.h @@ -124,6 +124,8 @@ void omap_voltage_get_volttable(struct voltagedomain *voltdm, struct omap_volt_data *omap_voltage_get_voltdata(struct voltagedomain *voltdm, unsigned long volt); struct omap_volt_data *omap_voltage_get_nom_volt(struct voltagedomain *voltdm); +bool omap_vp_is_transdone(struct voltagedomain *voltdm); +bool omap_vp_clear_transdone(struct voltagedomain *voltdm); struct dentry *omap_voltage_get_dbgdir(struct voltagedomain *voltdm); #ifdef CONFIG_PM int omap_voltage_register_pmic(struct voltagedomain *voltdm,