blob: 6d4655f1adea984f19147cf165c943e482383053 [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>
Simon Glass3ba929a2020-10-30 21:38:53 -060011#include <asm/global_data.h>
Scott Woodb71689b2008-06-30 14:13:28 -050012
Mario Sixb47839c2019-01-21 09:17:58 +010013#include "lblaw/lblaw.h"
Mario Six1faf95d2019-01-21 09:18:03 +010014#include "elbc/elbc.h"
Mario Sixb47839c2019-01-21 09:17:58 +010015
Scott Woodb71689b2008-06-30 14:13:28 -050016DECLARE_GLOBAL_DATA_PTR;
17
18/*
19 * Breathe some life into the CPU...
20 *
21 * Set up the memory map,
22 * initialize a bunch of registers,
23 * initialize the UPM's
24 */
25void cpu_init_f (volatile immap_t * im)
26{
Scott Woodb71689b2008-06-30 14:13:28 -050027 /* Pointer is writable since we allocated a register for it */
Tom Rini55f37562022-05-24 14:14:02 -040028 gd = (gd_t *)CONFIG_SYS_INIT_SP_ADDR;
Scott Woodb71689b2008-06-30 14:13:28 -050029
mario.six@gdsys.cc85df7b42017-01-17 08:33:48 +010030 /* global data region was cleared in start.S */
Scott Woodb71689b2008-06-30 14:13:28 -050031
32 /* system performance tweaking */
33
Mario Sixaa502542019-01-21 09:18:12 +010034#ifndef CONFIG_ACR_PIPE_DEP_UNSET
Scott Woodb71689b2008-06-30 14:13:28 -050035 /* Arbiter pipeline depth */
36 im->arbiter.acr = (im->arbiter.acr & ~ACR_PIPE_DEP) |
Mario Sixaa502542019-01-21 09:18:12 +010037 CONFIG_ACR_PIPE_DEP;
Scott Woodb71689b2008-06-30 14:13:28 -050038#endif
39
Mario Sixaa502542019-01-21 09:18:12 +010040#ifndef CONFIG_ACR_RPTCNT_UNSET
Scott Woodb71689b2008-06-30 14:13:28 -050041 /* Arbiter repeat count */
42 im->arbiter.acr = (im->arbiter.acr & ~(ACR_RPTCNT)) |
Mario Sixaa502542019-01-21 09:18:12 +010043 CONFIG_ACR_RPTCNT;
Scott Woodb71689b2008-06-30 14:13:28 -050044#endif
45
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020046#ifdef CONFIG_SYS_SPCR_OPT
Scott Woodb71689b2008-06-30 14:13:28 -050047 /* Optimize transactions between CSB and other devices */
48 im->sysconf.spcr = (im->sysconf.spcr & ~SPCR_OPT) |
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020049 (CONFIG_SYS_SPCR_OPT << SPCR_OPT_SHIFT);
Scott Woodb71689b2008-06-30 14:13:28 -050050#endif
51
Robert P. J. Daycbd618f2015-12-16 12:25:42 -050052 /* Enable Time Base & Decrementer (so we will have udelay()) */
Scott Woodb71689b2008-06-30 14:13:28 -050053 im->sysconf.spcr |= SPCR_TBEN;
54
55 /* DDR control driver register */
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020056#ifdef CONFIG_SYS_DDRCDR
57 im->sysconf.ddrcdr = CONFIG_SYS_DDRCDR;
Scott Woodb71689b2008-06-30 14:13:28 -050058#endif
59 /* Output buffer impedance register */
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020060#ifdef CONFIG_SYS_OBIR
61 im->sysconf.obir = CONFIG_SYS_OBIR;
Scott Woodb71689b2008-06-30 14:13:28 -050062#endif
63
64 /*
65 * Memory Controller:
66 */
67
68 /* Map banks 0 and 1 to the FLASH banks 0 and 1 at preliminary
69 * addresses - these have to be modified later when FLASH size
70 * has been determined
71 */
72
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020073#if defined(CONFIG_SYS_NAND_BR_PRELIM) \
74 && defined(CONFIG_SYS_NAND_OR_PRELIM) \
75 && defined(CONFIG_SYS_NAND_LBLAWBAR_PRELIM) \
76 && defined(CONFIG_SYS_NAND_LBLAWAR_PRELIM)
Becky Bruce0d4cee12010-06-17 11:37:20 -050077 set_lbc_br(0, CONFIG_SYS_NAND_BR_PRELIM);
78 set_lbc_or(0, CONFIG_SYS_NAND_OR_PRELIM);
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020079 im->sysconf.lblaw[0].bar = CONFIG_SYS_NAND_LBLAWBAR_PRELIM;
80 im->sysconf.lblaw[0].ar = CONFIG_SYS_NAND_LBLAWAR_PRELIM;
Scott Woodb71689b2008-06-30 14:13:28 -050081#else
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020082#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 -050083#endif
84}
85
86/*
87 * Get timebase clock frequency (like cpu_clk in Hz)
88 */
89unsigned long get_tbclk(void)
90{
91 return (gd->bus_clk + 3L) / 4L;
92}
93
94void puts(const char *str)
95{
96 while (*str)
97 putc(*str++);
98}
Mario Sixcd677ca2019-01-21 09:17:52 +010099
100ulong get_bus_freq(ulong dummy)
101{
102 volatile immap_t *im = (immap_t *) CONFIG_SYS_IMMR;
103 u8 spmf = (im->clk.spmr & SPMR_SPMF) >> SPMR_SPMF_SHIFT;
104
Tom Rini8c70baa2021-12-14 13:36:40 -0500105 return get_board_sys_clk() * spmf;
Mario Sixcd677ca2019-01-21 09:17:52 +0100106}