ARM: tegra11: dvfs: Re-arrange DFLL clock initialization
Alex Frid [Wed, 27 Feb 2013 22:59:31 +0000 (14:59 -0800)]
- Re-assigned DFLL clock init operation to late init function inside
init operation itslef (instead of external assignment during global
tegra11x clocks initialization)

- Included into DFLL clock initialization call to Cl-DVFS debug init,
so that DFLL clock pointer can be passed as an argument, rather than
retrieved in CL-DVFS debug init from hard coded DFLL clock name.

- Added write attribute to tune_high_mv debugfs entry

Change-Id: I03c4cd5e33d7f27ad73ae3319ee1c318e135a639
Signed-off-by: Alex Frid <afrid@nvidia.com>
Reviewed-on: http://git-master/r/204969
Reviewed-by: Riham Haidar <rhaidar@nvidia.com>
Tested-by: Riham Haidar <rhaidar@nvidia.com>

arch/arm/mach-tegra/tegra11_clocks.c
arch/arm/mach-tegra/tegra_cl_dvfs.c
arch/arm/mach-tegra/tegra_cl_dvfs.h

index c69eacc..dafda19 100644 (file)
@@ -3559,11 +3559,17 @@ static void __init tegra11_dfll_cpu_late_init(struct clk *c)
 
                use_dfll = CONFIG_TEGRA_USE_DFLL_RANGE;
                tegra_dvfs_set_dfll_range(cpu->dvfs, use_dfll);
+               tegra_cl_dvfs_debug_init(c);
                pr_info("Tegra CPU DFLL is initialized\n");
        }
 #endif
 }
 
+static void tegra11_dfll_clk_init(struct clk *c)
+{
+       c->ops->init = tegra11_dfll_cpu_late_init;
+}
+
 static int tegra11_dfll_clk_enable(struct clk *c)
 {
        return tegra_cl_dvfs_enable(c->u.dfll.cl_dvfs);
@@ -3611,6 +3617,7 @@ static void tegra11_dfll_clk_resume(struct clk *c)
 #endif
 
 static struct clk_ops tegra_dfll_ops = {
+       .init                   = tegra11_dfll_clk_init,
        .enable                 = tegra11_dfll_clk_enable,
        .disable                = tegra11_dfll_clk_disable,
        .set_rate               = tegra11_dfll_clk_set_rate,
@@ -7667,9 +7674,6 @@ void __init tegra11x_init_clocks(void)
        /* Initialize to default */
        tegra_init_cpu_edp_limits(0);
 
-       /* To be ready for DFLL late init */
-       tegra_dfll_cpu.ops->init = tegra11_dfll_cpu_late_init;
-
 #ifdef CONFIG_PM_SLEEP
        register_syscore_ops(&tegra_clk_syscore_ops);
 #endif
index 945bf77..99baeb5 100644 (file)
@@ -1589,48 +1589,45 @@ static const struct file_operations cl_register_fops = {
        .release        = single_release,
 };
 
-static int __init tegra_cl_dvfs_debug_init(void)
+int __init tegra_cl_dvfs_debug_init(struct clk *dfll_clk)
 {
-       struct dentry *cpu_cl_dvfs_dentry;
-       struct clk *dfll_cpu = tegra_get_clock_by_name("dfll_cpu");
+       struct dentry *cl_dvfs_dentry;
 
-       if (!dfll_cpu || !dfll_cpu->dent || (dfll_cpu->state == UNINITIALIZED))
+       if (!dfll_clk || !dfll_clk->dent || (dfll_clk->state == UNINITIALIZED))
                return 0;
 
        if (!debugfs_create_file("lock", S_IRUGO | S_IWUSR,
-               dfll_cpu->dent, dfll_cpu, &lock_fops))
+               dfll_clk->dent, dfll_clk, &lock_fops))
                goto err_out;
 
-       cpu_cl_dvfs_dentry = debugfs_create_dir("cl_dvfs", dfll_cpu->dent);
-       if (!cpu_cl_dvfs_dentry)
+       cl_dvfs_dentry = debugfs_create_dir("cl_dvfs", dfll_clk->dent);
+       if (!cl_dvfs_dentry)
                goto err_out;
 
        if (!debugfs_create_file("monitor", S_IRUGO,
-               cpu_cl_dvfs_dentry, dfll_cpu, &monitor_fops))
+               cl_dvfs_dentry, dfll_clk, &monitor_fops))
                goto err_out;
 
        if (!debugfs_create_file("vmin_mv", S_IRUGO,
-               cpu_cl_dvfs_dentry, dfll_cpu, &vmin_fops))
+               cl_dvfs_dentry, dfll_clk, &vmin_fops))
                goto err_out;
 
-       if (!debugfs_create_file("tune_high_mv", S_IRUGO,
-               cpu_cl_dvfs_dentry, dfll_cpu, &tune_high_mv_fops))
+       if (!debugfs_create_file("tune_high_mv", S_IRUGO | S_IWUSR,
+               cl_dvfs_dentry, dfll_clk, &tune_high_mv_fops))
                goto err_out;
 
        if (!debugfs_create_file("dvco_min", S_IRUGO,
-               cpu_cl_dvfs_dentry, dfll_cpu, &dvco_rate_min_fops))
+               cl_dvfs_dentry, dfll_clk, &dvco_rate_min_fops))
                goto err_out;
 
        if (!debugfs_create_file("registers", S_IRUGO | S_IWUSR,
-               cpu_cl_dvfs_dentry, dfll_cpu, &cl_register_fops))
+               cl_dvfs_dentry, dfll_clk, &cl_register_fops))
                goto err_out;
 
        return 0;
 
 err_out:
-       debugfs_remove_recursive(dfll_cpu->dent);
+       debugfs_remove_recursive(dfll_clk->dent);
        return -ENOMEM;
 }
-
-late_initcall(tegra_cl_dvfs_debug_init);
 #endif
index b5cdbd0..105e05e 100644 (file)
@@ -80,6 +80,7 @@ struct tegra_cl_dvfs_platform_data {
 
 #ifdef CONFIG_ARCH_TEGRA_HAS_CL_DVFS
 int tegra_init_cl_dvfs(void);
+int tegra_cl_dvfs_debug_init(struct clk *dfll_clk);
 void tegra_cl_dvfs_resume(struct tegra_cl_dvfs *cld);
 
 void tegra_cl_dvfs_disable(struct tegra_cl_dvfs *cld);
@@ -91,6 +92,8 @@ unsigned long tegra_cl_dvfs_request_get(struct tegra_cl_dvfs *cld);
 #else
 static inline int tegra_init_cl_dvfs(void)
 { return -ENOSYS; }
+static inline int tegra_cl_dvfs_debug_init(struct clk *dfll_clk)
+{ return -ENOSYS; }
 static inline void tegra_cl_dvfs_resume(struct tegra_cl_dvfs *cld)
 {}