9
0
Fork 0

svn_rev_593

intrduce get_clock_* functions
This commit is contained in:
Sascha Hauer 2007-07-05 18:02:08 +02:00 committed by Sascha Hauer
parent 34392fc041
commit 6834609691
3 changed files with 58 additions and 48 deletions

View File

@ -27,10 +27,6 @@
#include <asm/processor.h>
#include <types.h>
DECLARE_GLOBAL_DATA_PTR;
/* ------------------------------------------------------------------------- */
/* Bus-to-Core Multipliers */
static int bus2core[] = {
@ -39,57 +35,73 @@ static int bus2core[] = {
6, 5, 13, 2, 14, 4, 15, 9,
0, 11, 8, 10, 16, 12, 7, 0
};
/* ------------------------------------------------------------------------- */
/*
*
*/
int get_clocks (void)
unsigned long get_bus_clock(void)
{
ulong val, vco;
unsigned long val, vco;
#if !defined(CFG_MPC5XXX_CLKIN)
#error clock measuring not implemented yet - define CFG_MPC5XXX_CLKIN
#endif
val = *(vu_long *)MPC5XXX_CDM_PORCFG;
if (val & (1 << 6)) {
if (val & (1 << 6))
vco = CFG_MPC5XXX_CLKIN * 12;
} else {
else
vco = CFG_MPC5XXX_CLKIN * 16;
}
if (val & (1 << 5)) {
gd->bus_clk = vco / 8;
} else {
gd->bus_clk = vco / 4;
}
gd->cpu_clk = gd->bus_clk * bus2core[val & 0x1f] / 2;
val = *(vu_long *)MPC5XXX_CDM_CFG;
if (val & (1 << 8)) {
gd->ipb_clk = gd->bus_clk / 2;
} else {
gd->ipb_clk = gd->bus_clk;
}
switch (val & 3) {
case 0: gd->pci_clk = gd->ipb_clk; break;
case 1: gd->pci_clk = gd->ipb_clk / 2; break;
default: gd->pci_clk = gd->bus_clk / 4; break;
}
return 0;
if (val & (1 << 5))
return vco / 8;
else
return vco / 4;
}
core_initcall(get_clocks);
unsigned long get_cpu_clock(void)
{
unsigned long val;
val = *(vu_long *)MPC5XXX_CDM_PORCFG;
return get_bus_clock() * bus2core[val & 0x1f] / 2;
}
unsigned long get_ipb_clock(void)
{
unsigned long val;
val = *(vu_long *)MPC5XXX_CDM_CFG;
if (val & (1 << 8))
return get_bus_clock() / 2;
else
return get_bus_clock();
}
unsigned long get_pci_clock(void)
{
unsigned long val;
val = *(vu_long *)MPC5XXX_CDM_CFG;
switch (val & 3) {
case 0:
return get_ipb_clock();
case 1:
return get_ipb_clock() / 2;
default:
return get_bus_clock() / 4;
}
}
unsigned long get_timebase_clock(void)
{
return (get_bus_clock() + 3L) / 4L;
}
int prt_mpc5xxx_clks (void)
{
printf(" Bus %ld MHz, IPB %ld MHz, PCI %ld MHz\n",
gd->bus_clk / 1000000, gd->ipb_clk / 1000000,
gd->pci_clk / 1000000);
get_bus_clock() / 1000000, get_ipb_clock() / 1000000,
get_pci_clock() / 1000000);
return 0;
}
late_initcall(prt_mpc5xxx_clks);

View File

@ -15,11 +15,10 @@
#include <driver.h>
#include <asm/arch/sdma.h>
#include <asm/arch/fec.h>
#include <asm/arch/clocks.h>
#include <miiphy.h>
#include "fec_mpc5200.h"
DECLARE_GLOBAL_DATA_PTR;
#define CONFIG_PHY_ADDR 1 /* FIXME */
/* #define DEBUG 0x28 */
@ -263,7 +262,9 @@ static int mpc5xxx_fec_init(struct eth_device *dev)
* Set MII_SPEED = (1/(mii_speed * 2)) * System Clock
* and do not drop the Preamble.
*/
fec->eth->mii_speed = (((gd->ipb_clk >> 20) / 5) << 1); /* No MII for 7-wire mode */
printf("%s: miispeed\n", __FUNCTION__);
fec->eth->mii_speed = (((get_ipb_clock() >> 20) / 5) << 1); /* No MII for 7-wire mode */
printf("done: %d\n", get_ipb_clock());
}
/*

View File

@ -39,8 +39,7 @@
#include <init.h>
#include <console.h>
#include <xfuncs.h>
DECLARE_GLOBAL_DATA_PTR;
#include <asm/arch/clocks.h>
static void mpc5xxx_serial_setbrg(struct console_device *cdev)
{
@ -48,13 +47,14 @@ static void mpc5xxx_serial_setbrg(struct console_device *cdev)
volatile struct mpc5xxx_psc *psc = (struct mpc5xxx_psc *)dev->map_base;
unsigned long baseclk;
int div;
return;
printf("%s: ipb\n", __FUNCTION__);
#if defined(CONFIG_MGT5100)
baseclk = (CFG_MPC5XXX_CLKIN + 16) / 32;
#elif defined(CONFIG_MPC5200)
baseclk = (gd->ipb_clk + 16) / 32;
baseclk = (get_ipb_clock() + 16) / 32;
#endif
printf("done: %d\n", get_ipb_clock());
/* set up UART divisor */
#if 0
div = (baseclk + (gd->baudrate/2)) / gd->baudrate;
@ -70,18 +70,15 @@ static int mpc5xxx_serial_init(struct console_device *cdev)
{
struct device_d *dev = cdev->dev;
volatile struct mpc5xxx_psc *psc = (struct mpc5xxx_psc *)dev->map_base;
unsigned long baseclk;
return 0;
/* reset PSC */
psc->command = PSC_SEL_MODE_REG_1;
/* select clock sources */
#if defined(CONFIG_MGT5100)
psc->psc_clock_select = 0xdd00;
baseclk = (CFG_MPC5XXX_CLKIN + 16) / 32;
#elif defined(CONFIG_MPC5200)
psc->psc_clock_select = 0;
baseclk = (gd->ipb_clk + 16) / 32;
#endif
/* switch to UART mode */