]>
git.ipfire.org Git - people/ms/u-boot.git/blob - cpu/mpc5xx/speed.c
3 * Martin Winistoerfer, martinwinistoerfer@gmx.ch.
5 * See file CREDITS for list of people who contributed to this
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.
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.
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
26 * Discription: Provides cpu speed calculation
32 #include <asm/processor.h>
35 * Get cpu and bus clock
39 DECLARE_GLOBAL_DATA_PTR
;
40 volatile immap_t
*immr
= (immap_t
*) CFG_IMMR
;
42 #ifndef CONFIG_5xx_GCLK_FREQ
43 uint divf
= (immr
->im_clkrst
.car_plprcr
& PLPRCR_DIVF_MSK
);
44 uint mf
= ((immr
->im_clkrst
.car_plprcr
& PLPRCR_MF_MSK
) >> PLPRCR_MF_SHIFT
);
47 vcoout
= (CFG_OSC_CLK
/ (divf
+ 1)) * (mf
+ 1) * 2;
48 if(immr
->im_clkrst
.car_plprcr
& PLPRCR_CSRC_MSK
) {
49 gd
->cpu_clk
= vcoout
/ (2^(((immr
->im_clkrst
.car_sccr
& SCCR_DFNL_MSK
) >> SCCR_DFNL_SHIFT
) + 1));
51 gd
->cpu_clk
= vcoout
/ (2^(immr
->im_clkrst
.car_sccr
& SCCR_DFNH_MSK
));
54 #else /* CONFIG_5xx_GCLK_FREQ */
55 gd
->bus_clk
= CONFIG_5xx_GCLK_FREQ
;
56 #endif /* CONFIG_5xx_GCLK_FREQ */
58 if ((immr
->im_clkrst
.car_sccr
& SCCR_EBDF11
) == 0) {
59 /* No Bus Divider active */
60 gd
->bus_clk
= gd
->cpu_clk
;
62 /* CLKOUT is GCLK / 2 */
63 gd
->bus_clk
= gd
->cpu_clk
/ 2;