2009-05-29 01:56:16 +08:00
|
|
|
/*
|
|
|
|
* OMAP Power Management debug routines
|
|
|
|
*
|
|
|
|
* Copyright (C) 2005 Texas Instruments, Inc.
|
|
|
|
* Copyright (C) 2006-2008 Nokia Corporation
|
|
|
|
*
|
|
|
|
* Written by:
|
|
|
|
* Richard Woodruff <r-woodruff2@ti.com>
|
|
|
|
* Tony Lindgren
|
|
|
|
* Juha Yrjola
|
|
|
|
* Amit Kucheria <amit.kucheria@nokia.com>
|
|
|
|
* Igor Stoppa <igor.stoppa@nokia.com>
|
|
|
|
* Jouni Hogander
|
|
|
|
*
|
|
|
|
* Based on pm.c for omap2
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/kernel.h>
|
2008-10-15 23:13:48 +08:00
|
|
|
#include <linux/sched.h>
|
2009-05-29 01:56:16 +08:00
|
|
|
#include <linux/clk.h>
|
|
|
|
#include <linux/err.h>
|
|
|
|
#include <linux/io.h>
|
|
|
|
|
|
|
|
#include <mach/clock.h>
|
|
|
|
#include <mach/board.h>
|
2008-10-15 23:13:48 +08:00
|
|
|
#include <mach/powerdomain.h>
|
|
|
|
#include <mach/clockdomain.h>
|
2009-05-29 01:56:16 +08:00
|
|
|
|
|
|
|
#include "prm.h"
|
|
|
|
#include "cm.h"
|
|
|
|
#include "pm.h"
|
|
|
|
|
|
|
|
int omap2_pm_debug;
|
|
|
|
|
|
|
|
#define DUMP_PRM_MOD_REG(mod, reg) \
|
|
|
|
regs[reg_count].name = #mod "." #reg; \
|
|
|
|
regs[reg_count++].val = prm_read_mod_reg(mod, reg)
|
|
|
|
#define DUMP_CM_MOD_REG(mod, reg) \
|
|
|
|
regs[reg_count].name = #mod "." #reg; \
|
|
|
|
regs[reg_count++].val = cm_read_mod_reg(mod, reg)
|
|
|
|
#define DUMP_PRM_REG(reg) \
|
|
|
|
regs[reg_count].name = #reg; \
|
|
|
|
regs[reg_count++].val = __raw_readl(reg)
|
|
|
|
#define DUMP_CM_REG(reg) \
|
|
|
|
regs[reg_count].name = #reg; \
|
|
|
|
regs[reg_count++].val = __raw_readl(reg)
|
|
|
|
#define DUMP_INTC_REG(reg, off) \
|
|
|
|
regs[reg_count].name = #reg; \
|
2009-08-29 01:50:33 +08:00
|
|
|
regs[reg_count++].val = __raw_readl(OMAP2_IO_ADDRESS(0x480fe000 + (off)))
|
2009-05-29 01:56:16 +08:00
|
|
|
|
|
|
|
void omap2_pm_dump(int mode, int resume, unsigned int us)
|
|
|
|
{
|
|
|
|
struct reg {
|
|
|
|
const char *name;
|
|
|
|
u32 val;
|
|
|
|
} regs[32];
|
|
|
|
int reg_count = 0, i;
|
|
|
|
const char *s1 = NULL, *s2 = NULL;
|
|
|
|
|
|
|
|
if (!resume) {
|
|
|
|
#if 0
|
|
|
|
/* MPU */
|
|
|
|
DUMP_PRM_MOD_REG(OCP_MOD, OMAP2_PRM_IRQENABLE_MPU_OFFSET);
|
|
|
|
DUMP_CM_MOD_REG(MPU_MOD, CM_CLKSTCTRL);
|
|
|
|
DUMP_PRM_MOD_REG(MPU_MOD, PM_PWSTCTRL);
|
|
|
|
DUMP_PRM_MOD_REG(MPU_MOD, PM_PWSTST);
|
|
|
|
DUMP_PRM_MOD_REG(MPU_MOD, PM_WKDEP);
|
|
|
|
#endif
|
|
|
|
#if 0
|
|
|
|
/* INTC */
|
|
|
|
DUMP_INTC_REG(INTC_MIR0, 0x0084);
|
|
|
|
DUMP_INTC_REG(INTC_MIR1, 0x00a4);
|
|
|
|
DUMP_INTC_REG(INTC_MIR2, 0x00c4);
|
|
|
|
#endif
|
|
|
|
#if 0
|
|
|
|
DUMP_CM_MOD_REG(CORE_MOD, CM_FCLKEN1);
|
|
|
|
if (cpu_is_omap24xx()) {
|
|
|
|
DUMP_CM_MOD_REG(CORE_MOD, OMAP24XX_CM_FCLKEN2);
|
|
|
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M_PWSTST);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
} else {
|
|
|
|
DUMP_PRM_MOD_REG(CORE_MOD, PM_WKST1);
|
|
|
|
if (cpu_is_omap24xx())
|
|
|
|
DUMP_PRM_MOD_REG(CORE_MOD, OMAP24XX_PM_WKST2);
|
|
|
|
DUMP_PRM_MOD_REG(WKUP_MOD, PM_WKST);
|
|
|
|
DUMP_PRM_MOD_REG(OCP_MOD, OMAP2_PRCM_IRQSTATUS_MPU_OFFSET);
|
|
|
|
#if 1
|
|
|
|
DUMP_INTC_REG(INTC_PENDING_IRQ0, 0x0098);
|
|
|
|
DUMP_INTC_REG(INTC_PENDING_IRQ1, 0x00b8);
|
|
|
|
DUMP_INTC_REG(INTC_PENDING_IRQ2, 0x00d8);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (mode) {
|
|
|
|
case 0:
|
|
|
|
s1 = "full";
|
|
|
|
s2 = "retention";
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
s1 = "MPU";
|
|
|
|
s2 = "retention";
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
s1 = "MPU";
|
|
|
|
s2 = "idle";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!resume)
|
|
|
|
#ifdef CONFIG_NO_HZ
|
|
|
|
printk(KERN_INFO
|
|
|
|
"--- Going to %s %s (next timer after %u ms)\n", s1, s2,
|
|
|
|
jiffies_to_msecs(get_next_timer_interrupt(jiffies) -
|
|
|
|
jiffies));
|
|
|
|
#else
|
|
|
|
printk(KERN_INFO "--- Going to %s %s\n", s1, s2);
|
|
|
|
#endif
|
|
|
|
else
|
|
|
|
printk(KERN_INFO "--- Woke up (slept for %u.%03u ms)\n",
|
|
|
|
us / 1000, us % 1000);
|
|
|
|
|
|
|
|
for (i = 0; i < reg_count; i++)
|
|
|
|
printk(KERN_INFO "%-20s: 0x%08x\n", regs[i].name, regs[i].val);
|
|
|
|
}
|
2008-10-15 23:13:48 +08:00
|
|
|
|
|
|
|
#ifdef CONFIG_DEBUG_FS
|
|
|
|
#include <linux/debugfs.h>
|
|
|
|
#include <linux/seq_file.h>
|
|
|
|
|
|
|
|
struct dentry *pm_dbg_dir;
|
|
|
|
|
|
|
|
static int pm_dbg_init_done;
|
|
|
|
|
|
|
|
enum {
|
|
|
|
DEBUG_FILE_COUNTERS = 0,
|
|
|
|
DEBUG_FILE_TIMERS,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const char pwrdm_state_names[][4] = {
|
|
|
|
"OFF",
|
|
|
|
"RET",
|
|
|
|
"INA",
|
|
|
|
"ON"
|
|
|
|
};
|
|
|
|
|
|
|
|
void pm_dbg_update_time(struct powerdomain *pwrdm, int prev)
|
|
|
|
{
|
|
|
|
s64 t;
|
|
|
|
|
|
|
|
if (!pm_dbg_init_done)
|
|
|
|
return ;
|
|
|
|
|
|
|
|
/* Update timer for previous state */
|
|
|
|
t = sched_clock();
|
|
|
|
|
|
|
|
pwrdm->state_timer[prev] += t - pwrdm->timer;
|
|
|
|
|
|
|
|
pwrdm->timer = t;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int clkdm_dbg_show_counter(struct clockdomain *clkdm, void *user)
|
|
|
|
{
|
|
|
|
struct seq_file *s = (struct seq_file *)user;
|
|
|
|
|
|
|
|
if (strcmp(clkdm->name, "emu_clkdm") == 0 ||
|
|
|
|
strcmp(clkdm->name, "wkup_clkdm") == 0 ||
|
|
|
|
strncmp(clkdm->name, "dpll", 4) == 0)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
seq_printf(s, "%s->%s (%d)", clkdm->name,
|
|
|
|
clkdm->pwrdm.ptr->name,
|
|
|
|
atomic_read(&clkdm->usecount));
|
|
|
|
seq_printf(s, "\n");
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int pwrdm_dbg_show_counter(struct powerdomain *pwrdm, void *user)
|
|
|
|
{
|
|
|
|
struct seq_file *s = (struct seq_file *)user;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (strcmp(pwrdm->name, "emu_pwrdm") == 0 ||
|
|
|
|
strcmp(pwrdm->name, "wkup_pwrdm") == 0 ||
|
|
|
|
strncmp(pwrdm->name, "dpll", 4) == 0)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (pwrdm->state != pwrdm_read_pwrst(pwrdm))
|
|
|
|
printk(KERN_ERR "pwrdm state mismatch(%s) %d != %d\n",
|
|
|
|
pwrdm->name, pwrdm->state, pwrdm_read_pwrst(pwrdm));
|
|
|
|
|
|
|
|
seq_printf(s, "%s (%s)", pwrdm->name,
|
|
|
|
pwrdm_state_names[pwrdm->state]);
|
|
|
|
for (i = 0; i < 4; i++)
|
|
|
|
seq_printf(s, ",%s:%d", pwrdm_state_names[i],
|
|
|
|
pwrdm->state_counter[i]);
|
|
|
|
|
|
|
|
seq_printf(s, "\n");
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int pwrdm_dbg_show_timer(struct powerdomain *pwrdm, void *user)
|
|
|
|
{
|
|
|
|
struct seq_file *s = (struct seq_file *)user;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (strcmp(pwrdm->name, "emu_pwrdm") == 0 ||
|
|
|
|
strcmp(pwrdm->name, "wkup_pwrdm") == 0 ||
|
|
|
|
strncmp(pwrdm->name, "dpll", 4) == 0)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
pwrdm_state_switch(pwrdm);
|
|
|
|
|
|
|
|
seq_printf(s, "%s (%s)", pwrdm->name,
|
|
|
|
pwrdm_state_names[pwrdm->state]);
|
|
|
|
|
|
|
|
for (i = 0; i < 4; i++)
|
|
|
|
seq_printf(s, ",%s:%lld", pwrdm_state_names[i],
|
|
|
|
pwrdm->state_timer[i]);
|
|
|
|
|
|
|
|
seq_printf(s, "\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int pm_dbg_show_counters(struct seq_file *s, void *unused)
|
|
|
|
{
|
|
|
|
pwrdm_for_each(pwrdm_dbg_show_counter, s);
|
|
|
|
clkdm_for_each(clkdm_dbg_show_counter, s);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int pm_dbg_show_timers(struct seq_file *s, void *unused)
|
|
|
|
{
|
|
|
|
pwrdm_for_each(pwrdm_dbg_show_timer, s);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int pm_dbg_open(struct inode *inode, struct file *file)
|
|
|
|
{
|
|
|
|
switch ((int)inode->i_private) {
|
|
|
|
case DEBUG_FILE_COUNTERS:
|
|
|
|
return single_open(file, pm_dbg_show_counters,
|
|
|
|
&inode->i_private);
|
|
|
|
case DEBUG_FILE_TIMERS:
|
|
|
|
default:
|
|
|
|
return single_open(file, pm_dbg_show_timers,
|
|
|
|
&inode->i_private);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct file_operations debug_fops = {
|
|
|
|
.open = pm_dbg_open,
|
|
|
|
.read = seq_read,
|
|
|
|
.llseek = seq_lseek,
|
|
|
|
.release = single_release,
|
|
|
|
};
|
|
|
|
|
|
|
|
static int __init pwrdms_setup(struct powerdomain *pwrdm, void *unused)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
s64 t;
|
|
|
|
|
|
|
|
t = sched_clock();
|
|
|
|
|
|
|
|
for (i = 0; i < 4; i++)
|
|
|
|
pwrdm->state_timer[i] = 0;
|
|
|
|
|
|
|
|
pwrdm->timer = t;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int __init pm_dbg_init(void)
|
|
|
|
{
|
|
|
|
struct dentry *d;
|
|
|
|
|
|
|
|
d = debugfs_create_dir("pm_debug", NULL);
|
|
|
|
if (IS_ERR(d))
|
|
|
|
return PTR_ERR(d);
|
|
|
|
|
|
|
|
(void) debugfs_create_file("count", S_IRUGO,
|
|
|
|
d, (void *)DEBUG_FILE_COUNTERS, &debug_fops);
|
|
|
|
(void) debugfs_create_file("time", S_IRUGO,
|
|
|
|
d, (void *)DEBUG_FILE_TIMERS, &debug_fops);
|
|
|
|
|
|
|
|
pwrdm_for_each(pwrdms_setup, NULL);
|
|
|
|
|
|
|
|
pm_dbg_init_done = 1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
late_initcall(pm_dbg_init);
|
|
|
|
|
|
|
|
#else
|
|
|
|
void pm_dbg_update_time(struct powerdomain *pwrdm, int prev) {}
|
|
|
|
#endif
|