blob: 69ec871995776ba0e05ba3424f8974288cb862b2 [file] [log] [blame]
Rafal Jaworowski8993e542007-07-27 14:43:59 +02001/*
2 * Copyright (C) 2004-2006 Freescale Semiconductor, Inc.
Wolfgang Denk843efb12009-05-16 10:47:43 +02003 * Copyright (C) 2007-2009 DENX Software Engineering
Rafal Jaworowski8993e542007-07-27 14:43:59 +02004 *
5 * See file CREDITS for list of people who contributed to this
6 * project.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21 * MA 02111-1307 USA
22 *
23 * Derived from the MPC83xx code.
24 *
25 */
26
27#include <common.h>
28#include <mpc512x.h>
Wolfgang Denk843efb12009-05-16 10:47:43 +020029#include <asm/io.h>
30#include <asm/processor.h>
Rafal Jaworowski8993e542007-07-27 14:43:59 +020031
32DECLARE_GLOBAL_DATA_PTR;
33
34/*
35 * Set up the memory map, initialize registers,
36 */
37void cpu_init_f (volatile immap_t * im)
38{
39 u32 ips_div;
40
41 /* Pointer is writable since we allocated a register for it */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020042 gd = (gd_t *) (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_GBL_DATA_OFFSET);
Rafal Jaworowski8993e542007-07-27 14:43:59 +020043
44 /* Clear initial global data */
45 memset ((void *) gd, 0, sizeof (gd_t));
46
47 /* system performance tweaking */
48
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020049#ifdef CONFIG_SYS_ACR_PIPE_DEP
Rafal Jaworowski8993e542007-07-27 14:43:59 +020050 /* Arbiter pipeline depth */
Wolfgang Denk843efb12009-05-16 10:47:43 +020051 out_be32(&im->arbiter.acr,
52 (im->arbiter.acr & ~ACR_PIPE_DEP) |
53 (CONFIG_SYS_ACR_PIPE_DEP << ACR_PIPE_DEP_SHIFT)
54 );
Rafal Jaworowski8993e542007-07-27 14:43:59 +020055#endif
56
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020057#ifdef CONFIG_SYS_ACR_RPTCNT
Rafal Jaworowski8993e542007-07-27 14:43:59 +020058 /* Arbiter repeat count */
Wolfgang Denk843efb12009-05-16 10:47:43 +020059 out_be32(im->arbiter.acr,
60 (im->arbiter.acr & ~(ACR_RPTCNT)) |
61 (CONFIG_SYS_ACR_RPTCNT << ACR_RPTCNT_SHIFT)
62 );
Rafal Jaworowski8993e542007-07-27 14:43:59 +020063#endif
64
65 /* RSR - Reset Status Register - clear all status */
66 gd->reset_status = im->reset.rsr;
Wolfgang Denk843efb12009-05-16 10:47:43 +020067 out_be32(&im->reset.rsr, ~RSR_RES);
Rafal Jaworowski8993e542007-07-27 14:43:59 +020068
69 /*
70 * RMR - Reset Mode Register - enable checkstop reset
71 */
Wolfgang Denk843efb12009-05-16 10:47:43 +020072 out_be32(&im->reset.rmr, RMR_CSRE & (1 << RMR_CSRE_SHIFT));
Rafal Jaworowski8993e542007-07-27 14:43:59 +020073
74 /* Set IPS-CSB divider: IPS = 1/2 CSB */
Wolfgang Denk843efb12009-05-16 10:47:43 +020075 ips_div = in_be32(&im->clk.scfr[0]);
Rafal Jaworowski8993e542007-07-27 14:43:59 +020076 ips_div &= ~(SCFR1_IPS_DIV_MASK);
77 ips_div |= SCFR1_IPS_DIV << SCFR1_IPS_DIV_SHIFT;
Wolfgang Denk843efb12009-05-16 10:47:43 +020078 out_be32(&im->clk.scfr[0], ips_div);
Rafal Jaworowski8993e542007-07-27 14:43:59 +020079
80 /*
81 * Enable Time Base/Decrementer
82 *
83 * NOTICE: TB needs to be enabled as early as possible in order to
84 * have udelay() working; if not enabled, usually leads to a hang, like
Wolfgang Denkb1b54e32007-08-02 21:27:46 +020085 * during FLASH chip identification etc.
Rafal Jaworowski8993e542007-07-27 14:43:59 +020086 */
Wolfgang Denk843efb12009-05-16 10:47:43 +020087 setbits_be32(&im->sysconf.spcr, SPCR_TBEN);
Rafal Jaworowski8993e542007-07-27 14:43:59 +020088}
89
90int cpu_init_r (void)
91{
92 return 0;
93}