2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2005-07-28 15:08:46 +00:00
|
|
|
/*
|
|
|
|
* (C) Copyright 2000-2002
|
|
|
|
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
|
|
|
|
*
|
2007-09-18 04:36:11 +00:00
|
|
|
* Copyright (C) 2004-2007 Freescale Semiconductor, Inc.
|
2005-07-28 15:08:46 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <mpc83xx.h>
|
2007-04-30 20:26:21 +00:00
|
|
|
#include <command.h>
|
2005-07-28 15:08:46 +00:00
|
|
|
#include <asm/processor.h>
|
|
|
|
|
2006-03-31 16:32:53 +00:00
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
|
|
|
|
2005-07-28 15:08:46 +00:00
|
|
|
/* ----------------------------------------------------------------- */
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
_unk,
|
|
|
|
_off,
|
|
|
|
_byp,
|
|
|
|
_x8,
|
|
|
|
_x4,
|
|
|
|
_x2,
|
|
|
|
_x1,
|
|
|
|
_1x,
|
|
|
|
_1_5x,
|
|
|
|
_2x,
|
|
|
|
_2_5x,
|
|
|
|
_3x
|
|
|
|
} mult_t;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
mult_t core_csb_ratio;
|
2006-11-03 01:47:11 +00:00
|
|
|
mult_t vco_divider;
|
2005-07-28 15:08:46 +00:00
|
|
|
} corecnf_t;
|
|
|
|
|
powerpc/mpc83xx: sparse fixes
fdt.c:91:78: warning: Using plain integer as NULL pointer
fdt.c:103:78: warning: Using plain integer as NULL pointer
speed.c:55:11: warning: symbol 'corecnf_tab' was not declared. Should it be static?
speed.c:519:5: warning: symbol 'do_clocks' was not declared. Should it be static?
mpc8313erdb.c:73:17: warning: obsolete struct initializer, use C99 syntax
mpc8313erdb.c:74:17: warning: obsolete struct initializer, use C99 syntax
mpc8313erdb.c:75:17: warning: obsolete struct initializer, use C99 syntax
mpc8313erdb.c:76:17: warning: obsolete struct initializer, use C99 syntax
mpc8313erdb.c:79:17: warning: obsolete struct initializer, use C99 syntax
mpc8313erdb.c:80:17: warning: obsolete struct initializer, use C99 syntax
mpc8313erdb.c:81:17: warning: obsolete struct initializer, use C99 syntax
mpc8313erdb.c:82:17: warning: obsolete struct initializer, use C99 syntax
mpc8313erdb.c:85:17: warning: obsolete struct initializer, use C99 syntax
mpc8313erdb.c:86:17: warning: obsolete struct initializer, use C99 syntax
mpc8313erdb.c:87:17: warning: obsolete struct initializer, use C99 syntax
mpc8313erdb.c:88:17: warning: obsolete struct initializer, use C99 syntax
Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
2012-10-29 13:34:39 +00:00
|
|
|
static corecnf_t corecnf_tab[] = {
|
2006-11-03 01:47:11 +00:00
|
|
|
{_byp, _byp}, /* 0x00 */
|
|
|
|
{_byp, _byp}, /* 0x01 */
|
|
|
|
{_byp, _byp}, /* 0x02 */
|
|
|
|
{_byp, _byp}, /* 0x03 */
|
|
|
|
{_byp, _byp}, /* 0x04 */
|
|
|
|
{_byp, _byp}, /* 0x05 */
|
|
|
|
{_byp, _byp}, /* 0x06 */
|
|
|
|
{_byp, _byp}, /* 0x07 */
|
|
|
|
{_1x, _x2}, /* 0x08 */
|
|
|
|
{_1x, _x4}, /* 0x09 */
|
|
|
|
{_1x, _x8}, /* 0x0A */
|
|
|
|
{_1x, _x8}, /* 0x0B */
|
|
|
|
{_1_5x, _x2}, /* 0x0C */
|
|
|
|
{_1_5x, _x4}, /* 0x0D */
|
|
|
|
{_1_5x, _x8}, /* 0x0E */
|
|
|
|
{_1_5x, _x8}, /* 0x0F */
|
|
|
|
{_2x, _x2}, /* 0x10 */
|
|
|
|
{_2x, _x4}, /* 0x11 */
|
|
|
|
{_2x, _x8}, /* 0x12 */
|
|
|
|
{_2x, _x8}, /* 0x13 */
|
|
|
|
{_2_5x, _x2}, /* 0x14 */
|
|
|
|
{_2_5x, _x4}, /* 0x15 */
|
|
|
|
{_2_5x, _x8}, /* 0x16 */
|
|
|
|
{_2_5x, _x8}, /* 0x17 */
|
|
|
|
{_3x, _x2}, /* 0x18 */
|
|
|
|
{_3x, _x4}, /* 0x19 */
|
|
|
|
{_3x, _x8}, /* 0x1A */
|
|
|
|
{_3x, _x8}, /* 0x1B */
|
2005-07-28 15:08:46 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* ----------------------------------------------------------------- */
|
|
|
|
|
|
|
|
/*
|
|
|
|
*
|
|
|
|
*/
|
2006-11-03 01:47:11 +00:00
|
|
|
int get_clocks(void)
|
2005-07-28 15:08:46 +00:00
|
|
|
{
|
2008-10-16 13:01:15 +00:00
|
|
|
volatile immap_t *im = (immap_t *) CONFIG_SYS_IMMR;
|
2005-07-28 15:08:46 +00:00
|
|
|
u32 pci_sync_in;
|
2006-11-03 01:47:11 +00:00
|
|
|
u8 spmf;
|
|
|
|
u8 clkin_div;
|
2005-07-28 15:08:46 +00:00
|
|
|
u32 sccr;
|
|
|
|
u32 corecnf_tab_index;
|
2006-11-03 01:47:11 +00:00
|
|
|
u8 corepll;
|
2005-07-28 15:08:46 +00:00
|
|
|
u32 lcrr;
|
2005-08-01 18:20:47 +00:00
|
|
|
|
2005-07-28 15:08:46 +00:00
|
|
|
u32 csb_clk;
|
2010-06-28 12:44:33 +00:00
|
|
|
#if defined(CONFIG_MPC8308) || defined(CONFIG_MPC831x) || \
|
|
|
|
defined(CONFIG_MPC834x) || defined(CONFIG_MPC837x)
|
2005-07-28 15:08:46 +00:00
|
|
|
u32 tsec1_clk;
|
|
|
|
u32 tsec2_clk;
|
|
|
|
u32 usbdr_clk;
|
2012-10-10 22:13:08 +00:00
|
|
|
#elif defined(CONFIG_MPC8309)
|
|
|
|
u32 usbdr_clk;
|
2007-04-16 19:34:19 +00:00
|
|
|
#endif
|
2009-05-22 22:23:25 +00:00
|
|
|
#ifdef CONFIG_MPC834x
|
2007-04-16 19:34:19 +00:00
|
|
|
u32 usbmph_clk;
|
2006-11-04 01:33:44 +00:00
|
|
|
#endif
|
|
|
|
u32 core_clk;
|
|
|
|
u32 i2c1_clk;
|
2009-05-22 22:23:25 +00:00
|
|
|
#if !defined(CONFIG_MPC832x)
|
2006-11-04 01:33:44 +00:00
|
|
|
u32 i2c2_clk;
|
2007-09-18 04:36:11 +00:00
|
|
|
#endif
|
2007-09-18 04:36:58 +00:00
|
|
|
#if defined(CONFIG_MPC8315)
|
|
|
|
u32 tdm_clk;
|
|
|
|
#endif
|
2010-04-15 14:03:05 +00:00
|
|
|
#if defined(CONFIG_FSL_ESDHC)
|
2007-09-18 04:36:11 +00:00
|
|
|
u32 sdhc_clk;
|
2006-12-07 13:13:15 +00:00
|
|
|
#endif
|
2012-10-10 22:13:08 +00:00
|
|
|
#if !defined(CONFIG_MPC8309)
|
2005-07-28 15:08:46 +00:00
|
|
|
u32 enc_clk;
|
2012-10-10 22:13:08 +00:00
|
|
|
#endif
|
2005-07-28 15:08:46 +00:00
|
|
|
u32 lbiu_clk;
|
|
|
|
u32 lclk_clk;
|
2008-03-28 15:18:40 +00:00
|
|
|
u32 mem_clk;
|
2006-12-07 13:13:15 +00:00
|
|
|
#if defined(CONFIG_MPC8360)
|
2008-03-28 15:18:40 +00:00
|
|
|
u32 mem_sec_clk;
|
2006-12-07 13:13:15 +00:00
|
|
|
#endif
|
2012-10-10 22:13:06 +00:00
|
|
|
#if defined(CONFIG_QE)
|
2006-11-04 01:33:44 +00:00
|
|
|
u32 qepmf;
|
|
|
|
u32 qepdf;
|
|
|
|
u32 qe_clk;
|
|
|
|
u32 brg_clk;
|
|
|
|
#endif
|
2010-06-28 12:44:33 +00:00
|
|
|
#if defined(CONFIG_MPC8308) || defined(CONFIG_MPC831x) || \
|
|
|
|
defined(CONFIG_MPC837x)
|
2007-09-18 04:36:11 +00:00
|
|
|
u32 pciexp1_clk;
|
|
|
|
u32 pciexp2_clk;
|
2007-09-18 04:36:58 +00:00
|
|
|
#endif
|
2009-05-22 22:23:25 +00:00
|
|
|
#if defined(CONFIG_MPC837x) || defined(CONFIG_MPC8315)
|
2007-09-18 04:36:11 +00:00
|
|
|
u32 sata_clk;
|
|
|
|
#endif
|
2005-08-01 18:20:47 +00:00
|
|
|
|
2006-11-03 01:47:11 +00:00
|
|
|
if ((im->sysconf.immrbar & IMMRBAR_BASE_ADDR) != (u32) im)
|
2005-07-28 15:08:46 +00:00
|
|
|
return -1;
|
2005-08-01 18:20:47 +00:00
|
|
|
|
2006-11-04 01:33:44 +00:00
|
|
|
clkin_div = ((im->clk.spmr & SPMR_CKID) >> SPMR_CKID_SHIFT);
|
2005-10-11 17:09:42 +00:00
|
|
|
|
2006-11-04 01:33:44 +00:00
|
|
|
if (im->reset.rcwh & HRCWH_PCI_HOST) {
|
|
|
|
#if defined(CONFIG_83XX_CLKIN)
|
|
|
|
pci_sync_in = CONFIG_83XX_CLKIN / (1 + clkin_div);
|
|
|
|
#else
|
|
|
|
pci_sync_in = 0xDEADBEEF;
|
|
|
|
#endif
|
|
|
|
} else {
|
|
|
|
#if defined(CONFIG_83XX_PCICLK)
|
|
|
|
pci_sync_in = CONFIG_83XX_PCICLK;
|
|
|
|
#else
|
|
|
|
pci_sync_in = 0xDEADBEEF;
|
|
|
|
#endif
|
2005-07-28 15:08:46 +00:00
|
|
|
}
|
|
|
|
|
2011-01-27 15:30:54 +00:00
|
|
|
spmf = (im->clk.spmr & SPMR_SPMF) >> SPMR_SPMF_SHIFT;
|
2006-11-04 01:33:44 +00:00
|
|
|
csb_clk = pci_sync_in * (1 + clkin_div) * spmf;
|
2005-08-01 18:20:47 +00:00
|
|
|
|
2005-07-28 15:08:46 +00:00
|
|
|
sccr = im->clk.sccr;
|
2006-11-04 01:33:44 +00:00
|
|
|
|
2010-06-28 12:44:33 +00:00
|
|
|
#if defined(CONFIG_MPC8308) || defined(CONFIG_MPC831x) || \
|
|
|
|
defined(CONFIG_MPC834x) || defined(CONFIG_MPC837x)
|
2005-07-28 15:08:46 +00:00
|
|
|
switch ((sccr & SCCR_TSEC1CM) >> SCCR_TSEC1CM_SHIFT) {
|
|
|
|
case 0:
|
|
|
|
tsec1_clk = 0;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
tsec1_clk = csb_clk;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
tsec1_clk = csb_clk / 2;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
tsec1_clk = csb_clk / 3;
|
|
|
|
break;
|
|
|
|
default:
|
2015-12-16 17:25:42 +00:00
|
|
|
/* unknown SCCR_TSEC1CM value */
|
2007-09-18 04:36:11 +00:00
|
|
|
return -2;
|
2005-07-28 15:08:46 +00:00
|
|
|
}
|
2012-10-10 22:13:07 +00:00
|
|
|
#endif
|
2005-08-01 18:20:47 +00:00
|
|
|
|
2012-10-10 22:13:07 +00:00
|
|
|
#if defined(CONFIG_MPC830x) || defined(CONFIG_MPC831x) || \
|
|
|
|
defined(CONFIG_MPC834x) || defined(CONFIG_MPC837x)
|
2007-04-16 19:34:19 +00:00
|
|
|
switch ((sccr & SCCR_USBDRCM) >> SCCR_USBDRCM_SHIFT) {
|
|
|
|
case 0:
|
|
|
|
usbdr_clk = 0;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
usbdr_clk = csb_clk;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
usbdr_clk = csb_clk / 2;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
usbdr_clk = csb_clk / 3;
|
|
|
|
break;
|
|
|
|
default:
|
2015-12-16 17:25:42 +00:00
|
|
|
/* unknown SCCR_USBDRCM value */
|
2007-09-18 04:36:11 +00:00
|
|
|
return -3;
|
2007-04-16 19:34:19 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-06-28 12:44:33 +00:00
|
|
|
#if defined(CONFIG_MPC8308) || defined(CONFIG_MPC8315) || \
|
|
|
|
defined(CONFIG_MPC834x) || defined(CONFIG_MPC837x)
|
2005-07-28 15:08:46 +00:00
|
|
|
switch ((sccr & SCCR_TSEC2CM) >> SCCR_TSEC2CM_SHIFT) {
|
|
|
|
case 0:
|
|
|
|
tsec2_clk = 0;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
tsec2_clk = csb_clk;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
tsec2_clk = csb_clk / 2;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
tsec2_clk = csb_clk / 3;
|
|
|
|
break;
|
|
|
|
default:
|
2015-12-16 17:25:42 +00:00
|
|
|
/* unknown SCCR_TSEC2CM value */
|
2007-09-18 04:36:11 +00:00
|
|
|
return -4;
|
2005-07-28 15:08:46 +00:00
|
|
|
}
|
2007-09-18 04:36:58 +00:00
|
|
|
#elif defined(CONFIG_MPC8313)
|
2007-09-18 04:36:11 +00:00
|
|
|
tsec2_clk = tsec1_clk;
|
2005-08-01 18:20:47 +00:00
|
|
|
|
2007-09-18 04:36:11 +00:00
|
|
|
if (!(sccr & SCCR_TSEC1ON))
|
|
|
|
tsec1_clk = 0;
|
|
|
|
if (!(sccr & SCCR_TSEC2ON))
|
|
|
|
tsec2_clk = 0;
|
|
|
|
#endif
|
2005-08-01 18:20:47 +00:00
|
|
|
|
2009-05-22 22:23:25 +00:00
|
|
|
#if defined(CONFIG_MPC834x)
|
2005-07-28 15:08:46 +00:00
|
|
|
switch ((sccr & SCCR_USBMPHCM) >> SCCR_USBMPHCM_SHIFT) {
|
|
|
|
case 0:
|
|
|
|
usbmph_clk = 0;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
usbmph_clk = csb_clk;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
usbmph_clk = csb_clk / 2;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
usbmph_clk = csb_clk / 3;
|
|
|
|
break;
|
|
|
|
default:
|
2015-12-16 17:25:42 +00:00
|
|
|
/* unknown SCCR_USBMPHCM value */
|
2007-09-18 04:36:11 +00:00
|
|
|
return -5;
|
2005-07-28 15:08:46 +00:00
|
|
|
}
|
|
|
|
|
2006-11-03 01:47:11 +00:00
|
|
|
if (usbmph_clk != 0 && usbdr_clk != 0 && usbmph_clk != usbdr_clk) {
|
|
|
|
/* if USB MPH clock is not disabled and
|
|
|
|
* USB DR clock is not disabled then
|
|
|
|
* USB MPH & USB DR must have the same rate
|
|
|
|
*/
|
2007-09-18 04:36:11 +00:00
|
|
|
return -6;
|
|
|
|
}
|
|
|
|
#endif
|
2012-10-10 22:13:08 +00:00
|
|
|
#if !defined(CONFIG_MPC8309)
|
2007-09-18 04:36:11 +00:00
|
|
|
switch ((sccr & SCCR_ENCCM) >> SCCR_ENCCM_SHIFT) {
|
|
|
|
case 0:
|
|
|
|
enc_clk = 0;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
enc_clk = csb_clk;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
enc_clk = csb_clk / 2;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
enc_clk = csb_clk / 3;
|
|
|
|
break;
|
|
|
|
default:
|
2015-12-16 17:25:42 +00:00
|
|
|
/* unknown SCCR_ENCCM value */
|
2007-09-18 04:36:11 +00:00
|
|
|
return -7;
|
2005-07-28 15:08:46 +00:00
|
|
|
}
|
2012-10-10 22:13:08 +00:00
|
|
|
#endif
|
2007-04-16 19:34:19 +00:00
|
|
|
|
2010-04-15 14:03:05 +00:00
|
|
|
#if defined(CONFIG_FSL_ESDHC)
|
2007-09-18 04:36:11 +00:00
|
|
|
switch ((sccr & SCCR_SDHCCM) >> SCCR_SDHCCM_SHIFT) {
|
|
|
|
case 0:
|
|
|
|
sdhc_clk = 0;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
sdhc_clk = csb_clk;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
sdhc_clk = csb_clk / 2;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
sdhc_clk = csb_clk / 3;
|
|
|
|
break;
|
|
|
|
default:
|
2015-12-16 17:25:42 +00:00
|
|
|
/* unknown SCCR_SDHCCM value */
|
2007-09-18 04:36:11 +00:00
|
|
|
return -8;
|
|
|
|
}
|
2006-11-04 01:33:44 +00:00
|
|
|
#endif
|
2007-09-18 04:36:58 +00:00
|
|
|
#if defined(CONFIG_MPC8315)
|
|
|
|
switch ((sccr & SCCR_TDMCM) >> SCCR_TDMCM_SHIFT) {
|
|
|
|
case 0:
|
|
|
|
tdm_clk = 0;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
tdm_clk = csb_clk;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
tdm_clk = csb_clk / 2;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
tdm_clk = csb_clk / 3;
|
|
|
|
break;
|
|
|
|
default:
|
2015-12-16 17:25:42 +00:00
|
|
|
/* unknown SCCR_TDMCM value */
|
2007-09-18 04:36:58 +00:00
|
|
|
return -8;
|
|
|
|
}
|
|
|
|
#endif
|
2007-04-16 19:34:19 +00:00
|
|
|
|
2009-05-22 22:23:25 +00:00
|
|
|
#if defined(CONFIG_MPC834x)
|
2007-09-18 04:36:11 +00:00
|
|
|
i2c1_clk = tsec2_clk;
|
|
|
|
#elif defined(CONFIG_MPC8360)
|
2006-11-04 01:33:44 +00:00
|
|
|
i2c1_clk = csb_clk;
|
2009-05-22 22:23:25 +00:00
|
|
|
#elif defined(CONFIG_MPC832x)
|
2007-09-18 04:36:11 +00:00
|
|
|
i2c1_clk = enc_clk;
|
2010-06-28 12:44:33 +00:00
|
|
|
#elif defined(CONFIG_MPC8308) || defined(CONFIG_MPC831x)
|
2007-09-18 04:36:11 +00:00
|
|
|
i2c1_clk = enc_clk;
|
2010-04-15 14:03:05 +00:00
|
|
|
#elif defined(CONFIG_FSL_ESDHC)
|
2007-09-18 04:36:11 +00:00
|
|
|
i2c1_clk = sdhc_clk;
|
2011-04-14 12:57:40 +00:00
|
|
|
#elif defined(CONFIG_MPC837x)
|
|
|
|
i2c1_clk = enc_clk;
|
2012-10-10 22:13:08 +00:00
|
|
|
#elif defined(CONFIG_MPC8309)
|
|
|
|
i2c1_clk = csb_clk;
|
2006-11-04 01:33:44 +00:00
|
|
|
#endif
|
2009-05-22 22:23:25 +00:00
|
|
|
#if !defined(CONFIG_MPC832x)
|
2007-09-18 04:36:11 +00:00
|
|
|
i2c2_clk = csb_clk; /* i2c-2 clk is equal to csb clk */
|
2006-12-07 13:13:15 +00:00
|
|
|
#endif
|
2005-08-01 18:20:47 +00:00
|
|
|
|
2010-06-28 12:44:33 +00:00
|
|
|
#if defined(CONFIG_MPC8308) || defined(CONFIG_MPC831x) || \
|
|
|
|
defined(CONFIG_MPC837x)
|
2007-09-18 04:36:11 +00:00
|
|
|
switch ((sccr & SCCR_PCIEXP1CM) >> SCCR_PCIEXP1CM_SHIFT) {
|
2006-11-04 01:33:44 +00:00
|
|
|
case 0:
|
2007-09-18 04:36:11 +00:00
|
|
|
pciexp1_clk = 0;
|
2006-11-04 01:33:44 +00:00
|
|
|
break;
|
|
|
|
case 1:
|
2007-09-18 04:36:11 +00:00
|
|
|
pciexp1_clk = csb_clk;
|
2006-11-04 01:33:44 +00:00
|
|
|
break;
|
|
|
|
case 2:
|
2007-09-18 04:36:11 +00:00
|
|
|
pciexp1_clk = csb_clk / 2;
|
2006-11-04 01:33:44 +00:00
|
|
|
break;
|
|
|
|
case 3:
|
2007-09-18 04:36:11 +00:00
|
|
|
pciexp1_clk = csb_clk / 3;
|
2006-11-04 01:33:44 +00:00
|
|
|
break;
|
|
|
|
default:
|
2015-12-16 17:25:42 +00:00
|
|
|
/* unknown SCCR_PCIEXP1CM value */
|
2007-09-18 04:36:11 +00:00
|
|
|
return -9;
|
2006-11-04 01:33:44 +00:00
|
|
|
}
|
2006-12-07 13:13:15 +00:00
|
|
|
|
2007-09-18 04:36:11 +00:00
|
|
|
switch ((sccr & SCCR_PCIEXP2CM) >> SCCR_PCIEXP2CM_SHIFT) {
|
|
|
|
case 0:
|
|
|
|
pciexp2_clk = 0;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
pciexp2_clk = csb_clk;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
pciexp2_clk = csb_clk / 2;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
pciexp2_clk = csb_clk / 3;
|
|
|
|
break;
|
|
|
|
default:
|
2015-12-16 17:25:42 +00:00
|
|
|
/* unknown SCCR_PCIEXP2CM value */
|
2007-09-18 04:36:11 +00:00
|
|
|
return -10;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-05-22 22:23:25 +00:00
|
|
|
#if defined(CONFIG_MPC837x) || defined(CONFIG_MPC8315)
|
2008-01-17 10:23:19 +00:00
|
|
|
switch ((sccr & SCCR_SATA1CM) >> SCCR_SATA1CM_SHIFT) {
|
|
|
|
case 0:
|
2007-09-18 04:36:11 +00:00
|
|
|
sata_clk = 0;
|
|
|
|
break;
|
2008-01-17 10:23:19 +00:00
|
|
|
case 1:
|
2007-09-18 04:36:11 +00:00
|
|
|
sata_clk = csb_clk;
|
|
|
|
break;
|
2008-01-17 10:23:19 +00:00
|
|
|
case 2:
|
2007-09-18 04:36:11 +00:00
|
|
|
sata_clk = csb_clk / 2;
|
|
|
|
break;
|
2008-01-17 10:23:19 +00:00
|
|
|
case 3:
|
2007-09-18 04:36:11 +00:00
|
|
|
sata_clk = csb_clk / 3;
|
|
|
|
break;
|
|
|
|
default:
|
2015-12-16 17:25:42 +00:00
|
|
|
/* unknown SCCR_SATA1CM value */
|
2007-09-18 04:36:11 +00:00
|
|
|
return -11;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2006-11-03 01:47:11 +00:00
|
|
|
lbiu_clk = csb_clk *
|
2011-01-27 15:30:54 +00:00
|
|
|
(1 + ((im->clk.spmr & SPMR_LBIUCM) >> SPMR_LBIUCM_SHIFT));
|
2010-06-17 16:37:20 +00:00
|
|
|
lcrr = (im->im_lbc.lcrr & LCRR_CLKDIV) >> LCRR_CLKDIV_SHIFT;
|
2005-07-28 15:08:46 +00:00
|
|
|
switch (lcrr) {
|
|
|
|
case 2:
|
|
|
|
case 4:
|
|
|
|
case 8:
|
|
|
|
lclk_clk = lbiu_clk / lcrr;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* unknown lcrr */
|
2007-09-18 04:36:11 +00:00
|
|
|
return -12;
|
2005-07-28 15:08:46 +00:00
|
|
|
}
|
2006-12-07 13:13:15 +00:00
|
|
|
|
2008-03-28 15:18:40 +00:00
|
|
|
mem_clk = csb_clk *
|
2011-01-27 15:30:54 +00:00
|
|
|
(1 + ((im->clk.spmr & SPMR_DDRCM) >> SPMR_DDRCM_SHIFT));
|
|
|
|
corepll = (im->clk.spmr & SPMR_COREPLL) >> SPMR_COREPLL_SHIFT;
|
|
|
|
|
2006-12-07 13:13:15 +00:00
|
|
|
#if defined(CONFIG_MPC8360)
|
2008-03-28 15:18:40 +00:00
|
|
|
mem_sec_clk = csb_clk * (1 +
|
2011-01-27 15:30:54 +00:00
|
|
|
((im->clk.spmr & SPMR_LBIUCM) >> SPMR_LBIUCM_SHIFT));
|
2006-11-04 01:33:44 +00:00
|
|
|
#endif
|
|
|
|
|
2005-07-28 15:08:46 +00:00
|
|
|
corecnf_tab_index = ((corepll & 0x1F) << 2) | ((corepll & 0x60) >> 5);
|
2016-05-23 10:49:21 +00:00
|
|
|
if (corecnf_tab_index > (ARRAY_SIZE(corecnf_tab))) {
|
2015-12-16 17:25:42 +00:00
|
|
|
/* corecnf_tab_index is too high, possibly wrong value */
|
2005-07-28 15:08:46 +00:00
|
|
|
return -11;
|
|
|
|
}
|
|
|
|
switch (corecnf_tab[corecnf_tab_index].core_csb_ratio) {
|
|
|
|
case _byp:
|
|
|
|
case _x1:
|
|
|
|
case _1x:
|
|
|
|
core_clk = csb_clk;
|
|
|
|
break;
|
|
|
|
case _1_5x:
|
|
|
|
core_clk = (3 * csb_clk) / 2;
|
|
|
|
break;
|
|
|
|
case _2x:
|
|
|
|
core_clk = 2 * csb_clk;
|
|
|
|
break;
|
|
|
|
case _2_5x:
|
2006-11-03 01:47:11 +00:00
|
|
|
core_clk = (5 * csb_clk) / 2;
|
2005-07-28 15:08:46 +00:00
|
|
|
break;
|
|
|
|
case _3x:
|
|
|
|
core_clk = 3 * csb_clk;
|
|
|
|
break;
|
|
|
|
default:
|
2015-12-16 17:25:42 +00:00
|
|
|
/* unknown core to csb ratio */
|
2007-09-18 04:36:11 +00:00
|
|
|
return -13;
|
2005-07-28 15:08:46 +00:00
|
|
|
}
|
2005-08-01 18:20:47 +00:00
|
|
|
|
2012-10-10 22:13:06 +00:00
|
|
|
#if defined(CONFIG_QE)
|
2011-01-27 15:30:54 +00:00
|
|
|
qepmf = (im->clk.spmr & SPMR_CEPMF) >> SPMR_CEPMF_SHIFT;
|
|
|
|
qepdf = (im->clk.spmr & SPMR_CEPDF) >> SPMR_CEPDF_SHIFT;
|
2006-11-03 01:47:11 +00:00
|
|
|
qe_clk = (pci_sync_in * qepmf) / (1 + qepdf);
|
2006-11-04 01:33:44 +00:00
|
|
|
brg_clk = qe_clk / 2;
|
|
|
|
#endif
|
|
|
|
|
2012-12-13 20:48:47 +00:00
|
|
|
gd->arch.csb_clk = csb_clk;
|
2010-06-28 12:44:33 +00:00
|
|
|
#if defined(CONFIG_MPC8308) || defined(CONFIG_MPC831x) || \
|
|
|
|
defined(CONFIG_MPC834x) || defined(CONFIG_MPC837x)
|
2012-12-13 20:48:47 +00:00
|
|
|
gd->arch.tsec1_clk = tsec1_clk;
|
|
|
|
gd->arch.tsec2_clk = tsec2_clk;
|
|
|
|
gd->arch.usbdr_clk = usbdr_clk;
|
2012-10-10 22:13:08 +00:00
|
|
|
#elif defined(CONFIG_MPC8309)
|
2012-12-13 20:48:47 +00:00
|
|
|
gd->arch.usbdr_clk = usbdr_clk;
|
2007-04-16 19:34:19 +00:00
|
|
|
#endif
|
2009-05-22 22:23:25 +00:00
|
|
|
#if defined(CONFIG_MPC834x)
|
2012-12-13 20:48:47 +00:00
|
|
|
gd->arch.usbmph_clk = usbmph_clk;
|
2007-09-18 04:36:11 +00:00
|
|
|
#endif
|
2007-09-18 04:36:58 +00:00
|
|
|
#if defined(CONFIG_MPC8315)
|
2012-12-13 20:48:47 +00:00
|
|
|
gd->arch.tdm_clk = tdm_clk;
|
2007-09-18 04:36:58 +00:00
|
|
|
#endif
|
2010-04-15 14:03:05 +00:00
|
|
|
#if defined(CONFIG_FSL_ESDHC)
|
2012-12-13 20:49:05 +00:00
|
|
|
gd->arch.sdhc_clk = sdhc_clk;
|
2006-11-04 01:33:44 +00:00
|
|
|
#endif
|
2012-12-13 20:48:47 +00:00
|
|
|
gd->arch.core_clk = core_clk;
|
2012-12-13 20:48:49 +00:00
|
|
|
gd->arch.i2c1_clk = i2c1_clk;
|
2009-05-22 22:23:25 +00:00
|
|
|
#if !defined(CONFIG_MPC832x)
|
2012-12-13 20:48:49 +00:00
|
|
|
gd->arch.i2c2_clk = i2c2_clk;
|
2006-12-07 13:13:15 +00:00
|
|
|
#endif
|
2012-10-10 22:13:08 +00:00
|
|
|
#if !defined(CONFIG_MPC8309)
|
2012-12-13 20:48:47 +00:00
|
|
|
gd->arch.enc_clk = enc_clk;
|
2012-10-10 22:13:08 +00:00
|
|
|
#endif
|
2012-12-13 20:48:47 +00:00
|
|
|
gd->arch.lbiu_clk = lbiu_clk;
|
|
|
|
gd->arch.lclk_clk = lclk_clk;
|
2008-03-28 15:18:40 +00:00
|
|
|
gd->mem_clk = mem_clk;
|
2006-12-07 13:13:15 +00:00
|
|
|
#if defined(CONFIG_MPC8360)
|
2012-12-13 20:48:47 +00:00
|
|
|
gd->arch.mem_sec_clk = mem_sec_clk;
|
2006-12-07 13:13:15 +00:00
|
|
|
#endif
|
2012-10-10 22:13:06 +00:00
|
|
|
#if defined(CONFIG_QE)
|
2012-12-13 20:48:50 +00:00
|
|
|
gd->arch.qe_clk = qe_clk;
|
2012-12-13 20:48:44 +00:00
|
|
|
gd->arch.brg_clk = brg_clk;
|
2007-09-18 04:36:11 +00:00
|
|
|
#endif
|
2011-05-25 19:51:07 +00:00
|
|
|
#if defined(CONFIG_MPC8308) || defined(CONFIG_MPC831x) || \
|
|
|
|
defined(CONFIG_MPC837x)
|
2012-12-13 20:48:47 +00:00
|
|
|
gd->arch.pciexp1_clk = pciexp1_clk;
|
|
|
|
gd->arch.pciexp2_clk = pciexp2_clk;
|
2007-09-18 04:36:58 +00:00
|
|
|
#endif
|
2009-05-22 22:23:25 +00:00
|
|
|
#if defined(CONFIG_MPC837x) || defined(CONFIG_MPC8315)
|
2012-12-13 20:48:47 +00:00
|
|
|
gd->arch.sata_clk = sata_clk;
|
2006-11-04 01:33:44 +00:00
|
|
|
#endif
|
2007-08-16 03:30:19 +00:00
|
|
|
gd->pci_clk = pci_sync_in;
|
2012-12-13 20:48:47 +00:00
|
|
|
gd->cpu_clk = gd->arch.core_clk;
|
|
|
|
gd->bus_clk = gd->arch.csb_clk;
|
2005-07-28 15:08:46 +00:00
|
|
|
return 0;
|
2006-11-04 01:33:44 +00:00
|
|
|
|
2005-07-28 15:08:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/********************************************
|
|
|
|
* get_bus_freq
|
|
|
|
* return system bus freq in Hz
|
|
|
|
*********************************************/
|
2006-11-03 01:47:11 +00:00
|
|
|
ulong get_bus_freq(ulong dummy)
|
2005-07-28 15:08:46 +00:00
|
|
|
{
|
2012-12-13 20:48:47 +00:00
|
|
|
return gd->arch.csb_clk;
|
2005-07-28 15:08:46 +00:00
|
|
|
}
|
|
|
|
|
2011-08-26 18:32:44 +00:00
|
|
|
/********************************************
|
|
|
|
* get_ddr_freq
|
|
|
|
* return ddr bus freq in Hz
|
|
|
|
*********************************************/
|
|
|
|
ulong get_ddr_freq(ulong dummy)
|
|
|
|
{
|
|
|
|
return gd->mem_clk;
|
|
|
|
}
|
|
|
|
|
powerpc/mpc83xx: sparse fixes
fdt.c:91:78: warning: Using plain integer as NULL pointer
fdt.c:103:78: warning: Using plain integer as NULL pointer
speed.c:55:11: warning: symbol 'corecnf_tab' was not declared. Should it be static?
speed.c:519:5: warning: symbol 'do_clocks' was not declared. Should it be static?
mpc8313erdb.c:73:17: warning: obsolete struct initializer, use C99 syntax
mpc8313erdb.c:74:17: warning: obsolete struct initializer, use C99 syntax
mpc8313erdb.c:75:17: warning: obsolete struct initializer, use C99 syntax
mpc8313erdb.c:76:17: warning: obsolete struct initializer, use C99 syntax
mpc8313erdb.c:79:17: warning: obsolete struct initializer, use C99 syntax
mpc8313erdb.c:80:17: warning: obsolete struct initializer, use C99 syntax
mpc8313erdb.c:81:17: warning: obsolete struct initializer, use C99 syntax
mpc8313erdb.c:82:17: warning: obsolete struct initializer, use C99 syntax
mpc8313erdb.c:85:17: warning: obsolete struct initializer, use C99 syntax
mpc8313erdb.c:86:17: warning: obsolete struct initializer, use C99 syntax
mpc8313erdb.c:87:17: warning: obsolete struct initializer, use C99 syntax
mpc8313erdb.c:88:17: warning: obsolete struct initializer, use C99 syntax
Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
2012-10-29 13:34:39 +00:00
|
|
|
static int do_clocks(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
2005-07-28 15:08:46 +00:00
|
|
|
{
|
2008-10-19 00:35:49 +00:00
|
|
|
char buf[32];
|
|
|
|
|
2005-07-28 15:08:46 +00:00
|
|
|
printf("Clock configuration:\n");
|
2012-12-13 20:48:47 +00:00
|
|
|
printf(" Core: %-4s MHz\n",
|
|
|
|
strmhz(buf, gd->arch.core_clk));
|
|
|
|
printf(" Coherent System Bus: %-4s MHz\n",
|
|
|
|
strmhz(buf, gd->arch.csb_clk));
|
2012-10-10 22:13:06 +00:00
|
|
|
#if defined(CONFIG_QE)
|
2012-12-13 20:48:50 +00:00
|
|
|
printf(" QE: %-4s MHz\n",
|
|
|
|
strmhz(buf, gd->arch.qe_clk));
|
2012-12-13 20:48:44 +00:00
|
|
|
printf(" BRG: %-4s MHz\n",
|
|
|
|
strmhz(buf, gd->arch.brg_clk));
|
2006-11-04 01:33:44 +00:00
|
|
|
#endif
|
2012-12-13 20:48:47 +00:00
|
|
|
printf(" Local Bus Controller:%-4s MHz\n",
|
|
|
|
strmhz(buf, gd->arch.lbiu_clk));
|
|
|
|
printf(" Local Bus: %-4s MHz\n",
|
|
|
|
strmhz(buf, gd->arch.lclk_clk));
|
2008-10-19 00:35:49 +00:00
|
|
|
printf(" DDR: %-4s MHz\n", strmhz(buf, gd->mem_clk));
|
2006-12-07 13:13:15 +00:00
|
|
|
#if defined(CONFIG_MPC8360)
|
2012-12-13 20:48:47 +00:00
|
|
|
printf(" DDR Secondary: %-4s MHz\n",
|
|
|
|
strmhz(buf, gd->arch.mem_sec_clk));
|
2006-11-04 01:33:44 +00:00
|
|
|
#endif
|
2012-10-10 22:13:08 +00:00
|
|
|
#if !defined(CONFIG_MPC8309)
|
2012-12-13 20:48:47 +00:00
|
|
|
printf(" SEC: %-4s MHz\n",
|
|
|
|
strmhz(buf, gd->arch.enc_clk));
|
2012-10-10 22:13:08 +00:00
|
|
|
#endif
|
2012-12-13 20:48:49 +00:00
|
|
|
printf(" I2C1: %-4s MHz\n",
|
|
|
|
strmhz(buf, gd->arch.i2c1_clk));
|
2009-05-22 22:23:25 +00:00
|
|
|
#if !defined(CONFIG_MPC832x)
|
2012-12-13 20:48:49 +00:00
|
|
|
printf(" I2C2: %-4s MHz\n",
|
|
|
|
strmhz(buf, gd->arch.i2c2_clk));
|
2006-12-07 13:13:15 +00:00
|
|
|
#endif
|
2007-09-18 04:36:58 +00:00
|
|
|
#if defined(CONFIG_MPC8315)
|
2012-12-13 20:48:47 +00:00
|
|
|
printf(" TDM: %-4s MHz\n",
|
|
|
|
strmhz(buf, gd->arch.tdm_clk));
|
2007-09-18 04:36:58 +00:00
|
|
|
#endif
|
2010-04-15 14:03:05 +00:00
|
|
|
#if defined(CONFIG_FSL_ESDHC)
|
2012-12-13 20:49:05 +00:00
|
|
|
printf(" SDHC: %-4s MHz\n",
|
|
|
|
strmhz(buf, gd->arch.sdhc_clk));
|
2007-09-18 04:36:11 +00:00
|
|
|
#endif
|
2010-06-28 12:44:33 +00:00
|
|
|
#if defined(CONFIG_MPC8308) || defined(CONFIG_MPC831x) || \
|
|
|
|
defined(CONFIG_MPC834x) || defined(CONFIG_MPC837x)
|
2012-12-13 20:48:47 +00:00
|
|
|
printf(" TSEC1: %-4s MHz\n",
|
|
|
|
strmhz(buf, gd->arch.tsec1_clk));
|
|
|
|
printf(" TSEC2: %-4s MHz\n",
|
|
|
|
strmhz(buf, gd->arch.tsec2_clk));
|
|
|
|
printf(" USB DR: %-4s MHz\n",
|
|
|
|
strmhz(buf, gd->arch.usbdr_clk));
|
2012-10-10 22:13:08 +00:00
|
|
|
#elif defined(CONFIG_MPC8309)
|
2012-12-13 20:48:47 +00:00
|
|
|
printf(" USB DR: %-4s MHz\n",
|
|
|
|
strmhz(buf, gd->arch.usbdr_clk));
|
2007-04-16 19:34:19 +00:00
|
|
|
#endif
|
2009-05-22 22:23:25 +00:00
|
|
|
#if defined(CONFIG_MPC834x)
|
2012-12-13 20:48:47 +00:00
|
|
|
printf(" USB MPH: %-4s MHz\n",
|
|
|
|
strmhz(buf, gd->arch.usbmph_clk));
|
2007-09-18 04:36:11 +00:00
|
|
|
#endif
|
2011-05-25 19:51:07 +00:00
|
|
|
#if defined(CONFIG_MPC8308) || defined(CONFIG_MPC831x) || \
|
|
|
|
defined(CONFIG_MPC837x)
|
2012-12-13 20:48:47 +00:00
|
|
|
printf(" PCIEXP1: %-4s MHz\n",
|
|
|
|
strmhz(buf, gd->arch.pciexp1_clk));
|
|
|
|
printf(" PCIEXP2: %-4s MHz\n",
|
|
|
|
strmhz(buf, gd->arch.pciexp2_clk));
|
2007-09-18 04:36:58 +00:00
|
|
|
#endif
|
2009-05-22 22:23:25 +00:00
|
|
|
#if defined(CONFIG_MPC837x) || defined(CONFIG_MPC8315)
|
2012-12-13 20:48:47 +00:00
|
|
|
printf(" SATA: %-4s MHz\n",
|
|
|
|
strmhz(buf, gd->arch.sata_clk));
|
2006-11-04 01:33:44 +00:00
|
|
|
#endif
|
2005-08-01 18:20:47 +00:00
|
|
|
return 0;
|
2005-07-28 15:08:46 +00:00
|
|
|
}
|
2007-04-30 20:26:21 +00:00
|
|
|
|
|
|
|
U_BOOT_CMD(clocks, 1, 0, do_clocks,
|
2009-01-28 00:03:12 +00:00
|
|
|
"print clock configuration",
|
2009-05-24 15:06:54 +00:00
|
|
|
" clocks"
|
2007-04-30 20:26:21 +00:00
|
|
|
);
|