wdenk | 945af8d | 2003-07-16 21:53:01 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2000-2003 |
| 3 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
| 4 | * |
| 5 | * See file CREDITS for list of people who contributed to this |
| 6 | * project. |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or |
| 9 | * modify it under the terms of the GNU General Public License as |
| 10 | * published by the Free Software Foundation; either version 2 of |
| 11 | * the License, or (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program; if not, write to the Free Software |
| 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 21 | * MA 02111-1307 USA |
| 22 | */ |
| 23 | |
| 24 | #include <common.h> |
| 25 | #include <mpc5xxx.h> |
| 26 | |
Wolfgang Denk | d87080b | 2006-03-31 18:32:53 +0200 | [diff] [blame] | 27 | DECLARE_GLOBAL_DATA_PTR; |
| 28 | |
wdenk | 945af8d | 2003-07-16 21:53:01 +0000 | [diff] [blame] | 29 | /* |
| 30 | * Breath some life into the CPU... |
| 31 | * |
| 32 | * Set up the memory map, |
| 33 | * initialize a bunch of registers. |
| 34 | */ |
| 35 | void cpu_init_f (void) |
| 36 | { |
wdenk | 945af8d | 2003-07-16 21:53:01 +0000 | [diff] [blame] | 37 | unsigned long addecr = (1 << 25); /* Boot_CS */ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 38 | #if defined(CONFIG_SYS_RAMBOOT) && defined(CONFIG_MGT5100) |
wdenk | 945af8d | 2003-07-16 21:53:01 +0000 | [diff] [blame] | 39 | addecr |= (1 << 22); /* SDRAM enable */ |
| 40 | #endif |
| 41 | /* Pointer is writable since we allocated a register for it */ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 42 | gd = (gd_t *) (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_GBL_DATA_OFFSET); |
wdenk | 945af8d | 2003-07-16 21:53:01 +0000 | [diff] [blame] | 43 | |
| 44 | /* Clear initial global data */ |
| 45 | memset ((void *) gd, 0, sizeof (gd_t)); |
| 46 | |
| 47 | /* |
| 48 | * Memory Controller: configure chip selects and enable them |
| 49 | */ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 50 | #if defined(CONFIG_SYS_BOOTCS_START) && defined(CONFIG_SYS_BOOTCS_SIZE) |
| 51 | *(vu_long *)MPC5XXX_BOOTCS_START = START_REG(CONFIG_SYS_BOOTCS_START); |
| 52 | *(vu_long *)MPC5XXX_BOOTCS_STOP = STOP_REG(CONFIG_SYS_BOOTCS_START, |
| 53 | CONFIG_SYS_BOOTCS_SIZE); |
wdenk | 945af8d | 2003-07-16 21:53:01 +0000 | [diff] [blame] | 54 | #endif |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 55 | #if defined(CONFIG_SYS_BOOTCS_CFG) |
| 56 | *(vu_long *)MPC5XXX_BOOTCS_CFG = CONFIG_SYS_BOOTCS_CFG; |
wdenk | 945af8d | 2003-07-16 21:53:01 +0000 | [diff] [blame] | 57 | #endif |
| 58 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 59 | #if defined(CONFIG_SYS_CS0_START) && defined(CONFIG_SYS_CS0_SIZE) |
| 60 | *(vu_long *)MPC5XXX_CS0_START = START_REG(CONFIG_SYS_CS0_START); |
| 61 | *(vu_long *)MPC5XXX_CS0_STOP = STOP_REG(CONFIG_SYS_CS0_START, CONFIG_SYS_CS0_SIZE); |
wdenk | 945af8d | 2003-07-16 21:53:01 +0000 | [diff] [blame] | 62 | /* CS0 and BOOT_CS cannot be enabled at once. */ |
| 63 | /* addecr |= (1 << 16); */ |
| 64 | #endif |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 65 | #if defined(CONFIG_SYS_CS0_CFG) |
| 66 | *(vu_long *)MPC5XXX_CS0_CFG = CONFIG_SYS_CS0_CFG; |
wdenk | 945af8d | 2003-07-16 21:53:01 +0000 | [diff] [blame] | 67 | #endif |
| 68 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 69 | #if defined(CONFIG_SYS_CS1_START) && defined(CONFIG_SYS_CS1_SIZE) |
| 70 | *(vu_long *)MPC5XXX_CS1_START = START_REG(CONFIG_SYS_CS1_START); |
| 71 | *(vu_long *)MPC5XXX_CS1_STOP = STOP_REG(CONFIG_SYS_CS1_START, CONFIG_SYS_CS1_SIZE); |
wdenk | 945af8d | 2003-07-16 21:53:01 +0000 | [diff] [blame] | 72 | addecr |= (1 << 17); |
| 73 | #endif |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 74 | #if defined(CONFIG_SYS_CS1_CFG) |
| 75 | *(vu_long *)MPC5XXX_CS1_CFG = CONFIG_SYS_CS1_CFG; |
wdenk | 945af8d | 2003-07-16 21:53:01 +0000 | [diff] [blame] | 76 | #endif |
| 77 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 78 | #if defined(CONFIG_SYS_CS2_START) && defined(CONFIG_SYS_CS2_SIZE) |
| 79 | *(vu_long *)MPC5XXX_CS2_START = START_REG(CONFIG_SYS_CS2_START); |
| 80 | *(vu_long *)MPC5XXX_CS2_STOP = STOP_REG(CONFIG_SYS_CS2_START, CONFIG_SYS_CS2_SIZE); |
wdenk | 945af8d | 2003-07-16 21:53:01 +0000 | [diff] [blame] | 81 | addecr |= (1 << 18); |
| 82 | #endif |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 83 | #if defined(CONFIG_SYS_CS2_CFG) |
| 84 | *(vu_long *)MPC5XXX_CS2_CFG = CONFIG_SYS_CS2_CFG; |
wdenk | 945af8d | 2003-07-16 21:53:01 +0000 | [diff] [blame] | 85 | #endif |
| 86 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 87 | #if defined(CONFIG_SYS_CS3_START) && defined(CONFIG_SYS_CS3_SIZE) |
| 88 | *(vu_long *)MPC5XXX_CS3_START = START_REG(CONFIG_SYS_CS3_START); |
| 89 | *(vu_long *)MPC5XXX_CS3_STOP = STOP_REG(CONFIG_SYS_CS3_START, CONFIG_SYS_CS3_SIZE); |
wdenk | 945af8d | 2003-07-16 21:53:01 +0000 | [diff] [blame] | 90 | addecr |= (1 << 19); |
| 91 | #endif |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 92 | #if defined(CONFIG_SYS_CS3_CFG) |
| 93 | *(vu_long *)MPC5XXX_CS3_CFG = CONFIG_SYS_CS3_CFG; |
wdenk | 945af8d | 2003-07-16 21:53:01 +0000 | [diff] [blame] | 94 | #endif |
| 95 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 96 | #if defined(CONFIG_SYS_CS4_START) && defined(CONFIG_SYS_CS4_SIZE) |
| 97 | *(vu_long *)MPC5XXX_CS4_START = START_REG(CONFIG_SYS_CS4_START); |
| 98 | *(vu_long *)MPC5XXX_CS4_STOP = STOP_REG(CONFIG_SYS_CS4_START, CONFIG_SYS_CS4_SIZE); |
wdenk | 945af8d | 2003-07-16 21:53:01 +0000 | [diff] [blame] | 99 | addecr |= (1 << 20); |
| 100 | #endif |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 101 | #if defined(CONFIG_SYS_CS4_CFG) |
| 102 | *(vu_long *)MPC5XXX_CS4_CFG = CONFIG_SYS_CS4_CFG; |
wdenk | 945af8d | 2003-07-16 21:53:01 +0000 | [diff] [blame] | 103 | #endif |
| 104 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 105 | #if defined(CONFIG_SYS_CS5_START) && defined(CONFIG_SYS_CS5_SIZE) |
| 106 | *(vu_long *)MPC5XXX_CS5_START = START_REG(CONFIG_SYS_CS5_START); |
| 107 | *(vu_long *)MPC5XXX_CS5_STOP = STOP_REG(CONFIG_SYS_CS5_START, CONFIG_SYS_CS5_SIZE); |
wdenk | 945af8d | 2003-07-16 21:53:01 +0000 | [diff] [blame] | 108 | addecr |= (1 << 21); |
| 109 | #endif |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 110 | #if defined(CONFIG_SYS_CS5_CFG) |
| 111 | *(vu_long *)MPC5XXX_CS5_CFG = CONFIG_SYS_CS5_CFG; |
wdenk | 945af8d | 2003-07-16 21:53:01 +0000 | [diff] [blame] | 112 | #endif |
| 113 | |
| 114 | #if defined(CONFIG_MPC5200) |
| 115 | addecr |= 1; |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 116 | #if defined(CONFIG_SYS_CS6_START) && defined(CONFIG_SYS_CS6_SIZE) |
| 117 | *(vu_long *)MPC5XXX_CS6_START = START_REG(CONFIG_SYS_CS6_START); |
| 118 | *(vu_long *)MPC5XXX_CS6_STOP = STOP_REG(CONFIG_SYS_CS6_START, CONFIG_SYS_CS6_SIZE); |
wdenk | 945af8d | 2003-07-16 21:53:01 +0000 | [diff] [blame] | 119 | addecr |= (1 << 26); |
| 120 | #endif |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 121 | #if defined(CONFIG_SYS_CS6_CFG) |
| 122 | *(vu_long *)MPC5XXX_CS6_CFG = CONFIG_SYS_CS6_CFG; |
wdenk | 945af8d | 2003-07-16 21:53:01 +0000 | [diff] [blame] | 123 | #endif |
| 124 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 125 | #if defined(CONFIG_SYS_CS7_START) && defined(CONFIG_SYS_CS7_SIZE) |
| 126 | *(vu_long *)MPC5XXX_CS7_START = START_REG(CONFIG_SYS_CS7_START); |
| 127 | *(vu_long *)MPC5XXX_CS7_STOP = STOP_REG(CONFIG_SYS_CS7_START, CONFIG_SYS_CS7_SIZE); |
wdenk | 945af8d | 2003-07-16 21:53:01 +0000 | [diff] [blame] | 128 | addecr |= (1 << 27); |
| 129 | #endif |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 130 | #if defined(CONFIG_SYS_CS7_CFG) |
| 131 | *(vu_long *)MPC5XXX_CS7_CFG = CONFIG_SYS_CS7_CFG; |
wdenk | 945af8d | 2003-07-16 21:53:01 +0000 | [diff] [blame] | 132 | #endif |
| 133 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 134 | #if defined(CONFIG_SYS_CS_BURST) |
| 135 | *(vu_long *)MPC5XXX_CS_BURST = CONFIG_SYS_CS_BURST; |
wdenk | 945af8d | 2003-07-16 21:53:01 +0000 | [diff] [blame] | 136 | #endif |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 137 | #if defined(CONFIG_SYS_CS_DEADCYCLE) |
| 138 | *(vu_long *)MPC5XXX_CS_DEADCYCLE = CONFIG_SYS_CS_DEADCYCLE; |
wdenk | 945af8d | 2003-07-16 21:53:01 +0000 | [diff] [blame] | 139 | #endif |
| 140 | #endif /* CONFIG_MPC5200 */ |
| 141 | |
| 142 | /* Enable chip selects */ |
| 143 | *(vu_long *)MPC5XXX_ADDECR = addecr; |
| 144 | *(vu_long *)MPC5XXX_CS_CTRL = (1 << 24); |
| 145 | |
| 146 | /* Setup pin multiplexing */ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 147 | #if defined(CONFIG_SYS_GPS_PORT_CONFIG) |
| 148 | *(vu_long *)MPC5XXX_GPS_PORT_CONFIG = CONFIG_SYS_GPS_PORT_CONFIG; |
wdenk | 945af8d | 2003-07-16 21:53:01 +0000 | [diff] [blame] | 149 | #endif |
wdenk | 96dd9af | 2003-07-31 22:56:30 +0000 | [diff] [blame] | 150 | |
| 151 | #if defined(CONFIG_MPC5200) |
| 152 | /* enable timebase */ |
| 153 | *(vu_long *)(MPC5XXX_XLBARB + 0x40) |= (1 << 13); |
wdenk | 7152b1d | 2003-09-05 23:19:14 +0000 | [diff] [blame] | 154 | |
Wolfgang Denk | 8419c01 | 2006-04-18 11:05:03 +0200 | [diff] [blame] | 155 | /* Enable snooping for RAM */ |
| 156 | *(vu_long *)(MPC5XXX_XLBARB + 0x40) |= (1 << 15); |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 157 | *(vu_long *)(MPC5XXX_XLBARB + 0x70) = CONFIG_SYS_SDRAM_BASE | 0x1d; |
Wolfgang Denk | 8419c01 | 2006-04-18 11:05:03 +0200 | [diff] [blame] | 158 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 159 | # if defined(CONFIG_SYS_IPBCLK_EQUALS_XLBCLK) |
wdenk | 7152b1d | 2003-09-05 23:19:14 +0000 | [diff] [blame] | 160 | /* Motorola reports IPB should better run at 133 MHz. */ |
| 161 | *(vu_long *)MPC5XXX_ADDECR |= 1; |
| 162 | /* pci_clk_sel = 0x02, ipb_clk_sel = 0x00; */ |
| 163 | addecr = *(vu_long *)MPC5XXX_CDM_CFG; |
| 164 | addecr &= ~0x103; |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 165 | # if defined(CONFIG_SYS_PCICLK_EQUALS_IPBCLK_DIV2) |
wdenk | 56523f1 | 2004-07-11 17:40:54 +0000 | [diff] [blame] | 166 | /* pci_clk_sel = 0x01 -> IPB_CLK/2 */ |
| 167 | addecr |= 0x01; |
| 168 | # else |
| 169 | /* pci_clk_sel = 0x02 -> XLB_CLK/4 = IPB_CLK/4 */ |
wdenk | 7152b1d | 2003-09-05 23:19:14 +0000 | [diff] [blame] | 170 | addecr |= 0x02; |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 171 | # endif /* CONFIG_SYS_PCICLK_EQUALS_IPBCLK_DIV2 */ |
wdenk | 7152b1d | 2003-09-05 23:19:14 +0000 | [diff] [blame] | 172 | *(vu_long *)MPC5XXX_CDM_CFG = addecr; |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 173 | # endif /* CONFIG_SYS_IPBCLK_EQUALS_XLBCLK */ |
wdenk | 4aeb251 | 2003-09-16 17:06:05 +0000 | [diff] [blame] | 174 | /* Configure the XLB Arbiter */ |
| 175 | *(vu_long *)MPC5XXX_XLBARB_MPRIEN = 0xff; |
| 176 | *(vu_long *)MPC5XXX_XLBARB_MPRIVAL = 0x11111111; |
wdenk | e1599e8 | 2004-10-10 23:27:33 +0000 | [diff] [blame] | 177 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 178 | # if defined(CONFIG_SYS_XLB_PIPELINING) |
wdenk | e1599e8 | 2004-10-10 23:27:33 +0000 | [diff] [blame] | 179 | /* Enable piplining */ |
| 180 | *(vu_long *)(MPC5XXX_XLBARB + 0x40) &= ~(1 << 31); |
| 181 | # endif |
wdenk | 56523f1 | 2004-07-11 17:40:54 +0000 | [diff] [blame] | 182 | #endif /* CONFIG_MPC5200 */ |
wdenk | 945af8d | 2003-07-16 21:53:01 +0000 | [diff] [blame] | 183 | } |
| 184 | |
| 185 | /* |
| 186 | * initialize higher level parts of CPU like time base and timers |
| 187 | */ |
| 188 | int cpu_init_r (void) |
| 189 | { |
| 190 | /* mask all interrupts */ |
| 191 | #if defined(CONFIG_MGT5100) |
| 192 | *(vu_long *)MPC5XXX_ICTL_PER_MASK = 0xfffffc00; |
| 193 | #elif defined(CONFIG_MPC5200) |
| 194 | *(vu_long *)MPC5XXX_ICTL_PER_MASK = 0xffffff00; |
| 195 | #endif |
| 196 | *(vu_long *)MPC5XXX_ICTL_CRIT |= 0x0001ffff; |
| 197 | *(vu_long *)MPC5XXX_ICTL_EXT &= ~0x00000f00; |
wdenk | 4aeb251 | 2003-09-16 17:06:05 +0000 | [diff] [blame] | 198 | /* route critical ints to normal ints */ |
| 199 | *(vu_long *)MPC5XXX_ICTL_EXT |= 0x00000001; |
wdenk | 945af8d | 2003-07-16 21:53:01 +0000 | [diff] [blame] | 200 | |
Jon Loeliger | 4431283 | 2007-07-09 19:06:00 -0500 | [diff] [blame] | 201 | #if defined(CONFIG_CMD_NET) && defined(CONFIG_MPC5xxx_FEC) |
wdenk | 945af8d | 2003-07-16 21:53:01 +0000 | [diff] [blame] | 202 | /* load FEC microcode */ |
| 203 | loadtask(0, 2); |
| 204 | #endif |
| 205 | |
| 206 | return (0); |
| 207 | } |