]>
git.ipfire.org Git - people/ms/u-boot.git/blob - arch/ppc/cpu/mpc86xx/speed.c
2 * Copyright 2004 Freescale Semiconductor.
4 * Srikanth Srinivasan (srikanth.srinivasan@freescale.com)
6 * (C) Copyright 2000-2002
7 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
9 * See file CREDITS for list of people who contributed to this
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License as
14 * published by the Free Software Foundation; either version 2 of
15 * the License, or (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
30 #include <asm/processor.h>
33 DECLARE_GLOBAL_DATA_PTR
;
35 /* used in some defintiions of CONFIG_SYS_CLK_FREQ */
36 extern unsigned long get_board_sys_clk(unsigned long dummy
);
38 void get_sys_info(sys_info_t
*sysInfo
)
40 volatile immap_t
*immap
= (immap_t
*) CONFIG_SYS_IMMR
;
41 volatile ccsr_gur_t
*gur
= &immap
->im_gur
;
42 uint plat_ratio
, e600_ratio
;
45 plat_ratio
= (gur
->porpllsr
) & 0x0000003e;
50 sysInfo
->freqSystemBus
= 16 * CONFIG_SYS_CLK_FREQ
;
62 sysInfo
->freqSystemBus
= plat_ratio
* CONFIG_SYS_CLK_FREQ
;
65 sysInfo
->freqSystemBus
= 0;
69 e600_ratio
= (gur
->porpllsr
) & 0x003f0000;
74 sysInfo
->freqProcessor
= 2 * sysInfo
->freqSystemBus
;
77 sysInfo
->freqProcessor
= 5 * sysInfo
->freqSystemBus
/ 2;
80 sysInfo
->freqProcessor
= 3 * sysInfo
->freqSystemBus
;
83 sysInfo
->freqProcessor
= 7 * sysInfo
->freqSystemBus
/ 2;
86 sysInfo
->freqProcessor
= 4 * sysInfo
->freqSystemBus
;
89 sysInfo
->freqProcessor
= 9 * sysInfo
->freqSystemBus
/ 2;
92 sysInfo
->freqProcessor
= e600_ratio
+ sysInfo
->freqSystemBus
;
96 #if defined(CONFIG_SYS_LBC_LCRR)
97 /* We will program LCRR to this value later */
98 lcrr_div
= CONFIG_SYS_LBC_LCRR
& LCRR_CLKDIV
;
101 volatile ccsr_lbc_t
*lbc
= &immap
->im_lbc
;
102 lcrr_div
= in_be32(&lbc
->lcrr
) & LCRR_CLKDIV
;
105 if (lcrr_div
== 2 || lcrr_div
== 4 || lcrr_div
== 8) {
106 sysInfo
->freqLocalBus
= sysInfo
->freqSystemBus
/ (lcrr_div
* 2);
108 /* In case anyone cares what the unknown value is */
109 sysInfo
->freqLocalBus
= lcrr_div
;
115 * Measure CPU clock speed (core clock GCLK1, GCLK2)
116 * (Approx. GCLK frequency in Hz)
123 get_sys_info(&sys_info
);
124 gd
->cpu_clk
= sys_info
.freqProcessor
;
125 gd
->bus_clk
= sys_info
.freqSystemBus
;
126 gd
->lbc_clk
= sys_info
.freqLocalBus
;
129 * The base clock for I2C depends on the actual SOC. Unfortunately,
130 * there is no pattern that can be used to determine the frequency, so
131 * the only choice is to look up the actual SOC number and use the value
132 * for that SOC. This information is taken from application note
135 #ifdef CONFIG_MPC8610
136 gd
->i2c1_clk
= sys_info
.freqSystemBus
;
138 gd
->i2c1_clk
= sys_info
.freqSystemBus
/ 2;
140 gd
->i2c2_clk
= gd
->i2c1_clk
;
142 if (gd
->cpu_clk
!= 0)
151 * Return system bus freq in Hz
154 ulong
get_bus_freq(ulong dummy
)
159 get_sys_info(&sys_info
);
160 val
= sys_info
.freqSystemBus
;