aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/arm/mach-tegra/include/mach/powergate.h1
-rw-r--r--arch/arm/mach-tegra/powergate.c33
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 39c396d2ddb0..36846dc6e8ef 100644
--- a/arch/arm/mach-tegra/include/mach/powergate.h
+++ b/arch/arm/mach-tegra/include/mach/powergate.h
@@ -27,7 +27,6 @@
27#define TEGRA_POWERGATE_VDEC 4 27#define TEGRA_POWERGATE_VDEC 4
28#define TEGRA_POWERGATE_L2 5 28#define TEGRA_POWERGATE_L2 5
29#define TEGRA_POWERGATE_MPE 6 29#define TEGRA_POWERGATE_MPE 6
30#define TEGRA_NUM_POWERGATE 7
31 30
32int tegra_powergate_power_on(int id); 31int tegra_powergate_power_on(int id);
33int tegra_powergate_power_off(int id); 32int tegra_powergate_power_off(int id);
diff --git a/arch/arm/mach-tegra/powergate.c b/arch/arm/mach-tegra/powergate.c
index 948306491a59..9b828f2ed2b6 100644
--- a/arch/arm/mach-tegra/powergate.c
+++ b/arch/arm/mach-tegra/powergate.c
@@ -31,6 +31,8 @@
31#include <mach/iomap.h> 31#include <mach/iomap.h>
32#include <mach/powergate.h> 32#include <mach/powergate.h>
33 33
34#include "fuse.h"
35
34#define PWRGATE_TOGGLE 0x30 36#define PWRGATE_TOGGLE 0x30
35#define PWRGATE_TOGGLE_START (1 << 8) 37#define PWRGATE_TOGGLE_START (1 << 8)
36 38
@@ -38,6 +40,8 @@
38 40
39#define PWRGATE_STATUS 0x38 41#define PWRGATE_STATUS 0x38
40 42
43static int tegra_num_powerdomains;
44
41static DEFINE_SPINLOCK(tegra_powergate_lock); 45static DEFINE_SPINLOCK(tegra_powergate_lock);
42 46
43static void __iomem *pmc = IO_ADDRESS(TEGRA_PMC_BASE); 47static void __iomem *pmc = IO_ADDRESS(TEGRA_PMC_BASE);
@@ -75,7 +79,7 @@ static int tegra_powergate_set(int id, bool new_state)
75 79
76int tegra_powergate_power_on(int id) 80int tegra_powergate_power_on(int id)
77{ 81{
78 if (id < 0 || id >= TEGRA_NUM_POWERGATE) 82 if (id < 0 || id >= tegra_num_powerdomains)
79 return -EINVAL; 83 return -EINVAL;
80 84
81 return tegra_powergate_set(id, true); 85 return tegra_powergate_set(id, true);
@@ -83,17 +87,18 @@ int tegra_powergate_power_on(int id)
83 87
84int tegra_powergate_power_off(int id) 88int tegra_powergate_power_off(int id)
85{ 89{
86 if (id < 0 || id >= TEGRA_NUM_POWERGATE) 90 if (id < 0 || id >= tegra_num_powerdomains)
87 return -EINVAL; 91 return -EINVAL;
88 92
89 return tegra_powergate_set(id, false); 93 return tegra_powergate_set(id, false);
90} 94}
91 95
92static bool tegra_powergate_is_powered(int id) 96static int tegra_powergate_is_powered(int id)
93{ 97{
94 u32 status; 98 u32 status;
95 99
96 WARN_ON(id < 0 || id >= TEGRA_NUM_POWERGATE); 100 if (id < 0 || id >= tegra_num_powerdomains)
101 return -EINVAL;
97 102
98 status = pmc_read(PWRGATE_STATUS) & (1 << id); 103 status = pmc_read(PWRGATE_STATUS) & (1 << id);
99 return !!status; 104 return !!status;
@@ -103,7 +108,7 @@ int tegra_powergate_remove_clamping(int id)
103{ 108{
104 u32 mask; 109 u32 mask;
105 110
106 if (id < 0 || id >= TEGRA_NUM_POWERGATE) 111 if (id < 0 || id >= tegra_num_powerdomains)
107 return -EINVAL; 112 return -EINVAL;
108 113
109 /* 114 /*
@@ -156,6 +161,22 @@ err_power:
156 return ret; 161 return ret;
157} 162}
158 163
164int __init tegra_powergate_init(void)
165{
166 switch (tegra_chip_id) {
167 case TEGRA20:
168 tegra_num_powerdomains = 7;
169 break;
170 default:
171 /* Unknown Tegra variant. Disable powergating */
172 tegra_num_powerdomains = 0;
173 break;
174 }
175
176 return 0;
177}
178arch_initcall(tegra_powergate_init);
179
159#ifdef CONFIG_DEBUG_FS 180#ifdef CONFIG_DEBUG_FS
160 181
161static const char * const powergate_name[] = { 182static const char * const powergate_name[] = {
@@ -175,7 +196,7 @@ static int powergate_show(struct seq_file *s, void *data)
175 seq_printf(s, " powergate powered\n"); 196 seq_printf(s, " powergate powered\n");
176 seq_printf(s, "------------------\n"); 197 seq_printf(s, "------------------\n");
177 198
178 for (i = 0; i < TEGRA_NUM_POWERGATE; i++) 199 for (i = 0; i < tegra_num_powerdomains; i++)
179 seq_printf(s, " %9s %7s\n", powergate_name[i], 200 seq_printf(s, " %9s %7s\n", powergate_name[i],
180 tegra_powergate_is_powered(i) ? "yes" : "no"); 201 tegra_powergate_is_powered(i) ? "yes" : "no");
181 return 0; 202 return 0;