ARM: tegra: dvfs: Add CL-DVFS calibration delay to debugfs
Alex Frid [Wed, 20 Mar 2013 06:12:33 +0000 (23:12 -0700)]
Change-Id: I423659742523c5a641c656352b9a9e75e3f20c51
Signed-off-by: Alex Frid <afrid@nvidia.com>
Reviewed-on: http://git-master/r/211054
(cherry picked from commit 36b33bf62c05080ef3e3c93696cb7c9558ea606a)
Reviewed-on: http://git-master/r/212380
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Yu-Huan Hsu <yhsu@nvidia.com>

arch/arm/mach-tegra/tegra_cl_dvfs.c

index 8473653..1d9148c 100644 (file)
@@ -548,6 +548,8 @@ static void tune_timer_cb(unsigned long data)
 
 static inline void calibration_timer_update(struct tegra_cl_dvfs *cld)
 {
+       if (!cld->calibration_delay)
+               return;
        mod_timer(&cld->calibration_timer, jiffies + cld->calibration_delay);
 }
 
@@ -616,6 +618,8 @@ static void calibration_timer_cb(unsigned long data)
        unsigned long flags;
        struct tegra_cl_dvfs *cld = (struct tegra_cl_dvfs *)data;
 
+       pr_debug("%s\n", __func__);
+
        clk_lock_save(cld->dfll_clk, &flags);
        cl_dvfs_calibrate(cld);
        clk_unlock_restore(cld->dfll_clk, &flags);
@@ -1536,6 +1540,26 @@ static int fmin_get(void *data, u64 *val)
 }
 DEFINE_SIMPLE_ATTRIBUTE(dvco_rate_min_fops, fmin_get, NULL, "%llu\n");
 
+static int calibr_delay_get(void *data, u64 *val)
+{
+       struct tegra_cl_dvfs *cld = ((struct clk *)data)->u.dfll.cl_dvfs;
+       *val = jiffies_to_msecs(cld->calibration_delay);
+       return 0;
+}
+static int calibr_delay_set(void *data, u64 val)
+{
+       unsigned long flags;
+       struct clk *c = (struct clk *)data;
+       struct tegra_cl_dvfs *cld = c->u.dfll.cl_dvfs;
+
+       clk_lock_save(c, &flags);
+       cld->calibration_delay = msecs_to_jiffies(val);
+       clk_unlock_restore(c, &flags);
+       return 0;
+}
+DEFINE_SIMPLE_ATTRIBUTE(calibr_delay_fops, calibr_delay_get, calibr_delay_set,
+                       "%llu\n");
+
 static int cl_register_show(struct seq_file *s, void *data)
 {
        u32 offs;
@@ -1643,6 +1667,10 @@ int __init tegra_cl_dvfs_debug_init(struct clk *dfll_clk)
                cl_dvfs_dentry, dfll_clk, &dvco_rate_min_fops))
                goto err_out;
 
+       if (!debugfs_create_file("calibr_delay", S_IRUGO,
+               cl_dvfs_dentry, dfll_clk, &calibr_delay_fops))
+               goto err_out;
+
        if (!debugfs_create_file("registers", S_IRUGO | S_IWUSR,
                cl_dvfs_dentry, dfll_clk, &cl_register_fops))
                goto err_out;