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 14/19] OMAP3+: SR: introduce notifiers flags
Date: Sat,  5 Mar 2011 20:59:17 +0530	[thread overview]
Message-ID: <1299338962-5602-15-git-send-email-nm@ti.com> (raw)
In-Reply-To: <1299338962-5602-1-git-send-email-nm@ti.com>

SmartReflex IP V1 and V2 have different registers and offsets.
Currently, we pass the status as is to the class driver. However,
since we don't pass the version of the underlying SR hardware
to the Class driver, it will not be unable to make consistent
sense of the status bits coming over to it.

A class driver should be able to function without dependency
on the exact IP version it is actually running on. We hence
introduce our own translation in software level for a generic
notification flag.

As part of this change, we will now call the notifier iff we get
a match with the notifier flags that the class driver requested.

Signed-off-by: Nishanth Menon <nm@ti.com>
---
 arch/arm/mach-omap2/smartreflex.c |   73 +++++++++++++++++++++++++++++++++++--
 arch/arm/mach-omap2/smartreflex.h |    6 +++
 2 files changed, 76 insertions(+), 3 deletions(-)

diff --git a/arch/arm/mach-omap2/smartreflex.c b/arch/arm/mach-omap2/smartreflex.c
index d839fa6..21944e2 100644
--- a/arch/arm/mach-omap2/smartreflex.c
+++ b/arch/arm/mach-omap2/smartreflex.c
@@ -123,27 +123,94 @@ static struct omap_sr *_sr_lookup(struct voltagedomain *voltdm)
 	return ERR_PTR(-ENODATA);
 }
 
+static inline u32 notifier_to_irqen_v1(u8 notify_flags)
+{
+	u32 val;
+	val = (notify_flags & SR_NOTIFY_MCUACCUM) ?
+		ERRCONFIG_MCUACCUMINTEN : 0;
+	val |= (notify_flags & SR_NOTIFY_MCUVALID) ?
+		ERRCONFIG_MCUVALIDINTEN : 0;
+	val |= (notify_flags & SR_NOTIFY_MCUBOUND) ?
+		ERRCONFIG_MCUBOUNDINTEN : 0;
+	val |= (notify_flags & SR_NOTIFY_MCUDISACK) ?
+		ERRCONFIG_MCUDISACKINTEN : 0;
+	return val;
+}
+
+static inline u32 notifier_to_irqen_v2(u8 notify_flags)
+{
+	u32 val;
+	val = (notify_flags & SR_NOTIFY_MCUACCUM) ?
+		IRQENABLE_MCUACCUMINT : 0;
+	val |= (notify_flags & SR_NOTIFY_MCUVALID) ?
+		IRQENABLE_MCUVALIDINT : 0;
+	val |= (notify_flags & SR_NOTIFY_MCUBOUND) ?
+		IRQENABLE_MCUBOUNDSINT : 0;
+	val |= (notify_flags & SR_NOTIFY_MCUDISACK) ?
+		IRQENABLE_MCUDISABLEACKINT : 0;
+	return val;
+}
+
+static inline u8 irqstat_to_notifier_v1(u32 status)
+{
+	u8 val;
+	val = (status & ERRCONFIG_MCUACCUMINTST) ?
+		SR_NOTIFY_MCUACCUM : 0;
+	val |= (status & ERRCONFIG_MCUVALIDINTEN) ?
+		SR_NOTIFY_MCUVALID : 0;
+	val |= (status & ERRCONFIG_MCUBOUNDINTEN) ?
+		SR_NOTIFY_MCUBOUND : 0;
+	val |= (status & ERRCONFIG_MCUDISACKINTEN) ?
+		SR_NOTIFY_MCUDISACK : 0;
+	return val;
+}
+
+static inline u8 irqstat_to_notifier_v2(u32 status)
+{
+	u8 val;
+	val = (status & IRQENABLE_MCUACCUMINT) ?
+		SR_NOTIFY_MCUACCUM : 0;
+	val |= (status & IRQENABLE_MCUVALIDINT) ?
+		SR_NOTIFY_MCUVALID : 0;
+	val |= (status & IRQENABLE_MCUBOUNDSINT) ?
+		SR_NOTIFY_MCUBOUND : 0;
+	val |= (status & IRQENABLE_MCUDISABLEACKINT) ?
+		SR_NOTIFY_MCUDISACK : 0;
+	return val;
+}
+
+
 static irqreturn_t sr_interrupt(int irq, void *data)
 {
 	struct omap_sr *sr_info = (struct omap_sr *)data;
 	u32 status = 0;
+	u32 value = 0;
 
 	if (sr_info->ip_type == SR_TYPE_V1) {
+		/* Status bits are one bit before enable bits in v1 */
+		value = notifier_to_irqen_v1(sr_class->notify_flags) >> 1;
+
 		/* Read the status bits */
 		status = sr_read_reg(sr_info, ERRCONFIG_V1);
+		status &= value;
 
 		/* Clear them by writing back */
-		sr_write_reg(sr_info, ERRCONFIG_V1, status);
+		sr_modify_reg(sr_info, ERRCONFIG_V1, value, status);
+
+		value = irqstat_to_notifier_v1(status);
 	} else if (sr_info->ip_type == SR_TYPE_V2) {
+		value = notifier_to_irqen_v2(sr_class->notify_flags);
 		/* Read the status bits */
-		sr_read_reg(sr_info, IRQSTATUS);
+		status = sr_read_reg(sr_info, IRQSTATUS);
+		status &= value;
 
 		/* Clear them by writing back */
 		sr_write_reg(sr_info, IRQSTATUS, status);
+		value = irqstat_to_notifier_v2(status);
 	}
 
 	if (sr_class->notify)
-		sr_class->notify(sr_info->voltdm, status);
+		sr_class->notify(sr_info->voltdm, value);
 
 	return IRQ_HANDLED;
 }
diff --git a/arch/arm/mach-omap2/smartreflex.h b/arch/arm/mach-omap2/smartreflex.h
index d4b8bee..2976bf6 100644
--- a/arch/arm/mach-omap2/smartreflex.h
+++ b/arch/arm/mach-omap2/smartreflex.h
@@ -142,6 +142,12 @@
 #define OMAP3430_SR_ERRWEIGHT		0x04
 #define OMAP3430_SR_ERRMAXLIMIT		0x02
 
+/* Smart reflex notifiers for class drivers to use */
+#define SR_NOTIFY_MCUDISACK		BIT(3)
+#define SR_NOTIFY_MCUBOUND		BIT(2)
+#define SR_NOTIFY_MCUVALID		BIT(1)
+#define SR_NOTIFY_MCUACCUM		BIT(0)
+
 /**
  * struct omap_sr_pmic_data - Strucutre to be populated by pmic code to pass
  *				pmic specific info to smartreflex driver
-- 
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 14/19] OMAP3+: SR: introduce notifiers flags
Date: Sat,  5 Mar 2011 20:59:17 +0530	[thread overview]
Message-ID: <1299338962-5602-15-git-send-email-nm@ti.com> (raw)
In-Reply-To: <1299338962-5602-1-git-send-email-nm@ti.com>

SmartReflex IP V1 and V2 have different registers and offsets.
Currently, we pass the status as is to the class driver. However,
since we don't pass the version of the underlying SR hardware
to the Class driver, it will not be unable to make consistent
sense of the status bits coming over to it.

A class driver should be able to function without dependency
on the exact IP version it is actually running on. We hence
introduce our own translation in software level for a generic
notification flag.

As part of this change, we will now call the notifier iff we get
a match with the notifier flags that the class driver requested.

Signed-off-by: Nishanth Menon <nm@ti.com>
---
 arch/arm/mach-omap2/smartreflex.c |   73 +++++++++++++++++++++++++++++++++++--
 arch/arm/mach-omap2/smartreflex.h |    6 +++
 2 files changed, 76 insertions(+), 3 deletions(-)

diff --git a/arch/arm/mach-omap2/smartreflex.c b/arch/arm/mach-omap2/smartreflex.c
index d839fa6..21944e2 100644
--- a/arch/arm/mach-omap2/smartreflex.c
+++ b/arch/arm/mach-omap2/smartreflex.c
@@ -123,27 +123,94 @@ static struct omap_sr *_sr_lookup(struct voltagedomain *voltdm)
 	return ERR_PTR(-ENODATA);
 }
 
+static inline u32 notifier_to_irqen_v1(u8 notify_flags)
+{
+	u32 val;
+	val = (notify_flags & SR_NOTIFY_MCUACCUM) ?
+		ERRCONFIG_MCUACCUMINTEN : 0;
+	val |= (notify_flags & SR_NOTIFY_MCUVALID) ?
+		ERRCONFIG_MCUVALIDINTEN : 0;
+	val |= (notify_flags & SR_NOTIFY_MCUBOUND) ?
+		ERRCONFIG_MCUBOUNDINTEN : 0;
+	val |= (notify_flags & SR_NOTIFY_MCUDISACK) ?
+		ERRCONFIG_MCUDISACKINTEN : 0;
+	return val;
+}
+
+static inline u32 notifier_to_irqen_v2(u8 notify_flags)
+{
+	u32 val;
+	val = (notify_flags & SR_NOTIFY_MCUACCUM) ?
+		IRQENABLE_MCUACCUMINT : 0;
+	val |= (notify_flags & SR_NOTIFY_MCUVALID) ?
+		IRQENABLE_MCUVALIDINT : 0;
+	val |= (notify_flags & SR_NOTIFY_MCUBOUND) ?
+		IRQENABLE_MCUBOUNDSINT : 0;
+	val |= (notify_flags & SR_NOTIFY_MCUDISACK) ?
+		IRQENABLE_MCUDISABLEACKINT : 0;
+	return val;
+}
+
+static inline u8 irqstat_to_notifier_v1(u32 status)
+{
+	u8 val;
+	val = (status & ERRCONFIG_MCUACCUMINTST) ?
+		SR_NOTIFY_MCUACCUM : 0;
+	val |= (status & ERRCONFIG_MCUVALIDINTEN) ?
+		SR_NOTIFY_MCUVALID : 0;
+	val |= (status & ERRCONFIG_MCUBOUNDINTEN) ?
+		SR_NOTIFY_MCUBOUND : 0;
+	val |= (status & ERRCONFIG_MCUDISACKINTEN) ?
+		SR_NOTIFY_MCUDISACK : 0;
+	return val;
+}
+
+static inline u8 irqstat_to_notifier_v2(u32 status)
+{
+	u8 val;
+	val = (status & IRQENABLE_MCUACCUMINT) ?
+		SR_NOTIFY_MCUACCUM : 0;
+	val |= (status & IRQENABLE_MCUVALIDINT) ?
+		SR_NOTIFY_MCUVALID : 0;
+	val |= (status & IRQENABLE_MCUBOUNDSINT) ?
+		SR_NOTIFY_MCUBOUND : 0;
+	val |= (status & IRQENABLE_MCUDISABLEACKINT) ?
+		SR_NOTIFY_MCUDISACK : 0;
+	return val;
+}
+
+
 static irqreturn_t sr_interrupt(int irq, void *data)
 {
 	struct omap_sr *sr_info = (struct omap_sr *)data;
 	u32 status = 0;
+	u32 value = 0;
 
 	if (sr_info->ip_type == SR_TYPE_V1) {
+		/* Status bits are one bit before enable bits in v1 */
+		value = notifier_to_irqen_v1(sr_class->notify_flags) >> 1;
+
 		/* Read the status bits */
 		status = sr_read_reg(sr_info, ERRCONFIG_V1);
+		status &= value;
 
 		/* Clear them by writing back */
-		sr_write_reg(sr_info, ERRCONFIG_V1, status);
+		sr_modify_reg(sr_info, ERRCONFIG_V1, value, status);
+
+		value = irqstat_to_notifier_v1(status);
 	} else if (sr_info->ip_type == SR_TYPE_V2) {
+		value = notifier_to_irqen_v2(sr_class->notify_flags);
 		/* Read the status bits */
-		sr_read_reg(sr_info, IRQSTATUS);
+		status = sr_read_reg(sr_info, IRQSTATUS);
+		status &= value;
 
 		/* Clear them by writing back */
 		sr_write_reg(sr_info, IRQSTATUS, status);
+		value = irqstat_to_notifier_v2(status);
 	}
 
 	if (sr_class->notify)
-		sr_class->notify(sr_info->voltdm, status);
+		sr_class->notify(sr_info->voltdm, value);
 
 	return IRQ_HANDLED;
 }
diff --git a/arch/arm/mach-omap2/smartreflex.h b/arch/arm/mach-omap2/smartreflex.h
index d4b8bee..2976bf6 100644
--- a/arch/arm/mach-omap2/smartreflex.h
+++ b/arch/arm/mach-omap2/smartreflex.h
@@ -142,6 +142,12 @@
 #define OMAP3430_SR_ERRWEIGHT		0x04
 #define OMAP3430_SR_ERRMAXLIMIT		0x02
 
+/* Smart reflex notifiers for class drivers to use */
+#define SR_NOTIFY_MCUDISACK		BIT(3)
+#define SR_NOTIFY_MCUBOUND		BIT(2)
+#define SR_NOTIFY_MCUVALID		BIT(1)
+#define SR_NOTIFY_MCUACCUM		BIT(0)
+
 /**
  * struct omap_sr_pmic_data - Strucutre to be populated by pmic code to pass
  *				pmic specific info to smartreflex driver
-- 
1.7.1

  parent reply	other threads:[~2011-03-05 15:31 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 ` [PATCH V3 07/19] OMAP3+: voltage: add transdone APIs Nishanth Menon
2011-03-05 15:29   ` 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 ` Nishanth Menon [this message]
2011-03-05 15:29   ` [PATCH V3 14/19] OMAP3+: SR: introduce notifiers flags 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-15-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.