opp: Add a summary tree in debugfs

On rk3568-evb1-ddr4-v10 the opp_summary looks something like as follow.

 device                rate(Hz)    target(uV)    min(uV)    max(uV)
-------------------------------------------------------------------
 platform-fde60000.gpu
                      200000000       825000      825000      825000
                      300000000       825000      825000      825000
                      400000000       825000      825000      825000
                      600000000       825000      825000      825000
                      700000000       900000      900000      900000
                      800000000      1000000     1000000     1000000
 platform-bus-npu
                      900000000            0           0           0
                     1000000000       925000      925000      925000
 cpu0
                      408000000       825000      825000     1150000
                      600000000       825000      825000     1150000
                      816000000       825000      825000     1150000
                     1104000000       825000      825000     1150000
                     1416000000       900000      900000     1150000
                     1608000000       975000      975000     1150000
                     1800000000      1050000     1050000     1150000
                     1992000000      1150000     1150000     1150000

Change-Id: Ia357b4088805cf640dd659f510dd031488bd3ab3
Signed-off-by: Finley Xiao <finley.xiao@rock-chips.com>
This commit is contained in:
Finley Xiao
2019-06-11 15:57:44 +08:00
parent 3e45580f16
commit 37d5c1a6fd
+44
View File
@@ -239,11 +239,55 @@ out:
opp_dev->dentry = NULL;
}
static int opp_summary_show(struct seq_file *s, void *data)
{
struct list_head *lists = (struct list_head *)s->private;
struct opp_table *opp_table;
struct dev_pm_opp *opp;
mutex_lock(&opp_table_lock);
seq_puts(s, " device rate(Hz) target(uV) min(uV) max(uV)\n");
seq_puts(s, "-------------------------------------------------------------------\n");
list_for_each_entry(opp_table, lists, node) {
seq_printf(s, " %s\n", opp_table->dentry_name);
mutex_lock(&opp_table->lock);
list_for_each_entry(opp, &opp_table->opp_list, node) {
seq_printf(s, "%31lu %12lu %11lu %11lu\n",
opp->rate,
opp->supplies[0].u_volt,
opp->supplies[0].u_volt_min,
opp->supplies[0].u_volt_max);
}
mutex_unlock(&opp_table->lock);
}
mutex_unlock(&opp_table_lock);
return 0;
}
static int opp_summary_open(struct inode *inode, struct file *file)
{
return single_open(file, opp_summary_show, inode->i_private);
}
static const struct file_operations opp_summary_fops = {
.open = opp_summary_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
static int __init opp_debug_init(void)
{
/* Create /sys/kernel/debug/opp directory */
rootdir = debugfs_create_dir("opp", NULL);
debugfs_create_file("opp_summary", 0444, rootdir, &opp_tables,
&opp_summary_fops);
return 0;
}
core_initcall(opp_debug_init);