blob: 746f1febba0c050820f757565115bc447caad4e0 [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>
7#include <mpc83xx.h>
8
9DECLARE_GLOBAL_DATA_PTR;
10
11/*
12 * Breathe some life into the CPU...
13 *
14 * Set up the memory map,
15 * initialize a bunch of registers,
16 * initialize the UPM's
17 */
18void cpu_init_f (volatile immap_t * im)
19{
Scott Woodb71689b2008-06-30 14:13:28 -050020 /* Pointer is writable since we allocated a register for it */
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020021 gd = (gd_t *) (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_GBL_DATA_OFFSET);
Scott Woodb71689b2008-06-30 14:13:28 -050022
mario.six@gdsys.cc85df7b42017-01-17 08:33:48 +010023 /* global data region was cleared in start.S */
Scott Woodb71689b2008-06-30 14:13:28 -050024
25 /* system performance tweaking */
26
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020027#ifdef CONFIG_SYS_ACR_PIPE_DEP
Scott Woodb71689b2008-06-30 14:13:28 -050028 /* Arbiter pipeline depth */
29 im->arbiter.acr = (im->arbiter.acr & ~ACR_PIPE_DEP) |
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020030 (CONFIG_SYS_ACR_PIPE_DEP << ACR_PIPE_DEP_SHIFT);
Scott Woodb71689b2008-06-30 14:13:28 -050031#endif
32
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020033#ifdef CONFIG_SYS_ACR_RPTCNT
Scott Woodb71689b2008-06-30 14:13:28 -050034 /* Arbiter repeat count */
35 im->arbiter.acr = (im->arbiter.acr & ~(ACR_RPTCNT)) |
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020036 (CONFIG_SYS_ACR_RPTCNT << ACR_RPTCNT_SHIFT);
Scott Woodb71689b2008-06-30 14:13:28 -050037#endif
38
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020039#ifdef CONFIG_SYS_SPCR_OPT
Scott Woodb71689b2008-06-30 14:13:28 -050040 /* Optimize transactions between CSB and other devices */
41 im->sysconf.spcr = (im->sysconf.spcr & ~SPCR_OPT) |
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020042 (CONFIG_SYS_SPCR_OPT << SPCR_OPT_SHIFT);
Scott Woodb71689b2008-06-30 14:13:28 -050043#endif
44
Robert P. J. Daycbd618f2015-12-16 12:25:42 -050045 /* Enable Time Base & Decrementer (so we will have udelay()) */
Scott Woodb71689b2008-06-30 14:13:28 -050046 im->sysconf.spcr |= SPCR_TBEN;
47
48 /* DDR control driver register */
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020049#ifdef CONFIG_SYS_DDRCDR
50 im->sysconf.ddrcdr = CONFIG_SYS_DDRCDR;
Scott Woodb71689b2008-06-30 14:13:28 -050051#endif
52 /* Output buffer impedance register */
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020053#ifdef CONFIG_SYS_OBIR
54 im->sysconf.obir = CONFIG_SYS_OBIR;
Scott Woodb71689b2008-06-30 14:13:28 -050055#endif
56
57 /*
58 * Memory Controller:
59 */
60
61 /* Map banks 0 and 1 to the FLASH banks 0 and 1 at preliminary
62 * addresses - these have to be modified later when FLASH size
63 * has been determined
64 */
65
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020066#if defined(CONFIG_SYS_NAND_BR_PRELIM) \
67 && defined(CONFIG_SYS_NAND_OR_PRELIM) \
68 && defined(CONFIG_SYS_NAND_LBLAWBAR_PRELIM) \
69 && defined(CONFIG_SYS_NAND_LBLAWAR_PRELIM)
Becky Bruce0d4cee12010-06-17 11:37:20 -050070 set_lbc_br(0, CONFIG_SYS_NAND_BR_PRELIM);
71 set_lbc_or(0, CONFIG_SYS_NAND_OR_PRELIM);
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020072 im->sysconf.lblaw[0].bar = CONFIG_SYS_NAND_LBLAWBAR_PRELIM;
73 im->sysconf.lblaw[0].ar = CONFIG_SYS_NAND_LBLAWAR_PRELIM;
Scott Woodb71689b2008-06-30 14:13:28 -050074#else
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020075#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 -050076#endif
77}
78
79/*
80 * Get timebase clock frequency (like cpu_clk in Hz)
81 */
82unsigned long get_tbclk(void)
83{
84 return (gd->bus_clk + 3L) / 4L;
85}
86
87void puts(const char *str)
88{
89 while (*str)
90 putc(*str++);
91}