wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1 | /* |
wdenk | 4d81677 | 2003-09-03 14:03:26 +0000 | [diff] [blame] | 2 | * (C) Copyright 2000-2003 |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 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 | /* |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 25 | * CPU specific code |
| 26 | * |
| 27 | * written or collected and sometimes rewritten by |
| 28 | * Magnus Damm <damm@bitsmart.com> |
| 29 | * |
| 30 | * minor modifications by |
| 31 | * Wolfgang Denk <wd@denx.de> |
| 32 | */ |
| 33 | |
| 34 | #include <common.h> |
| 35 | #include <watchdog.h> |
| 36 | #include <command.h> |
| 37 | #include <asm/cache.h> |
| 38 | #include <ppc4xx.h> |
| 39 | |
| 40 | |
Stefan Roese | 3d9569b | 2005-11-27 19:36:26 +0100 | [diff] [blame] | 41 | #if defined(CONFIG_405GP) |
| 42 | #define PCI_ARBITER_ENABLED (mfdcr(strap) & PSR_PCI_ARBIT_EN) |
| 43 | #define PCI_ASYNC_ENABLED (mfdcr(strap) & PSR_PCI_ASYNC_EN) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 44 | #endif |
| 45 | |
Stefan Roese | 3d9569b | 2005-11-27 19:36:26 +0100 | [diff] [blame] | 46 | #if defined(CONFIG_405EP) |
| 47 | #define PCI_ARBITER_ENABLED (mfdcr(cpc0_pci) & CPC0_PCI_ARBIT_EN) |
| 48 | #define I2C_BOOTROM_ENABLED (mfdcr(cpc0_boot) & CPC0_BOOT_SEP) |
| 49 | #endif |
| 50 | |
| 51 | #if defined(CONFIG_440EP) || defined(CONFIG_440GR) |
| 52 | #define SDR0_SDSTP1_PAE (0x80000000 >> 21) |
| 53 | #define SDR0_SDSTP1_PAME (0x80000000 >> 27) |
| 54 | |
| 55 | #define PCI_ARBITER_ENABLED (mfdcr(cpc0_strp1) & SDR0_SDSTP1_PAE) |
| 56 | #define PCI_ASYNC_ENABLED (mfdcr(cpc0_strp1) & SDR0_SDSTP1_PAME) |
| 57 | #endif |
| 58 | |
| 59 | #if defined(CONFIG_440GP) |
| 60 | #define CPC0_STRP1_PAE (0x80000000 >> 11) |
| 61 | |
| 62 | #define PCI_ARBITER_ENABLED (mfdcr(cpc0_strp1) & CPC0_STRP1_PAE) |
| 63 | #endif |
| 64 | |
| 65 | #if defined(CONFIG_440GX) |
| 66 | #define SDR0_SDSTP1_PAE (0x80000000 >> 13) |
| 67 | |
| 68 | #define PCI_ARBITER_ENABLED (mfdcr(cpc0_strp1) & SDR0_SDSTP1_PAE) |
| 69 | #endif |
| 70 | |
| 71 | #if defined(CONFIG_440) |
| 72 | #define FREQ_EBC (sys_info.freqEPB) |
| 73 | #else |
| 74 | #define FREQ_EBC (sys_info.freqPLB / sys_info.pllExtBusDiv) |
| 75 | #endif |
| 76 | |
| 77 | |
| 78 | #if defined(CONFIG_440) |
| 79 | static int do_chip_reset(unsigned long sys0, unsigned long sys1); |
| 80 | #endif |
| 81 | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 82 | |
| 83 | int checkcpu (void) |
| 84 | { |
Stefan Roese | 3d9569b | 2005-11-27 19:36:26 +0100 | [diff] [blame] | 85 | #if !defined(CONFIG_405) /* not used on Xilinx 405 FPGA implementations */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 86 | DECLARE_GLOBAL_DATA_PTR; |
Stefan Roese | 3d9569b | 2005-11-27 19:36:26 +0100 | [diff] [blame] | 87 | uint pvr = get_pvr(); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 88 | ulong clock = gd->cpu_clk; |
| 89 | char buf[32]; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 90 | |
Stefan Roese | 3d9569b | 2005-11-27 19:36:26 +0100 | [diff] [blame] | 91 | #if !defined(CONFIG_IOP480) |
| 92 | sys_info_t sys_info; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 93 | |
| 94 | puts ("CPU: "); |
| 95 | |
| 96 | get_sys_info(&sys_info); |
| 97 | |
Stefan Roese | 3d9569b | 2005-11-27 19:36:26 +0100 | [diff] [blame] | 98 | puts("AMCC PowerPC 4"); |
| 99 | |
| 100 | #if defined(CONFIG_405GP) || defined(CONFIG_405CR) || defined(CONFIG_405EP) |
| 101 | puts("05"); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 102 | #endif |
Stefan Roese | 3d9569b | 2005-11-27 19:36:26 +0100 | [diff] [blame] | 103 | #if defined(CONFIG_440) |
| 104 | puts("40"); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 105 | #endif |
Stefan Roese | 3d9569b | 2005-11-27 19:36:26 +0100 | [diff] [blame] | 106 | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 107 | switch (pvr) { |
| 108 | case PVR_405GP_RB: |
Stefan Roese | 3d9569b | 2005-11-27 19:36:26 +0100 | [diff] [blame] | 109 | puts("GP Rev. B"); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 110 | break; |
Stefan Roese | 3d9569b | 2005-11-27 19:36:26 +0100 | [diff] [blame] | 111 | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 112 | case PVR_405GP_RC: |
Stefan Roese | 3d9569b | 2005-11-27 19:36:26 +0100 | [diff] [blame] | 113 | puts("GP Rev. C"); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 114 | break; |
Stefan Roese | 3d9569b | 2005-11-27 19:36:26 +0100 | [diff] [blame] | 115 | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 116 | case PVR_405GP_RD: |
Stefan Roese | 3d9569b | 2005-11-27 19:36:26 +0100 | [diff] [blame] | 117 | puts("GP Rev. D"); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 118 | break; |
Stefan Roese | 3d9569b | 2005-11-27 19:36:26 +0100 | [diff] [blame] | 119 | |
wdenk | 42dfe7a | 2004-03-14 22:25:36 +0000 | [diff] [blame] | 120 | #ifdef CONFIG_405GP |
Stefan Roese | 3d9569b | 2005-11-27 19:36:26 +0100 | [diff] [blame] | 121 | case PVR_405GP_RE: /* 405GP rev E and 405CR rev C have same PVR */ |
| 122 | puts("GP Rev. E"); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 123 | break; |
| 124 | #endif |
Stefan Roese | 3d9569b | 2005-11-27 19:36:26 +0100 | [diff] [blame] | 125 | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 126 | case PVR_405CR_RA: |
Stefan Roese | 3d9569b | 2005-11-27 19:36:26 +0100 | [diff] [blame] | 127 | puts("CR Rev. A"); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 128 | break; |
Stefan Roese | 3d9569b | 2005-11-27 19:36:26 +0100 | [diff] [blame] | 129 | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 130 | case PVR_405CR_RB: |
Stefan Roese | 3d9569b | 2005-11-27 19:36:26 +0100 | [diff] [blame] | 131 | puts("CR Rev. B"); |
| 132 | break; |
| 133 | |
| 134 | #ifdef CONFIG_405CR |
| 135 | case PVR_405CR_RC: /* 405GP rev E and 405CR rev C have same PVR */ |
| 136 | puts("CR Rev. C"); |
| 137 | break; |
| 138 | #endif |
| 139 | |
| 140 | case PVR_405GPR_RB: |
| 141 | puts("GPr Rev. B"); |
| 142 | break; |
| 143 | |
stroese | b867d70 | 2003-05-23 11:18:02 +0000 | [diff] [blame] | 144 | case PVR_405EP_RB: |
Stefan Roese | 3d9569b | 2005-11-27 19:36:26 +0100 | [diff] [blame] | 145 | puts("EP Rev. B"); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 146 | break; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 147 | |
| 148 | #if defined(CONFIG_440) |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 149 | case PVR_440GP_RB: |
Stefan Roese | c157d8e | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 150 | puts("GP Rev. B"); |
wdenk | 4d81677 | 2003-09-03 14:03:26 +0000 | [diff] [blame] | 151 | /* See errata 1.12: CHIP_4 */ |
| 152 | if ((mfdcr(cpc0_sys0) != mfdcr(cpc0_strp0)) || |
| 153 | (mfdcr(cpc0_sys1) != mfdcr(cpc0_strp1)) ){ |
| 154 | puts ( "\n\t CPC0_SYSx DCRs corrupted. " |
| 155 | "Resetting chip ...\n"); |
| 156 | udelay( 1000 * 1000 ); /* Give time for serial buf to clear */ |
| 157 | do_chip_reset ( mfdcr(cpc0_strp0), |
| 158 | mfdcr(cpc0_strp1) ); |
| 159 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 160 | break; |
Stefan Roese | 3d9569b | 2005-11-27 19:36:26 +0100 | [diff] [blame] | 161 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 162 | case PVR_440GP_RC: |
Stefan Roese | c157d8e | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 163 | puts("GP Rev. C"); |
wdenk | ba56f62 | 2004-02-06 23:19:44 +0000 | [diff] [blame] | 164 | break; |
Stefan Roese | 3d9569b | 2005-11-27 19:36:26 +0100 | [diff] [blame] | 165 | |
wdenk | ba56f62 | 2004-02-06 23:19:44 +0000 | [diff] [blame] | 166 | case PVR_440GX_RA: |
Stefan Roese | c157d8e | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 167 | puts("GX Rev. A"); |
wdenk | ba56f62 | 2004-02-06 23:19:44 +0000 | [diff] [blame] | 168 | break; |
Stefan Roese | 3d9569b | 2005-11-27 19:36:26 +0100 | [diff] [blame] | 169 | |
wdenk | ba56f62 | 2004-02-06 23:19:44 +0000 | [diff] [blame] | 170 | case PVR_440GX_RB: |
Stefan Roese | c157d8e | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 171 | puts("GX Rev. B"); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 172 | break; |
Stefan Roese | 3d9569b | 2005-11-27 19:36:26 +0100 | [diff] [blame] | 173 | |
stroese | 0a7c539 | 2005-04-07 05:33:41 +0000 | [diff] [blame] | 174 | case PVR_440GX_RC: |
Stefan Roese | c157d8e | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 175 | puts("GX Rev. C"); |
stroese | 0a7c539 | 2005-04-07 05:33:41 +0000 | [diff] [blame] | 176 | break; |
Stefan Roese | 3d9569b | 2005-11-27 19:36:26 +0100 | [diff] [blame] | 177 | |
Stefan Roese | 57275b6 | 2005-11-01 10:08:03 +0100 | [diff] [blame] | 178 | case PVR_440GX_RF: |
| 179 | puts("GX Rev. F"); |
| 180 | break; |
Stefan Roese | 3d9569b | 2005-11-27 19:36:26 +0100 | [diff] [blame] | 181 | |
Stefan Roese | c157d8e | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 182 | case PVR_440EP_RA: |
| 183 | puts("EP Rev. A"); |
| 184 | break; |
Stefan Roese | 3d9569b | 2005-11-27 19:36:26 +0100 | [diff] [blame] | 185 | |
Stefan Roese | 9a8d82f | 2005-10-04 15:00:30 +0200 | [diff] [blame] | 186 | #ifdef CONFIG_440EP |
| 187 | case PVR_440EP_RB: /* 440EP rev B and 440GR rev A have same PVR */ |
Stefan Roese | c157d8e | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 188 | puts("EP Rev. B"); |
| 189 | break; |
Stefan Roese | 9a8d82f | 2005-10-04 15:00:30 +0200 | [diff] [blame] | 190 | #endif /* CONFIG_440EP */ |
Stefan Roese | 3d9569b | 2005-11-27 19:36:26 +0100 | [diff] [blame] | 191 | |
Stefan Roese | 9a8d82f | 2005-10-04 15:00:30 +0200 | [diff] [blame] | 192 | #ifdef CONFIG_440GR |
| 193 | case PVR_440GR_RA: /* 440EP rev B and 440GR rev A have same PVR */ |
| 194 | puts("GR Rev. A"); |
| 195 | break; |
| 196 | #endif /* CONFIG_440GR */ |
Stefan Roese | 3d9569b | 2005-11-27 19:36:26 +0100 | [diff] [blame] | 197 | #endif /* CONFIG_440 */ |
| 198 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 199 | default: |
Stefan Roese | 17f50f22 | 2005-08-04 17:09:16 +0200 | [diff] [blame] | 200 | printf (" UNKNOWN (PVR=%08x)", pvr); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 201 | break; |
| 202 | } |
Stefan Roese | 3d9569b | 2005-11-27 19:36:26 +0100 | [diff] [blame] | 203 | |
| 204 | printf (" at %s MHz (PLB=%lu, OPB=%lu, EBC=%lu MHz)\n", strmhz(buf, clock), |
| 205 | sys_info.freqPLB / 1000000, |
| 206 | sys_info.freqPLB / sys_info.pllOpbDiv / 1000000, |
| 207 | FREQ_EBC / 1000000); |
| 208 | |
| 209 | #if defined(I2C_BOOTROM_ENABLED) |
| 210 | printf (" IIC Boot EEPROM %sabled\n", I2C_BOOTROM_ENABLED ? "en" : "dis"); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 211 | #endif |
Stefan Roese | 3d9569b | 2005-11-27 19:36:26 +0100 | [diff] [blame] | 212 | |
| 213 | #if defined(PCI_ARBITER_ENABLED) |
| 214 | printf (" %sternal PCI arbiter enabled", |
| 215 | (PCI_ARBITER_ENABLED) ? "In" : "Ex"); |
| 216 | #endif |
| 217 | |
| 218 | #if defined(PCI_ASYNC_ENABLED) |
| 219 | if (PCI_ASYNC_ENABLED) { |
| 220 | printf (", PCI async ext clock used"); |
| 221 | } else { |
| 222 | printf (", PCI sync clock at %lu MHz", |
| 223 | sys_info.freqPLB / sys_info.pllPciDiv / 1000000); |
| 224 | } |
| 225 | #endif |
| 226 | |
| 227 | #if defined(PCI_ARBITER_ENABLED) || defined(PCI_ASYNC_ENABLED) |
| 228 | putc('\n'); |
| 229 | #endif |
| 230 | |
| 231 | #if defined(CONFIG_405EP) |
| 232 | printf (" 16 kB I-Cache 16 kB D-Cache"); |
| 233 | #elif defined(CONFIG_440) |
| 234 | printf (" 32 kB I-Cache 32 kB D-Cache"); |
| 235 | #else |
| 236 | printf (" 16 kB I-Cache %d kB D-Cache", |
| 237 | ((pvr | 0x00000001) == PVR_405GPR_RB) ? 16 : 8); |
| 238 | #endif |
| 239 | #endif /* !defined(CONFIG_IOP480) */ |
| 240 | |
| 241 | #if defined(CONFIG_IOP480) |
| 242 | printf ("PLX IOP480 (PVR=%08x)", pvr); |
| 243 | printf (" at %s MHz:", strmhz(buf, clock)); |
| 244 | printf (" %u kB I-Cache", 4); |
| 245 | printf (" %u kB D-Cache", 2); |
| 246 | #endif |
| 247 | |
| 248 | #endif /* !defined(CONFIG_405) */ |
| 249 | |
| 250 | putc ('\n'); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 251 | |
| 252 | return 0; |
| 253 | } |
| 254 | |
| 255 | |
| 256 | /* ------------------------------------------------------------------------- */ |
| 257 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 258 | int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 259 | { |
Stefan Roese | c157d8e | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 260 | #if defined(CONFIG_YOSEMITE) || defined(CONFIG_YELLOWSTONE) |
| 261 | /*give reset to BCSR*/ |
| 262 | *(unsigned char*)(CFG_BCSR_BASE | 0x06) = 0x09; |
| 263 | |
| 264 | #else |
| 265 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 266 | /* |
| 267 | * Initiate system reset in debug control register DBCR |
| 268 | */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 269 | __asm__ __volatile__("lis 3, 0x3000" ::: "r3"); |
| 270 | #if defined(CONFIG_440) |
| 271 | __asm__ __volatile__("mtspr 0x134, 3"); |
| 272 | #else |
| 273 | __asm__ __volatile__("mtspr 0x3f2, 3"); |
| 274 | #endif |
Stefan Roese | c157d8e | 2005-08-01 16:41:48 +0200 | [diff] [blame] | 275 | |
| 276 | #endif/* defined(CONFIG_YOSEMITE) || defined(CONFIG_YELLOWSTONE)*/ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 277 | return 1; |
| 278 | } |
| 279 | |
| 280 | #if defined(CONFIG_440) |
Stefan Roese | 3d9569b | 2005-11-27 19:36:26 +0100 | [diff] [blame] | 281 | static int do_chip_reset (unsigned long sys0, unsigned long sys1) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 282 | { |
wdenk | 4d81677 | 2003-09-03 14:03:26 +0000 | [diff] [blame] | 283 | /* Changes to cpc0_sys0 and cpc0_sys1 require chip |
| 284 | * reset. |
| 285 | */ |
| 286 | mtdcr (cntrl0, mfdcr (cntrl0) | 0x80000000); /* Set SWE */ |
| 287 | mtdcr (cpc0_sys0, sys0); |
| 288 | mtdcr (cpc0_sys1, sys1); |
| 289 | mtdcr (cntrl0, mfdcr (cntrl0) & ~0x80000000); /* Clr SWE */ |
| 290 | mtspr (dbcr0, 0x20000000); /* Reset the chip */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 291 | |
wdenk | 4d81677 | 2003-09-03 14:03:26 +0000 | [diff] [blame] | 292 | return 1; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 293 | } |
| 294 | #endif |
| 295 | |
| 296 | |
| 297 | /* |
| 298 | * Get timebase clock frequency |
| 299 | */ |
| 300 | unsigned long get_tbclk (void) |
| 301 | { |
Stefan Roese | 3d9569b | 2005-11-27 19:36:26 +0100 | [diff] [blame] | 302 | #if !defined(CONFIG_IOP480) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 303 | sys_info_t sys_info; |
| 304 | |
| 305 | get_sys_info(&sys_info); |
| 306 | return (sys_info.freqProcessor); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 307 | #else |
Stefan Roese | 3d9569b | 2005-11-27 19:36:26 +0100 | [diff] [blame] | 308 | return (66000000); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 309 | #endif |
| 310 | |
| 311 | } |
| 312 | |
| 313 | |
| 314 | #if defined(CONFIG_WATCHDOG) |
| 315 | void |
| 316 | watchdog_reset(void) |
| 317 | { |
| 318 | int re_enable = disable_interrupts(); |
| 319 | reset_4xx_watchdog(); |
| 320 | if (re_enable) enable_interrupts(); |
| 321 | } |
| 322 | |
| 323 | void |
| 324 | reset_4xx_watchdog(void) |
| 325 | { |
| 326 | /* |
| 327 | * Clear TSR(WIS) bit |
| 328 | */ |
| 329 | mtspr(tsr, 0x40000000); |
| 330 | } |
| 331 | #endif /* CONFIG_WATCHDOG */ |