diff options
Diffstat (limited to 'drivers/sh')
-rw-r--r-- | drivers/sh/Makefile | 8 | ||||
-rw-r--r-- | drivers/sh/clk/core.c | 107 | ||||
-rw-r--r-- | drivers/sh/pm_runtime.c | 65 |
3 files changed, 93 insertions, 87 deletions
diff --git a/drivers/sh/Makefile b/drivers/sh/Makefile index 24e6cec0ae8d..67e272ab1623 100644 --- a/drivers/sh/Makefile +++ b/drivers/sh/Makefile | |||
@@ -7,3 +7,11 @@ obj-$(CONFIG_HAVE_CLK) += clk/ | |||
7 | obj-$(CONFIG_MAPLE) += maple/ | 7 | obj-$(CONFIG_MAPLE) += maple/ |
8 | obj-$(CONFIG_SUPERHYWAY) += superhyway/ | 8 | obj-$(CONFIG_SUPERHYWAY) += superhyway/ |
9 | obj-$(CONFIG_GENERIC_GPIO) += pfc.o | 9 | obj-$(CONFIG_GENERIC_GPIO) += pfc.o |
10 | |||
11 | # | ||
12 | # For the moment we only use this framework for ARM-based SH/R-Mobile | ||
13 | # platforms and generic SH. SH-based SH-Mobile platforms are still using | ||
14 | # an older framework that is pending up-porting, at which point this | ||
15 | # special casing can go away. | ||
16 | # | ||
17 | obj-$(CONFIG_SUPERH)$(CONFIG_ARCH_SHMOBILE) += pm_runtime.o | ||
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; |
diff --git a/drivers/sh/pm_runtime.c b/drivers/sh/pm_runtime.c new file mode 100644 index 000000000000..afe9282629b9 --- /dev/null +++ b/drivers/sh/pm_runtime.c | |||
@@ -0,0 +1,65 @@ | |||
1 | /* | ||
2 | * Runtime PM support code | ||
3 | * | ||
4 | * Copyright (C) 2009-2010 Magnus Damm | ||
5 | * | ||
6 | * This file is subject to the terms and conditions of the GNU General Public | ||
7 | * License. See the file "COPYING" in the main directory of this archive | ||
8 | * for more details. | ||
9 | */ | ||
10 | |||
11 | #include <linux/init.h> | ||
12 | #include <linux/kernel.h> | ||
13 | #include <linux/io.h> | ||
14 | #include <linux/pm_runtime.h> | ||
15 | #include <linux/pm_domain.h> | ||
16 | #include <linux/pm_clock.h> | ||
17 | #include <linux/platform_device.h> | ||
18 | #include <linux/clk.h> | ||
19 | #include <linux/sh_clk.h> | ||
20 | #include <linux/bitmap.h> | ||
21 | #include <linux/slab.h> | ||
22 | |||
23 | #ifdef CONFIG_PM_RUNTIME | ||
24 | |||
25 | static int default_platform_runtime_idle(struct device *dev) | ||
26 | { | ||
27 | /* suspend synchronously to disable clocks immediately */ | ||
28 | return pm_runtime_suspend(dev); | ||
29 | } | ||
30 | |||
31 | static struct dev_pm_domain default_pm_domain = { | ||
32 | .ops = { | ||
33 | .runtime_suspend = pm_clk_suspend, | ||
34 | .runtime_resume = pm_clk_resume, | ||
35 | .runtime_idle = default_platform_runtime_idle, | ||
36 | USE_PLATFORM_PM_SLEEP_OPS | ||
37 | }, | ||
38 | }; | ||
39 | |||
40 | #define DEFAULT_PM_DOMAIN_PTR (&default_pm_domain) | ||
41 | |||
42 | #else | ||
43 | |||
44 | #define DEFAULT_PM_DOMAIN_PTR NULL | ||
45 | |||
46 | #endif /* CONFIG_PM_RUNTIME */ | ||
47 | |||
48 | static struct pm_clk_notifier_block platform_bus_notifier = { | ||
49 | .pm_domain = DEFAULT_PM_DOMAIN_PTR, | ||
50 | .con_ids = { NULL, }, | ||
51 | }; | ||
52 | |||
53 | static int __init sh_pm_runtime_init(void) | ||
54 | { | ||
55 | pm_clk_add_notifier(&platform_bus_type, &platform_bus_notifier); | ||
56 | return 0; | ||
57 | } | ||
58 | core_initcall(sh_pm_runtime_init); | ||
59 | |||
60 | static int __init sh_pm_runtime_late_init(void) | ||
61 | { | ||
62 | pm_genpd_poweroff_unused(); | ||
63 | return 0; | ||
64 | } | ||
65 | late_initcall(sh_pm_runtime_late_init); | ||