1
2
3
4
5
6
7
8
9
10
11
12
13
14 #ifndef _CLK_IPROC_H
15 #define _CLK_IPROC_H
16
17 #include <linux/kernel.h>
18 #include <linux/list.h>
19 #include <linux/spinlock.h>
20 #include <linux/slab.h>
21 #include <linux/device.h>
22 #include <linux/of.h>
23 #include <linux/clk-provider.h>
24
25 #define IPROC_CLK_NAME_LEN 25
26 #define IPROC_CLK_INVALID_OFFSET 0xffffffff
27 #define bit_mask(width) ((1 << (width)) - 1)
28
29
30 #define IPROC_CLK_AON BIT(0)
31
32
33 #define IPROC_CLK_PLL_ASIU BIT(1)
34
35
36 #define IPROC_CLK_PLL_HAS_NDIV_FRAC BIT(2)
37
38
39
40
41
42
43 #define IPROC_CLK_NEEDS_READ_BACK BIT(3)
44
45
46
47
48
49 #define IPROC_CLK_PLL_NEEDS_SW_CFG BIT(4)
50
51
52
53
54
55 #define IPROC_CLK_EMBED_PWRCTRL BIT(5)
56
57
58
59
60
61 #define IPROC_CLK_PLL_SPLIT_STAT_CTRL BIT(6)
62
63
64
65
66
67
68 #define IPROC_CLK_MCLK_DIV_BY_2 BIT(7)
69
70
71
72
73
74
75
76 #define IPROC_CLK_PLL_USER_MODE_ON BIT(8)
77
78
79
80
81 #define IPROC_CLK_PLL_RESET_ACTIVE_LOW BIT(9)
82
83
84
85
86 #define IPROC_CLK_PLL_CALC_PARAM BIT(10)
87
88
89
90
91
92
93
94 struct iproc_pll_vco_param {
95 unsigned long rate;
96 unsigned int ndiv_int;
97 unsigned int ndiv_frac;
98 unsigned int pdiv;
99 };
100
101 struct iproc_clk_reg_op {
102 unsigned int offset;
103 unsigned int shift;
104 unsigned int width;
105 };
106
107
108
109
110 struct iproc_asiu_gate {
111 unsigned int offset;
112 unsigned int en_shift;
113 };
114
115
116
117
118
119
120 struct iproc_pll_aon_pwr_ctrl {
121 unsigned int offset;
122 unsigned int pwr_width;
123 unsigned int pwr_shift;
124 unsigned int iso_shift;
125 };
126
127
128
129
130 struct iproc_pll_reset_ctrl {
131 unsigned int offset;
132 unsigned int reset_shift;
133 unsigned int p_reset_shift;
134 };
135
136
137
138
139 struct iproc_pll_dig_filter_ctrl {
140 unsigned int offset;
141 unsigned int ki_shift;
142 unsigned int ki_width;
143 unsigned int kp_shift;
144 unsigned int kp_width;
145 unsigned int ka_shift;
146 unsigned int ka_width;
147 };
148
149
150
151
152 struct iproc_pll_sw_ctrl {
153 unsigned int offset;
154 unsigned int shift;
155 };
156
157 struct iproc_pll_vco_ctrl {
158 unsigned int u_offset;
159 unsigned int l_offset;
160 };
161
162
163
164
165 struct iproc_pll_ctrl {
166 unsigned long flags;
167 struct iproc_pll_aon_pwr_ctrl aon;
168 struct iproc_asiu_gate asiu;
169 struct iproc_pll_reset_ctrl reset;
170 struct iproc_pll_dig_filter_ctrl dig_filter;
171 struct iproc_pll_sw_ctrl sw_ctrl;
172 struct iproc_clk_reg_op ndiv_int;
173 struct iproc_clk_reg_op ndiv_frac;
174 struct iproc_clk_reg_op pdiv;
175 struct iproc_pll_vco_ctrl vco_ctrl;
176 struct iproc_clk_reg_op status;
177 struct iproc_clk_reg_op macro_mode;
178 };
179
180
181
182
183 struct iproc_clk_enable_ctrl {
184 unsigned int offset;
185 unsigned int enable_shift;
186 unsigned int hold_shift;
187 unsigned int bypass_shift;
188 };
189
190
191
192
193 struct iproc_clk_ctrl {
194 unsigned int channel;
195 unsigned long flags;
196 struct iproc_clk_enable_ctrl enable;
197 struct iproc_clk_reg_op mdiv;
198 };
199
200
201
202
203 struct iproc_asiu_div {
204 unsigned int offset;
205 unsigned int en_shift;
206 unsigned int high_shift;
207 unsigned int high_width;
208 unsigned int low_shift;
209 unsigned int low_width;
210 };
211
212 void iproc_armpll_setup(struct device_node *node);
213 void iproc_pll_clk_setup(struct device_node *node,
214 const struct iproc_pll_ctrl *pll_ctrl,
215 const struct iproc_pll_vco_param *vco,
216 unsigned int num_vco_entries,
217 const struct iproc_clk_ctrl *clk_ctrl,
218 unsigned int num_clks);
219 void iproc_asiu_setup(struct device_node *node,
220 const struct iproc_asiu_div *div,
221 const struct iproc_asiu_gate *gate,
222 unsigned int num_clks);
223
224 #endif