wdenk | 0db5bca | 2003-03-31 17:27:09 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2003 Martin Winistoerfer, martinwinistoerfer@gmx.ch. |
| 3 | * |
| 4 | * See file CREDITS for list of people who contributed to this |
| 5 | * project. |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU General Public License as |
| 9 | * published by the Free Software Foundation; either version 2 of |
| 10 | * the License, or (at your option) any later version. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with this program; if not, write to the Free Software |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 19 | * Foundation, |
wdenk | 0db5bca | 2003-03-31 17:27:09 +0000 | [diff] [blame] | 20 | */ |
| 21 | |
| 22 | /* |
| 23 | * File: cpu_init.c |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 24 | * |
wdenk | 0db5bca | 2003-03-31 17:27:09 +0000 | [diff] [blame] | 25 | * Discription: Contains initialisation functions to setup |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 26 | * the cpu properly |
wdenk | 0db5bca | 2003-03-31 17:27:09 +0000 | [diff] [blame] | 27 | * |
| 28 | */ |
| 29 | |
| 30 | #include <common.h> |
| 31 | #include <mpc5xx.h> |
| 32 | #include <watchdog.h> |
| 33 | |
| 34 | /* |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 35 | * Setup essential cpu registers to run |
wdenk | 0db5bca | 2003-03-31 17:27:09 +0000 | [diff] [blame] | 36 | */ |
| 37 | void cpu_init_f (volatile immap_t * immr) |
| 38 | { |
| 39 | volatile memctl5xx_t *memctl = &immr->im_memctl; |
| 40 | ulong reg; |
| 41 | |
| 42 | /* SYPCR - contains watchdog control. This will enable watchdog */ |
| 43 | /* if CONFIG_WATCHDOG is set */ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 44 | immr->im_siu_conf.sc_sypcr = CONFIG_SYS_SYPCR; |
wdenk | 0db5bca | 2003-03-31 17:27:09 +0000 | [diff] [blame] | 45 | |
| 46 | #if defined(CONFIG_WATCHDOG) |
| 47 | reset_5xx_watchdog (immr); |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 48 | #endif |
wdenk | 0db5bca | 2003-03-31 17:27:09 +0000 | [diff] [blame] | 49 | |
| 50 | /* SIUMCR - contains debug pin configuration */ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 51 | immr->im_siu_conf.sc_siumcr |= CONFIG_SYS_SIUMCR; |
wdenk | 0db5bca | 2003-03-31 17:27:09 +0000 | [diff] [blame] | 52 | |
| 53 | /* Initialize timebase. Unlock TBSCRK */ |
| 54 | immr->im_sitk.sitk_tbscrk = KAPWR_KEY; |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 55 | immr->im_sit.sit_tbscr = CONFIG_SYS_TBSCR; |
wdenk | 0db5bca | 2003-03-31 17:27:09 +0000 | [diff] [blame] | 56 | |
| 57 | /* Full IMB bus speed */ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 58 | immr->im_uimb.uimb_umcr = CONFIG_SYS_UMCR; |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 59 | |
wdenk | 0db5bca | 2003-03-31 17:27:09 +0000 | [diff] [blame] | 60 | /* Time base and decrementer will be enables (TBE) */ |
| 61 | /* in init_timebase() in time.c called from board_init_f(). */ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 62 | |
wdenk | 0db5bca | 2003-03-31 17:27:09 +0000 | [diff] [blame] | 63 | /* Initialize the PIT. Unlock PISCRK */ |
| 64 | immr->im_sitk.sitk_piscrk = KAPWR_KEY; |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 65 | immr->im_sit.sit_piscr = CONFIG_SYS_PISCR; |
wdenk | 0db5bca | 2003-03-31 17:27:09 +0000 | [diff] [blame] | 66 | |
wdenk | b6e4c40 | 2004-01-02 16:05:07 +0000 | [diff] [blame] | 67 | #if !defined(CONFIG_PATI) |
| 68 | /* PATI sest PLL in start.S */ |
wdenk | 0db5bca | 2003-03-31 17:27:09 +0000 | [diff] [blame] | 69 | /* PLL (CPU clock) settings */ |
| 70 | immr->im_clkrstk.cark_plprcrk = KAPWR_KEY; |
| 71 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 72 | /* If CONFIG_SYS_PLPRCR (set in the various *_config.h files) tries to |
| 73 | * set the MF field, then just copy CONFIG_SYS_PLPRCR over car_plprcr, |
| 74 | * otherwise OR in CONFIG_SYS_PLPRCR so we do not change the currentMF |
wdenk | 0db5bca | 2003-03-31 17:27:09 +0000 | [diff] [blame] | 75 | * field value. |
| 76 | */ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 77 | #if ((CONFIG_SYS_PLPRCR & PLPRCR_MF_MSK) != 0) |
| 78 | reg = CONFIG_SYS_PLPRCR; /* reset control bits */ |
wdenk | 0db5bca | 2003-03-31 17:27:09 +0000 | [diff] [blame] | 79 | #else |
| 80 | reg = immr->im_clkrst.car_plprcr; |
| 81 | reg &= PLPRCR_MF_MSK; /* isolate MF field */ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 82 | reg |= CONFIG_SYS_PLPRCR; /* reset control bits */ |
wdenk | 0db5bca | 2003-03-31 17:27:09 +0000 | [diff] [blame] | 83 | #endif |
| 84 | immr->im_clkrst.car_plprcr = reg; |
| 85 | |
wdenk | b6e4c40 | 2004-01-02 16:05:07 +0000 | [diff] [blame] | 86 | #endif /* !defined(CONFIG_PATI) */ |
| 87 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 88 | /* System integration timers. CONFIG_SYS_MASK has EBDF configuration */ |
wdenk | 0db5bca | 2003-03-31 17:27:09 +0000 | [diff] [blame] | 89 | immr->im_clkrstk.cark_sccrk = KAPWR_KEY; |
| 90 | reg = immr->im_clkrst.car_sccr; |
| 91 | reg &= SCCR_MASK; |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 92 | reg |= CONFIG_SYS_SCCR; |
wdenk | 0db5bca | 2003-03-31 17:27:09 +0000 | [diff] [blame] | 93 | immr->im_clkrst.car_sccr = reg; |
| 94 | |
| 95 | /* Memory Controller */ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 96 | memctl->memc_br0 = CONFIG_SYS_BR0_PRELIM; |
| 97 | memctl->memc_or0 = CONFIG_SYS_OR0_PRELIM; |
wdenk | 0db5bca | 2003-03-31 17:27:09 +0000 | [diff] [blame] | 98 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 99 | #if (defined(CONFIG_SYS_OR1_PRELIM) && defined(CONFIG_SYS_BR1_PRELIM)) |
| 100 | memctl->memc_or1 = CONFIG_SYS_OR1_PRELIM; |
| 101 | memctl->memc_br1 = CONFIG_SYS_BR1_PRELIM; |
wdenk | 0db5bca | 2003-03-31 17:27:09 +0000 | [diff] [blame] | 102 | #endif |
| 103 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 104 | #if defined(CONFIG_SYS_OR2_PRELIM) && defined(CONFIG_SYS_BR2_PRELIM) |
| 105 | memctl->memc_or2 = CONFIG_SYS_OR2_PRELIM; |
| 106 | memctl->memc_br2 = CONFIG_SYS_BR2_PRELIM; |
wdenk | 0db5bca | 2003-03-31 17:27:09 +0000 | [diff] [blame] | 107 | #endif |
| 108 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 109 | #if defined(CONFIG_SYS_OR3_PRELIM) && defined(CONFIG_SYS_BR3_PRELIM) |
| 110 | memctl->memc_or3 = CONFIG_SYS_OR3_PRELIM; |
| 111 | memctl->memc_br3 = CONFIG_SYS_BR3_PRELIM; |
wdenk | 0db5bca | 2003-03-31 17:27:09 +0000 | [diff] [blame] | 112 | #endif |
| 113 | |
| 114 | } |
| 115 | |
| 116 | /* |
| 117 | * Initialize higher level parts of cpu |
| 118 | */ |
| 119 | int cpu_init_r (void) |
| 120 | { |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 121 | /* Nothing to do at the moment */ |
wdenk | 0db5bca | 2003-03-31 17:27:09 +0000 | [diff] [blame] | 122 | return (0); |
| 123 | } |