From: Peter De Schrijver <pdeschrijver@nvidia.com>
To: Peter De Schrijver <pdeschrijver@nvidia.com>
Cc: Colin Cross <ccross@android.com>, Olof Johansson <olof@lixom.net>,
Stephen Warren <swarren@nvidia.com>,
Russell King <linux@arm.linux.org.uk>,
Gary King <gking@nvidia.com>, Arnd Bergmann <arnd@arndb.de>,
linux-tegra@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: [PATCH v1 4/8] ARM: tegra: prepare powergate.c for multiple variants
Date: Thu, 26 Jan 2012 19:07:09 +0200 [thread overview]
Message-ID: <1327597641-7519-5-git-send-email-pdeschrijver@nvidia.com> (raw)
In-Reply-To: <1327597641-7519-1-git-send-email-pdeschrijver@nvidia.com>
Prepare the powergating code for other Tegra variants which have a different
number of powerdomains.
Signed-off-by: Peter De Schrijver <pdeschrijver@nvidia.com>
---
arch/arm/mach-tegra/include/mach/powergate.h | 1 -
arch/arm/mach-tegra/powergate.c | 33 +++++++++++++++++++++----
2 files changed, 27 insertions(+), 7 deletions(-)
diff --git a/arch/arm/mach-tegra/include/mach/powergate.h b/arch/arm/mach-tegra/include/mach/powergate.h
index 39c396d..36846dc 100644
--- a/arch/arm/mach-tegra/include/mach/powergate.h
+++ b/arch/arm/mach-tegra/include/mach/powergate.h
@@ -27,7 +27,6 @@
#define TEGRA_POWERGATE_VDEC 4
#define TEGRA_POWERGATE_L2 5
#define TEGRA_POWERGATE_MPE 6
-#define TEGRA_NUM_POWERGATE 7
int tegra_powergate_power_on(int id);
int tegra_powergate_power_off(int id);
diff --git a/arch/arm/mach-tegra/powergate.c b/arch/arm/mach-tegra/powergate.c
index 9483064..61734c0 100644
--- a/arch/arm/mach-tegra/powergate.c
+++ b/arch/arm/mach-tegra/powergate.c
@@ -31,6 +31,8 @@
#include <mach/iomap.h>
#include <mach/powergate.h>
+#include "chipid.h"
+
#define PWRGATE_TOGGLE 0x30
#define PWRGATE_TOGGLE_START (1 << 8)
@@ -38,6 +40,8 @@
#define PWRGATE_STATUS 0x38
+static int tegra_num_powerdomains;
+
static DEFINE_SPINLOCK(tegra_powergate_lock);
static void __iomem *pmc = IO_ADDRESS(TEGRA_PMC_BASE);
@@ -75,7 +79,7 @@ static int tegra_powergate_set(int id, bool new_state)
int tegra_powergate_power_on(int id)
{
- if (id < 0 || id >= TEGRA_NUM_POWERGATE)
+ if (id < 0 || id >= tegra_num_powerdomains)
return -EINVAL;
return tegra_powergate_set(id, true);
@@ -83,17 +87,18 @@ int tegra_powergate_power_on(int id)
int tegra_powergate_power_off(int id)
{
- if (id < 0 || id >= TEGRA_NUM_POWERGATE)
+ if (id < 0 || id >= tegra_num_powerdomains)
return -EINVAL;
return tegra_powergate_set(id, false);
}
-static bool tegra_powergate_is_powered(int id)
+static int tegra_powergate_is_powered(int id)
{
u32 status;
- WARN_ON(id < 0 || id >= TEGRA_NUM_POWERGATE);
+ if (id < 0 || id >= tegra_num_powerdomains)
+ return -EINVAL;
status = pmc_read(PWRGATE_STATUS) & (1 << id);
return !!status;
@@ -103,7 +108,7 @@ int tegra_powergate_remove_clamping(int id)
{
u32 mask;
- if (id < 0 || id >= TEGRA_NUM_POWERGATE)
+ if (id < 0 || id >= tegra_num_powerdomains)
return -EINVAL;
/*
@@ -156,6 +161,22 @@ err_power:
return ret;
}
+int __init tegra_powergate_init(void)
+{
+ switch (tegra_get_chipid()) {
+ case TEGRA20:
+ tegra_num_powerdomains = 7;
+ break;
+ default:
+ /* Unknown Tegra variant. Disable powergating */
+ tegra_num_powerdomains = 0;
+ break;
+ }
+
+ return 0;
+}
+arch_initcall(tegra_powergate_init);
+
#ifdef CONFIG_DEBUG_FS
static const char * const powergate_name[] = {
@@ -175,7 +196,7 @@ static int powergate_show(struct seq_file *s, void *data)
seq_printf(s, " powergate powered\n");
seq_printf(s, "------------------\n");
- for (i = 0; i < TEGRA_NUM_POWERGATE; i++)
+ for (i = 0; i < tegra_num_powerdomains; i++)
seq_printf(s, " %9s %7s\n", powergate_name[i],
tegra_powergate_is_powered(i) ? "yes" : "no");
return 0;
--
1.7.7.rc0.72.g4b5ea.dirty
next prev parent reply other threads:[~2012-01-26 17:08 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-26 17:07 [PATCH v1 0/8] Support for secondary cores on Tegra30 Peter De Schrijver
2012-01-26 17:07 ` [PATCH v1 1/8] ARM: tegra: introduce support for reading chipid Peter De Schrijver
2012-01-27 8:19 ` Olof Johansson
2012-01-26 17:07 ` [PATCH v1 2/8] ARM: tegra: functions to access the flowcontroller Peter De Schrijver
2012-01-26 17:07 ` [PATCH v1 3/8] ARM: tegra: rework Tegra secondary CPU core bringup Peter De Schrijver
2012-01-26 20:25 ` Stephen Warren
2012-01-27 8:18 ` Peter De Schrijver
2012-02-02 17:32 ` Stephen Warren
2012-01-26 17:07 ` Peter De Schrijver [this message]
2012-01-26 17:07 ` [PATCH v1 5/8] ARM: tegra: export tegra_powergate_is_powered() Peter De Schrijver
2012-01-26 17:07 ` [PATCH v1 6/8] ARM: tegra: add support for Tegra30 powerdomains Peter De Schrijver
2012-01-26 17:07 ` [PATCH v1 7/8] ARM: tegra: support for Tegra30 CPU powerdomains Peter De Schrijver
2012-01-26 20:40 ` Stephen Warren
2012-01-26 17:07 ` [PATCH v1 8/8] ARM: tegra: support for secondary cores on Tegra30 Peter De Schrijver
2012-01-26 20:44 ` Stephen Warren
2012-01-27 5:58 ` Murali N
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=1327597641-7519-5-git-send-email-pdeschrijver@nvidia.com \
--to=pdeschrijver@nvidia.com \
--cc=arnd@arndb.de \
--cc=ccross@android.com \
--cc=gking@nvidia.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=linux@arm.linux.org.uk \
--cc=olof@lixom.net \
--cc=swarren@nvidia.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®