3 * Wolfgang Denk, DENX Software Engineering, wd@denx.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,
27 #include <asm/inca-ip.h>
30 /*******************************************************************************
32 * get_cpuclk - returns the frequency of the CPU.
34 * Gets the value directly from the INCA-IP hardware.
37 * 150.000.000 for 150 MHz
38 * 133.333.333 for 133 Mhz (= 400MHz/3)
39 * 100.000.000 for 100 Mhz (= 400MHz/4)
41 * This functions should be used by the hardware driver to get the correct
42 * frequency of the CPU. Don't use the macros, which are set to init the CPU
43 * frequency in the ROM code.
45 uint
incaip_get_cpuclk (void)
47 /*-------------------------------------------------------------------------*/
48 /* CPU Clock Input Multiplexer (MUX I) */
49 /* Multiplexer MUX I selects the maximum input clock to the CPU. */
50 /*-------------------------------------------------------------------------*/
51 if (*((volatile ulong
*) INCA_IP_CGU_CGU_MUXCR
) &
52 INCA_IP_CGU_CGU_MUXCR_MUXI
) {
53 /* MUX I set to 150 MHz clock */
56 /* MUX I set to 100/133 MHz clock */
57 if (*((volatile ulong
*) INCA_IP_CGU_CGU_DIVCR
) & 0x40) {
58 /* Division value is 1/3, maximum CPU operating */
59 /* frequency is 133.3 MHz */
62 /* Division value is 1/4, maximum CPU operating */
63 /* frequency is 100 MHz */
69 /*******************************************************************************
71 * get_fpiclk - returns the frequency of the FPI bus.
73 * Gets the value directly from the INCA-IP hardware.
75 * RETURNS: Frquency in Hz
78 * This functions should be used by the hardware driver to get the correct
79 * frequency of the CPU. Don't use the macros, which are set to init the CPU
80 * frequency in the ROM code.
81 * The calculation for the
83 uint
incaip_get_fpiclk (void)
87 clkCPU
= incaip_get_cpuclk ();
89 switch (*((volatile ulong
*) INCA_IP_CGU_CGU_DIVCR
) & 0xC) {
91 return clkCPU
>> 1; /* devided by 2 */
94 return clkCPU
>> 2; /* devided by 4 */
102 int incaip_set_cpuclk (void)
104 extern void ebu_init(long);
105 extern void cgu_init(long);
106 extern void sdram_init(long);
110 if (getenv_r ("cpuclk", tmp
, sizeof (tmp
)) > 0) {
111 cpuclk
= simple_strtoul (tmp
, NULL
, 10) * 1000000;
120 #endif /* CONFIG_INCA_IP */