Loading...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 | /* * (C) Copyright 2001 * Josh Huber <huber@mclx.com>, Mission Critical Linux, Inc. * * See file CREDITS for list of people who contributed to this * project. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA */ /* * cpu.c * * CPU specific code * * written or collected and sometimes rewritten by * Magnus Damm <damm@bitsmart.com> * * minor modifications by * Wolfgang Denk <wd@denx.de> * * more modifications by * Josh Huber <huber@mclx.com> * added support for the 74xx series of cpus * added support for the 7xx series of cpus * made the code a little less hard-coded, and more auto-detectish */ #include <common.h> #include <command.h> #include <74xx_7xx.h> #include <asm/cache.h> #ifdef CONFIG_AMIGAONEG3SE #include "../board/MAI/AmigaOneG3SE/via686.h" #include "../board/MAI/AmigaOneG3SE/memio.h" #endif cpu_t get_cpu_type(void) { uint pvr = get_pvr(); cpu_t type; type = CPU_UNKNOWN; switch (PVR_VER(pvr)) { case 0x000c: type = CPU_7400; break; case 0x0008: type = CPU_750; if (((pvr >> 8) & 0xff) == 0x01) { type = CPU_750CX; /* old CX (80100 and 8010x?)*/ } else if (((pvr >> 8) & 0xff) == 0x22) { type = CPU_750CX; /* CX (82201,82202) and CXe (82214) */ } else if (((pvr >> 8) & 0xff) == 0x33) { type = CPU_750CX; /* CXe (83311) */ } else if (((pvr >> 12) & 0xF) == 0x3) { type = CPU_755; } break; case 0x7000: type = CPU_750FX; break; case 0x800C: type = CPU_7410; break; case 0x8000: type = CPU_7450; break; default: break; } return type; } /* ------------------------------------------------------------------------- */ #if !defined(CONFIG_BAB7xx) int checkcpu (void) { DECLARE_GLOBAL_DATA_PTR; uint type = get_cpu_type(); uint pvr = get_pvr(); ulong clock = gd->cpu_clk; char buf[32]; char *str; puts ("CPU: "); switch (type) { case CPU_750CX: printf ("750CX%s v%d.%d", (pvr&0xf0)?"e":"", (pvr>>8) & 0xf, pvr & 0xf); goto PR_CLK; case CPU_750: str = "750"; break; case CPU_750FX: str = "750FX"; break; case CPU_755: str = "755"; break; case CPU_7400: str = "MPC7400"; break; case CPU_7410: str = "MPC7410"; break; case CPU_7450: str = "MPC7450"; break; default: printf("Unknown CPU -- PVR: 0x%08x\n", pvr); return -1; } printf ("%s v%d.%d", str, (pvr >> 8) & 0xFF, pvr & 0xFF); PR_CLK: printf (" @ %s MHz\n", strmhz(buf, clock)); return (0); } #endif /* these two functions are unimplemented currently [josh] */ /* -------------------------------------------------------------------- */ /* L1 i-cache */ int checkicache(void) { return 0; /* XXX */ } /* -------------------------------------------------------------------- */ /* L1 d-cache */ int checkdcache(void) { return 0; /* XXX */ } /* -------------------------------------------------------------------- */ static inline void soft_restart(unsigned long addr) { /* SRR0 has system reset vector, SRR1 has default MSR value */ /* rfi restores MSR from SRR1 and sets the PC to the SRR0 value */ __asm__ __volatile__ ("mtspr 26, %0" :: "r" (addr)); __asm__ __volatile__ ("li 4, (1 << 6)" ::: "r4"); __asm__ __volatile__ ("mtspr 27, 4"); __asm__ __volatile__ ("rfi"); while(1); /* not reached */ } #if !defined(CONFIG_PCIPPC2) && \ !defined(CONFIG_BAB7xx) && \ !defined(CONFIG_ELPPC) /* no generic way to do board reset. simply call soft_reset. */ void do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) { ulong addr; /* flush and disable I/D cache */ __asm__ __volatile__ ("mfspr 3, 1008" ::: "r3"); __asm__ __volatile__ ("ori 5, 5, 0xcc00" ::: "r5"); __asm__ __volatile__ ("ori 4, 3, 0xc00" ::: "r4"); __asm__ __volatile__ ("andc 5, 3, 5" ::: "r5"); __asm__ __volatile__ ("sync"); __asm__ __volatile__ ("mtspr 1008, 4"); __asm__ __volatile__ ("isync"); __asm__ __volatile__ ("sync"); __asm__ __volatile__ ("mtspr 1008, 5"); __asm__ __volatile__ ("isync"); __asm__ __volatile__ ("sync"); #ifdef CFG_RESET_ADDRESS addr = CFG_RESET_ADDRESS; #else /* * note: when CFG_MONITOR_BASE points to a RAM address, * CFG_MONITOR_BASE - sizeof (ulong) is usually a valid * address. Better pick an address known to be invalid on your * system and assign it to CFG_RESET_ADDRESS. */ addr = CFG_MONITOR_BASE - sizeof (ulong); #endif soft_restart(addr); while(1); /* not reached */ } #endif /* ------------------------------------------------------------------------- */ /* * For the 7400 the TB clock runs at 1/4 the cpu bus speed. */ #ifdef CONFIG_AMIGAONEG3SE unsigned long get_tbclk(void) { DECLARE_GLOBAL_DATA_PTR; return (gd->bus_clk / 4); } #else /* ! CONFIG_AMIGAONEG3SE */ unsigned long get_tbclk (void) { return CFG_BUS_HZ / 4; } #endif /* CONFIG_AMIGAONEG3SE */ /* ------------------------------------------------------------------------- */ #if defined(CONFIG_WATCHDOG) #if !defined(CONFIG_PCIPPC2) && !defined(CONFIG_BAB7xx) void watchdog_reset(void) { } #endif /* !CONFIG_PCIPPC2 && !CONFIG_BAB7xx */ #endif /* CONFIG_WATCHDOG */ /* ------------------------------------------------------------------------- */ |