Commit 8f5d6f1b authored by Peter De Schrijver's avatar Peter De Schrijver Committed by Olof Johansson

ARM: tegra: prepare powergate.c for multiple variants

Prepare the powergating code for other Tegra variants which have a different
number of powerdomains.
Signed-off-by: default avatarPeter De Schrijver <pdeschrijver@nvidia.com>
Acked-by: default avatarStephen Warren <swarren@nvidia.com>
Tested-by: default avatarStephen Warren <swarren@nvidia.com>
Signed-off-by: default avatarOlof Johansson <olof@lixom.net>
parent b36ab975
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
#define TEGRA_POWERGATE_VDEC 4 #define TEGRA_POWERGATE_VDEC 4
#define TEGRA_POWERGATE_L2 5 #define TEGRA_POWERGATE_L2 5
#define TEGRA_POWERGATE_MPE 6 #define TEGRA_POWERGATE_MPE 6
#define TEGRA_NUM_POWERGATE 7
int tegra_powergate_power_on(int id); int tegra_powergate_power_on(int id);
int tegra_powergate_power_off(int id); int tegra_powergate_power_off(int id);
......
...@@ -31,6 +31,8 @@ ...@@ -31,6 +31,8 @@
#include <mach/iomap.h> #include <mach/iomap.h>
#include <mach/powergate.h> #include <mach/powergate.h>
#include "fuse.h"
#define PWRGATE_TOGGLE 0x30 #define PWRGATE_TOGGLE 0x30
#define PWRGATE_TOGGLE_START (1 << 8) #define PWRGATE_TOGGLE_START (1 << 8)
...@@ -38,6 +40,8 @@ ...@@ -38,6 +40,8 @@
#define PWRGATE_STATUS 0x38 #define PWRGATE_STATUS 0x38
static int tegra_num_powerdomains;
static DEFINE_SPINLOCK(tegra_powergate_lock); static DEFINE_SPINLOCK(tegra_powergate_lock);
static void __iomem *pmc = IO_ADDRESS(TEGRA_PMC_BASE); static void __iomem *pmc = IO_ADDRESS(TEGRA_PMC_BASE);
...@@ -75,7 +79,7 @@ static int tegra_powergate_set(int id, bool new_state) ...@@ -75,7 +79,7 @@ static int tegra_powergate_set(int id, bool new_state)
int tegra_powergate_power_on(int id) int tegra_powergate_power_on(int id)
{ {
if (id < 0 || id >= TEGRA_NUM_POWERGATE) if (id < 0 || id >= tegra_num_powerdomains)
return -EINVAL; return -EINVAL;
return tegra_powergate_set(id, true); return tegra_powergate_set(id, true);
...@@ -83,17 +87,18 @@ int tegra_powergate_power_on(int id) ...@@ -83,17 +87,18 @@ int tegra_powergate_power_on(int id)
int tegra_powergate_power_off(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 -EINVAL;
return tegra_powergate_set(id, false); return tegra_powergate_set(id, false);
} }
static bool tegra_powergate_is_powered(int id) static int tegra_powergate_is_powered(int id)
{ {
u32 status; 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); status = pmc_read(PWRGATE_STATUS) & (1 << id);
return !!status; return !!status;
...@@ -103,7 +108,7 @@ int tegra_powergate_remove_clamping(int id) ...@@ -103,7 +108,7 @@ int tegra_powergate_remove_clamping(int id)
{ {
u32 mask; u32 mask;
if (id < 0 || id >= TEGRA_NUM_POWERGATE) if (id < 0 || id >= tegra_num_powerdomains)
return -EINVAL; return -EINVAL;
/* /*
...@@ -156,6 +161,22 @@ int tegra_powergate_sequence_power_up(int id, struct clk *clk) ...@@ -156,6 +161,22 @@ int tegra_powergate_sequence_power_up(int id, struct clk *clk)
return ret; return ret;
} }
int __init tegra_powergate_init(void)
{
switch (tegra_chip_id) {
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 #ifdef CONFIG_DEBUG_FS
static const char * const powergate_name[] = { static const char * const powergate_name[] = {
...@@ -175,7 +196,7 @@ static int powergate_show(struct seq_file *s, void *data) ...@@ -175,7 +196,7 @@ static int powergate_show(struct seq_file *s, void *data)
seq_printf(s, " powergate powered\n"); seq_printf(s, " powergate powered\n");
seq_printf(s, "------------------\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], seq_printf(s, " %9s %7s\n", powergate_name[i],
tegra_powergate_is_powered(i) ? "yes" : "no"); tegra_powergate_is_powered(i) ? "yes" : "no");
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment