blob: 2c61f2b81dbfacb97b4d13ae309c90df9e93b467 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Scott Woodb71689b2008-06-30 14:13:28 -05002/*
3 * Copyright (C) 2004-2008 Freescale Semiconductor, Inc.
Scott Woodb71689b2008-06-30 14:13:28 -05004 */
5
6#include <common.h>
Simon Glass40d9b242020-05-10 11:40:07 -06007#include <asm-offsets.h>
Simon Glass85d65312019-12-28 10:44:58 -07008#include <clock_legacy.h>
Scott Woodb71689b2008-06-30 14:13:28 -05009#include <mpc83xx.h>
Simon Glassa9dc0682019-12-28 10:44:59 -070010#include <time.h>
Scott Woodb71689b2008-06-30 14:13:28 -050011
Mario Sixb47839c2019-01-21 09:17:58 +010012#include "lblaw/lblaw.h"
Mario Six1faf95d2019-01-21 09:18:03 +010013#include "elbc/elbc.h"
Mario Sixb47839c2019-01-21 09:17:58 +010014
Scott Woodb71689b2008-06-30 14:13:28 -050015DECLARE_GLOBAL_DATA_PTR;
16
17/*
18 * Breathe some life into the CPU...
19 *
20 * Set up the memory map,
21 * initialize a bunch of registers,
22 * initialize the UPM's
23 */
24void cpu_init_f (volatile immap_t * im)
25{
Scott Woodb71689b2008-06-30 14:13:28 -050026 /* Pointer is writable since we allocated a register for it */
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020027 gd = (gd_t *) (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_GBL_DATA_OFFSET);
Scott Woodb71689b2008-06-30 14:13:28 -050028
mario.six@gdsys.cc85df7b42017-01-17 08:33:48 +010029 /* global data region was cleared in start.S */
Scott Woodb71689b2008-06-30 14:13:28 -050030
31 /* system performance tweaking */
32
Mario Sixaa502542019-01-21 09:18:12 +010033#ifndef CONFIG_ACR_PIPE_DEP_UNSET
Scott Woodb71689b2008-06-30 14:13:28 -050034 /* Arbiter pipeline depth */
35 im->arbiter.acr = (im->arbiter.acr & ~ACR_PIPE_DEP) |
Mario Sixaa502542019-01-21 09:18:12 +010036 CONFIG_ACR_PIPE_DEP;
Scott Woodb71689b2008-06-30 14:13:28 -050037#endif
38
Mario Sixaa502542019-01-21 09:18:12 +010039#ifndef CONFIG_ACR_RPTCNT_UNSET
Scott Woodb71689b2008-06-30 14:13:28 -050040 /* Arbiter repeat count */
41 im->arbiter.acr = (im->arbiter.acr & ~(ACR_RPTCNT)) |
Mario Sixaa502542019-01-21 09:18:12 +010042 CONFIG_ACR_RPTCNT;
Scott Woodb71689b2008-06-30 14:13:28 -050043#endif
44
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020045#ifdef CONFIG_SYS_SPCR_OPT
Scott Woodb71689b2008-06-30 14:13:28 -050046 /* Optimize transactions between CSB and other devices */
47 im->sysconf.spcr = (im->sysconf.spcr & ~SPCR_OPT) |
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020048 (CONFIG_SYS_SPCR_OPT << SPCR_OPT_SHIFT);
Scott Woodb71689b2008-06-30 14:13:28 -050049#endif
50
Robert P. J. Daycbd618f2015-12-16 12:25:42 -050051 /* Enable Time Base & Decrementer (so we will have udelay()) */
Scott Woodb71689b2008-06-30 14:13:28 -050052 im->sysconf.spcr |= SPCR_TBEN;
53
54 /* DDR control driver register */
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020055#ifdef CONFIG_SYS_DDRCDR
56 im->sysconf.ddrcdr = CONFIG_SYS_DDRCDR;
Scott Woodb71689b2008-06-30 14:13:28 -050057#endif
58 /* Output buffer impedance register */
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020059#ifdef CONFIG_SYS_OBIR
60 im->sysconf.obir = CONFIG_SYS_OBIR;
Scott Woodb71689b2008-06-30 14:13:28 -050061#endif
62
63 /*
64 * Memory Controller:
65 */
66
67 /* Map banks 0 and 1 to the FLASH banks 0 and 1 at preliminary
68 * addresses - these have to be modified later when FLASH size
69 * has been determined
70 */
71
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020072#if defined(CONFIG_SYS_NAND_BR_PRELIM) \
73 && defined(CONFIG_SYS_NAND_OR_PRELIM) \
74 && defined(CONFIG_SYS_NAND_LBLAWBAR_PRELIM) \
75 && defined(CONFIG_SYS_NAND_LBLAWAR_PRELIM)
Becky Bruce0d4cee12010-06-17 11:37:20 -050076 set_lbc_br(0, CONFIG_SYS_NAND_BR_PRELIM);
77 set_lbc_or(0, CONFIG_SYS_NAND_OR_PRELIM);
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020078 im->sysconf.lblaw[0].bar = CONFIG_SYS_NAND_LBLAWBAR_PRELIM;
79 im->sysconf.lblaw[0].ar = CONFIG_SYS_NAND_LBLAWAR_PRELIM;
Scott Woodb71689b2008-06-30 14:13:28 -050080#else
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020081#error CONFIG_SYS_NAND_BR_PRELIM, CONFIG_SYS_NAND_OR_PRELIM, CONFIG_SYS_NAND_LBLAWBAR_PRELIM & CONFIG_SYS_NAND_LBLAWAR_PRELIM must be defined
Scott Woodb71689b2008-06-30 14:13:28 -050082#endif
83}
84
85/*
86 * Get timebase clock frequency (like cpu_clk in Hz)
87 */
88unsigned long get_tbclk(void)
89{
90 return (gd->bus_clk + 3L) / 4L;
91}
92
93void puts(const char *str)
94{
95 while (*str)
96 putc(*str++);
97}
Mario Sixcd677ca2019-01-21 09:17:52 +010098
99ulong get_bus_freq(ulong dummy)
100{
101 volatile immap_t *im = (immap_t *) CONFIG_SYS_IMMR;
102 u8 spmf = (im->clk.spmr & SPMR_SPMF) >> SPMR_SPMF_SHIFT;
103
Mario Sixd10f3182019-01-21 09:17:53 +0100104 return CONFIG_SYS_CLK_FREQ * spmf;
Mario Sixcd677ca2019-01-21 09:17:52 +0100105}