diff options
author | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-01-17 16:15:55 -0500 |
---|---|---|
committer | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-01-17 16:15:55 -0500 |
commit | 8dea78da5cee153b8af9c07a2745f6c55057fe12 (patch) | |
tree | a8f4d49d63b1ecc92f2fddceba0655b2472c5bd9 /drivers/sh/clk/core.c | |
parent | 406089d01562f1e2bf9f089fd7637009ebaad589 (diff) |
Patched in Tegra support.
Diffstat (limited to 'drivers/sh/clk/core.c')
-rw-r--r-- | drivers/sh/clk/core.c | 116 |
1 files changed, 89 insertions, 27 deletions
diff --git a/drivers/sh/clk/core.c b/drivers/sh/clk/core.c index 7715de2629c..dc8d022c07a 100644 --- a/drivers/sh/clk/core.c +++ b/drivers/sh/clk/core.c | |||
@@ -25,6 +25,7 @@ | |||
25 | #include <linux/seq_file.h> | 25 | #include <linux/seq_file.h> |
26 | #include <linux/err.h> | 26 | #include <linux/err.h> |
27 | #include <linux/io.h> | 27 | #include <linux/io.h> |
28 | #include <linux/debugfs.h> | ||
28 | #include <linux/cpufreq.h> | 29 | #include <linux/cpufreq.h> |
29 | #include <linux/clk.h> | 30 | #include <linux/clk.h> |
30 | #include <linux/sh_clk.h> | 31 | #include <linux/sh_clk.h> |
@@ -172,26 +173,6 @@ long clk_rate_div_range_round(struct clk *clk, unsigned int div_min, | |||
172 | return clk_rate_round_helper(&div_range_round); | 173 | return clk_rate_round_helper(&div_range_round); |
173 | } | 174 | } |
174 | 175 | ||
175 | static long clk_rate_mult_range_iter(unsigned int pos, | ||
176 | struct clk_rate_round_data *rounder) | ||
177 | { | ||
178 | return clk_get_rate(rounder->arg) * pos; | ||
179 | } | ||
180 | |||
181 | long clk_rate_mult_range_round(struct clk *clk, unsigned int mult_min, | ||
182 | unsigned int mult_max, unsigned long rate) | ||
183 | { | ||
184 | struct clk_rate_round_data mult_range_round = { | ||
185 | .min = mult_min, | ||
186 | .max = mult_max, | ||
187 | .func = clk_rate_mult_range_iter, | ||
188 | .arg = clk_get_parent(clk), | ||
189 | .rate = rate, | ||
190 | }; | ||
191 | |||
192 | return clk_rate_round_helper(&mult_range_round); | ||
193 | } | ||
194 | |||
195 | int clk_rate_table_find(struct clk *clk, | 176 | int clk_rate_table_find(struct clk *clk, |
196 | struct cpufreq_frequency_table *freq_table, | 177 | struct cpufreq_frequency_table *freq_table, |
197 | unsigned long rate) | 178 | unsigned long rate) |
@@ -224,6 +205,9 @@ int clk_reparent(struct clk *child, struct clk *parent) | |||
224 | list_add(&child->sibling, &parent->children); | 205 | list_add(&child->sibling, &parent->children); |
225 | child->parent = parent; | 206 | child->parent = parent; |
226 | 207 | ||
208 | /* now do the debugfs renaming to reattach the child | ||
209 | to the proper parent */ | ||
210 | |||
227 | return 0; | 211 | return 0; |
228 | } | 212 | } |
229 | 213 | ||
@@ -355,7 +339,7 @@ static int clk_establish_mapping(struct clk *clk) | |||
355 | */ | 339 | */ |
356 | if (!clk->parent) { | 340 | if (!clk->parent) { |
357 | clk->mapping = &dummy_mapping; | 341 | clk->mapping = &dummy_mapping; |
358 | goto out; | 342 | return 0; |
359 | } | 343 | } |
360 | 344 | ||
361 | /* | 345 | /* |
@@ -384,9 +368,6 @@ static int clk_establish_mapping(struct clk *clk) | |||
384 | } | 368 | } |
385 | 369 | ||
386 | clk->mapping = mapping; | 370 | clk->mapping = mapping; |
387 | out: | ||
388 | clk->mapped_reg = clk->mapping->base; | ||
389 | clk->mapped_reg += (phys_addr_t)clk->enable_reg - clk->mapping->phys; | ||
390 | return 0; | 371 | return 0; |
391 | } | 372 | } |
392 | 373 | ||
@@ -405,12 +386,10 @@ static void clk_teardown_mapping(struct clk *clk) | |||
405 | 386 | ||
406 | /* Nothing to do */ | 387 | /* Nothing to do */ |
407 | if (mapping == &dummy_mapping) | 388 | if (mapping == &dummy_mapping) |
408 | goto out; | 389 | return; |
409 | 390 | ||
410 | kref_put(&mapping->ref, clk_destroy_mapping); | 391 | kref_put(&mapping->ref, clk_destroy_mapping); |
411 | clk->mapping = NULL; | 392 | clk->mapping = NULL; |
412 | out: | ||
413 | clk->mapped_reg = NULL; | ||
414 | } | 393 | } |
415 | 394 | ||
416 | int clk_register(struct clk *clk) | 395 | int clk_register(struct clk *clk) |
@@ -686,6 +665,89 @@ static int __init clk_syscore_init(void) | |||
686 | subsys_initcall(clk_syscore_init); | 665 | subsys_initcall(clk_syscore_init); |
687 | #endif | 666 | #endif |
688 | 667 | ||
668 | /* | ||
669 | * debugfs support to trace clock tree hierarchy and attributes | ||
670 | */ | ||
671 | static struct dentry *clk_debugfs_root; | ||
672 | |||
673 | static int clk_debugfs_register_one(struct clk *c) | ||
674 | { | ||
675 | int err; | ||
676 | struct dentry *d; | ||
677 | struct clk *pa = c->parent; | ||
678 | char s[255]; | ||
679 | char *p = s; | ||
680 | |||
681 | p += sprintf(p, "%p", c); | ||
682 | d = debugfs_create_dir(s, pa ? pa->dentry : clk_debugfs_root); | ||
683 | if (!d) | ||
684 | return -ENOMEM; | ||
685 | c->dentry = d; | ||
686 | |||
687 | d = debugfs_create_u8("usecount", S_IRUGO, c->dentry, (u8 *)&c->usecount); | ||
688 | if (!d) { | ||
689 | err = -ENOMEM; | ||
690 | goto err_out; | ||
691 | } | ||
692 | d = debugfs_create_u32("rate", S_IRUGO, c->dentry, (u32 *)&c->rate); | ||
693 | if (!d) { | ||
694 | err = -ENOMEM; | ||
695 | goto err_out; | ||
696 | } | ||
697 | d = debugfs_create_x32("flags", S_IRUGO, c->dentry, (u32 *)&c->flags); | ||
698 | if (!d) { | ||
699 | err = -ENOMEM; | ||
700 | goto err_out; | ||
701 | } | ||
702 | return 0; | ||
703 | |||
704 | err_out: | ||
705 | debugfs_remove_recursive(c->dentry); | ||
706 | return err; | ||
707 | } | ||
708 | |||
709 | static int clk_debugfs_register(struct clk *c) | ||
710 | { | ||
711 | int err; | ||
712 | struct clk *pa = c->parent; | ||
713 | |||
714 | if (pa && !pa->dentry) { | ||
715 | err = clk_debugfs_register(pa); | ||
716 | if (err) | ||
717 | return err; | ||
718 | } | ||
719 | |||
720 | if (!c->dentry) { | ||
721 | err = clk_debugfs_register_one(c); | ||
722 | if (err) | ||
723 | return err; | ||
724 | } | ||
725 | return 0; | ||
726 | } | ||
727 | |||
728 | static int __init clk_debugfs_init(void) | ||
729 | { | ||
730 | struct clk *c; | ||
731 | struct dentry *d; | ||
732 | int err; | ||
733 | |||
734 | d = debugfs_create_dir("clock", NULL); | ||
735 | if (!d) | ||
736 | return -ENOMEM; | ||
737 | clk_debugfs_root = d; | ||
738 | |||
739 | list_for_each_entry(c, &clock_list, node) { | ||
740 | err = clk_debugfs_register(c); | ||
741 | if (err) | ||
742 | goto err_out; | ||
743 | } | ||
744 | return 0; | ||
745 | err_out: | ||
746 | debugfs_remove_recursive(clk_debugfs_root); | ||
747 | return err; | ||
748 | } | ||
749 | late_initcall(clk_debugfs_init); | ||
750 | |||
689 | static int __init clk_late_init(void) | 751 | static int __init clk_late_init(void) |
690 | { | 752 | { |
691 | unsigned long flags; | 753 | unsigned long flags; |