summaryrefslogtreecommitdiff
path: root/package/uboot-ifxmips/files/cpu/mips/danube/ifx_clock.c
blob: c67cf15eb3bc49151c0f498ec64d7141a2e53147 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/*
 * (C) Copyright 2003
 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 *
 * See file CREDITS for list of people who contributed to this
 * project.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of
 * the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 * MA 02111-1307 USA
 */

#include <common.h>
#include <asm-mips/danube.h>



/*******************************************************************************
*
* get_cpuclk - returns the frequency of the CPU. 
*
* NOTE:
*   This functions should be used by the hardware driver to get the correct
*   frequency of the CPU. 
*/

unsigned int danube_get_ddr_hz(void)
{
	switch((*DANUBE_CGU_SYS) & 0x3){
		case 0:
		default:
			return 166666667;
		case 1:
			return 133333333;
		case 2:
			return 111111111;
		case 3:
			return 83333333;
	}
}


uint danube_get_cpuclk(void)
{
#ifdef CONFIG_USE_EMULATOR
	return EMULATOR_CPU_SPEED;
#else //NOT CONFIG_USE_EMULATOR
	unsigned int ddr_clock=danube_get_ddr_hz();
	switch((*DANUBE_CGU_SYS) & 0xc){
		case 0:
		default:
			return 333333333;
		case 4:
			return ddr_clock;
		case 8:
			return ddr_clock << 1;
	}
#endif
}


uint danube_get_fpiclk(void)
{
#ifdef CONFIG_USE_EMULATOR
	unsigned int  clkCPU;
	clkCPU = danube_get_cpu_hz();
	return clkCPU >> 2;
#else //NOT CONFIG_USE_EMULATOR
	unsigned int ddr_clock=danube_get_ddr_hz();
	if ((*DANUBE_CGU_SYS) & 0x40){
		return ddr_clock >> 1;
	}
	return ddr_clock;
#endif
}