Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Scott Wood | b71689b | 2008-06-30 14:13:28 -0500 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2004-2008 Freescale Semiconductor, Inc. |
Scott Wood | b71689b | 2008-06-30 14:13:28 -0500 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #include <common.h> |
| 7 | #include <mpc83xx.h> |
| 8 | |
| 9 | DECLARE_GLOBAL_DATA_PTR; |
| 10 | |
| 11 | /* |
| 12 | * Breathe some life into the CPU... |
| 13 | * |
| 14 | * Set up the memory map, |
| 15 | * initialize a bunch of registers, |
| 16 | * initialize the UPM's |
| 17 | */ |
| 18 | void cpu_init_f (volatile immap_t * im) |
| 19 | { |
Scott Wood | b71689b | 2008-06-30 14:13:28 -0500 | [diff] [blame] | 20 | /* Pointer is writable since we allocated a register for it */ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 21 | gd = (gd_t *) (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_GBL_DATA_OFFSET); |
Scott Wood | b71689b | 2008-06-30 14:13:28 -0500 | [diff] [blame] | 22 | |
mario.six@gdsys.cc | 85df7b4 | 2017-01-17 08:33:48 +0100 | [diff] [blame] | 23 | /* global data region was cleared in start.S */ |
Scott Wood | b71689b | 2008-06-30 14:13:28 -0500 | [diff] [blame] | 24 | |
| 25 | /* system performance tweaking */ |
| 26 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 27 | #ifdef CONFIG_SYS_ACR_PIPE_DEP |
Scott Wood | b71689b | 2008-06-30 14:13:28 -0500 | [diff] [blame] | 28 | /* Arbiter pipeline depth */ |
| 29 | im->arbiter.acr = (im->arbiter.acr & ~ACR_PIPE_DEP) | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 30 | (CONFIG_SYS_ACR_PIPE_DEP << ACR_PIPE_DEP_SHIFT); |
Scott Wood | b71689b | 2008-06-30 14:13:28 -0500 | [diff] [blame] | 31 | #endif |
| 32 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 33 | #ifdef CONFIG_SYS_ACR_RPTCNT |
Scott Wood | b71689b | 2008-06-30 14:13:28 -0500 | [diff] [blame] | 34 | /* Arbiter repeat count */ |
| 35 | im->arbiter.acr = (im->arbiter.acr & ~(ACR_RPTCNT)) | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 36 | (CONFIG_SYS_ACR_RPTCNT << ACR_RPTCNT_SHIFT); |
Scott Wood | b71689b | 2008-06-30 14:13:28 -0500 | [diff] [blame] | 37 | #endif |
| 38 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 39 | #ifdef CONFIG_SYS_SPCR_OPT |
Scott Wood | b71689b | 2008-06-30 14:13:28 -0500 | [diff] [blame] | 40 | /* Optimize transactions between CSB and other devices */ |
| 41 | im->sysconf.spcr = (im->sysconf.spcr & ~SPCR_OPT) | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 42 | (CONFIG_SYS_SPCR_OPT << SPCR_OPT_SHIFT); |
Scott Wood | b71689b | 2008-06-30 14:13:28 -0500 | [diff] [blame] | 43 | #endif |
| 44 | |
Robert P. J. Day | cbd618f | 2015-12-16 12:25:42 -0500 | [diff] [blame] | 45 | /* Enable Time Base & Decrementer (so we will have udelay()) */ |
Scott Wood | b71689b | 2008-06-30 14:13:28 -0500 | [diff] [blame] | 46 | im->sysconf.spcr |= SPCR_TBEN; |
| 47 | |
| 48 | /* DDR control driver register */ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 49 | #ifdef CONFIG_SYS_DDRCDR |
| 50 | im->sysconf.ddrcdr = CONFIG_SYS_DDRCDR; |
Scott Wood | b71689b | 2008-06-30 14:13:28 -0500 | [diff] [blame] | 51 | #endif |
| 52 | /* Output buffer impedance register */ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 53 | #ifdef CONFIG_SYS_OBIR |
| 54 | im->sysconf.obir = CONFIG_SYS_OBIR; |
Scott Wood | b71689b | 2008-06-30 14:13:28 -0500 | [diff] [blame] | 55 | #endif |
| 56 | |
| 57 | /* |
| 58 | * Memory Controller: |
| 59 | */ |
| 60 | |
| 61 | /* Map banks 0 and 1 to the FLASH banks 0 and 1 at preliminary |
| 62 | * addresses - these have to be modified later when FLASH size |
| 63 | * has been determined |
| 64 | */ |
| 65 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 66 | #if defined(CONFIG_SYS_NAND_BR_PRELIM) \ |
| 67 | && defined(CONFIG_SYS_NAND_OR_PRELIM) \ |
| 68 | && defined(CONFIG_SYS_NAND_LBLAWBAR_PRELIM) \ |
| 69 | && defined(CONFIG_SYS_NAND_LBLAWAR_PRELIM) |
Becky Bruce | 0d4cee1 | 2010-06-17 11:37:20 -0500 | [diff] [blame] | 70 | set_lbc_br(0, CONFIG_SYS_NAND_BR_PRELIM); |
| 71 | set_lbc_or(0, CONFIG_SYS_NAND_OR_PRELIM); |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 72 | im->sysconf.lblaw[0].bar = CONFIG_SYS_NAND_LBLAWBAR_PRELIM; |
| 73 | im->sysconf.lblaw[0].ar = CONFIG_SYS_NAND_LBLAWAR_PRELIM; |
Scott Wood | b71689b | 2008-06-30 14:13:28 -0500 | [diff] [blame] | 74 | #else |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 75 | #error CONFIG_SYS_NAND_BR_PRELIM, CONFIG_SYS_NAND_OR_PRELIM, CONFIG_SYS_NAND_LBLAWBAR_PRELIM & CONFIG_SYS_NAND_LBLAWAR_PRELIM must be defined |
Scott Wood | b71689b | 2008-06-30 14:13:28 -0500 | [diff] [blame] | 76 | #endif |
| 77 | } |
| 78 | |
| 79 | /* |
| 80 | * Get timebase clock frequency (like cpu_clk in Hz) |
| 81 | */ |
| 82 | unsigned long get_tbclk(void) |
| 83 | { |
| 84 | return (gd->bus_clk + 3L) / 4L; |
| 85 | } |
| 86 | |
| 87 | void puts(const char *str) |
| 88 | { |
| 89 | while (*str) |
| 90 | putc(*str++); |
| 91 | } |