This source file includes following definitions.
- omap2_clkops_enable_clkdm
- omap2_clkops_disable_clkdm
- omap2_init_clk_clkdm
- of_ti_clockdomain_setup
- ti_dt_clockdomains_setup
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 #include <linux/clk.h>
19 #include <linux/clk-provider.h>
20 #include <linux/slab.h>
21 #include <linux/of.h>
22 #include <linux/of_address.h>
23 #include <linux/clk/ti.h>
24
25 #include "clock.h"
26
27 #undef pr_fmt
28 #define pr_fmt(fmt) "%s: " fmt, __func__
29
30
31
32
33
34
35
36
37
38
39
40
41
42 int omap2_clkops_enable_clkdm(struct clk_hw *hw)
43 {
44 struct clk_hw_omap *clk;
45 int ret = 0;
46
47 clk = to_clk_hw_omap(hw);
48
49 if (unlikely(!clk->clkdm)) {
50 pr_err("%s: %s: no clkdm set ?!\n", __func__,
51 clk_hw_get_name(hw));
52 return -EINVAL;
53 }
54
55 if (ti_clk_get_features()->flags & TI_CLK_DISABLE_CLKDM_CONTROL) {
56 pr_err("%s: %s: clkfw-based clockdomain control disabled ?!\n",
57 __func__, clk_hw_get_name(hw));
58 return 0;
59 }
60
61 ret = ti_clk_ll_ops->clkdm_clk_enable(clk->clkdm, hw->clk);
62 WARN(ret, "%s: could not enable %s's clockdomain %s: %d\n",
63 __func__, clk_hw_get_name(hw), clk->clkdm_name, ret);
64
65 return ret;
66 }
67
68
69
70
71
72
73
74
75
76
77 void omap2_clkops_disable_clkdm(struct clk_hw *hw)
78 {
79 struct clk_hw_omap *clk;
80
81 clk = to_clk_hw_omap(hw);
82
83 if (unlikely(!clk->clkdm)) {
84 pr_err("%s: %s: no clkdm set ?!\n", __func__,
85 clk_hw_get_name(hw));
86 return;
87 }
88
89 if (ti_clk_get_features()->flags & TI_CLK_DISABLE_CLKDM_CONTROL) {
90 pr_err("%s: %s: clkfw-based clockdomain control disabled ?!\n",
91 __func__, clk_hw_get_name(hw));
92 return;
93 }
94
95 ti_clk_ll_ops->clkdm_clk_disable(clk->clkdm, hw->clk);
96 }
97
98
99
100
101
102
103
104
105
106 void omap2_init_clk_clkdm(struct clk_hw *hw)
107 {
108 struct clk_hw_omap *clk = to_clk_hw_omap(hw);
109 struct clockdomain *clkdm;
110 const char *clk_name;
111
112 if (!clk->clkdm_name)
113 return;
114
115 clk_name = __clk_get_name(hw->clk);
116
117 clkdm = ti_clk_ll_ops->clkdm_lookup(clk->clkdm_name);
118 if (clkdm) {
119 pr_debug("clock: associated clk %s to clkdm %s\n",
120 clk_name, clk->clkdm_name);
121 clk->clkdm = clkdm;
122 } else {
123 pr_debug("clock: could not associate clk %s to clkdm %s\n",
124 clk_name, clk->clkdm_name);
125 }
126 }
127
128 static void __init of_ti_clockdomain_setup(struct device_node *node)
129 {
130 struct clk *clk;
131 struct clk_hw *clk_hw;
132 const char *clkdm_name = node->name;
133 int i;
134 unsigned int num_clks;
135
136 num_clks = of_clk_get_parent_count(node);
137
138 for (i = 0; i < num_clks; i++) {
139 clk = of_clk_get(node, i);
140 if (IS_ERR(clk)) {
141 pr_err("%s: Failed get %pOF' clock nr %d (%ld)\n",
142 __func__, node, i, PTR_ERR(clk));
143 continue;
144 }
145 clk_hw = __clk_get_hw(clk);
146 if (!omap2_clk_is_hw_omap(clk_hw)) {
147 pr_warn("can't setup clkdm for basic clk %s\n",
148 __clk_get_name(clk));
149 continue;
150 }
151 to_clk_hw_omap(clk_hw)->clkdm_name = clkdm_name;
152 omap2_init_clk_clkdm(clk_hw);
153 }
154 }
155
156 static const struct of_device_id ti_clkdm_match_table[] __initconst = {
157 { .compatible = "ti,clockdomain" },
158 { }
159 };
160
161
162
163
164
165
166
167
168
169
170 void __init ti_dt_clockdomains_setup(void)
171 {
172 struct device_node *np;
173 for_each_matching_node(np, ti_clkdm_match_table) {
174 of_ti_clockdomain_setup(np);
175 }
176 }