blob: 34c81872591f20915d508cc0cbcebb7dd119101d [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 Glass85d65312019-12-28 10:44:58 -07007#include <clock_legacy.h>
Scott Woodb71689b2008-06-30 14:13:28 -05008#include <mpc83xx.h>
Simon Glassa9dc0682019-12-28 10:44:59 -07009#include <time.h>
Scott Woodb71689b2008-06-30 14:13:28 -050010
Mario Sixb47839c2019-01-21 09:17:58 +010011#include "lblaw/lblaw.h"
Mario Six1faf95d2019-01-21 09:18:03 +010012#include "elbc/elbc.h"
Mario Sixb47839c2019-01-21 09:17:58 +010013
Scott Woodb71689b2008-06-30 14:13:28 -050014DECLARE_GLOBAL_DATA_PTR;
15
16/*
17 * Breathe some life into the CPU...
18 *
19 * Set up the memory map,
20 * initialize a bunch of registers,
21 * initialize the UPM's
22 */
23void cpu_init_f (volatile immap_t * im)
24{
Scott Woodb71689b2008-06-30 14:13:28 -050025 /* Pointer is writable since we allocated a register for it */
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020026 gd = (gd_t *) (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_GBL_DATA_OFFSET);
Scott Woodb71689b2008-06-30 14:13:28 -050027
mario.six@gdsys.cc85df7b42017-01-17 08:33:48 +010028 /* global data region was cleared in start.S */
Scott Woodb71689b2008-06-30 14:13:28 -050029
30 /* system performance tweaking */
31
Mario Sixaa502542019-01-21 09:18:12 +010032#ifndef CONFIG_ACR_PIPE_DEP_UNSET
Scott Woodb71689b2008-06-30 14:13:28 -050033 /* Arbiter pipeline depth */
34 im->arbiter.acr = (im->arbiter.acr & ~ACR_PIPE_DEP) |
Mario Sixaa502542019-01-21 09:18:12 +010035 CONFIG_ACR_PIPE_DEP;
Scott Woodb71689b2008-06-30 14:13:28 -050036#endif
37
Mario Sixaa502542019-01-21 09:18:12 +010038#ifndef CONFIG_ACR_RPTCNT_UNSET
Scott Woodb71689b2008-06-30 14:13:28 -050039 /* Arbiter repeat count */
40 im->arbiter.acr = (im->arbiter.acr & ~(ACR_RPTCNT)) |
Mario Sixaa502542019-01-21 09:18:12 +010041 CONFIG_ACR_RPTCNT;
Scott Woodb71689b2008-06-30 14:13:28 -050042#endif
43
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020044#ifdef CONFIG_SYS_SPCR_OPT
Scott Woodb71689b2008-06-30 14:13:28 -050045 /* Optimize transactions between CSB and other devices */
46 im->sysconf.spcr = (im->sysconf.spcr & ~SPCR_OPT) |
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020047 (CONFIG_SYS_SPCR_OPT << SPCR_OPT_SHIFT);
Scott Woodb71689b2008-06-30 14:13:28 -050048#endif
49
Robert P. J. Daycbd618f2015-12-16 12:25:42 -050050 /* Enable Time Base & Decrementer (so we will have udelay()) */
Scott Woodb71689b2008-06-30 14:13:28 -050051 im->sysconf.spcr |= SPCR_TBEN;
52
53 /* DDR control driver register */
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020054#ifdef CONFIG_SYS_DDRCDR
55 im->sysconf.ddrcdr = CONFIG_SYS_DDRCDR;
Scott Woodb71689b2008-06-30 14:13:28 -050056#endif
57 /* Output buffer impedance register */
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020058#ifdef CONFIG_SYS_OBIR
59 im->sysconf.obir = CONFIG_SYS_OBIR;
Scott Woodb71689b2008-06-30 14:13:28 -050060#endif
61
62 /*
63 * Memory Controller:
64 */
65
66 /* Map banks 0 and 1 to the FLASH banks 0 and 1 at preliminary
67 * addresses - these have to be modified later when FLASH size
68 * has been determined
69 */
70
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020071#if defined(CONFIG_SYS_NAND_BR_PRELIM) \
72 && defined(CONFIG_SYS_NAND_OR_PRELIM) \
73 && defined(CONFIG_SYS_NAND_LBLAWBAR_PRELIM) \
74 && defined(CONFIG_SYS_NAND_LBLAWAR_PRELIM)
Becky Bruce0d4cee12010-06-17 11:37:20 -050075 set_lbc_br(0, CONFIG_SYS_NAND_BR_PRELIM);
76 set_lbc_or(0, CONFIG_SYS_NAND_OR_PRELIM);
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020077 im->sysconf.lblaw[0].bar = CONFIG_SYS_NAND_LBLAWBAR_PRELIM;
78 im->sysconf.lblaw[0].ar = CONFIG_SYS_NAND_LBLAWAR_PRELIM;
Scott Woodb71689b2008-06-30 14:13:28 -050079#else
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020080#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 -050081#endif
82}
83
84/*
85 * Get timebase clock frequency (like cpu_clk in Hz)
86 */
87unsigned long get_tbclk(void)
88{
89 return (gd->bus_clk + 3L) / 4L;
90}
91
92void puts(const char *str)
93{
94 while (*str)
95 putc(*str++);
96}
Mario Sixcd677ca2019-01-21 09:17:52 +010097
98ulong get_bus_freq(ulong dummy)
99{
100 volatile immap_t *im = (immap_t *) CONFIG_SYS_IMMR;
101 u8 spmf = (im->clk.spmr & SPMR_SPMF) >> SPMR_SPMF_SHIFT;
102
Mario Sixd10f3182019-01-21 09:17:53 +0100103 return CONFIG_SYS_CLK_FREQ * spmf;
Mario Sixcd677ca2019-01-21 09:17:52 +0100104}