All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kevin Hilman <khilman@deeprootsystems.com>
To: linux-arm-kernel@lists.arm.linux.org.uk
Cc: linux-omap@vger.kernel.org,
	Peter 'p2' De Schrijver <peter.de-schrijver@nokia.com>
Subject: [PATCH 12/21] OMAP: PM counter infrastructure.
Date: Wed,  4 Feb 2009 18:05:58 -0800	[thread overview]
Message-ID: <1233799567-22250-13-git-send-email-khilman@deeprootsystems.com> (raw)
In-Reply-To: <1233799567-22250-12-git-send-email-khilman@deeprootsystems.com>

From: Peter 'p2' De Schrijver <peter.de-schrijver@nokia.com>

This patch provides the infrastructure to count how many times a
powerdomain entered a given power state (on, inactive, retention,
off). A number of functions are provided which will be called by the
chip specific powerdomain and clockdomain code whenever a transition
might have happened.

Signed-off-by: Peter 'p2' De Schrijver <peter.de-schrijver@nokia.com>
Signed-off-by: Kevin Hilman <khilman@deeprootsystems.com>
---
 arch/arm/mach-omap2/clockdomain.c             |    2 +
 arch/arm/mach-omap2/powerdomain.c             |  101 ++++++++++++++++++++++++-
 arch/arm/plat-omap/include/mach/powerdomain.h |    7 ++
 3 files changed, 108 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-omap2/clockdomain.c b/arch/arm/mach-omap2/clockdomain.c
index f713d0b..a7c2d87 100644
--- a/arch/arm/mach-omap2/clockdomain.c
+++ b/arch/arm/mach-omap2/clockdomain.c
@@ -480,6 +480,8 @@ void omap2_clkdm_allow_idle(struct clockdomain *clkdm)
 			    v << __ffs(clkdm->clktrctrl_mask),
 			    clkdm->pwrdm.ptr->prcm_offs,
 			    CM_CLKSTCTRL);
+
+	pwrdm_clkdm_state_switch(clkdm);
 }
 
 /**
diff --git a/arch/arm/mach-omap2/powerdomain.c b/arch/arm/mach-omap2/powerdomain.c
index 73e2971..3a9e151 100644
--- a/arch/arm/mach-omap2/powerdomain.c
+++ b/arch/arm/mach-omap2/powerdomain.c
@@ -35,6 +35,11 @@
 #include <mach/powerdomain.h>
 #include <mach/clockdomain.h>
 
+enum {
+	PWRDM_STATE_NOW = 0,
+	PWRDM_STATE_PREV,
+};
+
 /* pwrdm_list contains all registered struct powerdomains */
 static LIST_HEAD(pwrdm_list);
 
@@ -102,6 +107,63 @@ static struct powerdomain *_pwrdm_deps_lookup(struct powerdomain *pwrdm,
 	return pd->pwrdm;
 }
 
+static int _pwrdm_state_switch(struct powerdomain *pwrdm, int flag)
+{
+
+	int prev;
+	int state;
+
+	if (pwrdm == NULL)
+		return -EINVAL;
+
+	state = pwrdm_read_pwrst(pwrdm);
+
+	switch (flag) {
+	case PWRDM_STATE_NOW:
+		prev = pwrdm->state;
+		break;
+	case PWRDM_STATE_PREV:
+		prev = pwrdm_read_prev_pwrst(pwrdm);
+		if (pwrdm->state != prev)
+			pwrdm->state_counter[prev]++;
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	if (state != prev)
+		pwrdm->state_counter[state]++;
+
+	pwrdm->state = state;
+
+	return 0;
+}
+
+static int _pwrdm_pre_transition_cb(struct powerdomain *pwrdm)
+{
+	pwrdm_clear_all_prev_pwrst(pwrdm);
+	_pwrdm_state_switch(pwrdm, PWRDM_STATE_NOW);
+	return 0;
+}
+
+static int _pwrdm_post_transition_cb(struct powerdomain *pwrdm)
+{
+	_pwrdm_state_switch(pwrdm, PWRDM_STATE_PREV);
+	return 0;
+}
+
+static __init void _pwrdm_setup(struct powerdomain *pwrdm)
+{
+	int i;
+
+	for (i = 0; i < 4; i++)
+		pwrdm->state_counter[i] = 0;
+
+	pwrdm_wait_transition(pwrdm);
+	pwrdm->state = pwrdm_read_pwrst(pwrdm);
+	pwrdm->state_counter[pwrdm->state] = 1;
+
+}
 
 /* Public functions */
 
@@ -117,9 +179,12 @@ void pwrdm_init(struct powerdomain **pwrdm_list)
 {
 	struct powerdomain **p = NULL;
 
-	if (pwrdm_list)
-		for (p = pwrdm_list; *p; p++)
+	if (pwrdm_list) {
+		for (p = pwrdm_list; *p; p++) {
 			pwrdm_register(*p);
+			_pwrdm_setup(*p);
+		}
+	}
 }
 
 /**
@@ -1110,4 +1175,36 @@ int pwrdm_wait_transition(struct powerdomain *pwrdm)
 	return 0;
 }
 
+int pwrdm_state_switch(struct powerdomain *pwrdm)
+{
+	return _pwrdm_state_switch(pwrdm, PWRDM_STATE_NOW);
+}
+
+int pwrdm_clkdm_state_switch(struct clockdomain *clkdm)
+{
+	if (clkdm != NULL && clkdm->pwrdm.ptr != NULL) {
+		pwrdm_wait_transition(clkdm->pwrdm.ptr);
+		return pwrdm_state_switch(clkdm->pwrdm.ptr);
+	}
+
+	return -EINVAL;
+}
+int pwrdm_clk_state_switch(struct clk *clk)
+{
+	if (clk != NULL && clk->clkdm.ptr != NULL)
+		return pwrdm_clkdm_state_switch(clk->clkdm.ptr);
+	return -EINVAL;
+}
+
+int pwrdm_pre_transition(void)
+{
+	pwrdm_for_each(_pwrdm_pre_transition_cb);
+	return 0;
+}
+
+int pwrdm_post_transition(void)
+{
+	pwrdm_for_each(_pwrdm_post_transition_cb);
+	return 0;
+}
 
diff --git a/arch/arm/plat-omap/include/mach/powerdomain.h b/arch/arm/plat-omap/include/mach/powerdomain.h
index 69c9e67..52663fc 100644
--- a/arch/arm/plat-omap/include/mach/powerdomain.h
+++ b/arch/arm/plat-omap/include/mach/powerdomain.h
@@ -117,6 +117,8 @@ struct powerdomain {
 
 	struct list_head node;
 
+	int state;
+	unsigned state_counter[4];
 };
 
 
@@ -164,4 +166,9 @@ bool pwrdm_has_hdwr_sar(struct powerdomain *pwrdm);
 
 int pwrdm_wait_transition(struct powerdomain *pwrdm);
 
+int pwrdm_state_switch(struct powerdomain *pwrdm);
+int pwrdm_clkdm_state_switch(struct clockdomain *clkdm);
+int pwrdm_pre_transition(void);
+int pwrdm_post_transition(void);
+
 #endif
-- 
1.6.1


  reply	other threads:[~2009-02-05  2:07 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-05  2:05 [PATCH 00/21] OMAP: update PM infrastructure Kevin Hilman
2009-02-05  2:05 ` [PATCH 01/21] OMAP2/3: PM: push core PM code from linux-omap Kevin Hilman
2009-02-05  2:05   ` [PATCH 02/21] OMAP: Add new function to check wether there is irq pending Kevin Hilman
2009-02-05  2:05     ` [PATCH 03/21] OMAP3: PM: SmartReflex driver integration Kevin Hilman
2009-02-05  2:05       ` [PATCH 04/21] OMAP: Kconfig: move GP timer selection alongside other timer options Kevin Hilman
2009-02-05  2:05         ` [PATCH 05/21] OMAP: dmtimer: enable all timers to be wakeup events Kevin Hilman
2009-02-05  2:05           ` [PATCH 06/21] OMAP3: PM: Add wake-up bit defintiions for CONTROL_PADCONF_X Kevin Hilman
2009-02-05  2:05             ` [PATCH 07/21] OMAP3: PM: UART: disable clocks when idle and off-mode support Kevin Hilman
2009-02-05  2:05               ` [PATCH 08/21] OMAP: UART: Add sysfs interface for adjusting UART sleep timeout Kevin Hilman
2009-02-05  2:05                 ` [PATCH 09/21] OMAP3: PM: Force IVA2 into idle during bootup Kevin Hilman
2009-02-05  2:05                   ` [PATCH 10/21] OMAP3: PM: Add D2D clocks and auto-idle setup to PRCM init Kevin Hilman
2009-02-05  2:05                     ` [PATCH 11/21] OMAP3: PM: D2D clockdomain supports SW supervised transitions Kevin Hilman
2009-02-05  2:05                       ` Kevin Hilman [this message]
2009-02-05  2:05                         ` [PATCH 13/21] OMAP: PM: Hook into PM counters Kevin Hilman
2009-02-05  2:06                           ` [PATCH 14/21] OMAP: PM: Add closures to clkdm_for_each and pwrdm_for_each Kevin Hilman
2009-02-05  2:06                             ` [PATCH 15/21] OMAP: PM: Add pm-debug counters Kevin Hilman
2009-02-05  2:06                               ` [PATCH 16/21] OMAP: PM debug: make powerdomains use PM-debug counters Kevin Hilman
2009-02-05  2:06                                 ` [PATCH 17/21] OMAP: PM debug: do not print out status for meta powerdomains (dpll*) Kevin Hilman
2009-02-05  2:06                                   ` [PATCH 18/21] OMAP: PM debug: Add PRCM register dump support Kevin Hilman
2009-02-05  2:06                                     ` [PATCH 19/21] OMAP: PM: Add definitions for ETK pads and observability registers Kevin Hilman
2009-02-05  2:06                                       ` [PATCH 20/21] OMAP: Debug observability and ETK padconf implementation Kevin Hilman
2009-02-05  2:06                                         ` [PATCH 21/21] OMAP: Add debug observablity (debobs) Kconfig item 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=1233799567-22250-13-git-send-email-khilman@deeprootsystems.com \
    --to=khilman@deeprootsystems.com \
    --cc=linux-arm-kernel@lists.arm.linux.org.uk \
    --cc=linux-omap@vger.kernel.org \
    --cc=peter.de-schrijver@nokia.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.