All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nishanth Menon <nm@ti.com>
To: linux-omap <linux-omap@vger.kernel.org>
Cc: linux-arm <linux-arm-kernel@lists.infradead.org>,
	Kevin Hilman <khilman@ti.com>, Tony <tony@atomide.com>,
	Paul <paul@pwsan.com>, Nishanth Menon <nm@ti.com>
Subject: [PATCH V3 07/19] OMAP3+: voltage: add transdone APIs
Date: Sat,  5 Mar 2011 20:59:10 +0530	[thread overview]
Message-ID: <1299338962-5602-8-git-send-email-nm@ti.com> (raw)
In-Reply-To: <1299338962-5602-1-git-send-email-nm@ti.com>

Transdone event in Voltage processor gives us fine grained status on
the current status of the voltage communication with the PMIC.
Unfortunately, IRQ generation by VP is based on the start of the
transmission to VC from VP, not at the end (or the completion of
the voltage setting). Hence any users of voltage layer who need
to know fine grained information such as confirmation if the voltage
is actually send to PMIC, needs to depend on this status.

Signed-off-by: Nishanth Menon <nm@ti.com>
---
 arch/arm/mach-omap2/voltage.c |   57 +++++++++++++++++++++++++++++++++++------
 arch/arm/mach-omap2/voltage.h |    2 +
 2 files changed, 51 insertions(+), 8 deletions(-)

diff --git a/arch/arm/mach-omap2/voltage.c b/arch/arm/mach-omap2/voltage.c
index a12ac1e..2d70d13 100644
--- a/arch/arm/mach-omap2/voltage.c
+++ b/arch/arm/mach-omap2/voltage.c
@@ -455,10 +455,8 @@ static int vp_forceupdate_scale_voltage(struct omap_vdd_info *vdd,
 	 * is <3us
 	 */
 	while (timeout++ < VP_TRANXDONE_TIMEOUT) {
-		vdd->write_reg(vdd->vp_data->prm_irqst_data->tranxdone_status,
-			       prm_irqst_ocp_mod_offs, prm_irqst_reg);
-		if (!(vdd->read_reg(prm_irqst_ocp_mod_offs, prm_irqst_reg) &
-		      vdd->vp_data->prm_irqst_data->tranxdone_status))
+		omap_vp_clear_transdone(&vdd->voltdm);
+		if (!omap_vp_is_transdone(&vdd->voltdm))
 			break;
 		udelay(1);
 	}
@@ -506,10 +504,8 @@ static int vp_forceupdate_scale_voltage(struct omap_vdd_info *vdd,
 	 */
 	timeout = 0;
 	while (timeout++ < VP_TRANXDONE_TIMEOUT) {
-		vdd->write_reg(vdd->vp_data->prm_irqst_data->tranxdone_status,
-			       prm_irqst_ocp_mod_offs, prm_irqst_reg);
-		if (!(vdd->read_reg(prm_irqst_ocp_mod_offs, prm_irqst_reg) &
-		      vdd->vp_data->prm_irqst_data->tranxdone_status))
+		omap_vp_clear_transdone(&vdd->voltdm);
+		if (!omap_vp_is_transdone(&vdd->voltdm))
 			break;
 		udelay(1);
 	}
@@ -824,6 +820,51 @@ 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(prm_irqst_ocp_mod_offs,
+		vdd->vp_data->prm_irqst_data->prm_irqst_reg) &
+		vdd->vp_data->prm_irqst_data->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_data->prm_irqst_data->tranxdone_status,
+			prm_irqst_ocp_mod_offs,
+			vdd->vp_data->prm_irqst_data->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/mach-omap2/voltage.h b/arch/arm/mach-omap2/voltage.h
index 6e9acd6..5b4e363 100644
--- a/arch/arm/mach-omap2/voltage.h
+++ b/arch/arm/mach-omap2/voltage.h
@@ -150,6 +150,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);
 int __init omap_voltage_early_init(s16 prm_mod, s16 prm_irqst_mod,
 				   struct omap_vdd_info *omap_vdd_array[],
-- 
1.7.1


WARNING: multiple messages have this Message-ID (diff)
From: nm@ti.com (Nishanth Menon)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH V3 07/19] OMAP3+: voltage: add transdone APIs
Date: Sat,  5 Mar 2011 20:59:10 +0530	[thread overview]
Message-ID: <1299338962-5602-8-git-send-email-nm@ti.com> (raw)
In-Reply-To: <1299338962-5602-1-git-send-email-nm@ti.com>

Transdone event in Voltage processor gives us fine grained status on
the current status of the voltage communication with the PMIC.
Unfortunately, IRQ generation by VP is based on the start of the
transmission to VC from VP, not at the end (or the completion of
the voltage setting). Hence any users of voltage layer who need
to know fine grained information such as confirmation if the voltage
is actually send to PMIC, needs to depend on this status.

Signed-off-by: Nishanth Menon <nm@ti.com>
---
 arch/arm/mach-omap2/voltage.c |   57 +++++++++++++++++++++++++++++++++++------
 arch/arm/mach-omap2/voltage.h |    2 +
 2 files changed, 51 insertions(+), 8 deletions(-)

diff --git a/arch/arm/mach-omap2/voltage.c b/arch/arm/mach-omap2/voltage.c
index a12ac1e..2d70d13 100644
--- a/arch/arm/mach-omap2/voltage.c
+++ b/arch/arm/mach-omap2/voltage.c
@@ -455,10 +455,8 @@ static int vp_forceupdate_scale_voltage(struct omap_vdd_info *vdd,
 	 * is <3us
 	 */
 	while (timeout++ < VP_TRANXDONE_TIMEOUT) {
-		vdd->write_reg(vdd->vp_data->prm_irqst_data->tranxdone_status,
-			       prm_irqst_ocp_mod_offs, prm_irqst_reg);
-		if (!(vdd->read_reg(prm_irqst_ocp_mod_offs, prm_irqst_reg) &
-		      vdd->vp_data->prm_irqst_data->tranxdone_status))
+		omap_vp_clear_transdone(&vdd->voltdm);
+		if (!omap_vp_is_transdone(&vdd->voltdm))
 			break;
 		udelay(1);
 	}
@@ -506,10 +504,8 @@ static int vp_forceupdate_scale_voltage(struct omap_vdd_info *vdd,
 	 */
 	timeout = 0;
 	while (timeout++ < VP_TRANXDONE_TIMEOUT) {
-		vdd->write_reg(vdd->vp_data->prm_irqst_data->tranxdone_status,
-			       prm_irqst_ocp_mod_offs, prm_irqst_reg);
-		if (!(vdd->read_reg(prm_irqst_ocp_mod_offs, prm_irqst_reg) &
-		      vdd->vp_data->prm_irqst_data->tranxdone_status))
+		omap_vp_clear_transdone(&vdd->voltdm);
+		if (!omap_vp_is_transdone(&vdd->voltdm))
 			break;
 		udelay(1);
 	}
@@ -824,6 +820,51 @@ 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(prm_irqst_ocp_mod_offs,
+		vdd->vp_data->prm_irqst_data->prm_irqst_reg) &
+		vdd->vp_data->prm_irqst_data->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_data->prm_irqst_data->tranxdone_status,
+			prm_irqst_ocp_mod_offs,
+			vdd->vp_data->prm_irqst_data->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/mach-omap2/voltage.h b/arch/arm/mach-omap2/voltage.h
index 6e9acd6..5b4e363 100644
--- a/arch/arm/mach-omap2/voltage.h
+++ b/arch/arm/mach-omap2/voltage.h
@@ -150,6 +150,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);
 int __init omap_voltage_early_init(s16 prm_mod, s16 prm_irqst_mod,
 				   struct omap_vdd_info *omap_vdd_array[],
-- 
1.7.1

  parent reply	other threads:[~2011-03-05 15:30 UTC|newest]

Thread overview: 106+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-05 15:29 [PATCH V3 00/19] OMAP3+: PM: introduce SR class 1.5 Nishanth Menon
2011-03-05 15:29 ` Nishanth Menon
2011-03-05 15:29 ` [PATCH V3 01/19] OMAP3: hwmod: add SmartReflex IRQs Nishanth Menon
2011-03-05 15:29   ` Nishanth Menon
2011-03-17 14:41   ` Kevin Hilman
2011-03-17 14:41     ` Kevin Hilman
2011-07-26 13:11   ` Felipe Balbi
2011-07-26 13:11     ` Felipe Balbi
2011-03-05 15:29 ` [PATCH V3 02/19] OMAP3+: voltage: fix build warning Nishanth Menon
2011-03-05 15:29   ` Nishanth Menon
2011-03-17 14:49   ` Kevin Hilman
2011-03-17 14:49     ` Kevin Hilman
2011-07-26 13:12   ` Felipe Balbi
2011-07-26 13:12     ` Felipe Balbi
2011-03-05 15:29 ` [PATCH V3 03/19] OMAP3+: voltage: remove initial voltage Nishanth Menon
2011-03-05 15:29   ` Nishanth Menon
2011-03-06 13:37   ` Sergei Shtylyov
2011-03-06 13:37     ` Sergei Shtylyov
2011-03-07  2:52     ` Nishanth Menon
2011-03-07  2:52       ` Nishanth Menon
2011-03-07 16:23       ` Sergei Shtylyov
2011-03-07 16:23         ` Sergei Shtylyov
2011-03-08  1:52         ` Nishanth Menon
2011-03-08  1:52           ` Nishanth Menon
2011-07-26 13:17           ` Felipe Balbi
2011-07-26 13:17             ` Felipe Balbi
2011-03-17 14:53   ` Kevin Hilman
2011-03-17 14:53     ` Kevin Hilman
2011-03-05 15:29 ` [PATCH V3 04/19] OMAP3+: voltage: remove spurious pr_notice for debugfs Nishanth Menon
2011-03-05 15:29   ` Nishanth Menon
2011-03-17 14:55   ` Kevin Hilman
2011-03-17 14:55     ` Kevin Hilman
2011-07-26 13:18   ` Felipe Balbi
2011-07-26 13:18     ` Felipe Balbi
2011-03-05 15:29 ` [PATCH V3 05/19] OMAP3+: voltage: use IS_ERR_OR_NULL Nishanth Menon
2011-03-05 15:29   ` Nishanth Menon
2011-03-05 17:36   ` David Cohen
2011-03-05 17:36     ` David Cohen
2011-03-06  2:45     ` Nishanth Menon
2011-03-06  2:45       ` Nishanth Menon
2011-03-06  8:18       ` Russell King - ARM Linux
2011-03-06  8:18         ` Russell King - ARM Linux
2011-03-07  2:56         ` Nishanth Menon
2011-03-07  2:56           ` Nishanth Menon
2011-07-26 13:19   ` Felipe Balbi
2011-07-26 13:19     ` Felipe Balbi
2011-03-05 15:29 ` [PATCH V3 06/19] OMAP3+: voltage: use volt_data pointer instead values Nishanth Menon
2011-03-05 15:29   ` Nishanth Menon
2011-03-17 17:09   ` Kevin Hilman
2011-03-17 17:09     ` Kevin Hilman
2011-03-05 15:29 ` Nishanth Menon [this message]
2011-03-05 15:29   ` [PATCH V3 07/19] OMAP3+: voltage: add transdone APIs Nishanth Menon
2011-03-17 17:14   ` Kevin Hilman
2011-03-17 17:14     ` Kevin Hilman
2011-03-05 15:29 ` [PATCH V3 08/19] OMAP3+: SR: make notify independent of class Nishanth Menon
2011-03-05 15:29   ` Nishanth Menon
2011-03-17 17:18   ` Kevin Hilman
2011-03-17 17:18     ` Kevin Hilman
2011-03-05 15:29 ` [PATCH V3 09/19] OMAP3+: SR: disable interrupt by default Nishanth Menon
2011-03-05 15:29   ` Nishanth Menon
2011-03-17 17:19   ` Kevin Hilman
2011-03-17 17:19     ` Kevin Hilman
2011-03-05 15:29 ` [PATCH V3 10/19] OMAP3+: SR: enable/disable SR only on need Nishanth Menon
2011-03-05 15:29   ` Nishanth Menon
2011-03-17 17:20   ` Kevin Hilman
2011-03-17 17:20     ` Kevin Hilman
2011-03-05 15:29 ` [PATCH V3 11/19] OMAP3+: SR: fix cosmetic indentation Nishanth Menon
2011-03-05 15:29   ` Nishanth Menon
2011-03-17 17:21   ` Kevin Hilman
2011-03-17 17:21     ` Kevin Hilman
2011-03-17 17:43     ` Aaro Koskinen
2011-03-17 17:43       ` Aaro Koskinen
2011-03-17 20:02       ` Kevin Hilman
2011-03-17 20:02         ` Kevin Hilman
2011-03-05 15:29 ` [PATCH V3 12/19] OMAP3+: SR: introduce class start,stop and priv data Nishanth Menon
2011-03-05 15:29   ` [PATCH V3 12/19] OMAP3+: SR: introduce class start, stop " Nishanth Menon
2011-03-17 17:23   ` [PATCH V3 12/19] OMAP3+: SR: introduce class start,stop " Kevin Hilman
2011-03-17 17:23     ` [PATCH V3 12/19] OMAP3+: SR: introduce class start, stop " Kevin Hilman
2011-03-05 15:29 ` [PATCH V3 13/19] OMAP3+: SR: Reuse sr_[start|stop]_vddautocomp functions Nishanth Menon
2011-03-05 15:29   ` Nishanth Menon
2011-03-07 14:40   ` Jarkko Nikula
2011-03-07 14:40     ` Jarkko Nikula
2011-03-17 17:25   ` Kevin Hilman
2011-03-17 17:25     ` Kevin Hilman
2011-03-05 15:29 ` [PATCH V3 14/19] OMAP3+: SR: introduce notifiers flags Nishanth Menon
2011-03-05 15:29   ` Nishanth Menon
2011-03-17 17:28   ` Kevin Hilman
2011-03-17 17:28     ` Kevin Hilman
2011-03-05 15:29 ` [PATCH V3 15/19] OMAP3+: SR: introduce notifier_control Nishanth Menon
2011-03-05 15:29   ` Nishanth Menon
2011-03-17 17:35   ` Kevin Hilman
2011-03-17 17:35     ` Kevin Hilman
2011-03-05 15:29 ` [PATCH V3 16/19] OMAP3+: SR: disable spamming interrupts Nishanth Menon
2011-03-05 15:29   ` Nishanth Menon
2011-03-05 15:29 ` [PATCH V3 17/19] OMAP3+: SR: make enable path use volt_data pointer Nishanth Menon
2011-03-05 15:29   ` Nishanth Menon
2011-03-17 17:41   ` Kevin Hilman
2011-03-17 17:41     ` Kevin Hilman
2011-03-05 15:29 ` [PATCH V3 18/19] OMAP3630+: SR: add support for class 1.5 Nishanth Menon
2011-03-05 15:29   ` Nishanth Menon
2011-03-17 19:57   ` Kevin Hilman
2011-03-17 19:57     ` Kevin Hilman
2011-03-05 15:29 ` [PATCH V3 19/19] OMAP3430: SR: class3: restrict CPU to run on Nishanth Menon
2011-03-05 15:29   ` Nishanth Menon
2011-03-17 19:58   ` Kevin Hilman
2011-03-17 19:58     ` Kevin Hilman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1299338962-5602-8-git-send-email-nm@ti.com \
    --to=nm@ti.com \
    --cc=khilman@ti.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=paul@pwsan.com \
    --cc=tony@atomide.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.