2 * (C) Copyright 2001-2004
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
6 * David Mueller, ELSOFT AG, d.mueller@elsoft.ch
8 * See file CREDITS for list of people who contributed to this
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License as
13 * published by the Free Software Foundation; either version 2 of
14 * the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
31 /* ------------------------------------------------------------------------- */
32 /* NOTE: This describes the proper use of this file.
34 * CONFIG_SYS_CLK_FREQ should be defined as the input frequency of the PLL.
36 * get_FCLK(), get_HCLK(), get_PCLK() return the clock of
37 * the specified bus in HZ.
39 /* ------------------------------------------------------------------------- */
41 ulong get_PLLCLK (void)
43 return CONFIG_SYS_CLK_FREQ;
46 /* return FCLK frequency */
49 lh7a40x_csc_t* csc = LH7A40X_CSC_PTR;
50 ulong maindiv1, maindiv2, prediv, ps;
53 * from userguide 6.1.1.2
55 * FCLK = ((MAINDIV1 +2) * (MAINDIV2 +2) * 14.7456MHz) /
56 * ((PREDIV+2) * (2^PS))
58 maindiv2 = (csc->clkset & CLKSET_MAINDIV2) >> 11;
59 maindiv1 = (csc->clkset & CLKSET_MAINDIV1) >> 7;
60 prediv = (csc->clkset & CLKSET_PREDIV) >> 2;
61 ps = (csc->clkset & CLKSET_PS) >> 16;
63 return (((maindiv2 + 2) * (maindiv1 + 2) * CONFIG_SYS_CLK_FREQ) /
64 ((prediv + 2) * (1 << ps)));
68 /* return HCLK frequency */
71 lh7a40x_csc_t* csc = LH7A40X_CSC_PTR;
73 return (get_FCLK () / ((csc->clkset & CLKSET_HCLKDIV) + 1));
76 /* return PCLK frequency */
79 lh7a40x_csc_t* csc = LH7A40X_CSC_PTR;
82 (1 << (((csc->clkset & CLKSET_PCLKDIV) >> 16) + 1)));