diff options
author | Scott Wood <scottwood@freescale.com> | 2007-07-16 14:26:35 -0400 |
---|---|---|
committer | Kumar Gala <galak@kernel.crashing.org> | 2007-10-04 12:02:14 -0400 |
commit | 2652d4ec4a363487d0106a8bf51f1b081dd7e397 (patch) | |
tree | b8deabfae85508ee396e463eed737b7887a7126d /arch/powerpc/sysdev/cpm2_common.c | |
parent | 449012daa92a60e42f0d55478641cfa796d51528 (diff) |
[POWERPC] cpm2: Add SCCs to cpm2_clk_setup(), and cpm2_smc_clk_setup().
Signed-off-by: Scott Wood <scottwood@freescale.com>
Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
Diffstat (limited to 'arch/powerpc/sysdev/cpm2_common.c')
-rw-r--r-- | arch/powerpc/sysdev/cpm2_common.c | 100 |
1 files changed, 95 insertions, 5 deletions
diff --git a/arch/powerpc/sysdev/cpm2_common.c b/arch/powerpc/sysdev/cpm2_common.c index 0330ca490928..c6dc0bf614b3 100644 --- a/arch/powerpc/sysdev/cpm2_common.c +++ b/arch/powerpc/sysdev/cpm2_common.c | |||
@@ -144,7 +144,8 @@ int cpm2_clk_setup(enum cpm_clk_target target, int clock, int mode) | |||
144 | cpmux_t __iomem *im_cpmux; | 144 | cpmux_t __iomem *im_cpmux; |
145 | u32 __iomem *reg; | 145 | u32 __iomem *reg; |
146 | u32 mask = 7; | 146 | u32 mask = 7; |
147 | u8 clk_map [24][3] = { | 147 | |
148 | u8 clk_map[][3] = { | ||
148 | {CPM_CLK_FCC1, CPM_BRG5, 0}, | 149 | {CPM_CLK_FCC1, CPM_BRG5, 0}, |
149 | {CPM_CLK_FCC1, CPM_BRG6, 1}, | 150 | {CPM_CLK_FCC1, CPM_BRG6, 1}, |
150 | {CPM_CLK_FCC1, CPM_BRG7, 2}, | 151 | {CPM_CLK_FCC1, CPM_BRG7, 2}, |
@@ -168,8 +169,40 @@ int cpm2_clk_setup(enum cpm_clk_target target, int clock, int mode) | |||
168 | {CPM_CLK_FCC3, CPM_CLK13, 4}, | 169 | {CPM_CLK_FCC3, CPM_CLK13, 4}, |
169 | {CPM_CLK_FCC3, CPM_CLK14, 5}, | 170 | {CPM_CLK_FCC3, CPM_CLK14, 5}, |
170 | {CPM_CLK_FCC3, CPM_CLK15, 6}, | 171 | {CPM_CLK_FCC3, CPM_CLK15, 6}, |
171 | {CPM_CLK_FCC3, CPM_CLK16, 7} | 172 | {CPM_CLK_FCC3, CPM_CLK16, 7}, |
172 | }; | 173 | {CPM_CLK_SCC1, CPM_BRG1, 0}, |
174 | {CPM_CLK_SCC1, CPM_BRG2, 1}, | ||
175 | {CPM_CLK_SCC1, CPM_BRG3, 2}, | ||
176 | {CPM_CLK_SCC1, CPM_BRG4, 3}, | ||
177 | {CPM_CLK_SCC1, CPM_CLK11, 4}, | ||
178 | {CPM_CLK_SCC1, CPM_CLK12, 5}, | ||
179 | {CPM_CLK_SCC1, CPM_CLK3, 6}, | ||
180 | {CPM_CLK_SCC1, CPM_CLK4, 7}, | ||
181 | {CPM_CLK_SCC2, CPM_BRG1, 0}, | ||
182 | {CPM_CLK_SCC2, CPM_BRG2, 1}, | ||
183 | {CPM_CLK_SCC2, CPM_BRG3, 2}, | ||
184 | {CPM_CLK_SCC2, CPM_BRG4, 3}, | ||
185 | {CPM_CLK_SCC2, CPM_CLK11, 4}, | ||
186 | {CPM_CLK_SCC2, CPM_CLK12, 5}, | ||
187 | {CPM_CLK_SCC2, CPM_CLK3, 6}, | ||
188 | {CPM_CLK_SCC2, CPM_CLK4, 7}, | ||
189 | {CPM_CLK_SCC3, CPM_BRG1, 0}, | ||
190 | {CPM_CLK_SCC3, CPM_BRG2, 1}, | ||
191 | {CPM_CLK_SCC3, CPM_BRG3, 2}, | ||
192 | {CPM_CLK_SCC3, CPM_BRG4, 3}, | ||
193 | {CPM_CLK_SCC3, CPM_CLK5, 4}, | ||
194 | {CPM_CLK_SCC3, CPM_CLK6, 5}, | ||
195 | {CPM_CLK_SCC3, CPM_CLK7, 6}, | ||
196 | {CPM_CLK_SCC3, CPM_CLK8, 7}, | ||
197 | {CPM_CLK_SCC4, CPM_BRG1, 0}, | ||
198 | {CPM_CLK_SCC4, CPM_BRG2, 1}, | ||
199 | {CPM_CLK_SCC4, CPM_BRG3, 2}, | ||
200 | {CPM_CLK_SCC4, CPM_BRG4, 3}, | ||
201 | {CPM_CLK_SCC4, CPM_CLK5, 4}, | ||
202 | {CPM_CLK_SCC4, CPM_CLK6, 5}, | ||
203 | {CPM_CLK_SCC4, CPM_CLK7, 6}, | ||
204 | {CPM_CLK_SCC4, CPM_CLK8, 7}, | ||
205 | }; | ||
173 | 206 | ||
174 | im_cpmux = cpm2_map(im_cpmux); | 207 | im_cpmux = cpm2_map(im_cpmux); |
175 | 208 | ||
@@ -209,23 +242,80 @@ int cpm2_clk_setup(enum cpm_clk_target target, int clock, int mode) | |||
209 | if (mode == CPM_CLK_RX) | 242 | if (mode == CPM_CLK_RX) |
210 | shift += 3; | 243 | shift += 3; |
211 | 244 | ||
212 | for (i=0; i<24; i++) { | 245 | for (i = 0; i < ARRAY_SIZE(clk_map); i++) { |
213 | if (clk_map[i][0] == target && clk_map[i][1] == clock) { | 246 | if (clk_map[i][0] == target && clk_map[i][1] == clock) { |
214 | bits = clk_map[i][2]; | 247 | bits = clk_map[i][2]; |
215 | break; | 248 | break; |
216 | } | 249 | } |
217 | } | 250 | } |
218 | if (i == sizeof(clk_map)/3) | 251 | if (i == ARRAY_SIZE(clk_map)) |
219 | ret = -EINVAL; | 252 | ret = -EINVAL; |
220 | 253 | ||
221 | bits <<= shift; | 254 | bits <<= shift; |
222 | mask <<= shift; | 255 | mask <<= shift; |
256 | |||
223 | out_be32(reg, (in_be32(reg) & ~mask) | bits); | 257 | out_be32(reg, (in_be32(reg) & ~mask) | bits); |
224 | 258 | ||
225 | cpm2_unmap(im_cpmux); | 259 | cpm2_unmap(im_cpmux); |
226 | return ret; | 260 | return ret; |
227 | } | 261 | } |
228 | 262 | ||
263 | int cpm2_smc_clk_setup(enum cpm_clk_target target, int clock) | ||
264 | { | ||
265 | int ret = 0; | ||
266 | int shift; | ||
267 | int i, bits = 0; | ||
268 | cpmux_t __iomem *im_cpmux; | ||
269 | u8 __iomem *reg; | ||
270 | u8 mask = 3; | ||
271 | |||
272 | u8 clk_map[][3] = { | ||
273 | {CPM_CLK_SMC1, CPM_BRG1, 0}, | ||
274 | {CPM_CLK_SMC1, CPM_BRG7, 1}, | ||
275 | {CPM_CLK_SMC1, CPM_CLK7, 2}, | ||
276 | {CPM_CLK_SMC1, CPM_CLK9, 3}, | ||
277 | {CPM_CLK_SMC2, CPM_BRG2, 0}, | ||
278 | {CPM_CLK_SMC2, CPM_BRG8, 1}, | ||
279 | {CPM_CLK_SMC2, CPM_CLK4, 2}, | ||
280 | {CPM_CLK_SMC2, CPM_CLK15, 3}, | ||
281 | }; | ||
282 | |||
283 | im_cpmux = cpm2_map(im_cpmux); | ||
284 | |||
285 | switch (target) { | ||
286 | case CPM_CLK_SMC1: | ||
287 | reg = &im_cpmux->cmx_smr; | ||
288 | mask = 3; | ||
289 | shift = 4; | ||
290 | break; | ||
291 | case CPM_CLK_SMC2: | ||
292 | reg = &im_cpmux->cmx_smr; | ||
293 | mask = 3; | ||
294 | shift = 0; | ||
295 | break; | ||
296 | default: | ||
297 | printk(KERN_ERR "cpm2_smc_clock_setup: invalid clock target\n"); | ||
298 | return -EINVAL; | ||
299 | } | ||
300 | |||
301 | for (i = 0; i < ARRAY_SIZE(clk_map); i++) { | ||
302 | if (clk_map[i][0] == target && clk_map[i][1] == clock) { | ||
303 | bits = clk_map[i][2]; | ||
304 | break; | ||
305 | } | ||
306 | } | ||
307 | if (i == ARRAY_SIZE(clk_map)) | ||
308 | ret = -EINVAL; | ||
309 | |||
310 | bits <<= shift; | ||
311 | mask <<= shift; | ||
312 | |||
313 | out_8(reg, (in_8(reg) & ~mask) | bits); | ||
314 | |||
315 | cpm2_unmap(im_cpmux); | ||
316 | return ret; | ||
317 | } | ||
318 | |||
229 | /* | 319 | /* |
230 | * dpalloc / dpfree bits. | 320 | * dpalloc / dpfree bits. |
231 | */ | 321 | */ |