xref: /openbmc/u-boot/arch/powerpc/cpu/mpc83xx/spl_minimal.c (revision dbcb2c0e2ba28fc61ab03f57de14f1085e69834f)
106f60ae3SScott Wood /*
206f60ae3SScott Wood  * Copyright (C) 2004-2008 Freescale Semiconductor, Inc.
306f60ae3SScott Wood  *
41a459660SWolfgang Denk  * SPDX-License-Identifier:	GPL-2.0+
506f60ae3SScott Wood  */
606f60ae3SScott Wood 
706f60ae3SScott Wood #include <common.h>
806f60ae3SScott Wood #include <mpc83xx.h>
906f60ae3SScott Wood 
1006f60ae3SScott Wood DECLARE_GLOBAL_DATA_PTR;
1106f60ae3SScott Wood 
1206f60ae3SScott Wood /*
1306f60ae3SScott Wood  * Breathe some life into the CPU...
1406f60ae3SScott Wood  *
1506f60ae3SScott Wood  * Set up the memory map,
1606f60ae3SScott Wood  * initialize a bunch of registers,
1706f60ae3SScott Wood  * initialize the UPM's
1806f60ae3SScott Wood  */
1906f60ae3SScott Wood void cpu_init_f (volatile immap_t * im)
2006f60ae3SScott Wood {
2106f60ae3SScott Wood 	/* Pointer is writable since we allocated a register for it */
2206f60ae3SScott Wood 	gd = (gd_t *) (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_GBL_DATA_OFFSET);
2306f60ae3SScott Wood 
24*dbcb2c0eSmario.six@gdsys.cc 	/* global data region was cleared in start.S */
2506f60ae3SScott Wood 
2606f60ae3SScott Wood 	/* system performance tweaking */
2706f60ae3SScott Wood 
2806f60ae3SScott Wood #ifdef CONFIG_SYS_ACR_PIPE_DEP
2906f60ae3SScott Wood 	/* Arbiter pipeline depth */
3006f60ae3SScott Wood 	im->arbiter.acr = (im->arbiter.acr & ~ACR_PIPE_DEP) |
3106f60ae3SScott Wood 			  (CONFIG_SYS_ACR_PIPE_DEP << ACR_PIPE_DEP_SHIFT);
3206f60ae3SScott Wood #endif
3306f60ae3SScott Wood 
3406f60ae3SScott Wood #ifdef CONFIG_SYS_ACR_RPTCNT
3506f60ae3SScott Wood 	/* Arbiter repeat count */
3606f60ae3SScott Wood 	im->arbiter.acr = (im->arbiter.acr & ~(ACR_RPTCNT)) |
3706f60ae3SScott Wood 			  (CONFIG_SYS_ACR_RPTCNT << ACR_RPTCNT_SHIFT);
3806f60ae3SScott Wood #endif
3906f60ae3SScott Wood 
4006f60ae3SScott Wood #ifdef CONFIG_SYS_SPCR_OPT
4106f60ae3SScott Wood 	/* Optimize transactions between CSB and other devices */
4206f60ae3SScott Wood 	im->sysconf.spcr = (im->sysconf.spcr & ~SPCR_OPT) |
4306f60ae3SScott Wood 			   (CONFIG_SYS_SPCR_OPT << SPCR_OPT_SHIFT);
4406f60ae3SScott Wood #endif
4506f60ae3SScott Wood 
46d7b4ca2bSRobert P. J. Day 	/* Enable Time Base & Decrementer (so we will have udelay()) */
4706f60ae3SScott Wood 	im->sysconf.spcr |= SPCR_TBEN;
4806f60ae3SScott Wood 
4906f60ae3SScott Wood 	/* DDR control driver register */
5006f60ae3SScott Wood #ifdef CONFIG_SYS_DDRCDR
5106f60ae3SScott Wood 	im->sysconf.ddrcdr = CONFIG_SYS_DDRCDR;
5206f60ae3SScott Wood #endif
5306f60ae3SScott Wood 	/* Output buffer impedance register */
5406f60ae3SScott Wood #ifdef CONFIG_SYS_OBIR
5506f60ae3SScott Wood 	im->sysconf.obir = CONFIG_SYS_OBIR;
5606f60ae3SScott Wood #endif
5706f60ae3SScott Wood 
5806f60ae3SScott Wood 	/*
5906f60ae3SScott Wood 	 * Memory Controller:
6006f60ae3SScott Wood 	 */
6106f60ae3SScott Wood 
6206f60ae3SScott Wood 	/* Map banks 0 and 1 to the FLASH banks 0 and 1 at preliminary
6306f60ae3SScott Wood 	 * addresses - these have to be modified later when FLASH size
6406f60ae3SScott Wood 	 * has been determined
6506f60ae3SScott Wood 	 */
6606f60ae3SScott Wood 
6706f60ae3SScott Wood #if defined(CONFIG_SYS_NAND_BR_PRELIM)  \
6806f60ae3SScott Wood 	&& defined(CONFIG_SYS_NAND_OR_PRELIM) \
6906f60ae3SScott Wood 	&& defined(CONFIG_SYS_NAND_LBLAWBAR_PRELIM) \
7006f60ae3SScott Wood 	&& defined(CONFIG_SYS_NAND_LBLAWAR_PRELIM)
7106f60ae3SScott Wood 	set_lbc_br(0, CONFIG_SYS_NAND_BR_PRELIM);
7206f60ae3SScott Wood 	set_lbc_or(0, CONFIG_SYS_NAND_OR_PRELIM);
7306f60ae3SScott Wood 	im->sysconf.lblaw[0].bar = CONFIG_SYS_NAND_LBLAWBAR_PRELIM;
7406f60ae3SScott Wood 	im->sysconf.lblaw[0].ar = CONFIG_SYS_NAND_LBLAWAR_PRELIM;
7506f60ae3SScott Wood #else
7606f60ae3SScott Wood #error CONFIG_SYS_NAND_BR_PRELIM, CONFIG_SYS_NAND_OR_PRELIM, CONFIG_SYS_NAND_LBLAWBAR_PRELIM & CONFIG_SYS_NAND_LBLAWAR_PRELIM must be defined
7706f60ae3SScott Wood #endif
7806f60ae3SScott Wood }
7906f60ae3SScott Wood 
8006f60ae3SScott Wood /*
8106f60ae3SScott Wood  * Get timebase clock frequency (like cpu_clk in Hz)
8206f60ae3SScott Wood  */
8306f60ae3SScott Wood unsigned long get_tbclk(void)
8406f60ae3SScott Wood {
8506f60ae3SScott Wood 	return (gd->bus_clk + 3L) / 4L;
8606f60ae3SScott Wood }
8706f60ae3SScott Wood 
8806f60ae3SScott Wood void puts(const char *str)
8906f60ae3SScott Wood {
9006f60ae3SScott Wood 	while (*str)
9106f60ae3SScott Wood 		putc(*str++);
9206f60ae3SScott Wood }
93