blob: 3bf80e2b016c3b2055de25fad81ce096e0e7e26f [file] [log] [blame]
Jason Liudec11122011-11-25 00:18:02 +00001/*
2 * Copyright (C) 2010-2011 Freescale Semiconductor, Inc.
3 *
Wolfgang Denkd79de1d2013-07-08 09:37:19 +02004 * SPDX-License-Identifier: GPL-2.0+
Jason Liudec11122011-11-25 00:18:02 +00005 */
6
7#include <common.h>
8#include <asm/io.h>
9#include <asm/errno.h>
10#include <asm/arch/imx-regs.h>
Fabio Estevam6479f512012-04-29 08:11:13 +000011#include <asm/arch/crm_regs.h>
Jason Liudec11122011-11-25 00:18:02 +000012#include <asm/arch/clock.h>
Fabio Estevam6479f512012-04-29 08:11:13 +000013#include <asm/arch/sys_proto.h>
Jason Liudec11122011-11-25 00:18:02 +000014
15enum pll_clocks {
16 PLL_SYS, /* System PLL */
17 PLL_BUS, /* System Bus PLL*/
18 PLL_USBOTG, /* OTG USB PLL */
19 PLL_ENET, /* ENET PLL */
20};
21
Fabio Estevam6479f512012-04-29 08:11:13 +000022struct mxc_ccm_reg *imx_ccm = (struct mxc_ccm_reg *)CCM_BASE_ADDR;
Jason Liudec11122011-11-25 00:18:02 +000023
Benoît Thébaudeau20db6312013-04-23 10:17:44 +000024#ifdef CONFIG_MXC_OCOTP
25void enable_ocotp_clk(unsigned char enable)
26{
27 u32 reg;
28
29 reg = __raw_readl(&imx_ccm->CCGR2);
30 if (enable)
31 reg |= MXC_CCM_CCGR2_OCOTP_CTRL_MASK;
32 else
33 reg &= ~MXC_CCM_CCGR2_OCOTP_CTRL_MASK;
34 __raw_writel(reg, &imx_ccm->CCGR2);
35}
36#endif
37
Wolfgang Grandegger1859b702012-02-08 22:33:25 +000038void enable_usboh3_clk(unsigned char enable)
39{
40 u32 reg;
41
42 reg = __raw_readl(&imx_ccm->CCGR6);
43 if (enable)
Eric Nelsone4279542012-09-21 07:33:51 +000044 reg |= MXC_CCM_CCGR6_USBOH3_MASK;
Wolfgang Grandegger1859b702012-02-08 22:33:25 +000045 else
Eric Nelsone4279542012-09-21 07:33:51 +000046 reg &= ~(MXC_CCM_CCGR6_USBOH3_MASK);
Wolfgang Grandegger1859b702012-02-08 22:33:25 +000047 __raw_writel(reg, &imx_ccm->CCGR6);
48
49}
50
Troy Kiskyd4fdc992012-07-19 08:18:25 +000051#ifdef CONFIG_I2C_MXC
52/* i2c_num can be from 0 - 2 */
53int enable_i2c_clk(unsigned char enable, unsigned i2c_num)
54{
55 u32 reg;
56 u32 mask;
57
58 if (i2c_num > 2)
59 return -EINVAL;
Eric Nelsone4279542012-09-21 07:33:51 +000060
61 mask = MXC_CCM_CCGR_CG_MASK
62 << (MXC_CCM_CCGR2_I2C1_SERIAL_OFFSET + (i2c_num << 1));
Troy Kiskyd4fdc992012-07-19 08:18:25 +000063 reg = __raw_readl(&imx_ccm->CCGR2);
64 if (enable)
65 reg |= mask;
66 else
67 reg &= ~mask;
68 __raw_writel(reg, &imx_ccm->CCGR2);
69 return 0;
70}
71#endif
72
Jason Liudec11122011-11-25 00:18:02 +000073static u32 decode_pll(enum pll_clocks pll, u32 infreq)
74{
75 u32 div;
76
77 switch (pll) {
78 case PLL_SYS:
79 div = __raw_readl(&imx_ccm->analog_pll_sys);
80 div &= BM_ANADIG_PLL_SYS_DIV_SELECT;
81
82 return infreq * (div >> 1);
83 case PLL_BUS:
84 div = __raw_readl(&imx_ccm->analog_pll_528);
85 div &= BM_ANADIG_PLL_528_DIV_SELECT;
86
87 return infreq * (20 + (div << 1));
88 case PLL_USBOTG:
89 div = __raw_readl(&imx_ccm->analog_usb1_pll_480_ctrl);
90 div &= BM_ANADIG_USB1_PLL_480_CTRL_DIV_SELECT;
91
92 return infreq * (20 + (div << 1));
93 case PLL_ENET:
94 div = __raw_readl(&imx_ccm->analog_pll_enet);
95 div &= BM_ANADIG_PLL_ENET_DIV_SELECT;
96
97 return (div == 3 ? 125000000 : 25000000 * (div << 1));
98 default:
99 return 0;
100 }
101 /* NOTREACHED */
102}
Pierre Auberte8e62a72013-09-19 17:48:59 +0200103static u32 mxc_get_pll_pfd(enum pll_clocks pll, int pfd_num)
104{
105 u32 div;
106 u64 freq;
107
108 switch (pll) {
109 case PLL_BUS:
110 if (pfd_num == 3) {
111 /* No PFD3 on PPL2 */
112 return 0;
113 }
114 div = __raw_readl(&imx_ccm->analog_pfd_528);
115 freq = (u64)decode_pll(PLL_BUS, MXC_HCLK);
116 break;
117 case PLL_USBOTG:
118 div = __raw_readl(&imx_ccm->analog_pfd_480);
119 freq = (u64)decode_pll(PLL_USBOTG, MXC_HCLK);
120 break;
121 default:
122 /* No PFD on other PLL */
123 return 0;
124 }
125
126 return (freq * 18) / ((div & ANATOP_PFD_FRAC_MASK(pfd_num)) >>
127 ANATOP_PFD_FRAC_SHIFT(pfd_num));
128}
Jason Liudec11122011-11-25 00:18:02 +0000129
130static u32 get_mcu_main_clk(void)
131{
132 u32 reg, freq;
133
134 reg = __raw_readl(&imx_ccm->cacrr);
135 reg &= MXC_CCM_CACRR_ARM_PODF_MASK;
136 reg >>= MXC_CCM_CACRR_ARM_PODF_OFFSET;
Benoît Thébaudeauafac1652012-09-27 10:19:58 +0000137 freq = decode_pll(PLL_SYS, MXC_HCLK);
Jason Liudec11122011-11-25 00:18:02 +0000138
139 return freq / (reg + 1);
140}
141
Fabio Estevam6479f512012-04-29 08:11:13 +0000142u32 get_periph_clk(void)
Jason Liudec11122011-11-25 00:18:02 +0000143{
144 u32 reg, freq = 0;
145
146 reg = __raw_readl(&imx_ccm->cbcdr);
147 if (reg & MXC_CCM_CBCDR_PERIPH_CLK_SEL) {
148 reg = __raw_readl(&imx_ccm->cbcmr);
149 reg &= MXC_CCM_CBCMR_PERIPH_CLK2_SEL_MASK;
150 reg >>= MXC_CCM_CBCMR_PERIPH_CLK2_SEL_OFFSET;
151
152 switch (reg) {
153 case 0:
Benoît Thébaudeauafac1652012-09-27 10:19:58 +0000154 freq = decode_pll(PLL_USBOTG, MXC_HCLK);
Jason Liudec11122011-11-25 00:18:02 +0000155 break;
156 case 1:
157 case 2:
Benoît Thébaudeauafac1652012-09-27 10:19:58 +0000158 freq = MXC_HCLK;
Jason Liudec11122011-11-25 00:18:02 +0000159 break;
160 default:
161 break;
162 }
163 } else {
164 reg = __raw_readl(&imx_ccm->cbcmr);
165 reg &= MXC_CCM_CBCMR_PRE_PERIPH_CLK_SEL_MASK;
166 reg >>= MXC_CCM_CBCMR_PRE_PERIPH_CLK_SEL_OFFSET;
167
168 switch (reg) {
169 case 0:
Benoît Thébaudeauafac1652012-09-27 10:19:58 +0000170 freq = decode_pll(PLL_BUS, MXC_HCLK);
Jason Liudec11122011-11-25 00:18:02 +0000171 break;
172 case 1:
Pierre Auberte8e62a72013-09-19 17:48:59 +0200173 freq = mxc_get_pll_pfd(PLL_BUS, 2);
Jason Liudec11122011-11-25 00:18:02 +0000174 break;
175 case 2:
Pierre Auberte8e62a72013-09-19 17:48:59 +0200176 freq = mxc_get_pll_pfd(PLL_BUS, 0);
Jason Liudec11122011-11-25 00:18:02 +0000177 break;
178 case 3:
Pierre Auberte8e62a72013-09-19 17:48:59 +0200179 /* static / 2 divider */
180 freq = mxc_get_pll_pfd(PLL_BUS, 2) / 2;
Jason Liudec11122011-11-25 00:18:02 +0000181 break;
182 default:
183 break;
184 }
185 }
186
187 return freq;
188}
189
Jason Liudec11122011-11-25 00:18:02 +0000190static u32 get_ipg_clk(void)
191{
192 u32 reg, ipg_podf;
193
194 reg = __raw_readl(&imx_ccm->cbcdr);
195 reg &= MXC_CCM_CBCDR_IPG_PODF_MASK;
196 ipg_podf = reg >> MXC_CCM_CBCDR_IPG_PODF_OFFSET;
197
198 return get_ahb_clk() / (ipg_podf + 1);
199}
200
201static u32 get_ipg_per_clk(void)
202{
203 u32 reg, perclk_podf;
204
205 reg = __raw_readl(&imx_ccm->cscmr1);
206 perclk_podf = reg & MXC_CCM_CSCMR1_PERCLK_PODF_MASK;
207
208 return get_ipg_clk() / (perclk_podf + 1);
209}
210
211static u32 get_uart_clk(void)
212{
213 u32 reg, uart_podf;
Pierre Auberte8e62a72013-09-19 17:48:59 +0200214 u32 freq = decode_pll(PLL_USBOTG, MXC_HCLK) / 6; /* static divider */
Jason Liudec11122011-11-25 00:18:02 +0000215 reg = __raw_readl(&imx_ccm->cscdr1);
Fabio Estevamf7b9ac22013-04-10 09:32:57 +0000216#ifdef CONFIG_MX6SL
217 if (reg & MXC_CCM_CSCDR1_UART_CLK_SEL)
218 freq = MXC_HCLK;
219#endif
Jason Liudec11122011-11-25 00:18:02 +0000220 reg &= MXC_CCM_CSCDR1_UART_CLK_PODF_MASK;
221 uart_podf = reg >> MXC_CCM_CSCDR1_UART_CLK_PODF_OFFSET;
222
Fabio Estevamf7b9ac22013-04-10 09:32:57 +0000223 return freq / (uart_podf + 1);
Jason Liudec11122011-11-25 00:18:02 +0000224}
225
226static u32 get_cspi_clk(void)
227{
228 u32 reg, cspi_podf;
229
230 reg = __raw_readl(&imx_ccm->cscdr2);
231 reg &= MXC_CCM_CSCDR2_ECSPI_CLK_PODF_MASK;
232 cspi_podf = reg >> MXC_CCM_CSCDR2_ECSPI_CLK_PODF_OFFSET;
233
Pierre Auberte8e62a72013-09-19 17:48:59 +0200234 return decode_pll(PLL_USBOTG, MXC_HCLK) / (8 * (cspi_podf + 1));
Jason Liudec11122011-11-25 00:18:02 +0000235}
236
237static u32 get_axi_clk(void)
238{
239 u32 root_freq, axi_podf;
240 u32 cbcdr = __raw_readl(&imx_ccm->cbcdr);
241
242 axi_podf = cbcdr & MXC_CCM_CBCDR_AXI_PODF_MASK;
243 axi_podf >>= MXC_CCM_CBCDR_AXI_PODF_OFFSET;
244
245 if (cbcdr & MXC_CCM_CBCDR_AXI_SEL) {
246 if (cbcdr & MXC_CCM_CBCDR_AXI_ALT_SEL)
Pierre Auberte8e62a72013-09-19 17:48:59 +0200247 root_freq = mxc_get_pll_pfd(PLL_BUS, 2);
Jason Liudec11122011-11-25 00:18:02 +0000248 else
Pierre Auberte8e62a72013-09-19 17:48:59 +0200249 root_freq = mxc_get_pll_pfd(PLL_USBOTG, 1);
Jason Liudec11122011-11-25 00:18:02 +0000250 } else
251 root_freq = get_periph_clk();
252
253 return root_freq / (axi_podf + 1);
254}
255
256static u32 get_emi_slow_clk(void)
257{
Andrew Gabbasov4740e242013-07-04 06:27:32 -0500258 u32 emi_clk_sel, emi_slow_podf, cscmr1, root_freq = 0;
Jason Liudec11122011-11-25 00:18:02 +0000259
260 cscmr1 = __raw_readl(&imx_ccm->cscmr1);
261 emi_clk_sel = cscmr1 & MXC_CCM_CSCMR1_ACLK_EMI_SLOW_MASK;
262 emi_clk_sel >>= MXC_CCM_CSCMR1_ACLK_EMI_SLOW_OFFSET;
Andrew Gabbasov4740e242013-07-04 06:27:32 -0500263 emi_slow_podf = cscmr1 & MXC_CCM_CSCMR1_ACLK_EMI_SLOW_PODF_MASK;
264 emi_slow_podf >>= MXC_CCM_CSCMR1_ACLK_EMI_SLOW_PODF_OFFSET;
Jason Liudec11122011-11-25 00:18:02 +0000265
266 switch (emi_clk_sel) {
267 case 0:
268 root_freq = get_axi_clk();
269 break;
270 case 1:
Benoît Thébaudeauafac1652012-09-27 10:19:58 +0000271 root_freq = decode_pll(PLL_USBOTG, MXC_HCLK);
Jason Liudec11122011-11-25 00:18:02 +0000272 break;
273 case 2:
Pierre Auberte8e62a72013-09-19 17:48:59 +0200274 root_freq = mxc_get_pll_pfd(PLL_BUS, 2);
Jason Liudec11122011-11-25 00:18:02 +0000275 break;
276 case 3:
Pierre Auberte8e62a72013-09-19 17:48:59 +0200277 root_freq = mxc_get_pll_pfd(PLL_BUS, 0);
Jason Liudec11122011-11-25 00:18:02 +0000278 break;
279 }
280
Andrew Gabbasov4740e242013-07-04 06:27:32 -0500281 return root_freq / (emi_slow_podf + 1);
Jason Liudec11122011-11-25 00:18:02 +0000282}
283
Fabio Estevamf7b9ac22013-04-10 09:32:57 +0000284#ifdef CONFIG_MX6SL
285static u32 get_mmdc_ch0_clk(void)
286{
287 u32 cbcmr = __raw_readl(&imx_ccm->cbcmr);
288 u32 cbcdr = __raw_readl(&imx_ccm->cbcdr);
289 u32 freq, podf;
290
291 podf = (cbcdr & MXC_CCM_CBCDR_MMDC_CH1_PODF_MASK) \
292 >> MXC_CCM_CBCDR_MMDC_CH1_PODF_OFFSET;
293
294 switch ((cbcmr & MXC_CCM_CBCMR_PRE_PERIPH2_CLK_SEL_MASK) >>
295 MXC_CCM_CBCMR_PRE_PERIPH2_CLK_SEL_OFFSET) {
296 case 0:
297 freq = decode_pll(PLL_BUS, MXC_HCLK);
298 break;
299 case 1:
Pierre Auberte8e62a72013-09-19 17:48:59 +0200300 freq = mxc_get_pll_pfd(PLL_BUS, 2);
Fabio Estevamf7b9ac22013-04-10 09:32:57 +0000301 break;
302 case 2:
Pierre Auberte8e62a72013-09-19 17:48:59 +0200303 freq = mxc_get_pll_pfd(PLL_BUS, 0);
Fabio Estevamf7b9ac22013-04-10 09:32:57 +0000304 break;
305 case 3:
Pierre Auberte8e62a72013-09-19 17:48:59 +0200306 /* static / 2 divider */
307 freq = mxc_get_pll_pfd(PLL_BUS, 2) / 2;
Fabio Estevamf7b9ac22013-04-10 09:32:57 +0000308 }
309
310 return freq / (podf + 1);
311
312}
Fabio Estevam67b8b9d2013-09-13 00:36:28 -0300313
314int enable_fec_anatop_clock(void)
315{
316 u32 reg = 0;
317 s32 timeout = 100000;
318
319 struct anatop_regs __iomem *anatop =
320 (struct anatop_regs __iomem *)ANATOP_BASE_ADDR;
321
322 reg = readl(&anatop->pll_enet);
323 if ((reg & BM_ANADIG_PLL_ENET_POWERDOWN) ||
324 (!(reg & BM_ANADIG_PLL_ENET_LOCK))) {
325 reg &= ~BM_ANADIG_PLL_ENET_POWERDOWN;
326 writel(reg, &anatop->pll_enet);
327 while (timeout--) {
328 if (readl(&anatop->pll_enet) & BM_ANADIG_PLL_ENET_LOCK)
329 break;
330 }
331 if (timeout < 0)
332 return -ETIMEDOUT;
333 }
334
335 /* Enable FEC clock */
336 reg |= BM_ANADIG_PLL_ENET_ENABLE;
337 reg &= ~BM_ANADIG_PLL_ENET_BYPASS;
338 writel(reg, &anatop->pll_enet);
339
340 return 0;
341}
342
Fabio Estevamf7b9ac22013-04-10 09:32:57 +0000343#else
Jason Liudec11122011-11-25 00:18:02 +0000344static u32 get_mmdc_ch0_clk(void)
345{
346 u32 cbcdr = __raw_readl(&imx_ccm->cbcdr);
347 u32 mmdc_ch0_podf = (cbcdr & MXC_CCM_CBCDR_MMDC_CH0_PODF_MASK) >>
348 MXC_CCM_CBCDR_MMDC_CH0_PODF_OFFSET;
349
350 return get_periph_clk() / (mmdc_ch0_podf + 1);
351}
Fabio Estevamf7b9ac22013-04-10 09:32:57 +0000352#endif
Jason Liudec11122011-11-25 00:18:02 +0000353
354static u32 get_usdhc_clk(u32 port)
355{
356 u32 root_freq = 0, usdhc_podf = 0, clk_sel = 0;
357 u32 cscmr1 = __raw_readl(&imx_ccm->cscmr1);
358 u32 cscdr1 = __raw_readl(&imx_ccm->cscdr1);
359
360 switch (port) {
361 case 0:
362 usdhc_podf = (cscdr1 & MXC_CCM_CSCDR1_USDHC1_PODF_MASK) >>
363 MXC_CCM_CSCDR1_USDHC1_PODF_OFFSET;
364 clk_sel = cscmr1 & MXC_CCM_CSCMR1_USDHC1_CLK_SEL;
365
366 break;
367 case 1:
368 usdhc_podf = (cscdr1 & MXC_CCM_CSCDR1_USDHC2_PODF_MASK) >>
369 MXC_CCM_CSCDR1_USDHC2_PODF_OFFSET;
370 clk_sel = cscmr1 & MXC_CCM_CSCMR1_USDHC2_CLK_SEL;
371
372 break;
373 case 2:
374 usdhc_podf = (cscdr1 & MXC_CCM_CSCDR1_USDHC3_PODF_MASK) >>
375 MXC_CCM_CSCDR1_USDHC3_PODF_OFFSET;
376 clk_sel = cscmr1 & MXC_CCM_CSCMR1_USDHC3_CLK_SEL;
377
378 break;
379 case 3:
380 usdhc_podf = (cscdr1 & MXC_CCM_CSCDR1_USDHC4_PODF_MASK) >>
381 MXC_CCM_CSCDR1_USDHC4_PODF_OFFSET;
382 clk_sel = cscmr1 & MXC_CCM_CSCMR1_USDHC4_CLK_SEL;
383
384 break;
385 default:
386 break;
387 }
388
389 if (clk_sel)
Pierre Auberte8e62a72013-09-19 17:48:59 +0200390 root_freq = mxc_get_pll_pfd(PLL_BUS, 0);
Jason Liudec11122011-11-25 00:18:02 +0000391 else
Pierre Auberte8e62a72013-09-19 17:48:59 +0200392 root_freq = mxc_get_pll_pfd(PLL_BUS, 2);
Jason Liudec11122011-11-25 00:18:02 +0000393
394 return root_freq / (usdhc_podf + 1);
395}
396
397u32 imx_get_uartclk(void)
398{
399 return get_uart_clk();
400}
401
Jason Liu92aa90b2011-12-16 05:17:06 +0000402u32 imx_get_fecclk(void)
403{
Benoît Thébaudeauafac1652012-09-27 10:19:58 +0000404 return decode_pll(PLL_ENET, MXC_HCLK);
Jason Liu92aa90b2011-12-16 05:17:06 +0000405}
406
Eric Nelsonfdba0762012-03-27 09:52:21 +0000407int enable_sata_clock(void)
408{
409 u32 reg = 0;
410 s32 timeout = 100000;
411 struct mxc_ccm_reg *const imx_ccm
412 = (struct mxc_ccm_reg *) CCM_BASE_ADDR;
413
414 /* Enable sata clock */
415 reg = readl(&imx_ccm->CCGR5); /* CCGR5 */
Eric Nelsone4279542012-09-21 07:33:51 +0000416 reg |= MXC_CCM_CCGR5_SATA_MASK;
Eric Nelsonfdba0762012-03-27 09:52:21 +0000417 writel(reg, &imx_ccm->CCGR5);
418
419 /* Enable PLLs */
420 reg = readl(&imx_ccm->analog_pll_enet);
421 reg &= ~BM_ANADIG_PLL_SYS_POWERDOWN;
422 writel(reg, &imx_ccm->analog_pll_enet);
423 reg |= BM_ANADIG_PLL_SYS_ENABLE;
424 while (timeout--) {
425 if (readl(&imx_ccm->analog_pll_enet) & BM_ANADIG_PLL_SYS_LOCK)
426 break;
427 }
428 if (timeout <= 0)
429 return -EIO;
430 reg &= ~BM_ANADIG_PLL_SYS_BYPASS;
431 writel(reg, &imx_ccm->analog_pll_enet);
432 reg |= BM_ANADIG_PLL_ENET_ENABLE_SATA;
433 writel(reg, &imx_ccm->analog_pll_enet);
434
435 return 0 ;
436}
437
Jason Liudec11122011-11-25 00:18:02 +0000438unsigned int mxc_get_clock(enum mxc_clock clk)
439{
440 switch (clk) {
441 case MXC_ARM_CLK:
442 return get_mcu_main_clk();
443 case MXC_PER_CLK:
444 return get_periph_clk();
445 case MXC_AHB_CLK:
446 return get_ahb_clk();
447 case MXC_IPG_CLK:
448 return get_ipg_clk();
449 case MXC_IPG_PERCLK:
Matthias Weisser99ba3422012-09-24 02:46:53 +0000450 case MXC_I2C_CLK:
Jason Liudec11122011-11-25 00:18:02 +0000451 return get_ipg_per_clk();
452 case MXC_UART_CLK:
453 return get_uart_clk();
454 case MXC_CSPI_CLK:
455 return get_cspi_clk();
456 case MXC_AXI_CLK:
457 return get_axi_clk();
458 case MXC_EMI_SLOW_CLK:
459 return get_emi_slow_clk();
460 case MXC_DDR_CLK:
461 return get_mmdc_ch0_clk();
462 case MXC_ESDHC_CLK:
463 return get_usdhc_clk(0);
464 case MXC_ESDHC2_CLK:
465 return get_usdhc_clk(1);
466 case MXC_ESDHC3_CLK:
467 return get_usdhc_clk(2);
468 case MXC_ESDHC4_CLK:
469 return get_usdhc_clk(3);
470 case MXC_SATA_CLK:
471 return get_ahb_clk();
472 default:
473 break;
474 }
475
476 return -1;
477}
478
479/*
480 * Dump some core clockes.
481 */
482int do_mx6_showclocks(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
483{
484 u32 freq;
Benoît Thébaudeauafac1652012-09-27 10:19:58 +0000485 freq = decode_pll(PLL_SYS, MXC_HCLK);
Jason Liudec11122011-11-25 00:18:02 +0000486 printf("PLL_SYS %8d MHz\n", freq / 1000000);
Benoît Thébaudeauafac1652012-09-27 10:19:58 +0000487 freq = decode_pll(PLL_BUS, MXC_HCLK);
Jason Liudec11122011-11-25 00:18:02 +0000488 printf("PLL_BUS %8d MHz\n", freq / 1000000);
Benoît Thébaudeauafac1652012-09-27 10:19:58 +0000489 freq = decode_pll(PLL_USBOTG, MXC_HCLK);
Jason Liudec11122011-11-25 00:18:02 +0000490 printf("PLL_OTG %8d MHz\n", freq / 1000000);
Benoît Thébaudeauafac1652012-09-27 10:19:58 +0000491 freq = decode_pll(PLL_ENET, MXC_HCLK);
Jason Liudec11122011-11-25 00:18:02 +0000492 printf("PLL_NET %8d MHz\n", freq / 1000000);
493
494 printf("\n");
495 printf("IPG %8d kHz\n", mxc_get_clock(MXC_IPG_CLK) / 1000);
496 printf("UART %8d kHz\n", mxc_get_clock(MXC_UART_CLK) / 1000);
Fabio Estevamf6fde412012-11-16 01:30:10 +0000497#ifdef CONFIG_MXC_SPI
Jason Liudec11122011-11-25 00:18:02 +0000498 printf("CSPI %8d kHz\n", mxc_get_clock(MXC_CSPI_CLK) / 1000);
Fabio Estevamf6fde412012-11-16 01:30:10 +0000499#endif
Jason Liudec11122011-11-25 00:18:02 +0000500 printf("AHB %8d kHz\n", mxc_get_clock(MXC_AHB_CLK) / 1000);
501 printf("AXI %8d kHz\n", mxc_get_clock(MXC_AXI_CLK) / 1000);
502 printf("DDR %8d kHz\n", mxc_get_clock(MXC_DDR_CLK) / 1000);
503 printf("USDHC1 %8d kHz\n", mxc_get_clock(MXC_ESDHC_CLK) / 1000);
504 printf("USDHC2 %8d kHz\n", mxc_get_clock(MXC_ESDHC2_CLK) / 1000);
505 printf("USDHC3 %8d kHz\n", mxc_get_clock(MXC_ESDHC3_CLK) / 1000);
506 printf("USDHC4 %8d kHz\n", mxc_get_clock(MXC_ESDHC4_CLK) / 1000);
507 printf("EMI SLOW %8d kHz\n", mxc_get_clock(MXC_EMI_SLOW_CLK) / 1000);
508 printf("IPG PERCLK %8d kHz\n", mxc_get_clock(MXC_IPG_PERCLK) / 1000);
509
510 return 0;
511}
512
Pardeep Kumar Singlac1fa1302013-07-25 12:12:13 -0500513void enable_ipu_clock(void)
514{
515 struct mxc_ccm_reg *mxc_ccm = (struct mxc_ccm_reg *)CCM_BASE_ADDR;
516 int reg;
517 reg = readl(&mxc_ccm->CCGR3);
Pierre Aubert2cb5c382013-09-23 13:37:20 +0200518 reg |= MXC_CCM_CCGR3_IPU1_IPU_MASK;
Pardeep Kumar Singlac1fa1302013-07-25 12:12:13 -0500519 writel(reg, &mxc_ccm->CCGR3);
520}
Jason Liudec11122011-11-25 00:18:02 +0000521/***************************************************/
522
523U_BOOT_CMD(
524 clocks, CONFIG_SYS_MAXARGS, 1, do_mx6_showclocks,
525 "display clocks",
526 ""
527);