blob: 784f4ab8b3e5bee98faa4a61ad38e58fc2a973d1 [file] [log] [blame]
Scott Woode4c09502008-06-30 14:13:28 -05001/*
2 * Copyright (C) 2004-2008 Freescale Semiconductor, Inc.
3 *
Wolfgang Denk1a459662013-07-08 09:37:19 +02004 * SPDX-License-Identifier: GPL-2.0+
Scott Woode4c09502008-06-30 14:13:28 -05005 */
6
7#include <common.h>
8#include <mpc83xx.h>
9
10DECLARE_GLOBAL_DATA_PTR;
11
12/*
13 * Breathe some life into the CPU...
14 *
15 * Set up the memory map,
16 * initialize a bunch of registers,
17 * initialize the UPM's
18 */
19void cpu_init_f (volatile immap_t * im)
20{
21 int i;
22
23 /* Pointer is writable since we allocated a register for it */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020024 gd = (gd_t *) (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_GBL_DATA_OFFSET);
Scott Woode4c09502008-06-30 14:13:28 -050025
26 /* Clear initial global data */
27 for (i = 0; i < sizeof(gd_t); i++)
28 ((char *)gd)[i] = 0;
29
30 /* system performance tweaking */
31
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020032#ifdef CONFIG_SYS_ACR_PIPE_DEP
Scott Woode4c09502008-06-30 14:13:28 -050033 /* Arbiter pipeline depth */
34 im->arbiter.acr = (im->arbiter.acr & ~ACR_PIPE_DEP) |
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020035 (CONFIG_SYS_ACR_PIPE_DEP << ACR_PIPE_DEP_SHIFT);
Scott Woode4c09502008-06-30 14:13:28 -050036#endif
37
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020038#ifdef CONFIG_SYS_ACR_RPTCNT
Scott Woode4c09502008-06-30 14:13:28 -050039 /* Arbiter repeat count */
40 im->arbiter.acr = (im->arbiter.acr & ~(ACR_RPTCNT)) |
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020041 (CONFIG_SYS_ACR_RPTCNT << ACR_RPTCNT_SHIFT);
Scott Woode4c09502008-06-30 14:13:28 -050042#endif
43
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020044#ifdef CONFIG_SYS_SPCR_OPT
Scott Woode4c09502008-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-VILLARD6d0f6bc2008-10-16 15:01:15 +020047 (CONFIG_SYS_SPCR_OPT << SPCR_OPT_SHIFT);
Scott Woode4c09502008-06-30 14:13:28 -050048#endif
49
50 /* Enable Time Base & Decrimenter (so we will have udelay()) */
51 im->sysconf.spcr |= SPCR_TBEN;
52
53 /* DDR control driver register */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020054#ifdef CONFIG_SYS_DDRCDR
55 im->sysconf.ddrcdr = CONFIG_SYS_DDRCDR;
Scott Woode4c09502008-06-30 14:13:28 -050056#endif
57 /* Output buffer impedance register */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020058#ifdef CONFIG_SYS_OBIR
59 im->sysconf.obir = CONFIG_SYS_OBIR;
Scott Woode4c09502008-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-VILLARD6d0f6bc2008-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 Brucef51cdaf2010-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-VILLARD6d0f6bc2008-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 Woode4c09502008-06-30 14:13:28 -050079#else
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-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 Woode4c09502008-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}