2003-03-31 17:27:09 +00:00
|
|
|
/*
|
|
|
|
* (C) Copyright 2003
|
|
|
|
* Martin Winistoerfer, martinwinistoerfer@gmx.ch.
|
|
|
|
*
|
2013-07-08 07:37:19 +00:00
|
|
|
* SPDX-License-Identifier: GPL-2.0+
|
2003-03-31 17:27:09 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* File: speed.c
|
2003-06-27 21:31:46 +00:00
|
|
|
*
|
2003-03-31 17:27:09 +00:00
|
|
|
* Discription: Provides cpu speed calculation
|
2003-06-27 21:31:46 +00:00
|
|
|
*
|
2003-03-31 17:27:09 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <mpc5xx.h>
|
|
|
|
#include <asm/processor.h>
|
|
|
|
|
2006-03-31 16:32:53 +00:00
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
|
|
|
|
2003-03-31 17:27:09 +00:00
|
|
|
/*
|
|
|
|
* Get cpu and bus clock
|
|
|
|
*/
|
|
|
|
int get_clocks (void)
|
|
|
|
{
|
2008-10-16 13:01:15 +00:00
|
|
|
volatile immap_t *immr = (immap_t *) CONFIG_SYS_IMMR;
|
2003-03-31 17:27:09 +00:00
|
|
|
|
|
|
|
#ifndef CONFIG_5xx_GCLK_FREQ
|
|
|
|
uint divf = (immr->im_clkrst.car_plprcr & PLPRCR_DIVF_MSK);
|
|
|
|
uint mf = ((immr->im_clkrst.car_plprcr & PLPRCR_MF_MSK) >> PLPRCR_MF_SHIFT);
|
|
|
|
ulong vcoout;
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
vcoout = (CONFIG_SYS_OSC_CLK / (divf + 1)) * (mf + 1) * 2;
|
2003-03-31 17:27:09 +00:00
|
|
|
if(immr->im_clkrst.car_plprcr & PLPRCR_CSRC_MSK) {
|
|
|
|
gd->cpu_clk = vcoout / (2^(((immr->im_clkrst.car_sccr & SCCR_DFNL_MSK) >> SCCR_DFNL_SHIFT) + 1));
|
|
|
|
} else {
|
2008-05-20 14:00:29 +00:00
|
|
|
gd->cpu_clk = vcoout / (2^(immr->im_clkrst.car_sccr & SCCR_DFNH_MSK));
|
|
|
|
}
|
2003-06-27 21:31:46 +00:00
|
|
|
|
2003-03-31 17:27:09 +00:00
|
|
|
#else /* CONFIG_5xx_GCLK_FREQ */
|
|
|
|
gd->bus_clk = CONFIG_5xx_GCLK_FREQ;
|
|
|
|
#endif /* CONFIG_5xx_GCLK_FREQ */
|
|
|
|
|
|
|
|
if ((immr->im_clkrst.car_sccr & SCCR_EBDF11) == 0) {
|
|
|
|
/* No Bus Divider active */
|
|
|
|
gd->bus_clk = gd->cpu_clk;
|
|
|
|
} else {
|
|
|
|
/* CLKOUT is GCLK / 2 */
|
|
|
|
gd->bus_clk = gd->cpu_clk / 2;
|
|
|
|
}
|
|
|
|
return (0);
|
|
|
|
}
|