blob: 27f0609664dd8d98e2d1c7358a120ffff4178e4e [file] [log] [blame]
wdenkc0218802003-03-27 12:09:35 +00001/*
2 * (C) Copyright 2003
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4 *
5 * See file CREDITS for list of people who contributed to this
6 * project.
7 *
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.
12 *
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.
17 *
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,
21 * MA 02111-1307 USA
22 */
23
24#include <common.h>
25#include <asm/inca-ip.h>
26
27
wdenkc0218802003-03-27 12:09:35 +000028/*******************************************************************************
29*
wdenk8bde7f72003-06-27 21:31:46 +000030* get_cpuclk - returns the frequency of the CPU.
wdenkc0218802003-03-27 12:09:35 +000031*
32* Gets the value directly from the INCA-IP hardware.
33*
wdenk8bde7f72003-06-27 21:31:46 +000034* RETURNS:
wdenkc0218802003-03-27 12:09:35 +000035* 150.000.000 for 150 MHz
36* 130.000.000. for 130 Mhz
37* 100.000.000. for 100 Mhz
38* NOTE:
39* This functions should be used by the hardware driver to get the correct
40* frequency of the CPU. Don't use the macros, which are set to init the CPU
41* frequency in the ROM code.
42*/
43uint incaip_get_cpuclk(void)
44{
45 /*-------------------------------------------------------------------------*/
46 /* CPU Clock Input Multiplexer (MUX I) */
47 /* Multiplexer MUX I selects the maximum input clock to the CPU. */
48 /*-------------------------------------------------------------------------*/
49 if (*((volatile ulong*)INCA_IP_CGU_CGU_MUXCR) & INCA_IP_CGU_CGU_MUXCR_MUXI)
50 {
51 /* MUX I set to 150 MHz clock */
52 return 150000000;
53 }
54 else
55 {
56 /* MUX I set to 100/133 MHz clock */
wdenk8bde7f72003-06-27 21:31:46 +000057 if (*((volatile ulong*)INCA_IP_CGU_CGU_DIVCR) & 0x40)
wdenkc0218802003-03-27 12:09:35 +000058 {
wdenk8bde7f72003-06-27 21:31:46 +000059 /* Division value is 1/3, maximum CPU operating */
60 /* frequency is 133.3 MHz */
61 return 130000000;
wdenkc0218802003-03-27 12:09:35 +000062 }
63 else
64 {
wdenk8bde7f72003-06-27 21:31:46 +000065 /* Division value is 1/4, maximum CPU operating */
66 /* frequency is 100 MHz */
67 return 100000000;
wdenkc0218802003-03-27 12:09:35 +000068 }
69 }
70}
71
72/*******************************************************************************
73*
wdenk8bde7f72003-06-27 21:31:46 +000074* get_fpiclk - returns the frequency of the FPI bus.
wdenkc0218802003-03-27 12:09:35 +000075*
76* Gets the value directly from the INCA-IP hardware.
77*
78* RETURNS: Frquency in Hz
79*
80* NOTE:
81* This functions should be used by the hardware driver to get the correct
82* frequency of the CPU. Don't use the macros, which are set to init the CPU
83* frequency in the ROM code.
wdenk8bde7f72003-06-27 21:31:46 +000084* The calculation for the
wdenkc0218802003-03-27 12:09:35 +000085*/
86uint incaip_get_fpiclk(void)
87{
88 uint clkCPU;
wdenk8bde7f72003-06-27 21:31:46 +000089
wdenkc0218802003-03-27 12:09:35 +000090 clkCPU = incaip_get_cpuclk();
wdenk8bde7f72003-06-27 21:31:46 +000091
wdenkc0218802003-03-27 12:09:35 +000092 switch (*((volatile ulong*)INCA_IP_CGU_CGU_DIVCR) & 0xC)
93 {
94 case 0x4:
wdenk8bde7f72003-06-27 21:31:46 +000095 return clkCPU >> 1; /* devided by 2 */
96 break;
wdenkc0218802003-03-27 12:09:35 +000097 case 0x8:
wdenk8bde7f72003-06-27 21:31:46 +000098 return clkCPU >> 2; /* devided by 4 */
99 break;
wdenkc0218802003-03-27 12:09:35 +0000100 default:
wdenk8bde7f72003-06-27 21:31:46 +0000101 return clkCPU;
102 break;
wdenkc0218802003-03-27 12:09:35 +0000103 }
104}