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