Jon Loeliger | 5c8aa97 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 1 | /* |
Jon Loeliger | e65e32e | 2006-05-31 12:44:44 -0500 | [diff] [blame] | 2 | * Copyright 2006 Freescale Semiconductor |
| 3 | * Jeff Brown |
Jon Loeliger | 5c8aa97 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 4 | * Srikanth Srinivasan (srikanth.srinivasan@freescale.com) |
| 5 | * |
| 6 | * See file CREDITS for list of people who contributed to this |
| 7 | * project. |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or |
| 10 | * modify it under the terms of the GNU General Public License as |
| 11 | * published by the Free Software Foundation; either version 2 of |
| 12 | * the License, or (at your option) any later version. |
| 13 | * |
| 14 | * This program is distributed in the hope that it will be useful, |
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | * GNU General Public License for more details. |
| 18 | * |
| 19 | * You should have received a copy of the GNU General Public License |
| 20 | * along with this program; if not, write to the Free Software |
| 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 22 | * MA 02111-1307 USA |
| 23 | */ |
| 24 | |
| 25 | #include <common.h> |
| 26 | #include <watchdog.h> |
| 27 | #include <command.h> |
| 28 | #include <asm/cache.h> |
Becky Bruce | 7e07c77 | 2008-05-08 19:02:51 -0500 | [diff] [blame] | 29 | #include <asm/mmu.h> |
Jon Loeliger | 5c8aa97 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 30 | #include <mpc86xx.h> |
Andy Fleming | fecff2b | 2008-08-31 16:33:26 -0500 | [diff] [blame] | 31 | #include <tsec.h> |
Becky Bruce | b0b3094 | 2008-01-23 16:31:06 -0600 | [diff] [blame] | 32 | #include <asm/fsl_law.h> |
Jon Loeliger | 5c8aa97 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 33 | |
Kumar Gala | 1e2e9fa | 2009-06-18 08:23:01 -0500 | [diff] [blame] | 34 | struct cpu_type cpu_type_list [] = { |
| 35 | CPU_TYPE_ENTRY(8610, 8610), |
| 36 | CPU_TYPE_ENTRY(8641, 8641), |
| 37 | CPU_TYPE_ENTRY(8641D, 8641D), |
| 38 | }; |
| 39 | |
| 40 | struct cpu_type *identify_cpu(u32 ver) |
| 41 | { |
| 42 | int i; |
| 43 | for (i = 0; i < ARRAY_SIZE(cpu_type_list); i++) |
| 44 | if (cpu_type_list[i].soc_ver == ver) |
| 45 | return &cpu_type_list[i]; |
| 46 | |
| 47 | return NULL; |
| 48 | } |
Jon Loeliger | 5c8aa97 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 49 | |
Peter Tyser | 6945440 | 2009-02-05 11:25:25 -0600 | [diff] [blame] | 50 | /* |
| 51 | * Default board reset function |
| 52 | */ |
| 53 | static void |
| 54 | __board_reset(void) |
| 55 | { |
| 56 | /* Do nothing */ |
| 57 | } |
Peter Tyser | 21d2cd2 | 2009-04-20 11:08:46 -0500 | [diff] [blame] | 58 | void board_reset(void) __attribute__((weak, alias("__board_reset"))); |
Peter Tyser | 6945440 | 2009-02-05 11:25:25 -0600 | [diff] [blame] | 59 | |
| 60 | |
Jon Loeliger | a129544 | 2006-08-22 12:06:18 -0500 | [diff] [blame] | 61 | int |
| 62 | checkcpu(void) |
Jon Loeliger | 5c8aa97 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 63 | { |
| 64 | sys_info_t sysinfo; |
| 65 | uint pvr, svr; |
| 66 | uint ver; |
| 67 | uint major, minor; |
Peter Tyser | 698f3a1 | 2009-02-06 14:30:40 -0600 | [diff] [blame] | 68 | char buf1[32], buf2[32]; |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 69 | volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR; |
Jon Loeliger | 3b971c9 | 2007-10-16 15:26:51 -0500 | [diff] [blame] | 70 | volatile ccsr_gur_t *gur = &immap->im_gur; |
Kumar Gala | 1e2e9fa | 2009-06-18 08:23:01 -0500 | [diff] [blame] | 71 | struct cpu_type *cpu; |
Peter Tyser | 698f3a1 | 2009-02-06 14:30:40 -0600 | [diff] [blame] | 72 | uint msscr0 = mfspr(MSSCR0); |
Jon Loeliger | 5c8aa97 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 73 | |
| 74 | svr = get_svr(); |
Andy Fleming | f574097 | 2008-02-06 01:19:40 -0600 | [diff] [blame] | 75 | ver = SVR_SOC_VER(svr); |
Jon Loeliger | 5c8aa97 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 76 | major = SVR_MAJ(svr); |
| 77 | minor = SVR_MIN(svr); |
| 78 | |
Peter Tyser | 698f3a1 | 2009-02-06 14:30:40 -0600 | [diff] [blame] | 79 | puts("CPU: "); |
| 80 | |
Kumar Gala | 1e2e9fa | 2009-06-18 08:23:01 -0500 | [diff] [blame] | 81 | cpu = identify_cpu(ver); |
| 82 | if (cpu) { |
| 83 | puts(cpu->name); |
| 84 | } else { |
Jon Loeliger | 5c8aa97 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 85 | puts("Unknown"); |
Jon Loeliger | 5c8aa97 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 86 | } |
Kumar Gala | 1e2e9fa | 2009-06-18 08:23:01 -0500 | [diff] [blame] | 87 | |
Jon Loeliger | 5c8aa97 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 88 | printf(", Version: %d.%d, (0x%08x)\n", major, minor, svr); |
Peter Tyser | 698f3a1 | 2009-02-06 14:30:40 -0600 | [diff] [blame] | 89 | puts("Core: "); |
| 90 | |
| 91 | pvr = get_pvr(); |
| 92 | ver = PVR_E600_VER(pvr); |
| 93 | major = PVR_E600_MAJ(pvr); |
| 94 | minor = PVR_E600_MIN(pvr); |
| 95 | |
| 96 | printf("E600 Core %d", (msscr0 & 0x20) ? 1 : 0 ); |
| 97 | if (gur->pordevsr & MPC86xx_PORDEVSR_CORE1TE) |
| 98 | puts("\n Core1Translation Enabled"); |
| 99 | debug(" (MSSCR0=%x, PORDEVSR=%x)", msscr0, gur->pordevsr); |
| 100 | |
| 101 | printf(", Version: %d.%d, (0x%08x)\n", major, minor, pvr); |
Jon Loeliger | 5c8aa97 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 102 | |
| 103 | get_sys_info(&sysinfo); |
| 104 | |
Peter Tyser | 698f3a1 | 2009-02-06 14:30:40 -0600 | [diff] [blame] | 105 | puts("Clock Configuration:\n"); |
| 106 | printf(" CPU:%-4s MHz, ", strmhz(buf1, sysinfo.freqProcessor)); |
| 107 | printf("MPX:%-4s MHz\n", strmhz(buf1, sysinfo.freqSystemBus)); |
| 108 | printf(" DDR:%-4s MHz (%s MT/s data rate), ", |
| 109 | strmhz(buf1, sysinfo.freqSystemBus / 2), |
| 110 | strmhz(buf2, sysinfo.freqSystemBus)); |
Jon Loeliger | 465b9d8 | 2006-04-27 10:15:16 -0500 | [diff] [blame] | 111 | |
Trent Piepho | 0b691fc | 2008-12-03 15:16:37 -0800 | [diff] [blame] | 112 | if (sysinfo.freqLocalBus > LCRR_CLKDIV) { |
Peter Tyser | 698f3a1 | 2009-02-06 14:30:40 -0600 | [diff] [blame] | 113 | printf("LBC:%-4s MHz\n", strmhz(buf1, sysinfo.freqLocalBus)); |
Jon Loeliger | 5c8aa97 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 114 | } else { |
Wolfgang Denk | 3fe630c | 2009-01-12 14:50:35 +0100 | [diff] [blame] | 115 | printf("LBC: unknown (LCRR[CLKDIV] = 0x%02lx)\n", |
Trent Piepho | 0b691fc | 2008-12-03 15:16:37 -0800 | [diff] [blame] | 116 | sysinfo.freqLocalBus); |
Jon Loeliger | 5c8aa97 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 117 | } |
| 118 | |
Peter Tyser | 698f3a1 | 2009-02-06 14:30:40 -0600 | [diff] [blame] | 119 | puts("L1: D-cache 32 KB enabled\n"); |
| 120 | puts(" I-cache 32 KB enabled\n"); |
| 121 | |
| 122 | puts("L2: "); |
| 123 | if (get_l2cr() & 0x80000000) { |
| 124 | #if defined(CONFIG_MPC8610) |
| 125 | puts("256"); |
| 126 | #elif defined(CONFIG_MPC8641) |
| 127 | puts("512"); |
| 128 | #endif |
| 129 | puts(" KB enabled\n"); |
| 130 | } else { |
Jon Loeliger | e65e32e | 2006-05-31 12:44:44 -0500 | [diff] [blame] | 131 | puts("Disabled\n"); |
Peter Tyser | 698f3a1 | 2009-02-06 14:30:40 -0600 | [diff] [blame] | 132 | } |
Jon Loeliger | 465b9d8 | 2006-04-27 10:15:16 -0500 | [diff] [blame] | 133 | |
| 134 | return 0; |
Jon Loeliger | 5c8aa97 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 135 | } |
| 136 | |
| 137 | |
Jon Loeliger | 5c8aa97 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 138 | void |
Jon Loeliger | d68e2ba | 2006-05-30 17:47:00 -0500 | [diff] [blame] | 139 | do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) |
Jon Loeliger | 5c8aa97 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 140 | { |
Peter Tyser | 6945440 | 2009-02-05 11:25:25 -0600 | [diff] [blame] | 141 | volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR; |
| 142 | volatile ccsr_gur_t *gur = &immap->im_gur; |
Jon Loeliger | 465b9d8 | 2006-04-27 10:15:16 -0500 | [diff] [blame] | 143 | |
Peter Tyser | 6945440 | 2009-02-05 11:25:25 -0600 | [diff] [blame] | 144 | /* Attempt board-specific reset */ |
| 145 | board_reset(); |
Jon Loeliger | 465b9d8 | 2006-04-27 10:15:16 -0500 | [diff] [blame] | 146 | |
Peter Tyser | 6945440 | 2009-02-05 11:25:25 -0600 | [diff] [blame] | 147 | /* Next try asserting HRESET_REQ */ |
| 148 | out_be32(&gur->rstcr, MPC86xx_RSTCR_HRST_REQ); |
Jon Loeliger | 465b9d8 | 2006-04-27 10:15:16 -0500 | [diff] [blame] | 149 | |
Peter Tyser | 6945440 | 2009-02-05 11:25:25 -0600 | [diff] [blame] | 150 | while (1) |
| 151 | ; |
Jon Loeliger | 5c8aa97 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 152 | } |
| 153 | |
| 154 | |
Jon Loeliger | 5c8aa97 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 155 | /* |
| 156 | * Get timebase clock frequency |
| 157 | */ |
Jon Loeliger | a129544 | 2006-08-22 12:06:18 -0500 | [diff] [blame] | 158 | unsigned long |
| 159 | get_tbclk(void) |
Jon Loeliger | 5c8aa97 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 160 | { |
Jon Loeliger | a129544 | 2006-08-22 12:06:18 -0500 | [diff] [blame] | 161 | sys_info_t sys_info; |
Jon Loeliger | 5c8aa97 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 162 | |
| 163 | get_sys_info(&sys_info); |
Jon Loeliger | 465b9d8 | 2006-04-27 10:15:16 -0500 | [diff] [blame] | 164 | return (sys_info.freqSystemBus + 3L) / 4L; |
Jon Loeliger | 5c8aa97 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 165 | } |
| 166 | |
Jon Loeliger | 5c8aa97 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 167 | |
| 168 | #if defined(CONFIG_WATCHDOG) |
| 169 | void |
| 170 | watchdog_reset(void) |
| 171 | { |
Jason Jin | 6c71b94 | 2008-05-13 11:50:36 +0800 | [diff] [blame] | 172 | #if defined(CONFIG_MPC8610) |
| 173 | /* |
| 174 | * This actually feed the hard enabled watchdog. |
| 175 | */ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 176 | volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR; |
Jason Jin | 6c71b94 | 2008-05-13 11:50:36 +0800 | [diff] [blame] | 177 | volatile ccsr_wdt_t *wdt = &immap->im_wdt; |
| 178 | volatile ccsr_gur_t *gur = &immap->im_gur; |
| 179 | u32 tmp = gur->pordevsr; |
| 180 | |
| 181 | if (tmp & 0x4000) { |
| 182 | wdt->swsrr = 0x556c; |
| 183 | wdt->swsrr = 0xaa39; |
| 184 | } |
| 185 | #endif |
Jon Loeliger | 5c8aa97 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 186 | } |
| 187 | #endif /* CONFIG_WATCHDOG */ |
| 188 | |
Becky Bruce | b0b3094 | 2008-01-23 16:31:06 -0600 | [diff] [blame] | 189 | /* |
| 190 | * Print out the state of various machine registers. |
Becky Bruce | 7e07c77 | 2008-05-08 19:02:51 -0500 | [diff] [blame] | 191 | * Currently prints out LAWs, BR0/OR0, and BATs |
Becky Bruce | b0b3094 | 2008-01-23 16:31:06 -0600 | [diff] [blame] | 192 | */ |
| 193 | void mpc86xx_reginfo(void) |
| 194 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 195 | immap_t *immap = (immap_t *)CONFIG_SYS_IMMR; |
Becky Bruce | b0b3094 | 2008-01-23 16:31:06 -0600 | [diff] [blame] | 196 | ccsr_lbc_t *lbc = &immap->im_lbc; |
| 197 | |
Becky Bruce | 7e07c77 | 2008-05-08 19:02:51 -0500 | [diff] [blame] | 198 | print_bats(); |
Becky Bruce | b0b3094 | 2008-01-23 16:31:06 -0600 | [diff] [blame] | 199 | print_laws(); |
| 200 | |
| 201 | printf ("Local Bus Controller Registers\n" |
| 202 | "\tBR0\t0x%08X\tOR0\t0x%08X \n", in_be32(&lbc->br0), in_be32(&lbc->or0)); |
| 203 | printf("\tBR1\t0x%08X\tOR1\t0x%08X \n", in_be32(&lbc->br1), in_be32(&lbc->or1)); |
| 204 | printf("\tBR2\t0x%08X\tOR2\t0x%08X \n", in_be32(&lbc->br2), in_be32(&lbc->or2)); |
| 205 | printf("\tBR3\t0x%08X\tOR3\t0x%08X \n", in_be32(&lbc->br3), in_be32(&lbc->or3)); |
| 206 | printf("\tBR4\t0x%08X\tOR4\t0x%08X \n", in_be32(&lbc->br4), in_be32(&lbc->or4)); |
| 207 | printf("\tBR5\t0x%08X\tOR5\t0x%08X \n", in_be32(&lbc->br5), in_be32(&lbc->or5)); |
| 208 | printf("\tBR6\t0x%08X\tOR6\t0x%08X \n", in_be32(&lbc->br6), in_be32(&lbc->or6)); |
| 209 | printf("\tBR7\t0x%08X\tOR7\t0x%08X \n", in_be32(&lbc->br7), in_be32(&lbc->or7)); |
Jon Loeliger | 5c8aa97 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 210 | |
| 211 | } |
Ben Warren | d448a49 | 2008-06-23 22:57:27 -0700 | [diff] [blame] | 212 | |
Andy Fleming | fecff2b | 2008-08-31 16:33:26 -0500 | [diff] [blame] | 213 | /* |
| 214 | * Initializes on-chip ethernet controllers. |
| 215 | * to override, implement board_eth_init() |
Ben Warren | d448a49 | 2008-06-23 22:57:27 -0700 | [diff] [blame] | 216 | */ |
Ben Warren | d448a49 | 2008-06-23 22:57:27 -0700 | [diff] [blame] | 217 | int cpu_eth_init(bd_t *bis) |
| 218 | { |
Andy Fleming | fecff2b | 2008-08-31 16:33:26 -0500 | [diff] [blame] | 219 | #if defined(CONFIG_TSEC_ENET) |
| 220 | tsec_standard_init(bis); |
Ben Warren | d448a49 | 2008-06-23 22:57:27 -0700 | [diff] [blame] | 221 | #endif |
Andy Fleming | fecff2b | 2008-08-31 16:33:26 -0500 | [diff] [blame] | 222 | |
Ben Warren | d448a49 | 2008-06-23 22:57:27 -0700 | [diff] [blame] | 223 | return 0; |
| 224 | } |