diff options
Diffstat (limited to 'drivers/sh/clk/core.c')
| -rw-r--r-- | drivers/sh/clk/core.c | 107 |
1 files changed, 20 insertions, 87 deletions
diff --git a/drivers/sh/clk/core.c b/drivers/sh/clk/core.c index dc8d022c07a1..db257a35e71a 100644 --- a/drivers/sh/clk/core.c +++ b/drivers/sh/clk/core.c | |||
| @@ -25,7 +25,6 @@ | |||
| 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> | ||
| 29 | #include <linux/cpufreq.h> | 28 | #include <linux/cpufreq.h> |
| 30 | #include <linux/clk.h> | 29 | #include <linux/clk.h> |
| 31 | #include <linux/sh_clk.h> | 30 | #include <linux/sh_clk.h> |
| @@ -173,6 +172,26 @@ long clk_rate_div_range_round(struct clk *clk, unsigned int div_min, | |||
| 173 | return clk_rate_round_helper(&div_range_round); | 172 | return clk_rate_round_helper(&div_range_round); |
| 174 | } | 173 | } |
| 175 | 174 | ||
| 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 | |||
| 176 | int clk_rate_table_find(struct clk *clk, | 195 | int clk_rate_table_find(struct clk *clk, |
| 177 | struct cpufreq_frequency_table *freq_table, | 196 | struct cpufreq_frequency_table *freq_table, |
| 178 | unsigned long rate) | 197 | unsigned long rate) |
| @@ -205,9 +224,6 @@ int clk_reparent(struct clk *child, struct clk *parent) | |||
| 205 | list_add(&child->sibling, &parent->children); | 224 | list_add(&child->sibling, &parent->children); |
| 206 | child->parent = parent; | 225 | child->parent = parent; |
| 207 | 226 | ||
| 208 | /* now do the debugfs renaming to reattach the child | ||
| 209 | to the proper parent */ | ||
| 210 | |||
| 211 | return 0; | 227 | return 0; |
| 212 | } | 228 | } |
| 213 | 229 | ||
| @@ -665,89 +681,6 @@ static int __init clk_syscore_init(void) | |||
| 665 | subsys_initcall(clk_syscore_init); | 681 | subsys_initcall(clk_syscore_init); |
| 666 | #endif | 682 | #endif |
| 667 | 683 | ||
| 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 | |||
| 751 | static int __init clk_late_init(void) | 684 | static int __init clk_late_init(void) |
| 752 | { | 685 | { |
| 753 | unsigned long flags; | 686 | unsigned long flags; |
