From: jean.pihet@newoldbits.com
To: linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
Kevin Hilman <khilman@ti.com>, "Rafael J. Wysocki" <rjw@sisk.pl>,
LKML <linux-kernel@vger.kernel.org>
Cc: Jean Pihet <j-pihet@ti.com>
Subject: [PATCH 07/10] ARM: OMAP2+: SmartReflex: introduce a busy loop condition test macro
Date: Thu, 15 Mar 2012 17:44:02 +0100 [thread overview]
Message-ID: <1331829845-9526-8-git-send-email-j-pihet@ti.com> (raw)
In-Reply-To: <1331829845-9526-1-git-send-email-j-pihet@ti.com>
From: Jean Pihet <j-pihet@ti.com>
Now that omap_test_timeout is only accessible from mach-omap2/,
introduce a similar function for SR.
This change makes the SmartReflex implementation ready for the move
to drivers/.
Signed-off-by: Jean Pihet <j-pihet@ti.com>
---
arch/arm/mach-omap2/smartreflex.c | 12 ++++++------
arch/arm/mach-omap2/smartreflex.h | 23 +++++++++++++++++++++++
2 files changed, 29 insertions(+), 6 deletions(-)
diff --git a/arch/arm/mach-omap2/smartreflex.c b/arch/arm/mach-omap2/smartreflex.c
index dd80fde..ceb50b5 100644
--- a/arch/arm/mach-omap2/smartreflex.c
+++ b/arch/arm/mach-omap2/smartreflex.c
@@ -290,9 +290,9 @@ static void sr_v1_disable(struct omap_sr *sr)
* Wait for SR to be disabled.
* wait until ERRCONFIG.MCUDISACKINTST = 1. Typical latency is 1us.
*/
- omap_test_timeout((sr_read_reg(sr, ERRCONFIG_V1) &
- ERRCONFIG_MCUDISACKINTST), SR_DISABLE_TIMEOUT,
- timeout);
+ sr_test_cond_timeout((sr_read_reg(sr, ERRCONFIG_V1) &
+ ERRCONFIG_MCUDISACKINTST), SR_DISABLE_TIMEOUT,
+ timeout);
if (timeout >= SR_DISABLE_TIMEOUT)
dev_warn(&sr->pdev->dev, "%s: Smartreflex disable timedout\n",
@@ -335,9 +335,9 @@ static void sr_v2_disable(struct omap_sr *sr)
* Wait for SR to be disabled.
* wait until IRQSTATUS.MCUDISACKINTST = 1. Typical latency is 1us.
*/
- omap_test_timeout((sr_read_reg(sr, IRQSTATUS) &
- IRQSTATUS_MCUDISABLEACKINT), SR_DISABLE_TIMEOUT,
- timeout);
+ sr_test_cond_timeout((sr_read_reg(sr, IRQSTATUS) &
+ IRQSTATUS_MCUDISABLEACKINT), SR_DISABLE_TIMEOUT,
+ timeout);
if (timeout >= SR_DISABLE_TIMEOUT)
dev_warn(&sr->pdev->dev, "%s: Smartreflex disable timedout\n",
diff --git a/arch/arm/mach-omap2/smartreflex.h b/arch/arm/mach-omap2/smartreflex.h
index 8d3e3c2..3bd4fee 100644
--- a/arch/arm/mach-omap2/smartreflex.h
+++ b/arch/arm/mach-omap2/smartreflex.h
@@ -21,6 +21,7 @@
#define __ASM_ARM_OMAP_SMARTREFLEX_H
#include <linux/platform_device.h>
+#include <linux/delay.h>
#include <plat/smartreflex.h>
#include <plat/voltage.h>
@@ -144,6 +145,28 @@
#define OMAP3430_SR_ERRMAXLIMIT 0x02
/**
+ * test_cond_timeout - busy-loop, testing a condition
+ * @cond: condition to test until it evaluates to true
+ * @timeout: maximum number of microseconds in the timeout
+ * @index: loop index (integer)
+ *
+ * Loop waiting for @cond to become true or until at least @timeout
+ * microseconds have passed. To use, define some integer @index in the
+ * calling code. After running, if @index == @timeout, then the loop has
+ * timed out.
+ *
+ * Copied from omap_test_timeout
+ */
+#define sr_test_cond_timeout(cond, timeout, index) \
+({ \
+ for (index = 0; index < timeout; index++) { \
+ if (cond) \
+ break; \
+ udelay(1); \
+ } \
+})
+
+/**
* struct omap_sr_pmic_data - Strucutre to be populated by pmic code to pass
* pmic specific info to smartreflex driver
*
--
1.7.5.4
next prev parent reply other threads:[~2012-03-15 16:45 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-15 16:43 [PATCH 00/10] PM: Create the AVS class of drivers jean.pihet
2012-03-15 16:43 ` [PATCH 01/10] ARM: OMAP3+: voltage: export functions to plat/voltage.h jean.pihet
2012-03-15 16:43 ` [PATCH 02/10] ARM: OMAP2+: SmartReflex: move the platform specific macros in plat-omap jean.pihet
2012-03-15 17:14 ` Tony Lindgren
2012-03-16 15:19 ` Jean Pihet
2012-04-18 20:18 ` Tony Lindgren
2012-03-15 16:43 ` [PATCH 03/10] ARM: OMAP3+: SmartReflex: class drivers should use struct omap_sr * jean.pihet
2012-03-15 16:43 ` [PATCH 04/10] ARM: OMAP2+: smartreflex: Use the names from hwmod data instead of voltage domains jean.pihet
2012-03-15 16:44 ` [PATCH 05/10] ARM: OMAP3: hwmod: rename the smartreflex entries jean.pihet
2012-03-15 16:44 ` [PATCH 06/10] ARM: OMAP2+: SmartReflex: use the platform header file for voltage functions jean.pihet
2012-03-15 16:44 ` jean.pihet [this message]
2012-03-15 16:44 ` [PATCH 08/10] ARM: OMAP2+: SmartReflex: Use per-OPP data structure jean.pihet
2012-03-15 16:44 ` [PATCH 09/10] ARM: OMAP2+: SmartReflex: add POWER_AVS Kconfig options jean.pihet
2012-03-15 16:44 ` [PATCH 10/10] ARM: OMAP: SmartReflex: Move smartreflex driver to drivers/ jean.pihet
2012-03-15 21:19 ` Rafael J. Wysocki
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=1331829845-9526-8-git-send-email-j-pihet@ti.com \
--to=jean.pihet@newoldbits.com \
--cc=j-pihet@ti.com \
--cc=khilman@ti.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=rjw@sisk.pl \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).