3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5 * SPDX-License-Identifier: GPL-2.0+
9 #include <asm/inca-ip.h>
12 /*******************************************************************************
14 * get_cpuclk - returns the frequency of the CPU.
16 * Gets the value directly from the INCA-IP hardware.
19 * 150.000.000 for 150 MHz
20 * 133.333.333 for 133 MHz (= 400MHz/3)
21 * 100.000.000 for 100 MHz (= 400MHz/4)
23 * This functions should be used by the hardware driver to get the correct
24 * frequency of the CPU. Don't use the macros, which are set to init the CPU
25 * frequency in the ROM code.
27 uint incaip_get_cpuclk (void)
29 /*-------------------------------------------------------------------------*/
30 /* CPU Clock Input Multiplexer (MUX I) */
31 /* Multiplexer MUX I selects the maximum input clock to the CPU. */
32 /*-------------------------------------------------------------------------*/
33 if (*((volatile ulong *) INCA_IP_CGU_CGU_MUXCR) &
34 INCA_IP_CGU_CGU_MUXCR_MUXI) {
35 /* MUX I set to 150 MHz clock */
38 /* MUX I set to 100/133 MHz clock */
39 if (*((volatile ulong *) INCA_IP_CGU_CGU_DIVCR) & 0x40) {
40 /* Division value is 1/3, maximum CPU operating */
41 /* frequency is 133.3 MHz */
44 /* Division value is 1/4, maximum CPU operating */
45 /* frequency is 100 MHz */
51 /*******************************************************************************
53 * get_fpiclk - returns the frequency of the FPI bus.
55 * Gets the value directly from the INCA-IP hardware.
57 * RETURNS: Frquency in Hz
60 * This functions should be used by the hardware driver to get the correct
61 * frequency of the CPU. Don't use the macros, which are set to init the CPU
62 * frequency in the ROM code.
63 * The calculation for the
65 uint incaip_get_fpiclk (void)
69 clkCPU = incaip_get_cpuclk ();
71 switch (*((volatile ulong *) INCA_IP_CGU_CGU_DIVCR) & 0xC) {
73 return clkCPU >> 1; /* devided by 2 */
76 return clkCPU >> 2; /* devided by 4 */
84 int incaip_set_cpuclk (void)
86 extern void ebu_init(long);
87 extern void cgu_init(long);
88 extern void sdram_init(long);
92 if (getenv_f("cpuclk", tmp, sizeof (tmp)) > 0) {
93 cpuclk = simple_strtoul (tmp, NULL, 10) * 1000000;