3 * Sascha Hauer, Pengutronix
5 * (C) Copyright 2009 Freescale Semiconductor, Inc.
7 * SPDX-License-Identifier: GPL-2.0+
12 #include <linux/errno.h>
13 #include <asm/arch/imx-regs.h>
14 #include <asm/arch/crm_regs.h>
15 #include <asm/arch/clock.h>
17 #include <asm/arch/sys_proto.h>
29 struct mxc_pll_reg *mxc_plls[PLL_CLOCKS] = {
30 [PLL1_CLOCK] = (struct mxc_pll_reg *)PLL1_BASE_ADDR,
31 [PLL2_CLOCK] = (struct mxc_pll_reg *)PLL2_BASE_ADDR,
32 [PLL3_CLOCK] = (struct mxc_pll_reg *)PLL3_BASE_ADDR,
34 [PLL4_CLOCK] = (struct mxc_pll_reg *)PLL4_BASE_ADDR,
38 #define AHB_CLK_ROOT 133333333
39 #define SZ_DEC_1M 1000000
40 #define PLL_PD_MAX 16 /* Actual pd+1 */
41 #define PLL_MFI_MAX 15
49 #define MX5_CBCMR 0x00015154
50 #define MX5_CBCDR 0x02888945
52 struct fixed_pll_mfd {
57 const struct fixed_pll_mfd fixed_mfd[] = {
68 #define PLL_FREQ_MAX(ref_clk) (4 * (ref_clk) * PLL_MFI_MAX)
69 #define PLL_FREQ_MIN(ref_clk) \
70 ((2 * (ref_clk) * (PLL_MFI_MIN - 1)) / PLL_PD_MAX)
71 #define MAX_DDR_CLK 420000000
72 #define NFC_CLK_MAX 34000000
74 struct mxc_ccm_reg *mxc_ccm = (struct mxc_ccm_reg *)MXC_CCM_BASE;
76 void set_usboh3_clk(void)
78 clrsetbits_le32(&mxc_ccm->cscmr1,
79 MXC_CCM_CSCMR1_USBOH3_CLK_SEL_MASK,
80 MXC_CCM_CSCMR1_USBOH3_CLK_SEL(1));
81 clrsetbits_le32(&mxc_ccm->cscdr1,
82 MXC_CCM_CSCDR1_USBOH3_CLK_PODF_MASK |
83 MXC_CCM_CSCDR1_USBOH3_CLK_PRED_MASK,
84 MXC_CCM_CSCDR1_USBOH3_CLK_PRED(4) |
85 MXC_CCM_CSCDR1_USBOH3_CLK_PODF(1));
88 void enable_usboh3_clk(bool enable)
90 unsigned int cg = enable ? MXC_CCM_CCGR_CG_ON : MXC_CCM_CCGR_CG_OFF;
92 clrsetbits_le32(&mxc_ccm->CCGR2,
93 MXC_CCM_CCGR2_USBOH3_60M(MXC_CCM_CCGR_CG_MASK),
94 MXC_CCM_CCGR2_USBOH3_60M(cg));
97 #ifdef CONFIG_SYS_I2C_MXC
98 /* i2c_num can be from 0, to 1 for i.MX51 and 2 for i.MX53 */
99 int enable_i2c_clk(unsigned char enable, unsigned i2c_num)
103 #if defined(CONFIG_MX51)
105 #elif defined(CONFIG_MX53)
109 mask = MXC_CCM_CCGR_CG_MASK <<
110 (MXC_CCM_CCGR1_I2C1_OFFSET + (i2c_num << 1));
112 setbits_le32(&mxc_ccm->CCGR1, mask);
114 clrbits_le32(&mxc_ccm->CCGR1, mask);
119 void set_usb_phy_clk(void)
121 clrbits_le32(&mxc_ccm->cscmr1, MXC_CCM_CSCMR1_USB_PHY_CLK_SEL);
124 #if defined(CONFIG_MX51)
125 void enable_usb_phy1_clk(bool enable)
127 unsigned int cg = enable ? MXC_CCM_CCGR_CG_ON : MXC_CCM_CCGR_CG_OFF;
129 clrsetbits_le32(&mxc_ccm->CCGR2,
130 MXC_CCM_CCGR2_USB_PHY(MXC_CCM_CCGR_CG_MASK),
131 MXC_CCM_CCGR2_USB_PHY(cg));
134 void enable_usb_phy2_clk(bool enable)
136 /* i.MX51 has a single USB PHY clock, so do nothing here. */
138 #elif defined(CONFIG_MX53)
139 void enable_usb_phy1_clk(bool enable)
141 unsigned int cg = enable ? MXC_CCM_CCGR_CG_ON : MXC_CCM_CCGR_CG_OFF;
143 clrsetbits_le32(&mxc_ccm->CCGR4,
144 MXC_CCM_CCGR4_USB_PHY1(MXC_CCM_CCGR_CG_MASK),
145 MXC_CCM_CCGR4_USB_PHY1(cg));
148 void enable_usb_phy2_clk(bool enable)
150 unsigned int cg = enable ? MXC_CCM_CCGR_CG_ON : MXC_CCM_CCGR_CG_OFF;
152 clrsetbits_le32(&mxc_ccm->CCGR4,
153 MXC_CCM_CCGR4_USB_PHY2(MXC_CCM_CCGR_CG_MASK),
154 MXC_CCM_CCGR4_USB_PHY2(cg));
159 * Calculate the frequency of PLLn.
161 static uint32_t decode_pll(struct mxc_pll_reg *pll, uint32_t infreq)
163 uint32_t ctrl, op, mfd, mfn, mfi, pdf, ret;
164 uint64_t refclk, temp;
167 ctrl = readl(&pll->ctrl);
169 if (ctrl & MXC_DPLLC_CTL_HFSM) {
170 mfn = readl(&pll->hfs_mfn);
171 mfd = readl(&pll->hfs_mfd);
172 op = readl(&pll->hfs_op);
174 mfn = readl(&pll->mfn);
175 mfd = readl(&pll->mfd);
176 op = readl(&pll->op);
179 mfd &= MXC_DPLLC_MFD_MFD_MASK;
180 mfn &= MXC_DPLLC_MFN_MFN_MASK;
181 pdf = op & MXC_DPLLC_OP_PDF_MASK;
182 mfi = MXC_DPLLC_OP_MFI_RD(op);
189 if (mfn >= 0x04000000) {
196 if (ctrl & MXC_DPLLC_CTL_DPDCK0_2_EN)
199 do_div(refclk, pdf + 1);
200 temp = refclk * mfn_abs;
201 do_div(temp, mfd + 1);
214 * This function returns the Frequency Pre-Multiplier clock.
216 static u32 get_fpm(void)
219 u32 ccr = readl(&mxc_ccm->ccr);
221 if (ccr & MXC_CCM_CCR_FPM_MULT)
226 return MXC_CLK32 * mult;
231 * This function returns the low power audio clock.
233 static u32 get_lp_apm(void)
236 u32 ccsr = readl(&mxc_ccm->ccsr);
238 if (ccsr & MXC_CCM_CCSR_LP_APM)
239 #if defined(CONFIG_MX51)
241 #elif defined(CONFIG_MX53)
242 ret_val = decode_pll(mxc_plls[PLL4_CLOCK], MXC_HCLK);
253 u32 get_mcu_main_clk(void)
257 reg = MXC_CCM_CACRR_ARM_PODF_RD(readl(&mxc_ccm->cacrr));
258 freq = decode_pll(mxc_plls[PLL1_CLOCK], MXC_HCLK);
259 return freq / (reg + 1);
263 * Get the rate of peripheral's root clock.
265 u32 get_periph_clk(void)
269 reg = readl(&mxc_ccm->cbcdr);
270 if (!(reg & MXC_CCM_CBCDR_PERIPH_CLK_SEL))
271 return decode_pll(mxc_plls[PLL2_CLOCK], MXC_HCLK);
272 reg = readl(&mxc_ccm->cbcmr);
273 switch (MXC_CCM_CBCMR_PERIPH_CLK_SEL_RD(reg)) {
275 return decode_pll(mxc_plls[PLL1_CLOCK], MXC_HCLK);
277 return decode_pll(mxc_plls[PLL3_CLOCK], MXC_HCLK);
287 * Get the rate of ipg clock.
289 static u32 get_ipg_clk(void)
291 uint32_t freq, reg, div;
293 freq = get_ahb_clk();
295 reg = readl(&mxc_ccm->cbcdr);
296 div = MXC_CCM_CBCDR_IPG_PODF_RD(reg) + 1;
302 * Get the rate of ipg_per clock.
304 static u32 get_ipg_per_clk(void)
306 u32 freq, pred1, pred2, podf;
308 if (readl(&mxc_ccm->cbcmr) & MXC_CCM_CBCMR_PERCLK_IPG_CLK_SEL)
309 return get_ipg_clk();
311 if (readl(&mxc_ccm->cbcmr) & MXC_CCM_CBCMR_PERCLK_LP_APM_CLK_SEL)
314 freq = get_periph_clk();
315 podf = readl(&mxc_ccm->cbcdr);
316 pred1 = MXC_CCM_CBCDR_PERCLK_PRED1_RD(podf);
317 pred2 = MXC_CCM_CBCDR_PERCLK_PRED2_RD(podf);
318 podf = MXC_CCM_CBCDR_PERCLK_PODF_RD(podf);
319 return freq / ((pred1 + 1) * (pred2 + 1) * (podf + 1));
322 /* Get the output clock rate of a standard PLL MUX for peripherals. */
323 static u32 get_standard_pll_sel_clk(u32 clk_sel)
327 switch (clk_sel & 0x3) {
329 freq = decode_pll(mxc_plls[PLL1_CLOCK], MXC_HCLK);
332 freq = decode_pll(mxc_plls[PLL2_CLOCK], MXC_HCLK);
335 freq = decode_pll(mxc_plls[PLL3_CLOCK], MXC_HCLK);
346 * Get the rate of uart clk.
348 static u32 get_uart_clk(void)
350 unsigned int clk_sel, freq, reg, pred, podf;
352 reg = readl(&mxc_ccm->cscmr1);
353 clk_sel = MXC_CCM_CSCMR1_UART_CLK_SEL_RD(reg);
354 freq = get_standard_pll_sel_clk(clk_sel);
356 reg = readl(&mxc_ccm->cscdr1);
357 pred = MXC_CCM_CSCDR1_UART_CLK_PRED_RD(reg);
358 podf = MXC_CCM_CSCDR1_UART_CLK_PODF_RD(reg);
359 freq /= (pred + 1) * (podf + 1);
365 * get cspi clock rate.
367 static u32 imx_get_cspiclk(void)
369 u32 ret_val = 0, pdf, pre_pdf, clk_sel, freq;
370 u32 cscmr1 = readl(&mxc_ccm->cscmr1);
371 u32 cscdr2 = readl(&mxc_ccm->cscdr2);
373 pre_pdf = MXC_CCM_CSCDR2_CSPI_CLK_PRED_RD(cscdr2);
374 pdf = MXC_CCM_CSCDR2_CSPI_CLK_PODF_RD(cscdr2);
375 clk_sel = MXC_CCM_CSCMR1_CSPI_CLK_SEL_RD(cscmr1);
376 freq = get_standard_pll_sel_clk(clk_sel);
377 ret_val = freq / ((pre_pdf + 1) * (pdf + 1));
382 * get esdhc clock rate.
384 static u32 get_esdhc_clk(u32 port)
386 u32 clk_sel = 0, pred = 0, podf = 0, freq = 0;
387 u32 cscmr1 = readl(&mxc_ccm->cscmr1);
388 u32 cscdr1 = readl(&mxc_ccm->cscdr1);
392 clk_sel = MXC_CCM_CSCMR1_ESDHC1_MSHC1_CLK_SEL_RD(cscmr1);
393 pred = MXC_CCM_CSCDR1_ESDHC1_MSHC1_CLK_PRED_RD(cscdr1);
394 podf = MXC_CCM_CSCDR1_ESDHC1_MSHC1_CLK_PODF_RD(cscdr1);
397 clk_sel = MXC_CCM_CSCMR1_ESDHC2_MSHC2_CLK_SEL_RD(cscmr1);
398 pred = MXC_CCM_CSCDR1_ESDHC2_MSHC2_CLK_PRED_RD(cscdr1);
399 podf = MXC_CCM_CSCDR1_ESDHC2_MSHC2_CLK_PODF_RD(cscdr1);
402 if (cscmr1 & MXC_CCM_CSCMR1_ESDHC3_CLK_SEL)
403 return get_esdhc_clk(1);
405 return get_esdhc_clk(0);
407 if (cscmr1 & MXC_CCM_CSCMR1_ESDHC4_CLK_SEL)
408 return get_esdhc_clk(1);
410 return get_esdhc_clk(0);
415 freq = get_standard_pll_sel_clk(clk_sel) / ((pred + 1) * (podf + 1));
419 static u32 get_axi_a_clk(void)
421 u32 cbcdr = readl(&mxc_ccm->cbcdr);
422 u32 pdf = MXC_CCM_CBCDR_AXI_A_PODF_RD(cbcdr);
424 return get_periph_clk() / (pdf + 1);
427 static u32 get_axi_b_clk(void)
429 u32 cbcdr = readl(&mxc_ccm->cbcdr);
430 u32 pdf = MXC_CCM_CBCDR_AXI_B_PODF_RD(cbcdr);
432 return get_periph_clk() / (pdf + 1);
435 static u32 get_emi_slow_clk(void)
437 u32 cbcdr = readl(&mxc_ccm->cbcdr);
438 u32 emi_clk_sel = cbcdr & MXC_CCM_CBCDR_EMI_CLK_SEL;
439 u32 pdf = MXC_CCM_CBCDR_EMI_PODF_RD(cbcdr);
442 return get_ahb_clk() / (pdf + 1);
444 return get_periph_clk() / (pdf + 1);
447 static u32 get_ddr_clk(void)
450 u32 cbcmr = readl(&mxc_ccm->cbcmr);
451 u32 ddr_clk_sel = MXC_CCM_CBCMR_DDR_CLK_SEL_RD(cbcmr);
453 u32 cbcdr = readl(&mxc_ccm->cbcdr);
454 if (cbcdr & MXC_CCM_CBCDR_DDR_HIFREQ_SEL) {
455 u32 ddr_clk_podf = MXC_CCM_CBCDR_DDR_PODF_RD(cbcdr);
457 ret_val = decode_pll(mxc_plls[PLL1_CLOCK], MXC_HCLK);
458 ret_val /= ddr_clk_podf + 1;
463 switch (ddr_clk_sel) {
465 ret_val = get_axi_a_clk();
468 ret_val = get_axi_b_clk();
471 ret_val = get_emi_slow_clk();
474 ret_val = get_ahb_clk();
484 * The API of get mxc clocks.
486 unsigned int mxc_get_clock(enum mxc_clock clk)
490 return get_mcu_main_clk();
492 return get_ahb_clk();
494 return get_ipg_clk();
497 return get_ipg_per_clk();
499 return get_uart_clk();
501 return imx_get_cspiclk();
503 return get_esdhc_clk(0);
505 return get_esdhc_clk(1);
507 return get_esdhc_clk(2);
509 return get_esdhc_clk(3);
511 return get_ipg_clk();
513 return get_ahb_clk();
515 return get_ddr_clk();
522 u32 imx_get_uartclk(void)
524 return get_uart_clk();
527 u32 imx_get_fecclk(void)
529 return get_ipg_clk();
532 static int gcd(int m, int n)
547 * This is to calculate various parameters based on reference clock and
548 * targeted clock based on the equation:
549 * t_clk = 2*ref_freq*(mfi + mfn/(mfd+1))/(pd+1)
550 * This calculation is based on a fixed MFD value for simplicity.
552 static int calc_pll_params(u32 ref, u32 target, struct pll_param *pll)
554 u64 pd, mfi = 1, mfn, mfd, t1;
555 u32 n_target = target;
559 * Make sure targeted freq is in the valid range.
560 * Otherwise the following calculation might be wrong!!!
562 if (n_target < PLL_FREQ_MIN(ref) ||
563 n_target > PLL_FREQ_MAX(ref)) {
564 printf("Targeted peripheral clock should be"
565 "within [%d - %d]\n",
566 PLL_FREQ_MIN(ref) / SZ_DEC_1M,
567 PLL_FREQ_MAX(ref) / SZ_DEC_1M);
571 for (i = 0; i < ARRAY_SIZE(fixed_mfd); i++) {
572 if (fixed_mfd[i].ref_clk_hz == ref) {
573 mfd = fixed_mfd[i].mfd;
578 if (i == ARRAY_SIZE(fixed_mfd))
581 /* Use n_target and n_ref to avoid overflow */
582 for (pd = 1; pd <= PLL_PD_MAX; pd++) {
584 do_div(t1, (4 * n_ref));
586 if (mfi > PLL_MFI_MAX)
593 * Now got pd and mfi already
595 * mfn = (((n_target * pd) / 4 - n_ref * mfi) * mfd) / n_ref;
603 debug("ref=%d, target=%d, pd=%d," "mfi=%d,mfn=%d, mfd=%d\n",
604 ref, n_target, (u32)pd, (u32)mfi, (u32)mfn, (u32)mfd);
618 #define calc_div(tgt_clk, src_clk, limit) ({ \
620 if (((src_clk) % (tgt_clk)) <= 100) \
621 v = (src_clk) / (tgt_clk); \
623 v = ((src_clk) / (tgt_clk)) + 1;\
629 #define CHANGE_PLL_SETTINGS(pll, pd, fi, fn, fd) \
631 writel(0x1232, &pll->ctrl); \
632 writel(0x2, &pll->config); \
633 writel((((pd) - 1) << 0) | ((fi) << 4), \
635 writel(fn, &(pll->mfn)); \
636 writel((fd) - 1, &pll->mfd); \
637 writel((((pd) - 1) << 0) | ((fi) << 4), \
639 writel(fn, &pll->hfs_mfn); \
640 writel((fd) - 1, &pll->hfs_mfd); \
641 writel(0x1232, &pll->ctrl); \
642 while (!readl(&pll->ctrl) & 0x1) \
646 static int config_pll_clk(enum pll_clocks index, struct pll_param *pll_param)
648 u32 ccsr = readl(&mxc_ccm->ccsr);
649 struct mxc_pll_reg *pll = mxc_plls[index];
653 /* Switch ARM to PLL2 clock */
654 writel(ccsr | MXC_CCM_CCSR_PLL1_SW_CLK_SEL,
656 CHANGE_PLL_SETTINGS(pll, pll_param->pd,
657 pll_param->mfi, pll_param->mfn,
660 writel(ccsr & ~MXC_CCM_CCSR_PLL1_SW_CLK_SEL,
664 /* Switch to pll2 bypass clock */
665 writel(ccsr | MXC_CCM_CCSR_PLL2_SW_CLK_SEL,
667 CHANGE_PLL_SETTINGS(pll, pll_param->pd,
668 pll_param->mfi, pll_param->mfn,
671 writel(ccsr & ~MXC_CCM_CCSR_PLL2_SW_CLK_SEL,
675 /* Switch to pll3 bypass clock */
676 writel(ccsr | MXC_CCM_CCSR_PLL3_SW_CLK_SEL,
678 CHANGE_PLL_SETTINGS(pll, pll_param->pd,
679 pll_param->mfi, pll_param->mfn,
682 writel(ccsr & ~MXC_CCM_CCSR_PLL3_SW_CLK_SEL,
687 /* Switch to pll4 bypass clock */
688 writel(ccsr | MXC_CCM_CCSR_PLL4_SW_CLK_SEL,
690 CHANGE_PLL_SETTINGS(pll, pll_param->pd,
691 pll_param->mfi, pll_param->mfn,
694 writel(ccsr & ~MXC_CCM_CCSR_PLL4_SW_CLK_SEL,
705 /* Config CPU clock */
706 static int config_core_clk(u32 ref, u32 freq)
709 struct pll_param pll_param;
711 memset(&pll_param, 0, sizeof(struct pll_param));
713 /* The case that periph uses PLL1 is not considered here */
714 ret = calc_pll_params(ref, freq, &pll_param);
716 printf("Error:Can't find pll parameters: %d\n", ret);
720 return config_pll_clk(PLL1_CLOCK, &pll_param);
723 static int config_nfc_clk(u32 nfc_clk)
725 u32 parent_rate = get_emi_slow_clk();
730 div = parent_rate / nfc_clk;
733 if (parent_rate / div > NFC_CLK_MAX)
735 clrsetbits_le32(&mxc_ccm->cbcdr,
736 MXC_CCM_CBCDR_NFC_PODF_MASK,
737 MXC_CCM_CBCDR_NFC_PODF(div - 1));
738 while (readl(&mxc_ccm->cdhipr) != 0)
743 void enable_nfc_clk(unsigned char enable)
745 unsigned int cg = enable ? MXC_CCM_CCGR_CG_ON : MXC_CCM_CCGR_CG_OFF;
747 clrsetbits_le32(&mxc_ccm->CCGR5,
748 MXC_CCM_CCGR5_EMI_ENFC(MXC_CCM_CCGR_CG_MASK),
749 MXC_CCM_CCGR5_EMI_ENFC(cg));
752 #ifdef CONFIG_FSL_IIM
753 void enable_efuse_prog_supply(bool enable)
756 setbits_le32(&mxc_ccm->cgpr,
757 MXC_CCM_CGPR_EFUSE_PROG_SUPPLY_GATE);
759 clrbits_le32(&mxc_ccm->cgpr,
760 MXC_CCM_CGPR_EFUSE_PROG_SUPPLY_GATE);
764 /* Config main_bus_clock for periphs */
765 static int config_periph_clk(u32 ref, u32 freq)
768 struct pll_param pll_param;
770 memset(&pll_param, 0, sizeof(struct pll_param));
772 if (readl(&mxc_ccm->cbcdr) & MXC_CCM_CBCDR_PERIPH_CLK_SEL) {
773 ret = calc_pll_params(ref, freq, &pll_param);
775 printf("Error:Can't find pll parameters: %d\n",
779 switch (MXC_CCM_CBCMR_PERIPH_CLK_SEL_RD(
780 readl(&mxc_ccm->cbcmr))) {
782 return config_pll_clk(PLL1_CLOCK, &pll_param);
785 return config_pll_clk(PLL3_CLOCK, &pll_param);
795 static int config_ddr_clk(u32 emi_clk)
798 s32 shift = 0, clk_sel, div = 1;
799 u32 cbcmr = readl(&mxc_ccm->cbcmr);
801 if (emi_clk > MAX_DDR_CLK) {
802 printf("Warning:DDR clock should not exceed %d MHz\n",
803 MAX_DDR_CLK / SZ_DEC_1M);
804 emi_clk = MAX_DDR_CLK;
807 clk_src = get_periph_clk();
808 /* Find DDR clock input */
809 clk_sel = MXC_CCM_CBCMR_DDR_CLK_SEL_RD(cbcmr);
827 if ((clk_src % emi_clk) < 10000000)
828 div = clk_src / emi_clk;
830 div = (clk_src / emi_clk) + 1;
834 clrsetbits_le32(&mxc_ccm->cbcdr, 0x7 << shift, (div - 1) << shift);
835 while (readl(&mxc_ccm->cdhipr) != 0)
837 writel(0x0, &mxc_ccm->ccdr);
843 * This function assumes the expected core clock has to be changed by
844 * modifying the PLL. This is NOT true always but for most of the times,
845 * it is. So it assumes the PLL output freq is the same as the expected
846 * core clock (presc=1) unless the core clock is less than PLL_FREQ_MIN.
847 * In the latter case, it will try to increase the presc value until
848 * (presc*core_clk) is greater than PLL_FREQ_MIN. It then makes call to
849 * calc_pll_params() and obtains the values of PD, MFI,MFN, MFD based
850 * on the targeted PLL and reference input clock to the PLL. Lastly,
851 * it sets the register based on these values along with the dividers.
852 * Note 1) There is no value checking for the passed-in divider values
853 * so the caller has to make sure those values are sensible.
854 * 2) Also adjust the NFC divider such that the NFC clock doesn't
855 * exceed NFC_CLK_MAX.
856 * 3) IPU HSP clock is independent of AHB clock. Even it can go up to
857 * 177MHz for higher voltage, this function fixes the max to 133MHz.
858 * 4) This function should not have allowed diag_printf() calls since
859 * the serial driver has been stoped. But leave then here to allow
860 * easy debugging by NOT calling the cyg_hal_plf_serial_stop().
862 int mxc_set_clock(u32 ref, u32 freq, enum mxc_clock clk)
868 if (config_core_clk(ref, freq))
872 if (config_periph_clk(ref, freq))
876 if (config_ddr_clk(freq))
880 if (config_nfc_clk(freq))
884 printf("Warning:Unsupported or invalid clock type\n");
892 * The clock for the external interface can be set to use internal clock
893 * if fuse bank 4, row 3, bit 2 is set.
894 * This is an undocumented feature and it was confirmed by Freescale's support:
895 * Fuses (but not pins) may be used to configure SATA clocks.
896 * Particularly the i.MX53 Fuse_Map contains the next information
897 * about configuring SATA clocks : SATA_ALT_REF_CLK[1:0] (offset 0x180C)
898 * '00' - 100MHz (External)
899 * '01' - 50MHz (External)
900 * '10' - 120MHz, internal (USB PHY)
903 void mxc_set_sata_internal_clock(void)
906 (u32 *)(IIM_BASE_ADDR + 0x180c);
910 clrsetbits_le32(tmp_base, 0x6, 0x4);
914 #ifndef CONFIG_SPL_BUILD
916 * Dump some core clockes.
918 static int do_mx5_showclocks(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
922 freq = decode_pll(mxc_plls[PLL1_CLOCK], MXC_HCLK);
923 printf("PLL1 %8d MHz\n", freq / 1000000);
924 freq = decode_pll(mxc_plls[PLL2_CLOCK], MXC_HCLK);
925 printf("PLL2 %8d MHz\n", freq / 1000000);
926 freq = decode_pll(mxc_plls[PLL3_CLOCK], MXC_HCLK);
927 printf("PLL3 %8d MHz\n", freq / 1000000);
929 freq = decode_pll(mxc_plls[PLL4_CLOCK], MXC_HCLK);
930 printf("PLL4 %8d MHz\n", freq / 1000000);
934 printf("AHB %8d kHz\n", mxc_get_clock(MXC_AHB_CLK) / 1000);
935 printf("IPG %8d kHz\n", mxc_get_clock(MXC_IPG_CLK) / 1000);
936 printf("IPG PERCLK %8d kHz\n", mxc_get_clock(MXC_IPG_PERCLK) / 1000);
937 printf("DDR %8d kHz\n", mxc_get_clock(MXC_DDR_CLK) / 1000);
938 #ifdef CONFIG_MXC_SPI
939 printf("CSPI %8d kHz\n", mxc_get_clock(MXC_CSPI_CLK) / 1000);
944 /***************************************************/
947 clocks, CONFIG_SYS_MAXARGS, 1, do_mx5_showclocks,