2003-10-15 23:53:47 +00:00
|
|
|
/*
|
2009-07-31 06:38:14 +00:00
|
|
|
* Copyright 2004, 2007-2009 Freescale Semiconductor, Inc.
|
2003-10-15 23:53:47 +00:00
|
|
|
* (C) Copyright 2003 Motorola Inc.
|
|
|
|
* Xianghua Xiao, (X.Xiao@motorola.com)
|
|
|
|
*
|
|
|
|
* (C) Copyright 2000
|
|
|
|
* 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 <ppc_asm.tmpl>
|
|
|
|
#include <asm/processor.h>
|
mpc8[56]xx: Put localbus clock in sysinfo and gd
Currently MPC85xx and MPC86xx boards just calculate the localbus frequency
and print it out, but don't save it.
This changes where its calculated and stored to be more consistent with the
CPU, CCB, TB, and DDR frequencies and the MPC83xx localbus clock.
The localbus frequency is added to sysinfo and calculated when sysinfo is
set up, in cpu/mpc8[56]xx/speed.c, the same as the other frequencies are.
get_clocks() copies the frequency into the global data, as the other
frequencies are, into a new field that is only enabled for MPC85xx and
MPC86xx.
checkcpu() in cpu/mpc8[56]xx/cpu.c will print out the local bus frequency
from sysinfo, like the other frequencies, instead of calculating it on the
spot.
Signed-off-by: Trent Piepho <tpiepho@freescale.com>
Acked-by: Kumar Gala <galak@kernel.crashing.org>
Acked-by: Jon Loeliger <jdl@freescale.com>
2008-12-03 23:16:37 +00:00
|
|
|
#include <asm/io.h>
|
2003-10-15 23:53:47 +00:00
|
|
|
|
2006-03-31 16:32:53 +00:00
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
|
|
|
|
2003-10-15 23:53:47 +00:00
|
|
|
/* --------------------------------------------------------------- */
|
|
|
|
|
|
|
|
void get_sys_info (sys_info_t * sysInfo)
|
|
|
|
{
|
2008-10-16 13:01:15 +00:00
|
|
|
volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
|
2007-04-23 07:37:47 +00:00
|
|
|
uint plat_ratio,e500_ratio,half_freqSystemBus;
|
mpc8[56]xx: Put localbus clock in sysinfo and gd
Currently MPC85xx and MPC86xx boards just calculate the localbus frequency
and print it out, but don't save it.
This changes where its calculated and stored to be more consistent with the
CPU, CCB, TB, and DDR frequencies and the MPC83xx localbus clock.
The localbus frequency is added to sysinfo and calculated when sysinfo is
set up, in cpu/mpc8[56]xx/speed.c, the same as the other frequencies are.
get_clocks() copies the frequency into the global data, as the other
frequencies are, into a new field that is only enabled for MPC85xx and
MPC86xx.
checkcpu() in cpu/mpc8[56]xx/cpu.c will print out the local bus frequency
from sysinfo, like the other frequencies, instead of calculating it on the
spot.
Signed-off-by: Trent Piepho <tpiepho@freescale.com>
Acked-by: Kumar Gala <galak@kernel.crashing.org>
Acked-by: Jon Loeliger <jdl@freescale.com>
2008-12-03 23:16:37 +00:00
|
|
|
uint lcrr_div;
|
2009-01-15 16:58:35 +00:00
|
|
|
int i;
|
2009-05-20 16:30:29 +00:00
|
|
|
#ifdef CONFIG_QE
|
|
|
|
u32 qe_ratio;
|
|
|
|
#endif
|
2003-10-15 23:53:47 +00:00
|
|
|
|
|
|
|
plat_ratio = (gur->porpllsr) & 0x0000003e;
|
|
|
|
plat_ratio >>= 1;
|
2007-04-23 07:37:47 +00:00
|
|
|
sysInfo->freqSystemBus = plat_ratio * CONFIG_SYS_CLK_FREQ;
|
|
|
|
|
|
|
|
/* Divide before multiply to avoid integer
|
|
|
|
* overflow for processor speeds above 2GHz */
|
|
|
|
half_freqSystemBus = sysInfo->freqSystemBus/2;
|
2009-07-31 06:38:14 +00:00
|
|
|
for (i = 0; i < cpu_numcores(); i++) {
|
2009-01-15 16:58:35 +00:00
|
|
|
e500_ratio = ((gur->porpllsr) >> (i * 8 + 16)) & 0x3f;
|
|
|
|
sysInfo->freqProcessor[i] = e500_ratio * half_freqSystemBus;
|
|
|
|
}
|
2008-02-09 00:05:08 +00:00
|
|
|
|
|
|
|
/* Note: freqDDRBus is the MCLK frequency, not the data rate. */
|
2007-12-07 10:59:26 +00:00
|
|
|
sysInfo->freqDDRBus = sysInfo->freqSystemBus;
|
|
|
|
|
|
|
|
#ifdef CONFIG_DDR_CLK_FREQ
|
|
|
|
{
|
2008-09-27 06:40:57 +00:00
|
|
|
u32 ddr_ratio = ((gur->porpllsr) & MPC85xx_PORPLLSR_DDR_RATIO)
|
|
|
|
>> MPC85xx_PORPLLSR_DDR_RATIO_SHIFT;
|
2007-12-07 10:59:26 +00:00
|
|
|
if (ddr_ratio != 0x7)
|
|
|
|
sysInfo->freqDDRBus = ddr_ratio * CONFIG_DDR_CLK_FREQ;
|
|
|
|
}
|
|
|
|
#endif
|
mpc8[56]xx: Put localbus clock in sysinfo and gd
Currently MPC85xx and MPC86xx boards just calculate the localbus frequency
and print it out, but don't save it.
This changes where its calculated and stored to be more consistent with the
CPU, CCB, TB, and DDR frequencies and the MPC83xx localbus clock.
The localbus frequency is added to sysinfo and calculated when sysinfo is
set up, in cpu/mpc8[56]xx/speed.c, the same as the other frequencies are.
get_clocks() copies the frequency into the global data, as the other
frequencies are, into a new field that is only enabled for MPC85xx and
MPC86xx.
checkcpu() in cpu/mpc8[56]xx/cpu.c will print out the local bus frequency
from sysinfo, like the other frequencies, instead of calculating it on the
spot.
Signed-off-by: Trent Piepho <tpiepho@freescale.com>
Acked-by: Kumar Gala <galak@kernel.crashing.org>
Acked-by: Jon Loeliger <jdl@freescale.com>
2008-12-03 23:16:37 +00:00
|
|
|
|
2009-05-20 16:30:29 +00:00
|
|
|
#ifdef CONFIG_QE
|
|
|
|
qe_ratio = ((gur->porpllsr) & MPC85xx_PORPLLSR_QE_RATIO)
|
|
|
|
>> MPC85xx_PORPLLSR_QE_RATIO_SHIFT;
|
|
|
|
sysInfo->freqQE = qe_ratio * CONFIG_SYS_CLK_FREQ;
|
|
|
|
#endif
|
|
|
|
|
mpc8[56]xx: Put localbus clock in sysinfo and gd
Currently MPC85xx and MPC86xx boards just calculate the localbus frequency
and print it out, but don't save it.
This changes where its calculated and stored to be more consistent with the
CPU, CCB, TB, and DDR frequencies and the MPC83xx localbus clock.
The localbus frequency is added to sysinfo and calculated when sysinfo is
set up, in cpu/mpc8[56]xx/speed.c, the same as the other frequencies are.
get_clocks() copies the frequency into the global data, as the other
frequencies are, into a new field that is only enabled for MPC85xx and
MPC86xx.
checkcpu() in cpu/mpc8[56]xx/cpu.c will print out the local bus frequency
from sysinfo, like the other frequencies, instead of calculating it on the
spot.
Signed-off-by: Trent Piepho <tpiepho@freescale.com>
Acked-by: Kumar Gala <galak@kernel.crashing.org>
Acked-by: Jon Loeliger <jdl@freescale.com>
2008-12-03 23:16:37 +00:00
|
|
|
#if defined(CONFIG_SYS_LBC_LCRR)
|
|
|
|
/* We will program LCRR to this value later */
|
|
|
|
lcrr_div = CONFIG_SYS_LBC_LCRR & LCRR_CLKDIV;
|
|
|
|
#else
|
|
|
|
{
|
|
|
|
volatile ccsr_lbc_t *lbc = (void *)(CONFIG_SYS_MPC85xx_LBC_ADDR);
|
|
|
|
lcrr_div = in_be32(&lbc->lcrr) & LCRR_CLKDIV;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
if (lcrr_div == 2 || lcrr_div == 4 || lcrr_div == 8) {
|
|
|
|
#if !defined(CONFIG_MPC8540) && !defined(CONFIG_MPC8541) && \
|
|
|
|
!defined(CONFIG_MPC8555) && !defined(CONFIG_MPC8560)
|
|
|
|
/*
|
|
|
|
* Yes, the entire PQ38 family use the same
|
|
|
|
* bit-representation for twice the clock divider values.
|
|
|
|
*/
|
|
|
|
lcrr_div *= 2;
|
|
|
|
#endif
|
|
|
|
sysInfo->freqLocalBus = sysInfo->freqSystemBus / lcrr_div;
|
|
|
|
} else {
|
|
|
|
/* In case anyone cares what the unknown value is */
|
|
|
|
sysInfo->freqLocalBus = lcrr_div;
|
|
|
|
}
|
2003-10-15 23:53:47 +00:00
|
|
|
}
|
|
|
|
|
2007-04-23 07:37:47 +00:00
|
|
|
|
2003-10-15 23:53:47 +00:00
|
|
|
int get_clocks (void)
|
|
|
|
{
|
|
|
|
sys_info_t sys_info;
|
2008-04-04 16:15:58 +00:00
|
|
|
#ifdef CONFIG_MPC8544
|
2008-10-16 13:01:15 +00:00
|
|
|
volatile ccsr_gur_t *gur = (void *) CONFIG_SYS_MPC85xx_GUTS_ADDR;
|
2008-04-04 16:15:58 +00:00
|
|
|
#endif
|
2005-07-23 15:37:35 +00:00
|
|
|
#if defined(CONFIG_CPM2)
|
2008-10-16 13:01:15 +00:00
|
|
|
volatile ccsr_cpm_t *cpm = (ccsr_cpm_t *)CONFIG_SYS_MPC85xx_CPM_ADDR;
|
2003-10-15 23:53:47 +00:00
|
|
|
uint sccr, dfbrg;
|
|
|
|
|
|
|
|
/* set VCO = 4 * BRG */
|
2007-11-28 06:36:33 +00:00
|
|
|
cpm->im_cpm_intctl.sccr &= 0xfffffffc;
|
|
|
|
sccr = cpm->im_cpm_intctl.sccr;
|
2003-10-15 23:53:47 +00:00
|
|
|
dfbrg = (sccr & SCCR_DFBRG_MSK) >> SCCR_DFBRG_SHIFT;
|
|
|
|
#endif
|
|
|
|
get_sys_info (&sys_info);
|
2009-01-15 16:58:35 +00:00
|
|
|
gd->cpu_clk = sys_info.freqProcessor[0];
|
2003-10-15 23:53:47 +00:00
|
|
|
gd->bus_clk = sys_info.freqSystemBus;
|
2008-02-09 00:05:08 +00:00
|
|
|
gd->mem_clk = sys_info.freqDDRBus;
|
mpc8[56]xx: Put localbus clock in sysinfo and gd
Currently MPC85xx and MPC86xx boards just calculate the localbus frequency
and print it out, but don't save it.
This changes where its calculated and stored to be more consistent with the
CPU, CCB, TB, and DDR frequencies and the MPC83xx localbus clock.
The localbus frequency is added to sysinfo and calculated when sysinfo is
set up, in cpu/mpc8[56]xx/speed.c, the same as the other frequencies are.
get_clocks() copies the frequency into the global data, as the other
frequencies are, into a new field that is only enabled for MPC85xx and
MPC86xx.
checkcpu() in cpu/mpc8[56]xx/cpu.c will print out the local bus frequency
from sysinfo, like the other frequencies, instead of calculating it on the
spot.
Signed-off-by: Trent Piepho <tpiepho@freescale.com>
Acked-by: Kumar Gala <galak@kernel.crashing.org>
Acked-by: Jon Loeliger <jdl@freescale.com>
2008-12-03 23:16:37 +00:00
|
|
|
gd->lbc_clk = sys_info.freqLocalBus;
|
2008-04-04 16:15:58 +00:00
|
|
|
|
2009-05-20 16:30:29 +00:00
|
|
|
#ifdef CONFIG_QE
|
|
|
|
gd->qe_clk = sys_info.freqQE;
|
|
|
|
gd->brg_clk = gd->qe_clk / 2;
|
|
|
|
#endif
|
2008-04-04 16:15:58 +00:00
|
|
|
/*
|
|
|
|
* The base clock for I2C depends on the actual SOC. Unfortunately,
|
|
|
|
* there is no pattern that can be used to determine the frequency, so
|
|
|
|
* the only choice is to look up the actual SOC number and use the value
|
|
|
|
* for that SOC. This information is taken from application note
|
|
|
|
* AN2919.
|
|
|
|
*/
|
|
|
|
#if defined(CONFIG_MPC8540) || defined(CONFIG_MPC8541) || \
|
|
|
|
defined(CONFIG_MPC8560) || defined(CONFIG_MPC8555)
|
2008-01-09 20:35:26 +00:00
|
|
|
gd->i2c1_clk = sys_info.freqSystemBus;
|
2008-04-04 16:15:58 +00:00
|
|
|
#elif defined(CONFIG_MPC8544)
|
|
|
|
/*
|
|
|
|
* On the 8544, the I2C clock is the same as the SEC clock. This can be
|
|
|
|
* either CCB/2 or CCB/3, depending on the value of cfg_sec_freq. See
|
|
|
|
* 4.4.3.3 of the 8544 RM. Note that this might actually work for all
|
|
|
|
* 85xx, but only the 8544 has cfg_sec_freq, so it's unknown if the
|
|
|
|
* PORDEVSR2_SEC_CFG bit is 0 on all 85xx boards that are not an 8544.
|
|
|
|
*/
|
|
|
|
if (gur->pordevsr2 & MPC85xx_PORDEVSR2_SEC_CFG)
|
2008-09-30 08:55:57 +00:00
|
|
|
gd->i2c1_clk = sys_info.freqSystemBus / 3;
|
2008-10-17 02:58:49 +00:00
|
|
|
else
|
|
|
|
gd->i2c1_clk = sys_info.freqSystemBus / 2;
|
2008-04-04 16:15:58 +00:00
|
|
|
#else
|
|
|
|
/* Most 85xx SOCs use CCB/2, so this is the default behavior. */
|
|
|
|
gd->i2c1_clk = sys_info.freqSystemBus / 2;
|
|
|
|
#endif
|
|
|
|
gd->i2c2_clk = gd->i2c1_clk;
|
2008-01-09 20:35:26 +00:00
|
|
|
|
2008-08-12 16:14:19 +00:00
|
|
|
#if defined(CONFIG_MPC8536)
|
|
|
|
gd->sdhc_clk = gd->bus_clk / 2;
|
|
|
|
#endif
|
|
|
|
|
2005-07-23 15:37:35 +00:00
|
|
|
#if defined(CONFIG_CPM2)
|
2003-10-15 23:53:47 +00:00
|
|
|
gd->vco_out = 2*sys_info.freqSystemBus;
|
|
|
|
gd->cpm_clk = gd->vco_out / 2;
|
|
|
|
gd->scc_clk = gd->vco_out / 4;
|
|
|
|
gd->brg_clk = gd->vco_out / (1 << (2 * (dfbrg + 1)));
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if(gd->cpu_clk != 0) return (0);
|
|
|
|
else return (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/********************************************
|
|
|
|
* get_bus_freq
|
|
|
|
* return system bus freq in Hz
|
|
|
|
*********************************************/
|
|
|
|
ulong get_bus_freq (ulong dummy)
|
|
|
|
{
|
2008-02-09 00:05:08 +00:00
|
|
|
return gd->bus_clk;
|
2003-10-15 23:53:47 +00:00
|
|
|
}
|
2007-12-07 10:59:26 +00:00
|
|
|
|
|
|
|
/********************************************
|
|
|
|
* get_ddr_freq
|
|
|
|
* return ddr bus freq in Hz
|
|
|
|
*********************************************/
|
|
|
|
ulong get_ddr_freq (ulong dummy)
|
|
|
|
{
|
2008-02-09 00:05:08 +00:00
|
|
|
return gd->mem_clk;
|
2007-12-07 10:59:26 +00:00
|
|
|
}
|