]> git.sur5r.net Git - u-boot/blob - cpu/mips/incaip_clock.c
* Add support for MIPS32 4Kc CPUs
[u-boot] / cpu / mips / incaip_clock.c
1 /*
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
28
29 /*******************************************************************************
30 *
31 * get_cpuclk - returns the frequency of the CPU. 
32 *
33 * Gets the value directly from the INCA-IP hardware.
34 *
35 * RETURNS: 
36 *          150.000.000 for 150 MHz
37 *          130.000.000. for 130 Mhz
38 *          100.000.000. for 100 Mhz
39 * NOTE:
40 *   This functions should be used by the hardware driver to get the correct
41 *   frequency of the CPU. Don't use the macros, which are set to init the CPU
42 *   frequency in the ROM code.
43 */
44 uint incaip_get_cpuclk(void)
45 {
46    /*-------------------------------------------------------------------------*/
47    /* CPU Clock Input Multiplexer (MUX I)                                     */
48    /* Multiplexer MUX I selects the maximum input clock to the CPU.           */
49    /*-------------------------------------------------------------------------*/
50    if (*((volatile ulong*)INCA_IP_CGU_CGU_MUXCR) & INCA_IP_CGU_CGU_MUXCR_MUXI)
51    {
52       /* MUX I set to 150 MHz clock */
53       return 150000000;
54    }
55    else
56    {
57       /* MUX I set to 100/133 MHz clock */
58       if (*((volatile ulong*)INCA_IP_CGU_CGU_DIVCR) & 0x40) 
59       {
60          /* Division value is 1/3, maximum CPU operating */
61          /* frequency is 133.3 MHz                       */
62          return 130000000;
63       }
64       else
65       {
66          /* Division value is 1/4, maximum CPU operating */
67          /* frequency is 100 MHz                         */
68          return 100000000;
69       }
70    }
71 }
72
73 /*******************************************************************************
74 *
75 * get_fpiclk - returns the frequency of the FPI bus. 
76 *
77 * Gets the value directly from the INCA-IP hardware.
78 *
79 * RETURNS: Frquency in Hz
80 *
81 * NOTE:
82 *   This functions should be used by the hardware driver to get the correct
83 *   frequency of the CPU. Don't use the macros, which are set to init the CPU
84 *   frequency in the ROM code.
85 *   The calculation for the 
86 */
87 uint incaip_get_fpiclk(void)
88 {
89    uint  clkCPU;
90    
91    clkCPU = incaip_get_cpuclk();
92    
93    switch (*((volatile ulong*)INCA_IP_CGU_CGU_DIVCR) & 0xC)
94    {
95       case 0x4:
96          return clkCPU >> 1; /* devided by 2 */
97          break;
98       case 0x8:
99          return clkCPU >> 2; /* devided by 4 */
100          break;
101       default:
102          return clkCPU;
103          break;
104    }
105 }
106
107