1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2004-2008 Freescale Semiconductor, Inc.
7 #include <clock_legacy.h>
10 #include "lblaw/lblaw.h"
11 #include "elbc/elbc.h"
13 DECLARE_GLOBAL_DATA_PTR;
16 * Breathe some life into the CPU...
18 * Set up the memory map,
19 * initialize a bunch of registers,
20 * initialize the UPM's
22 void cpu_init_f (volatile immap_t * im)
24 /* Pointer is writable since we allocated a register for it */
25 gd = (gd_t *) (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_GBL_DATA_OFFSET);
27 /* global data region was cleared in start.S */
29 /* system performance tweaking */
31 #ifndef CONFIG_ACR_PIPE_DEP_UNSET
32 /* Arbiter pipeline depth */
33 im->arbiter.acr = (im->arbiter.acr & ~ACR_PIPE_DEP) |
37 #ifndef CONFIG_ACR_RPTCNT_UNSET
38 /* Arbiter repeat count */
39 im->arbiter.acr = (im->arbiter.acr & ~(ACR_RPTCNT)) |
43 #ifdef CONFIG_SYS_SPCR_OPT
44 /* Optimize transactions between CSB and other devices */
45 im->sysconf.spcr = (im->sysconf.spcr & ~SPCR_OPT) |
46 (CONFIG_SYS_SPCR_OPT << SPCR_OPT_SHIFT);
49 /* Enable Time Base & Decrementer (so we will have udelay()) */
50 im->sysconf.spcr |= SPCR_TBEN;
52 /* DDR control driver register */
53 #ifdef CONFIG_SYS_DDRCDR
54 im->sysconf.ddrcdr = CONFIG_SYS_DDRCDR;
56 /* Output buffer impedance register */
57 #ifdef CONFIG_SYS_OBIR
58 im->sysconf.obir = CONFIG_SYS_OBIR;
65 /* Map banks 0 and 1 to the FLASH banks 0 and 1 at preliminary
66 * addresses - these have to be modified later when FLASH size
70 #if defined(CONFIG_SYS_NAND_BR_PRELIM) \
71 && defined(CONFIG_SYS_NAND_OR_PRELIM) \
72 && defined(CONFIG_SYS_NAND_LBLAWBAR_PRELIM) \
73 && defined(CONFIG_SYS_NAND_LBLAWAR_PRELIM)
74 set_lbc_br(0, CONFIG_SYS_NAND_BR_PRELIM);
75 set_lbc_or(0, CONFIG_SYS_NAND_OR_PRELIM);
76 im->sysconf.lblaw[0].bar = CONFIG_SYS_NAND_LBLAWBAR_PRELIM;
77 im->sysconf.lblaw[0].ar = CONFIG_SYS_NAND_LBLAWAR_PRELIM;
79 #error CONFIG_SYS_NAND_BR_PRELIM, CONFIG_SYS_NAND_OR_PRELIM, CONFIG_SYS_NAND_LBLAWBAR_PRELIM & CONFIG_SYS_NAND_LBLAWAR_PRELIM must be defined
84 * Get timebase clock frequency (like cpu_clk in Hz)
86 unsigned long get_tbclk(void)
88 return (gd->bus_clk + 3L) / 4L;
91 void puts(const char *str)
97 ulong get_bus_freq(ulong dummy)
99 volatile immap_t *im = (immap_t *) CONFIG_SYS_IMMR;
100 u8 spmf = (im->clk.spmr & SPMR_SPMF) >> SPMR_SPMF_SHIFT;
102 return CONFIG_SYS_CLK_FREQ * spmf;