All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jon Hunter <jon-hunter@ti.com>
To: Benoit Cousson <b-cousson@ti.com>,
	Tony Lindgren <tony@atomide.com>, Paul Walmsley <paul@pwsan.com>,
	Rob Herring <rob.herring@calxeda.com>,
	Grant Likely <grant.likely@secretlab.ca>
Cc: device-tree <devicetree-discuss@lists.ozlabs.org>,
	linux-omap <linux-omap@vger.kernel.org>,
	linux-arm <linux-arm-kernel@lists.infradead.org>,
	Jon Hunter <jon-hunter@ti.com>
Subject: [PATCH V2 5/7] ARM: OMAP: Add function to request a timer by capability
Date: Thu, 13 Sep 2012 18:31:29 -0500	[thread overview]
Message-ID: <1347579091-3794-6-git-send-email-jon-hunter@ti.com> (raw)
In-Reply-To: <1347579091-3794-1-git-send-email-jon-hunter@ti.com>

Currently OMAP timers can be requested by requesting any available or by a
numerical device ID. If a specific timer is required because it has a particular
capability, such as can interrupt the on-chip DSP in addition to the ARM CPU,
then the user needs to know the device ID of the timer with this feature.
Therefore, add a new API called omap_dm_timer_request_by_cap() that allows
drivers to request a timer by capability.

Signed-off-by: Jon Hunter <jon-hunter@ti.com>
---
 arch/arm/plat-omap/dmtimer.c              |   53 +++++++++++++++++++++++++++++
 arch/arm/plat-omap/include/plat/dmtimer.h |    1 +
 2 files changed, 54 insertions(+)

diff --git a/arch/arm/plat-omap/dmtimer.c b/arch/arm/plat-omap/dmtimer.c
index 938b50a..061a0b9 100644
--- a/arch/arm/plat-omap/dmtimer.c
+++ b/arch/arm/plat-omap/dmtimer.c
@@ -237,6 +237,59 @@ struct omap_dm_timer *omap_dm_timer_request_specific(int id)
 }
 EXPORT_SYMBOL_GPL(omap_dm_timer_request_specific);
 
+/**
+ * omap_dm_timer_request_by_cap - Request a timer by capability
+ *
+ * @cap:	Bit mask of capabilities to match
+ *
+ * Find a timer based upon capabilities bit mask. Callers of this function
+ * should use the definitions found in the plat/dmtimer.h file under the
+ * comment "timer capabilities used in hwmod database". Returns pointer to
+ * timer handle on success and a NULL pointer on failure.
+ */
+struct omap_dm_timer *omap_dm_timer_request_by_cap(u32 cap)
+{
+	struct omap_dm_timer *timer = NULL, *t;
+	unsigned long flags;
+
+	if (!cap)
+		return NULL;
+
+	spin_lock_irqsave(&dm_timer_lock, flags);
+	list_for_each_entry(t, &omap_timer_list, node) {
+		if ((!t->reserved) && ((t->capability & cap) == cap)) {
+			/*
+			 * If timer is not NULL, we have already found one timer
+			 * but it was not an exact match because it had more
+			 * capabilites that what was required. Therefore,
+			 * unreserve the last timer found and see if this one
+			 * is a better match.
+			 */
+			if (timer)
+				timer->reserved = 0;
+
+			timer = t;
+			timer->reserved = 1;
+
+			/* Exit loop early if we find an exact match */
+			if (t->capability == cap)
+				break;
+		}
+	}
+	spin_unlock_irqrestore(&dm_timer_lock, flags);
+
+	if (timer && omap_dm_timer_prepare(timer)) {
+		timer->reserved = 0;
+		timer = NULL;
+	}
+
+	if (!timer)
+		pr_debug("%s: timer request failed!\n", __func__);
+
+	return timer;
+}
+EXPORT_SYMBOL_GPL(omap_dm_timer_request_by_cap);
+
 int omap_dm_timer_free(struct omap_dm_timer *timer)
 {
 	if (unlikely(!timer))
diff --git a/arch/arm/plat-omap/include/plat/dmtimer.h b/arch/arm/plat-omap/include/plat/dmtimer.h
index 85868e9..348f855 100644
--- a/arch/arm/plat-omap/include/plat/dmtimer.h
+++ b/arch/arm/plat-omap/include/plat/dmtimer.h
@@ -99,6 +99,7 @@ struct dmtimer_platform_data {
 int omap_dm_timer_reserve_systimer(int id);
 struct omap_dm_timer *omap_dm_timer_request(void);
 struct omap_dm_timer *omap_dm_timer_request_specific(int timer_id);
+struct omap_dm_timer *omap_dm_timer_request_by_cap(u32 cap);
 int omap_dm_timer_free(struct omap_dm_timer *timer);
 void omap_dm_timer_enable(struct omap_dm_timer *timer);
 void omap_dm_timer_disable(struct omap_dm_timer *timer);
-- 
1.7.9.5


WARNING: multiple messages have this Message-ID (diff)
From: jon-hunter@ti.com (Jon Hunter)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH V2 5/7] ARM: OMAP: Add function to request a timer by capability
Date: Thu, 13 Sep 2012 18:31:29 -0500	[thread overview]
Message-ID: <1347579091-3794-6-git-send-email-jon-hunter@ti.com> (raw)
In-Reply-To: <1347579091-3794-1-git-send-email-jon-hunter@ti.com>

Currently OMAP timers can be requested by requesting any available or by a
numerical device ID. If a specific timer is required because it has a particular
capability, such as can interrupt the on-chip DSP in addition to the ARM CPU,
then the user needs to know the device ID of the timer with this feature.
Therefore, add a new API called omap_dm_timer_request_by_cap() that allows
drivers to request a timer by capability.

Signed-off-by: Jon Hunter <jon-hunter@ti.com>
---
 arch/arm/plat-omap/dmtimer.c              |   53 +++++++++++++++++++++++++++++
 arch/arm/plat-omap/include/plat/dmtimer.h |    1 +
 2 files changed, 54 insertions(+)

diff --git a/arch/arm/plat-omap/dmtimer.c b/arch/arm/plat-omap/dmtimer.c
index 938b50a..061a0b9 100644
--- a/arch/arm/plat-omap/dmtimer.c
+++ b/arch/arm/plat-omap/dmtimer.c
@@ -237,6 +237,59 @@ struct omap_dm_timer *omap_dm_timer_request_specific(int id)
 }
 EXPORT_SYMBOL_GPL(omap_dm_timer_request_specific);
 
+/**
+ * omap_dm_timer_request_by_cap - Request a timer by capability
+ *
+ * @cap:	Bit mask of capabilities to match
+ *
+ * Find a timer based upon capabilities bit mask. Callers of this function
+ * should use the definitions found in the plat/dmtimer.h file under the
+ * comment "timer capabilities used in hwmod database". Returns pointer to
+ * timer handle on success and a NULL pointer on failure.
+ */
+struct omap_dm_timer *omap_dm_timer_request_by_cap(u32 cap)
+{
+	struct omap_dm_timer *timer = NULL, *t;
+	unsigned long flags;
+
+	if (!cap)
+		return NULL;
+
+	spin_lock_irqsave(&dm_timer_lock, flags);
+	list_for_each_entry(t, &omap_timer_list, node) {
+		if ((!t->reserved) && ((t->capability & cap) == cap)) {
+			/*
+			 * If timer is not NULL, we have already found one timer
+			 * but it was not an exact match because it had more
+			 * capabilites that what was required. Therefore,
+			 * unreserve the last timer found and see if this one
+			 * is a better match.
+			 */
+			if (timer)
+				timer->reserved = 0;
+
+			timer = t;
+			timer->reserved = 1;
+
+			/* Exit loop early if we find an exact match */
+			if (t->capability == cap)
+				break;
+		}
+	}
+	spin_unlock_irqrestore(&dm_timer_lock, flags);
+
+	if (timer && omap_dm_timer_prepare(timer)) {
+		timer->reserved = 0;
+		timer = NULL;
+	}
+
+	if (!timer)
+		pr_debug("%s: timer request failed!\n", __func__);
+
+	return timer;
+}
+EXPORT_SYMBOL_GPL(omap_dm_timer_request_by_cap);
+
 int omap_dm_timer_free(struct omap_dm_timer *timer)
 {
 	if (unlikely(!timer))
diff --git a/arch/arm/plat-omap/include/plat/dmtimer.h b/arch/arm/plat-omap/include/plat/dmtimer.h
index 85868e9..348f855 100644
--- a/arch/arm/plat-omap/include/plat/dmtimer.h
+++ b/arch/arm/plat-omap/include/plat/dmtimer.h
@@ -99,6 +99,7 @@ struct dmtimer_platform_data {
 int omap_dm_timer_reserve_systimer(int id);
 struct omap_dm_timer *omap_dm_timer_request(void);
 struct omap_dm_timer *omap_dm_timer_request_specific(int timer_id);
+struct omap_dm_timer *omap_dm_timer_request_by_cap(u32 cap);
 int omap_dm_timer_free(struct omap_dm_timer *timer);
 void omap_dm_timer_enable(struct omap_dm_timer *timer);
 void omap_dm_timer_disable(struct omap_dm_timer *timer);
-- 
1.7.9.5

  parent reply	other threads:[~2012-09-13 23:31 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-13 23:31 [PATCH V2 0/7] ARM: OMAP2+: Add device-tree support for timers Jon Hunter
2012-09-13 23:31 ` Jon Hunter
2012-09-13 23:31 ` [PATCH V2 1/7] ARM: dts: OMAP: Add timer nodes Jon Hunter
2012-09-13 23:31   ` Jon Hunter
2012-09-13 23:31 ` [PATCH V2 2/7] ARM: OMAP3: Dynamically disable secure timer nodes for secure devices Jon Hunter
2012-09-13 23:31   ` Jon Hunter
2012-09-13 23:31 ` [PATCH V2 3/7] ARM: OMAP4: Add timer clock aliases for device-tree Jon Hunter
2012-09-13 23:31   ` Jon Hunter
     [not found]   ` <1347579091-3794-4-git-send-email-jon-hunter-l0cyMroinI0@public.gmane.org>
2012-09-19 23:55     ` Paul Walmsley
2012-09-19 23:55       ` Paul Walmsley
2012-09-13 23:31 ` [PATCH V2 4/7] ARM: OMAP: Add a timer attribute for timers that can interrupt the DSP Jon Hunter
2012-09-13 23:31   ` Jon Hunter
2012-09-20  0:07   ` Paul Walmsley
2012-09-20  0:07     ` Paul Walmsley
2012-09-13 23:31 ` Jon Hunter [this message]
2012-09-13 23:31   ` [PATCH V2 5/7] ARM: OMAP: Add function to request a timer by capability Jon Hunter
2012-09-13 23:31 ` [PATCH V2 6/7] ARM: OMAP3: Add generic machine descriptor for boards with OMAP3 GP devices Jon Hunter
2012-09-13 23:31   ` Jon Hunter
2012-09-13 23:31 ` [PATCH V2 7/7] ARM: OMAP: Add DT support for timer driver Jon Hunter
2012-09-13 23:31   ` Jon Hunter
2012-09-20  0:19   ` Rob Herring
2012-09-20  0:19     ` Rob Herring
2012-09-26 15:51   ` Jon Hunter
2012-09-26 15:51     ` Jon Hunter
2012-09-26 16:11     ` Rob Herring
2012-09-26 16:11       ` Rob Herring
2012-09-13 23:39 ` [PATCH V2 0/7] ARM: OMAP2+: Add device-tree support for timers Jon Hunter
2012-09-13 23:39   ` Jon Hunter
2012-09-20  2:23 ` Benoit Cousson
2012-09-20  2:23   ` Benoit Cousson
2012-09-20 23:53   ` Tony Lindgren
2012-09-20 23:53     ` Tony Lindgren
2012-09-26 16:53     ` Jon Hunter
2012-09-26 16:53       ` Jon Hunter
2012-09-28 18:51       ` Vaibhav Hiremath
2012-09-28 18:51         ` Vaibhav Hiremath
2012-09-28 21:30         ` Jon Hunter
2012-09-28 21:30           ` Jon Hunter
     [not found]         ` <5065F19E.5020708-l0cyMroinI0@public.gmane.org>
2012-09-28 21:47           ` Jon Hunter
2012-09-28 21:47             ` Jon Hunter
2012-09-29  9:33             ` Hiremath, Vaibhav
2012-09-29  9:33               ` Hiremath, Vaibhav
2012-10-08 21:10             ` Tony Lindgren
2012-10-08 21:10               ` Tony Lindgren
2012-09-28 22:17         ` Jon Hunter
2012-09-28 22:17           ` Jon Hunter
2012-09-26 15:40 ` Jon Hunter
2012-09-26 15:40   ` Jon Hunter

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=1347579091-3794-6-git-send-email-jon-hunter@ti.com \
    --to=jon-hunter@ti.com \
    --cc=b-cousson@ti.com \
    --cc=devicetree-discuss@lists.ozlabs.org \
    --cc=grant.likely@secretlab.ca \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=paul@pwsan.com \
    --cc=rob.herring@calxeda.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.