2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2008-06-30 19:13:28 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2004-2008 Freescale Semiconductor, Inc.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
2020-05-10 17:40:07 +00:00
|
|
|
#include <asm-offsets.h>
|
2019-12-28 17:44:58 +00:00
|
|
|
#include <clock_legacy.h>
|
2008-06-30 19:13:28 +00:00
|
|
|
#include <mpc83xx.h>
|
2022-05-25 16:16:03 +00:00
|
|
|
#include <system-constants.h>
|
2019-12-28 17:44:59 +00:00
|
|
|
#include <time.h>
|
2020-10-31 03:38:53 +00:00
|
|
|
#include <asm/global_data.h>
|
2008-06-30 19:13:28 +00:00
|
|
|
|
2019-01-21 08:17:58 +00:00
|
|
|
#include "lblaw/lblaw.h"
|
2019-01-21 08:18:03 +00:00
|
|
|
#include "elbc/elbc.h"
|
2019-01-21 08:17:58 +00:00
|
|
|
|
2008-06-30 19:13:28 +00:00
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Breathe some life into the CPU...
|
|
|
|
*
|
|
|
|
* Set up the memory map,
|
|
|
|
* initialize a bunch of registers,
|
|
|
|
* initialize the UPM's
|
|
|
|
*/
|
|
|
|
void cpu_init_f (volatile immap_t * im)
|
|
|
|
{
|
|
|
|
/* Pointer is writable since we allocated a register for it */
|
2022-05-25 16:16:03 +00:00
|
|
|
gd = (gd_t *)SYS_INIT_SP_ADDR;
|
2008-06-30 19:13:28 +00:00
|
|
|
|
2017-01-17 07:33:48 +00:00
|
|
|
/* global data region was cleared in start.S */
|
2008-06-30 19:13:28 +00:00
|
|
|
|
|
|
|
/* system performance tweaking */
|
|
|
|
|
2019-01-21 08:18:12 +00:00
|
|
|
#ifndef CONFIG_ACR_PIPE_DEP_UNSET
|
2008-06-30 19:13:28 +00:00
|
|
|
/* Arbiter pipeline depth */
|
|
|
|
im->arbiter.acr = (im->arbiter.acr & ~ACR_PIPE_DEP) |
|
2019-01-21 08:18:12 +00:00
|
|
|
CONFIG_ACR_PIPE_DEP;
|
2008-06-30 19:13:28 +00:00
|
|
|
#endif
|
|
|
|
|
2019-01-21 08:18:12 +00:00
|
|
|
#ifndef CONFIG_ACR_RPTCNT_UNSET
|
2008-06-30 19:13:28 +00:00
|
|
|
/* Arbiter repeat count */
|
|
|
|
im->arbiter.acr = (im->arbiter.acr & ~(ACR_RPTCNT)) |
|
2019-01-21 08:18:12 +00:00
|
|
|
CONFIG_ACR_RPTCNT;
|
2008-06-30 19:13:28 +00:00
|
|
|
#endif
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
#ifdef CONFIG_SYS_SPCR_OPT
|
2008-06-30 19:13:28 +00:00
|
|
|
/* Optimize transactions between CSB and other devices */
|
|
|
|
im->sysconf.spcr = (im->sysconf.spcr & ~SPCR_OPT) |
|
2008-10-16 13:01:15 +00:00
|
|
|
(CONFIG_SYS_SPCR_OPT << SPCR_OPT_SHIFT);
|
2008-06-30 19:13:28 +00:00
|
|
|
#endif
|
|
|
|
|
2015-12-16 17:25:42 +00:00
|
|
|
/* Enable Time Base & Decrementer (so we will have udelay()) */
|
2008-06-30 19:13:28 +00:00
|
|
|
im->sysconf.spcr |= SPCR_TBEN;
|
|
|
|
|
|
|
|
/* DDR control driver register */
|
2022-11-16 18:10:41 +00:00
|
|
|
#ifdef CFG_SYS_DDRCDR
|
|
|
|
im->sysconf.ddrcdr = CFG_SYS_DDRCDR;
|
2008-06-30 19:13:28 +00:00
|
|
|
#endif
|
|
|
|
/* Output buffer impedance register */
|
2022-11-16 18:10:41 +00:00
|
|
|
#ifdef CFG_SYS_OBIR
|
|
|
|
im->sysconf.obir = CFG_SYS_OBIR;
|
2008-06-30 19:13:28 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Memory Controller:
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Map banks 0 and 1 to the FLASH banks 0 and 1 at preliminary
|
|
|
|
* addresses - these have to be modified later when FLASH size
|
|
|
|
* has been determined
|
|
|
|
*/
|
|
|
|
|
2022-11-12 22:36:51 +00:00
|
|
|
#if defined(CFG_SYS_NAND_BR_PRELIM) \
|
|
|
|
&& defined(CFG_SYS_NAND_OR_PRELIM) \
|
2008-10-16 13:01:15 +00:00
|
|
|
&& defined(CONFIG_SYS_NAND_LBLAWBAR_PRELIM) \
|
|
|
|
&& defined(CONFIG_SYS_NAND_LBLAWAR_PRELIM)
|
2022-11-12 22:36:51 +00:00
|
|
|
set_lbc_br(0, CFG_SYS_NAND_BR_PRELIM);
|
|
|
|
set_lbc_or(0, CFG_SYS_NAND_OR_PRELIM);
|
2008-10-16 13:01:15 +00:00
|
|
|
im->sysconf.lblaw[0].bar = CONFIG_SYS_NAND_LBLAWBAR_PRELIM;
|
|
|
|
im->sysconf.lblaw[0].ar = CONFIG_SYS_NAND_LBLAWAR_PRELIM;
|
2008-06-30 19:13:28 +00:00
|
|
|
#else
|
2022-11-12 22:36:51 +00:00
|
|
|
#error CFG_SYS_NAND_BR_PRELIM, CFG_SYS_NAND_OR_PRELIM, CONFIG_SYS_NAND_LBLAWBAR_PRELIM & CONFIG_SYS_NAND_LBLAWAR_PRELIM must be defined
|
2008-06-30 19:13:28 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Get timebase clock frequency (like cpu_clk in Hz)
|
|
|
|
*/
|
|
|
|
unsigned long get_tbclk(void)
|
|
|
|
{
|
|
|
|
return (gd->bus_clk + 3L) / 4L;
|
|
|
|
}
|
|
|
|
|
|
|
|
void puts(const char *str)
|
|
|
|
{
|
|
|
|
while (*str)
|
|
|
|
putc(*str++);
|
|
|
|
}
|
2019-01-21 08:17:52 +00:00
|
|
|
|
|
|
|
ulong get_bus_freq(ulong dummy)
|
|
|
|
{
|
|
|
|
volatile immap_t *im = (immap_t *) CONFIG_SYS_IMMR;
|
|
|
|
u8 spmf = (im->clk.spmr & SPMR_SPMF) >> SPMR_SPMF_SHIFT;
|
|
|
|
|
2021-12-14 18:36:40 +00:00
|
|
|
return get_board_sys_clk() * spmf;
|
2019-01-21 08:17:52 +00:00
|
|
|
}
|