xref: /openbmc/u-boot/arch/powerpc/cpu/mpc83xx/spl_minimal.c (revision 1a4596601fd395f3afb8f82f3f840c5e00bdd57a)
106f60ae3SScott Wood /*
206f60ae3SScott Wood  * Copyright (C) 2004-2008 Freescale Semiconductor, Inc.
306f60ae3SScott Wood  *
4*1a459660SWolfgang 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 	int i;
2206f60ae3SScott Wood 
2306f60ae3SScott Wood 	/* Pointer is writable since we allocated a register for it */
2406f60ae3SScott Wood 	gd = (gd_t *) (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_GBL_DATA_OFFSET);
2506f60ae3SScott Wood 
2606f60ae3SScott Wood 	/* Clear initial global data */
2706f60ae3SScott Wood 	for (i = 0; i < sizeof(gd_t); i++)
2806f60ae3SScott Wood 		((char *)gd)[i] = 0;
2906f60ae3SScott Wood 
3006f60ae3SScott Wood 	/* system performance tweaking */
3106f60ae3SScott Wood 
3206f60ae3SScott Wood #ifdef CONFIG_SYS_ACR_PIPE_DEP
3306f60ae3SScott Wood 	/* Arbiter pipeline depth */
3406f60ae3SScott Wood 	im->arbiter.acr = (im->arbiter.acr & ~ACR_PIPE_DEP) |
3506f60ae3SScott Wood 			  (CONFIG_SYS_ACR_PIPE_DEP << ACR_PIPE_DEP_SHIFT);
3606f60ae3SScott Wood #endif
3706f60ae3SScott Wood 
3806f60ae3SScott Wood #ifdef CONFIG_SYS_ACR_RPTCNT
3906f60ae3SScott Wood 	/* Arbiter repeat count */
4006f60ae3SScott Wood 	im->arbiter.acr = (im->arbiter.acr & ~(ACR_RPTCNT)) |
4106f60ae3SScott Wood 			  (CONFIG_SYS_ACR_RPTCNT << ACR_RPTCNT_SHIFT);
4206f60ae3SScott Wood #endif
4306f60ae3SScott Wood 
4406f60ae3SScott Wood #ifdef CONFIG_SYS_SPCR_OPT
4506f60ae3SScott Wood 	/* Optimize transactions between CSB and other devices */
4606f60ae3SScott Wood 	im->sysconf.spcr = (im->sysconf.spcr & ~SPCR_OPT) |
4706f60ae3SScott Wood 			   (CONFIG_SYS_SPCR_OPT << SPCR_OPT_SHIFT);
4806f60ae3SScott Wood #endif
4906f60ae3SScott Wood 
5006f60ae3SScott Wood 	/* Enable Time Base & Decrimenter (so we will have udelay()) */
5106f60ae3SScott Wood 	im->sysconf.spcr |= SPCR_TBEN;
5206f60ae3SScott Wood 
5306f60ae3SScott Wood 	/* DDR control driver register */
5406f60ae3SScott Wood #ifdef CONFIG_SYS_DDRCDR
5506f60ae3SScott Wood 	im->sysconf.ddrcdr = CONFIG_SYS_DDRCDR;
5606f60ae3SScott Wood #endif
5706f60ae3SScott Wood 	/* Output buffer impedance register */
5806f60ae3SScott Wood #ifdef CONFIG_SYS_OBIR
5906f60ae3SScott Wood 	im->sysconf.obir = CONFIG_SYS_OBIR;
6006f60ae3SScott Wood #endif
6106f60ae3SScott Wood 
6206f60ae3SScott Wood 	/*
6306f60ae3SScott Wood 	 * Memory Controller:
6406f60ae3SScott Wood 	 */
6506f60ae3SScott Wood 
6606f60ae3SScott Wood 	/* Map banks 0 and 1 to the FLASH banks 0 and 1 at preliminary
6706f60ae3SScott Wood 	 * addresses - these have to be modified later when FLASH size
6806f60ae3SScott Wood 	 * has been determined
6906f60ae3SScott Wood 	 */
7006f60ae3SScott Wood 
7106f60ae3SScott Wood #if defined(CONFIG_SYS_NAND_BR_PRELIM)  \
7206f60ae3SScott Wood 	&& defined(CONFIG_SYS_NAND_OR_PRELIM) \
7306f60ae3SScott Wood 	&& defined(CONFIG_SYS_NAND_LBLAWBAR_PRELIM) \
7406f60ae3SScott Wood 	&& defined(CONFIG_SYS_NAND_LBLAWAR_PRELIM)
7506f60ae3SScott Wood 	set_lbc_br(0, CONFIG_SYS_NAND_BR_PRELIM);
7606f60ae3SScott Wood 	set_lbc_or(0, CONFIG_SYS_NAND_OR_PRELIM);
7706f60ae3SScott Wood 	im->sysconf.lblaw[0].bar = CONFIG_SYS_NAND_LBLAWBAR_PRELIM;
7806f60ae3SScott Wood 	im->sysconf.lblaw[0].ar = CONFIG_SYS_NAND_LBLAWAR_PRELIM;
7906f60ae3SScott Wood #else
8006f60ae3SScott 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
8106f60ae3SScott Wood #endif
8206f60ae3SScott Wood }
8306f60ae3SScott Wood 
8406f60ae3SScott Wood /*
8506f60ae3SScott Wood  * Get timebase clock frequency (like cpu_clk in Hz)
8606f60ae3SScott Wood  */
8706f60ae3SScott Wood unsigned long get_tbclk(void)
8806f60ae3SScott Wood {
8906f60ae3SScott Wood 	return (gd->bus_clk + 3L) / 4L;
9006f60ae3SScott Wood }
9106f60ae3SScott Wood 
9206f60ae3SScott Wood void puts(const char *str)
9306f60ae3SScott Wood {
9406f60ae3SScott Wood 	while (*str)
9506f60ae3SScott Wood 		putc(*str++);
9606f60ae3SScott Wood }
97