3 * Sascha Hauer, Pengutronix
5 * (C) Copyright 2009-2010 Freescale Semiconductor
7 * See file CREDITS for list of people who contributed to this
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License as
12 * published by the Free Software Foundation; either version 2 of
13 * the License, or (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
27 #include <asm/errno.h>
28 #include <asm/arch/mx25-regs.h>
30 static u32 mx25_decode_pll(u32 reg)
32 u32 mfi = (reg >> 10) & 0xf;
33 u32 mfn = reg & 0x3ff;
34 u32 mfd = (reg >> 16) & 0x3ff;
35 u32 pd = (reg >> 26) & 0xf;
37 u32 ref_clk = PLL_REF_CLK;
39 mfi = mfi <= 5 ? 5 : mfi;
43 return ((2 * (ref_clk >> 10) * (mfi * mfd + mfn)) /
47 static u32 mx25_get_mcu_main_clk(void)
49 u32 cctl = __REG(CCM_CCTL);
50 u32 ret_val = mx25_decode_pll(__REG(CCM_MPCTL));
52 if (cctl & CRM_CCTL_ARM_SRC) {
60 static u32 mx25_get_ahb_clk(void)
62 u32 cctl = __REG(CCM_CCTL);
63 u32 ahb_div = ((cctl >> CRM_CCTL_AHB_OFFSET) & 3) + 1;
65 return mx25_get_mcu_main_clk()/ahb_div;
68 unsigned int mx25_get_ipg_clk(void)
70 return mx25_get_ahb_clk()/2;
73 unsigned int mx25_get_cspi_clk(void)
75 return mx25_get_ipg_clk();
78 void mx25_dump_clocks(void)
80 u32 cpufreq = mx25_get_mcu_main_clk();
81 printf("mx25 cpu clock: %dMHz\n", cpufreq / 1000000);
82 printf("ipg clock : %dHz\n", mx25_get_ipg_clk());
85 unsigned int mxc_get_clock(enum mxc_clock clk)
89 return mx25_get_mcu_main_clk();
91 return mx25_get_ahb_clk();
95 return mx25_get_ipg_clk();
97 return mx25_get_cspi_clk();
101 return mx25_get_ipg_clk();
107 #if defined(CONFIG_DISPLAY_CPUINFO)
108 int print_cpuinfo(void)
110 printf("CPU: Freescale i.MX25 at %d MHz\n",
111 mx25_get_mcu_main_clk() / 1000000);
117 #if defined(CONFIG_MXC_FEC)
118 extern int mxc_fec_initialize(bd_t *bis);
119 extern void mxc_fec_set_mac_from_env(char *mac_addr);
123 * Initializes on-chip ethernet controllers.
124 * to override, implement board_eth_init()
126 int cpu_eth_init(bd_t *bis)
130 #if defined(CONFIG_MXC_FEC)
131 rc = mxc_fec_initialize(bis);