aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-tegra/pmc.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/mach-tegra/pmc.c')
-rw-r--r--arch/arm/mach-tegra/pmc.c53
1 files changed, 52 insertions, 1 deletions
diff --git a/arch/arm/mach-tegra/pmc.c b/arch/arm/mach-tegra/pmc.c
index eb3fa4aee0e4..8acb881f7cfe 100644
--- a/arch/arm/mach-tegra/pmc.c
+++ b/arch/arm/mach-tegra/pmc.c
@@ -21,11 +21,14 @@
21#include <linux/of.h> 21#include <linux/of.h>
22#include <linux/of_address.h> 22#include <linux/of_address.h>
23 23
24#include "flowctrl.h"
24#include "fuse.h" 25#include "fuse.h"
25#include "pm.h" 26#include "pm.h"
26#include "pmc.h" 27#include "pmc.h"
27#include "sleep.h" 28#include "sleep.h"
28 29
30#define TEGRA_POWER_SYSCLK_POLARITY (1 << 10) /* sys clk polarity */
31#define TEGRA_POWER_SYSCLK_OE (1 << 11) /* system clock enable */
29#define TEGRA_POWER_EFFECT_LP0 (1 << 14) /* LP0 when CPU pwr gated */ 32#define TEGRA_POWER_EFFECT_LP0 (1 << 14) /* LP0 when CPU pwr gated */
30#define TEGRA_POWER_CPU_PWRREQ_POLARITY (1 << 15) /* CPU pwr req polarity */ 33#define TEGRA_POWER_CPU_PWRREQ_POLARITY (1 << 15) /* CPU pwr req polarity */
31#define TEGRA_POWER_CPU_PWRREQ_OE (1 << 16) /* CPU pwr req enable */ 34#define TEGRA_POWER_CPU_PWRREQ_OE (1 << 16) /* CPU pwr req enable */
@@ -193,16 +196,50 @@ enum tegra_suspend_mode tegra_pmc_get_suspend_mode(void)
193 return pmc_pm_data.suspend_mode; 196 return pmc_pm_data.suspend_mode;
194} 197}
195 198
199void tegra_pmc_set_suspend_mode(enum tegra_suspend_mode mode)
200{
201 if (mode < TEGRA_SUSPEND_NONE || mode >= TEGRA_MAX_SUSPEND_MODE)
202 return;
203
204 pmc_pm_data.suspend_mode = mode;
205}
206
207void tegra_pmc_suspend(void)
208{
209 tegra_pmc_writel(virt_to_phys(tegra_resume), PMC_SCRATCH41);
210}
211
212void tegra_pmc_resume(void)
213{
214 tegra_pmc_writel(0x0, PMC_SCRATCH41);
215}
216
196void tegra_pmc_pm_set(enum tegra_suspend_mode mode) 217void tegra_pmc_pm_set(enum tegra_suspend_mode mode)
197{ 218{
198 u32 reg; 219 u32 reg, csr_reg;
199 unsigned long rate = 0; 220 unsigned long rate = 0;
200 221
201 reg = tegra_pmc_readl(PMC_CTRL); 222 reg = tegra_pmc_readl(PMC_CTRL);
202 reg |= TEGRA_POWER_CPU_PWRREQ_OE; 223 reg |= TEGRA_POWER_CPU_PWRREQ_OE;
203 reg &= ~TEGRA_POWER_EFFECT_LP0; 224 reg &= ~TEGRA_POWER_EFFECT_LP0;
204 225
226 switch (tegra_chip_id) {
227 case TEGRA20:
228 case TEGRA30:
229 break;
230 default:
231 /* Turn off CRAIL */
232 csr_reg = flowctrl_read_cpu_csr(0);
233 csr_reg &= ~FLOW_CTRL_CSR_ENABLE_EXT_MASK;
234 csr_reg |= FLOW_CTRL_CSR_ENABLE_EXT_CRAIL;
235 flowctrl_write_cpu_csr(0, csr_reg);
236 break;
237 }
238
205 switch (mode) { 239 switch (mode) {
240 case TEGRA_SUSPEND_LP1:
241 rate = 32768;
242 break;
206 case TEGRA_SUSPEND_LP2: 243 case TEGRA_SUSPEND_LP2:
207 rate = clk_get_rate(tegra_pclk); 244 rate = clk_get_rate(tegra_pclk);
208 break; 245 break;
@@ -224,6 +261,20 @@ void tegra_pmc_suspend_init(void)
224 reg = tegra_pmc_readl(PMC_CTRL); 261 reg = tegra_pmc_readl(PMC_CTRL);
225 reg |= TEGRA_POWER_CPU_PWRREQ_OE; 262 reg |= TEGRA_POWER_CPU_PWRREQ_OE;
226 tegra_pmc_writel(reg, PMC_CTRL); 263 tegra_pmc_writel(reg, PMC_CTRL);
264
265 reg = tegra_pmc_readl(PMC_CTRL);
266
267 if (!pmc_pm_data.sysclkreq_high)
268 reg |= TEGRA_POWER_SYSCLK_POLARITY;
269 else
270 reg &= ~TEGRA_POWER_SYSCLK_POLARITY;
271
272 /* configure the output polarity while the request is tristated */
273 tegra_pmc_writel(reg, PMC_CTRL);
274
275 /* now enable the request */
276 reg |= TEGRA_POWER_SYSCLK_OE;
277 tegra_pmc_writel(reg, PMC_CTRL);
227} 278}
228#endif 279#endif
229 280