diff options
Diffstat (limited to 'drivers/clk/ti/composite.c')
-rw-r--r-- | drivers/clk/ti/composite.c | 48 |
1 files changed, 44 insertions, 4 deletions
diff --git a/drivers/clk/ti/composite.c b/drivers/clk/ti/composite.c index 19d8980ba458..3654f61912eb 100644 --- a/drivers/clk/ti/composite.c +++ b/drivers/clk/ti/composite.c | |||
@@ -23,6 +23,8 @@ | |||
23 | #include <linux/clk/ti.h> | 23 | #include <linux/clk/ti.h> |
24 | #include <linux/list.h> | 24 | #include <linux/list.h> |
25 | 25 | ||
26 | #include "clock.h" | ||
27 | |||
26 | #undef pr_fmt | 28 | #undef pr_fmt |
27 | #define pr_fmt(fmt) "%s: " fmt, __func__ | 29 | #define pr_fmt(fmt) "%s: " fmt, __func__ |
28 | 30 | ||
@@ -116,8 +118,46 @@ static inline struct clk_hw *_get_hw(struct clk_hw_omap_comp *clk, int idx) | |||
116 | 118 | ||
117 | #define to_clk_hw_comp(_hw) container_of(_hw, struct clk_hw_omap_comp, hw) | 119 | #define to_clk_hw_comp(_hw) container_of(_hw, struct clk_hw_omap_comp, hw) |
118 | 120 | ||
119 | static void __init ti_clk_register_composite(struct clk_hw *hw, | 121 | #if defined(CONFIG_ARCH_OMAP3) && defined(CONFIG_ATAGS) |
120 | struct device_node *node) | 122 | struct clk *ti_clk_register_composite(struct ti_clk *setup) |
123 | { | ||
124 | struct ti_clk_composite *comp; | ||
125 | struct clk_hw *gate; | ||
126 | struct clk_hw *mux; | ||
127 | struct clk_hw *div; | ||
128 | int num_parents = 1; | ||
129 | const char **parent_names = NULL; | ||
130 | struct clk *clk; | ||
131 | |||
132 | comp = setup->data; | ||
133 | |||
134 | div = ti_clk_build_component_div(comp->divider); | ||
135 | gate = ti_clk_build_component_gate(comp->gate); | ||
136 | mux = ti_clk_build_component_mux(comp->mux); | ||
137 | |||
138 | if (div) | ||
139 | parent_names = &comp->divider->parent; | ||
140 | |||
141 | if (gate) | ||
142 | parent_names = &comp->gate->parent; | ||
143 | |||
144 | if (mux) { | ||
145 | num_parents = comp->mux->num_parents; | ||
146 | parent_names = comp->mux->parents; | ||
147 | } | ||
148 | |||
149 | clk = clk_register_composite(NULL, setup->name, | ||
150 | parent_names, num_parents, mux, | ||
151 | &ti_clk_mux_ops, div, | ||
152 | &ti_composite_divider_ops, gate, | ||
153 | &ti_composite_gate_ops, 0); | ||
154 | |||
155 | return clk; | ||
156 | } | ||
157 | #endif | ||
158 | |||
159 | static void __init _register_composite(struct clk_hw *hw, | ||
160 | struct device_node *node) | ||
121 | { | 161 | { |
122 | struct clk *clk; | 162 | struct clk *clk; |
123 | struct clk_hw_omap_comp *cclk = to_clk_hw_comp(hw); | 163 | struct clk_hw_omap_comp *cclk = to_clk_hw_comp(hw); |
@@ -136,7 +176,7 @@ static void __init ti_clk_register_composite(struct clk_hw *hw, | |||
136 | pr_debug("component %s not ready for %s, retry\n", | 176 | pr_debug("component %s not ready for %s, retry\n", |
137 | cclk->comp_nodes[i]->name, node->name); | 177 | cclk->comp_nodes[i]->name, node->name); |
138 | if (!ti_clk_retry_init(node, hw, | 178 | if (!ti_clk_retry_init(node, hw, |
139 | ti_clk_register_composite)) | 179 | _register_composite)) |
140 | return; | 180 | return; |
141 | 181 | ||
142 | goto cleanup; | 182 | goto cleanup; |
@@ -216,7 +256,7 @@ static void __init of_ti_composite_clk_setup(struct device_node *node) | |||
216 | for (i = 0; i < num_clks; i++) | 256 | for (i = 0; i < num_clks; i++) |
217 | cclk->comp_nodes[i] = _get_component_node(node, i); | 257 | cclk->comp_nodes[i] = _get_component_node(node, i); |
218 | 258 | ||
219 | ti_clk_register_composite(&cclk->hw, node); | 259 | _register_composite(&cclk->hw, node); |
220 | } | 260 | } |
221 | CLK_OF_DECLARE(ti_composite_clock, "ti,composite-clock", | 261 | CLK_OF_DECLARE(ti_composite_clock, "ti,composite-clock", |
222 | of_ti_composite_clk_setup); | 262 | of_ti_composite_clk_setup); |