diff options
Diffstat (limited to 'drivers/misc')
-rw-r--r-- | drivers/misc/gcx/gccore/gcdebug.c | 29 | ||||
-rw-r--r-- | drivers/misc/gcx/gccore/gcmain.c | 25 | ||||
-rw-r--r-- | drivers/misc/gcx/gccore/gcmain.h | 1 |
3 files changed, 54 insertions, 1 deletions
diff --git a/drivers/misc/gcx/gccore/gcdebug.c b/drivers/misc/gcx/gccore/gcdebug.c index fdabcb2..fb0d502 100644 --- a/drivers/misc/gcx/gccore/gcdebug.c +++ b/drivers/misc/gcx/gccore/gcdebug.c @@ -16,6 +16,7 @@ #include <linux/seq_file.h> #include <linux/module.h> #include <linux/uaccess.h> +#include <linux/delay.h> #include <linux/gcx.h> #include <linux/gccore.h> #include "gcmain.h" @@ -571,6 +572,32 @@ static const struct file_operations gc_debug_fops_log_reset = { /*****************************************************************************/ +static int gc_debug_show_cur_freq(struct seq_file *s, void *data) +{ + unsigned mhz = gcpwr_get_speed(); + if (mhz) + seq_printf(s, "cur freq: %d mhz\n", mhz); + else + seq_printf(s, "unable to read cur freq\n"); + + return 0; +} + +static int gc_debug_open_cur_freq(struct inode *inode, struct file *file) +{ + return single_open(file, gc_debug_show_cur_freq, 0); +} + +static const struct file_operations gc_debug_fops_cur_freq = { + .open = gc_debug_open_cur_freq, + .write = NULL, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, +}; + +/*****************************************************************************/ + void gc_debug_init(void) { struct dentry *logDir; @@ -589,6 +616,8 @@ void gc_debug_init(void) &gc_debug_fops_gpu_last_error); debugfs_create_bool("cache_status_every_irq", 0664, debug_root, &gc_cache_status_every_irq); + debugfs_create_file("cur_freq", 0664, debug_root, NULL, + &gc_debug_fops_cur_freq); logDir = debugfs_create_dir("log", debug_root); if (!logDir) diff --git a/drivers/misc/gcx/gccore/gcmain.c b/drivers/misc/gcx/gccore/gcmain.c index 61a25ef..d4aca5a 100644 --- a/drivers/misc/gcx/gccore/gcmain.c +++ b/drivers/misc/gcx/gccore/gcmain.c @@ -421,7 +421,7 @@ void gcpwr_reset(struct gccorecontext *gccorecontext) gcclockcontrol.raw); /* Wait for reset. */ - mdelay(1); + msleep(1); /* Reset soft reset bit. */ gcclockcontrol.reg.reset = 0; @@ -464,6 +464,29 @@ void gcpwr_reset(struct gccorecontext *gccorecontext) GCEXIT(GCZONE_POWER); } +unsigned int gcpwr_get_speed(void) +{ + struct gccorecontext *gccorecontext = &g_context; + static const int seccount = 2; + unsigned int cyclecount; + unsigned int speedmhz = 0; + + GCLOCK(&gccorecontext->powerlock); + + if (gccorecontext->gcpower == GCPWR_ON) { + /* Reset cycle counter and sleep. */ + gc_write_reg(GC_TOTAL_CYCLES_Address, 0); + msleep(seccount * 1000); + + /* Read the cycle counter and compute the speed. */ + cyclecount = gc_read_reg(GC_TOTAL_CYCLES_Address); + speedmhz = cyclecount / 1000 / 1000 / seccount; + } + + GCUNLOCK(&gccorecontext->powerlock); + + return speedmhz; +} /******************************************************************************* * Public API. diff --git a/drivers/misc/gcx/gccore/gcmain.h b/drivers/misc/gcx/gccore/gcmain.h index 1c4ffa1..e2931d4 100644 --- a/drivers/misc/gcx/gccore/gcmain.h +++ b/drivers/misc/gcx/gccore/gcmain.h @@ -109,5 +109,6 @@ void gc_write_reg(unsigned int address, unsigned int data); enum gcpower gcpwr_get(void); void gcpwr_set(struct gccorecontext *gccorecontext, enum gcpower gcpower); void gcpwr_reset(struct gccorecontext *gccorecontext); +unsigned int gcpwr_get_speed(void); #endif |