1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2004-2008 Freescale Semiconductor, Inc.
7 #include <asm-offsets.h>
8 #include <clock_legacy.h>
10 #include <system-constants.h>
12 #include <asm/global_data.h>
14 #include "lblaw/lblaw.h"
15 #include "elbc/elbc.h"
17 DECLARE_GLOBAL_DATA_PTR;
20 * Breathe some life into the CPU...
22 * Set up the memory map,
23 * initialize a bunch of registers,
24 * initialize the UPM's
26 void cpu_init_f (volatile immap_t * im)
28 /* Pointer is writable since we allocated a register for it */
29 gd = (gd_t *)SYS_INIT_SP_ADDR;
31 /* global data region was cleared in start.S */
33 /* system performance tweaking */
35 #ifndef CONFIG_ACR_PIPE_DEP_UNSET
36 /* Arbiter pipeline depth */
37 im->arbiter.acr = (im->arbiter.acr & ~ACR_PIPE_DEP) |
41 #ifndef CONFIG_ACR_RPTCNT_UNSET
42 /* Arbiter repeat count */
43 im->arbiter.acr = (im->arbiter.acr & ~(ACR_RPTCNT)) |
47 #ifdef CONFIG_SYS_SPCR_OPT
48 /* Optimize transactions between CSB and other devices */
49 im->sysconf.spcr = (im->sysconf.spcr & ~SPCR_OPT) |
50 (CONFIG_SYS_SPCR_OPT << SPCR_OPT_SHIFT);
53 /* Enable Time Base & Decrementer (so we will have udelay()) */
54 im->sysconf.spcr |= SPCR_TBEN;
56 /* DDR control driver register */
57 #ifdef CONFIG_SYS_DDRCDR
58 im->sysconf.ddrcdr = CONFIG_SYS_DDRCDR;
60 /* Output buffer impedance register */
61 #ifdef CONFIG_SYS_OBIR
62 im->sysconf.obir = CONFIG_SYS_OBIR;
69 /* Map banks 0 and 1 to the FLASH banks 0 and 1 at preliminary
70 * addresses - these have to be modified later when FLASH size
74 #if defined(CONFIG_SYS_NAND_BR_PRELIM) \
75 && defined(CONFIG_SYS_NAND_OR_PRELIM) \
76 && defined(CONFIG_SYS_NAND_LBLAWBAR_PRELIM) \
77 && defined(CONFIG_SYS_NAND_LBLAWAR_PRELIM)
78 set_lbc_br(0, CONFIG_SYS_NAND_BR_PRELIM);
79 set_lbc_or(0, CONFIG_SYS_NAND_OR_PRELIM);
80 im->sysconf.lblaw[0].bar = CONFIG_SYS_NAND_LBLAWBAR_PRELIM;
81 im->sysconf.lblaw[0].ar = CONFIG_SYS_NAND_LBLAWAR_PRELIM;
83 #error CONFIG_SYS_NAND_BR_PRELIM, CONFIG_SYS_NAND_OR_PRELIM, CONFIG_SYS_NAND_LBLAWBAR_PRELIM & CONFIG_SYS_NAND_LBLAWAR_PRELIM must be defined
88 * Get timebase clock frequency (like cpu_clk in Hz)
90 unsigned long get_tbclk(void)
92 return (gd->bus_clk + 3L) / 4L;
95 void puts(const char *str)
101 ulong get_bus_freq(ulong dummy)
103 volatile immap_t *im = (immap_t *) CONFIG_SYS_IMMR;
104 u8 spmf = (im->clk.spmr & SPMR_SPMF) >> SPMR_SPMF_SHIFT;
106 return get_board_sys_clk() * spmf;