aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTero Kristo <t-kristo@ti.com>2015-03-02 12:06:54 -0500
committerTero Kristo <t-kristo@ti.com>2015-06-02 05:31:13 -0400
commitbf22bae794d696e411acfcac39b415e160e93834 (patch)
tree73614c7bd3659b8edaaf841cfb8f2e2c545b5795
parent5100349b95bf238c6c83cb702a64a56a6ee58fc9 (diff)
clk: ti: autoidle: move generic autoidle handling code to clock driver
This is no longer needed in platform directory, as the legacy clock data is gone, so move it under TI clock driver. Some static functions are renamed also. Signed-off-by: Tero Kristo <t-kristo@ti.com>
-rw-r--r--arch/arm/mach-omap2/clock.c104
-rw-r--r--arch/arm/mach-omap2/clock.h3
-rw-r--r--drivers/clk/ti/autoidle.c119
-rw-r--r--drivers/clk/ti/clock.h3
-rw-r--r--drivers/clk/ti/fixed-factor.c2
-rw-r--r--include/linux/clk/ti.h13
6 files changed, 119 insertions, 125 deletions
diff --git a/arch/arm/mach-omap2/clock.c b/arch/arm/mach-omap2/clock.c
index cbc65b3a3b62..42ce860e1d4c 100644
--- a/arch/arm/mach-omap2/clock.c
+++ b/arch/arm/mach-omap2/clock.c
@@ -69,8 +69,6 @@ u16 cpu_mask;
69 */ 69 */
70static bool clkdm_control = true; 70static bool clkdm_control = true;
71 71
72static LIST_HEAD(clk_hw_omap_clocks);
73
74struct clk_iomap { 72struct clk_iomap {
75 struct regmap *regmap; 73 struct regmap *regmap;
76 void __iomem *mem; 74 void __iomem *mem;
@@ -579,108 +577,6 @@ static int __init omap_clk_setup(char *str)
579__setup("mpurate=", omap_clk_setup); 577__setup("mpurate=", omap_clk_setup);
580 578
581/** 579/**
582 * omap2_init_clk_hw_omap_clocks - initialize an OMAP clock
583 * @clk: struct clk * to initialize
584 *
585 * Add an OMAP clock @clk to the internal list of OMAP clocks. Used
586 * temporarily for autoidle handling, until this support can be
587 * integrated into the common clock framework code in some way. No
588 * return value.
589 */
590void omap2_init_clk_hw_omap_clocks(struct clk *clk)
591{
592 struct clk_hw_omap *c;
593
594 if (__clk_get_flags(clk) & CLK_IS_BASIC)
595 return;
596
597 c = to_clk_hw_omap(__clk_get_hw(clk));
598 list_add(&c->node, &clk_hw_omap_clocks);
599}
600
601/**
602 * omap2_clk_enable_autoidle_all - enable autoidle on all OMAP clocks that
603 * support it
604 *
605 * Enable clock autoidle on all OMAP clocks that have allow_idle
606 * function pointers associated with them. This function is intended
607 * to be temporary until support for this is added to the common clock
608 * code. Returns 0.
609 */
610int omap2_clk_enable_autoidle_all(void)
611{
612 struct clk_hw_omap *c;
613
614 list_for_each_entry(c, &clk_hw_omap_clocks, node)
615 if (c->ops && c->ops->allow_idle)
616 c->ops->allow_idle(c);
617
618 of_ti_clk_allow_autoidle_all();
619
620 return 0;
621}
622
623/**
624 * omap2_clk_disable_autoidle_all - disable autoidle on all OMAP clocks that
625 * support it
626 *
627 * Disable clock autoidle on all OMAP clocks that have allow_idle
628 * function pointers associated with them. This function is intended
629 * to be temporary until support for this is added to the common clock
630 * code. Returns 0.
631 */
632int omap2_clk_disable_autoidle_all(void)
633{
634 struct clk_hw_omap *c;
635
636 list_for_each_entry(c, &clk_hw_omap_clocks, node)
637 if (c->ops && c->ops->deny_idle)
638 c->ops->deny_idle(c);
639
640 of_ti_clk_deny_autoidle_all();
641
642 return 0;
643}
644
645/**
646 * omap2_clk_deny_idle - disable autoidle on an OMAP clock
647 * @clk: struct clk * to disable autoidle for
648 *
649 * Disable autoidle on an OMAP clock.
650 */
651int omap2_clk_deny_idle(struct clk *clk)
652{
653 struct clk_hw_omap *c;
654
655 if (__clk_get_flags(clk) & CLK_IS_BASIC)
656 return -EINVAL;
657
658 c = to_clk_hw_omap(__clk_get_hw(clk));
659 if (c->ops && c->ops->deny_idle)
660 c->ops->deny_idle(c);
661 return 0;
662}
663
664/**
665 * omap2_clk_allow_idle - enable autoidle on an OMAP clock
666 * @clk: struct clk * to enable autoidle for
667 *
668 * Enable autoidle on an OMAP clock.
669 */
670int omap2_clk_allow_idle(struct clk *clk)
671{
672 struct clk_hw_omap *c;
673
674 if (__clk_get_flags(clk) & CLK_IS_BASIC)
675 return -EINVAL;
676
677 c = to_clk_hw_omap(__clk_get_hw(clk));
678 if (c->ops && c->ops->allow_idle)
679 c->ops->allow_idle(c);
680 return 0;
681}
682
683/**
684 * omap2_clk_enable_init_clocks - prepare & enable a list of clocks 580 * omap2_clk_enable_init_clocks - prepare & enable a list of clocks
685 * @clk_names: ptr to an array of strings of clock names to enable 581 * @clk_names: ptr to an array of strings of clock names to enable
686 * @num_clocks: number of clock names in @clk_names 582 * @num_clocks: number of clock names in @clk_names
diff --git a/arch/arm/mach-omap2/clock.h b/arch/arm/mach-omap2/clock.h
index b71d43051c26..950a17ae4f36 100644
--- a/arch/arm/mach-omap2/clock.h
+++ b/arch/arm/mach-omap2/clock.h
@@ -186,9 +186,6 @@ void omap3_dpll_deny_idle(struct clk_hw_omap *clk);
186 186
187void __init omap2_clk_disable_clkdm_control(void); 187void __init omap2_clk_disable_clkdm_control(void);
188 188
189int omap2_clk_enable_autoidle_all(void);
190int omap2_clk_allow_idle(struct clk *clk);
191int omap2_clk_deny_idle(struct clk *clk);
192int omap2_clk_switch_mpurate_at_boot(const char *mpurate_ck_name); 189int omap2_clk_switch_mpurate_at_boot(const char *mpurate_ck_name);
193void omap2_clk_print_new_rates(const char *hfclkin_ck_name, 190void omap2_clk_print_new_rates(const char *hfclkin_ck_name,
194 const char *core_ck_name, 191 const char *core_ck_name,
diff --git a/drivers/clk/ti/autoidle.c b/drivers/clk/ti/autoidle.c
index e75c64c9e81c..3dbcc3681058 100644
--- a/drivers/clk/ti/autoidle.c
+++ b/drivers/clk/ti/autoidle.c
@@ -33,8 +33,47 @@ struct clk_ti_autoidle {
33#define AUTOIDLE_LOW 0x1 33#define AUTOIDLE_LOW 0x1
34 34
35static LIST_HEAD(autoidle_clks); 35static LIST_HEAD(autoidle_clks);
36static LIST_HEAD(clk_hw_omap_clocks);
36 37
37static void ti_allow_autoidle(struct clk_ti_autoidle *clk) 38/**
39 * omap2_clk_deny_idle - disable autoidle on an OMAP clock
40 * @clk: struct clk * to disable autoidle for
41 *
42 * Disable autoidle on an OMAP clock.
43 */
44int omap2_clk_deny_idle(struct clk *clk)
45{
46 struct clk_hw_omap *c;
47
48 if (__clk_get_flags(clk) & CLK_IS_BASIC)
49 return -EINVAL;
50
51 c = to_clk_hw_omap(__clk_get_hw(clk));
52 if (c->ops && c->ops->deny_idle)
53 c->ops->deny_idle(c);
54 return 0;
55}
56
57/**
58 * omap2_clk_allow_idle - enable autoidle on an OMAP clock
59 * @clk: struct clk * to enable autoidle for
60 *
61 * Enable autoidle on an OMAP clock.
62 */
63int omap2_clk_allow_idle(struct clk *clk)
64{
65 struct clk_hw_omap *c;
66
67 if (__clk_get_flags(clk) & CLK_IS_BASIC)
68 return -EINVAL;
69
70 c = to_clk_hw_omap(__clk_get_hw(clk));
71 if (c->ops && c->ops->allow_idle)
72 c->ops->allow_idle(c);
73 return 0;
74}
75
76static void _allow_autoidle(struct clk_ti_autoidle *clk)
38{ 77{
39 u32 val; 78 u32 val;
40 79
@@ -48,7 +87,7 @@ static void ti_allow_autoidle(struct clk_ti_autoidle *clk)
48 ti_clk_ll_ops->clk_writel(val, clk->reg); 87 ti_clk_ll_ops->clk_writel(val, clk->reg);
49} 88}
50 89
51static void ti_deny_autoidle(struct clk_ti_autoidle *clk) 90static void _deny_autoidle(struct clk_ti_autoidle *clk)
52{ 91{
53 u32 val; 92 u32 val;
54 93
@@ -63,31 +102,31 @@ static void ti_deny_autoidle(struct clk_ti_autoidle *clk)
63} 102}
64 103
65/** 104/**
66 * of_ti_clk_allow_autoidle_all - enable autoidle for all clocks 105 * _clk_generic_allow_autoidle_all - enable autoidle for all clocks
67 * 106 *
68 * Enables hardware autoidle for all registered DT clocks, which have 107 * Enables hardware autoidle for all registered DT clocks, which have
69 * the feature. 108 * the feature.
70 */ 109 */
71void of_ti_clk_allow_autoidle_all(void) 110static void _clk_generic_allow_autoidle_all(void)
72{ 111{
73 struct clk_ti_autoidle *c; 112 struct clk_ti_autoidle *c;
74 113
75 list_for_each_entry(c, &autoidle_clks, node) 114 list_for_each_entry(c, &autoidle_clks, node)
76 ti_allow_autoidle(c); 115 _allow_autoidle(c);
77} 116}
78 117
79/** 118/**
80 * of_ti_clk_deny_autoidle_all - disable autoidle for all clocks 119 * _clk_generic_deny_autoidle_all - disable autoidle for all clocks
81 * 120 *
82 * Disables hardware autoidle for all registered DT clocks, which have 121 * Disables hardware autoidle for all registered DT clocks, which have
83 * the feature. 122 * the feature.
84 */ 123 */
85void of_ti_clk_deny_autoidle_all(void) 124static void _clk_generic_deny_autoidle_all(void)
86{ 125{
87 struct clk_ti_autoidle *c; 126 struct clk_ti_autoidle *c;
88 127
89 list_for_each_entry(c, &autoidle_clks, node) 128 list_for_each_entry(c, &autoidle_clks, node)
90 ti_deny_autoidle(c); 129 _deny_autoidle(c);
91} 130}
92 131
93/** 132/**
@@ -131,3 +170,67 @@ int __init of_ti_clk_autoidle_setup(struct device_node *node)
131 170
132 return 0; 171 return 0;
133} 172}
173
174/**
175 * omap2_init_clk_hw_omap_clocks - initialize an OMAP clock
176 * @clk: struct clk * to initialize
177 *
178 * Add an OMAP clock @clk to the internal list of OMAP clocks. Used
179 * temporarily for autoidle handling, until this support can be
180 * integrated into the common clock framework code in some way. No
181 * return value.
182 */
183void omap2_init_clk_hw_omap_clocks(struct clk *clk)
184{
185 struct clk_hw_omap *c;
186
187 if (__clk_get_flags(clk) & CLK_IS_BASIC)
188 return;
189
190 c = to_clk_hw_omap(__clk_get_hw(clk));
191 list_add(&c->node, &clk_hw_omap_clocks);
192}
193
194/**
195 * omap2_clk_enable_autoidle_all - enable autoidle on all OMAP clocks that
196 * support it
197 *
198 * Enable clock autoidle on all OMAP clocks that have allow_idle
199 * function pointers associated with them. This function is intended
200 * to be temporary until support for this is added to the common clock
201 * code. Returns 0.
202 */
203int omap2_clk_enable_autoidle_all(void)
204{
205 struct clk_hw_omap *c;
206
207 list_for_each_entry(c, &clk_hw_omap_clocks, node)
208 if (c->ops && c->ops->allow_idle)
209 c->ops->allow_idle(c);
210
211 _clk_generic_allow_autoidle_all();
212
213 return 0;
214}
215
216/**
217 * omap2_clk_disable_autoidle_all - disable autoidle on all OMAP clocks that
218 * support it
219 *
220 * Disable clock autoidle on all OMAP clocks that have allow_idle
221 * function pointers associated with them. This function is intended
222 * to be temporary until support for this is added to the common clock
223 * code. Returns 0.
224 */
225int omap2_clk_disable_autoidle_all(void)
226{
227 struct clk_hw_omap *c;
228
229 list_for_each_entry(c, &clk_hw_omap_clocks, node)
230 if (c->ops && c->ops->deny_idle)
231 c->ops->deny_idle(c);
232
233 _clk_generic_deny_autoidle_all();
234
235 return 0;
236}
diff --git a/drivers/clk/ti/clock.h b/drivers/clk/ti/clock.h
index a7256a98201d..9b51021f509a 100644
--- a/drivers/clk/ti/clock.h
+++ b/drivers/clk/ti/clock.h
@@ -169,6 +169,9 @@ void ti_clk_patch_legacy_clks(struct ti_clk **patch);
169struct clk *ti_clk_register_clk(struct ti_clk *setup); 169struct clk *ti_clk_register_clk(struct ti_clk *setup);
170int ti_clk_register_legacy_clks(struct ti_clk_alias *clks); 170int ti_clk_register_legacy_clks(struct ti_clk_alias *clks);
171 171
172void omap2_init_clk_hw_omap_clocks(struct clk *clk);
173int of_ti_clk_autoidle_setup(struct device_node *node);
174
172extern const struct clk_hw_omap_ops clkhwops_omap4_dpllmx; 175extern const struct clk_hw_omap_ops clkhwops_omap4_dpllmx;
173extern const struct clk_hw_omap_ops clkhwops_iclk; 176extern const struct clk_hw_omap_ops clkhwops_iclk;
174extern const struct clk_hw_omap_ops clkhwops_iclk_wait; 177extern const struct clk_hw_omap_ops clkhwops_iclk_wait;
diff --git a/drivers/clk/ti/fixed-factor.c b/drivers/clk/ti/fixed-factor.c
index c2c8a287408c..3cd406768909 100644
--- a/drivers/clk/ti/fixed-factor.c
+++ b/drivers/clk/ti/fixed-factor.c
@@ -22,6 +22,8 @@
22#include <linux/of_address.h> 22#include <linux/of_address.h>
23#include <linux/clk/ti.h> 23#include <linux/clk/ti.h>
24 24
25#include "clock.h"
26
25#undef pr_fmt 27#undef pr_fmt
26#define pr_fmt(fmt) "%s: " fmt, __func__ 28#define pr_fmt(fmt) "%s: " fmt, __func__
27 29
diff --git a/include/linux/clk/ti.h b/include/linux/clk/ti.h
index 79e143dfc793..320e107f9a7a 100644
--- a/include/linux/clk/ti.h
+++ b/include/linux/clk/ti.h
@@ -259,7 +259,6 @@ extern const struct clk_ops ti_clk_mux_ops;
259 259
260#define to_clk_hw_omap(_hw) container_of(_hw, struct clk_hw_omap, hw) 260#define to_clk_hw_omap(_hw) container_of(_hw, struct clk_hw_omap, hw)
261 261
262void omap2_init_clk_hw_omap_clocks(struct clk *clk);
263int omap3_noncore_dpll_enable(struct clk_hw *hw); 262int omap3_noncore_dpll_enable(struct clk_hw *hw);
264void omap3_noncore_dpll_disable(struct clk_hw *hw); 263void omap3_noncore_dpll_disable(struct clk_hw *hw);
265int omap3_noncore_dpll_set_parent(struct clk_hw *hw, u8 index); 264int omap3_noncore_dpll_set_parent(struct clk_hw *hw, u8 index);
@@ -288,6 +287,9 @@ long omap3_clkoutx2_round_rate(struct clk_hw *hw, unsigned long rate,
288int omap2_clkops_enable_clkdm(struct clk_hw *hw); 287int omap2_clkops_enable_clkdm(struct clk_hw *hw);
289void omap2_clkops_disable_clkdm(struct clk_hw *hw); 288void omap2_clkops_disable_clkdm(struct clk_hw *hw);
290int omap2_clk_disable_autoidle_all(void); 289int omap2_clk_disable_autoidle_all(void);
290int omap2_clk_enable_autoidle_all(void);
291int omap2_clk_allow_idle(struct clk *clk);
292int omap2_clk_deny_idle(struct clk *clk);
291void omap2_clk_enable_init_clocks(const char **clk_names, u8 num_clocks); 293void omap2_clk_enable_init_clocks(const char **clk_names, u8 num_clocks);
292int omap3_dpll4_set_rate(struct clk_hw *clk, unsigned long rate, 294int omap3_dpll4_set_rate(struct clk_hw *clk, unsigned long rate,
293 unsigned long parent_rate); 295 unsigned long parent_rate);
@@ -320,7 +322,6 @@ void ti_dt_clk_init_retry_clks(void);
320void ti_dt_clockdomains_setup(void); 322void ti_dt_clockdomains_setup(void);
321int ti_clk_retry_init(struct device_node *node, struct clk_hw *hw, 323int ti_clk_retry_init(struct device_node *node, struct clk_hw *hw,
322 ti_of_clk_init_cb_t func); 324 ti_of_clk_init_cb_t func);
323int of_ti_clk_autoidle_setup(struct device_node *node);
324int ti_clk_add_component(struct device_node *node, struct clk_hw *hw, int type); 325int ti_clk_add_component(struct device_node *node, struct clk_hw *hw, int type);
325 326
326int omap3430_dt_clk_init(void); 327int omap3430_dt_clk_init(void);
@@ -351,14 +352,6 @@ struct ti_clk_features {
351void ti_clk_setup_features(struct ti_clk_features *features); 352void ti_clk_setup_features(struct ti_clk_features *features);
352const struct ti_clk_features *ti_clk_get_features(void); 353const struct ti_clk_features *ti_clk_get_features(void);
353 354
354#ifdef CONFIG_OF
355void of_ti_clk_allow_autoidle_all(void);
356void of_ti_clk_deny_autoidle_all(void);
357#else
358static inline void of_ti_clk_allow_autoidle_all(void) { }
359static inline void of_ti_clk_deny_autoidle_all(void) { }
360#endif
361
362extern const struct clk_hw_omap_ops clkhwops_omap2xxx_dpll; 355extern const struct clk_hw_omap_ops clkhwops_omap2xxx_dpll;
363extern const struct clk_hw_omap_ops clkhwops_omap2430_i2chs_wait; 356extern const struct clk_hw_omap_ops clkhwops_omap2430_i2chs_wait;
364extern const struct clk_hw_omap_ops clkhwops_omap3_dpll; 357extern const struct clk_hw_omap_ops clkhwops_omap3_dpll;