3 * (c) 2004 Sascha Hauer <sascha@saschahauer.de>
5 * See file CREDITS for list of people who contributed to this
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
26 #if defined (CONFIG_IMX)
28 #include <asm/arch/imx-regs.h>
30 /* ------------------------------------------------------------------------- */
31 /* NOTE: This describes the proper use of this file.
33 * CONFIG_SYS_CLK_FREQ should be defined as the input frequency of the PLL.
34 * SH FIXME: 16780000 in our case
35 * get_FCLK(), get_HCLK(), get_PCLK() and get_UCLK() return the clock of
36 * the specified bus in HZ.
38 /* ------------------------------------------------------------------------- */
40 ulong
get_systemPLLCLK(void)
42 /* FIXME: We assume System_SEL = 0 here */
44 u32 mfi
= (spctl0
>> 10) & 0xf;
45 u32 mfn
= spctl0
& 0x3f;
46 u32 mfd
= (spctl0
>> 16) & 0x3f;
47 u32 pd
= (spctl0
>> 26) & 0xf;
49 mfi
= mfi
<=5 ? 5 : mfi
;
51 return (2*(CONFIG_SYSPLL_CLK_FREQ
>>10)*( (mfi
<<10) + (mfn
<<10)/(mfd
+1)))/(pd
+1);
54 ulong
get_mcuPLLCLK(void)
56 /* FIXME: We assume System_SEL = 0 here */
58 u32 mfi
= (mpctl0
>> 10) & 0xf;
59 u32 mfn
= mpctl0
& 0x3f;
60 u32 mfd
= (mpctl0
>> 16) & 0x3f;
61 u32 pd
= (mpctl0
>> 26) & 0xf;
63 mfi
= mfi
<=5 ? 5 : mfi
;
65 return (2*(CONFIG_SYS_CLK_FREQ
>>10)*( (mfi
<<10) + (mfn
<<10)/(mfd
+1)))/(pd
+1);
70 return (( CSCR
>>15)&1) ? get_mcuPLLCLK()>>1 : get_mcuPLLCLK();
73 /* return HCLK frequency */
76 u32 bclkdiv
= (( CSCR
>> 10 ) & 0xf) + 1;
77 printf("bclkdiv: %d\n", bclkdiv
);
78 return get_systemPLLCLK() / bclkdiv
;
81 /* return BCLK frequency */
87 ulong
get_PERCLK1(void)
89 return get_systemPLLCLK() / (((PCDR
) & 0xf)+1);
92 ulong
get_PERCLK2(void)
94 return get_systemPLLCLK() / (((PCDR
>>4) & 0xf)+1);
97 ulong
get_PERCLK3(void)
99 return get_systemPLLCLK() / (((PCDR
>>16) & 0x7f)+1);
102 #endif /* defined (CONFIG_IMX) */