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 | |
Jon Loeliger | 5c8aa97 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 34 | |
Peter Tyser | 6945440 | 2009-02-05 11:25:25 -0600 | [diff] [blame^] | 35 | /* |
| 36 | * Default board reset function |
| 37 | */ |
| 38 | static void |
| 39 | __board_reset(void) |
| 40 | { |
| 41 | /* Do nothing */ |
| 42 | } |
| 43 | void board_reset(void) __attribute((weak, alias("__board_reset"))); |
| 44 | |
| 45 | |
Jon Loeliger | a129544 | 2006-08-22 12:06:18 -0500 | [diff] [blame] | 46 | int |
| 47 | checkcpu(void) |
Jon Loeliger | 5c8aa97 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 48 | { |
| 49 | sys_info_t sysinfo; |
| 50 | uint pvr, svr; |
| 51 | uint ver; |
| 52 | uint major, minor; |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 53 | volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR; |
Jon Loeliger | 3b971c9 | 2007-10-16 15:26:51 -0500 | [diff] [blame] | 54 | volatile ccsr_gur_t *gur = &immap->im_gur; |
Jon Loeliger | 465b9d8 | 2006-04-27 10:15:16 -0500 | [diff] [blame] | 55 | |
Jon Loeliger | 5c8aa97 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 56 | puts("Freescale PowerPC\n"); |
| 57 | |
| 58 | pvr = get_pvr(); |
| 59 | ver = PVR_VER(pvr); |
| 60 | major = PVR_MAJ(pvr); |
| 61 | minor = PVR_MIN(pvr); |
| 62 | |
Jon Loeliger | 465b9d8 | 2006-04-27 10:15:16 -0500 | [diff] [blame] | 63 | puts("CPU:\n"); |
Jon Loeliger | e65e32e | 2006-05-31 12:44:44 -0500 | [diff] [blame] | 64 | puts(" Core: "); |
Jon Loeliger | 465b9d8 | 2006-04-27 10:15:16 -0500 | [diff] [blame] | 65 | |
Jon Loeliger | 5c8aa97 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 66 | switch (ver) { |
| 67 | case PVR_VER(PVR_86xx): |
Jon Loeliger | 3b971c9 | 2007-10-16 15:26:51 -0500 | [diff] [blame] | 68 | { |
| 69 | uint msscr0 = mfspr(MSSCR0); |
| 70 | printf("E600 Core %d", (msscr0 & 0x20) ? 1 : 0 ); |
| 71 | if (gur->pordevsr & MPC86xx_PORDEVSR_CORE1TE) |
| 72 | puts("\n Core1Translation Enabled"); |
| 73 | debug(" (MSSCR0=%x, PORDEVSR=%x)", msscr0, gur->pordevsr); |
| 74 | } |
| 75 | break; |
Jon Loeliger | 5c8aa97 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 76 | default: |
Jon Loeliger | a129544 | 2006-08-22 12:06:18 -0500 | [diff] [blame] | 77 | puts("Unknown"); |
| 78 | break; |
Jon Loeliger | 5c8aa97 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 79 | } |
| 80 | printf(", Version: %d.%d, (0x%08x)\n", major, minor, pvr); |
| 81 | |
| 82 | svr = get_svr(); |
Andy Fleming | f574097 | 2008-02-06 01:19:40 -0600 | [diff] [blame] | 83 | ver = SVR_SOC_VER(svr); |
Jon Loeliger | 5c8aa97 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 84 | major = SVR_MAJ(svr); |
| 85 | minor = SVR_MIN(svr); |
| 86 | |
| 87 | puts(" System: "); |
Jon Loeliger | 465b9d8 | 2006-04-27 10:15:16 -0500 | [diff] [blame] | 88 | switch (ver) { |
Jon Loeliger | 5c8aa97 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 89 | case SVR_8641: |
Jon Loeliger | f57e829 | 2006-09-14 08:40:36 -0500 | [diff] [blame] | 90 | if (SVR_SUBVER(svr) == 1) { |
Jon Loeliger | 5c8aa97 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 91 | puts("8641D"); |
Jon Loeliger | f57e829 | 2006-09-14 08:40:36 -0500 | [diff] [blame] | 92 | } else { |
| 93 | puts("8641"); |
| 94 | } |
| 95 | break; |
Jon Loeliger | 3b971c9 | 2007-10-16 15:26:51 -0500 | [diff] [blame] | 96 | case SVR_8610: |
| 97 | puts("8610"); |
| 98 | break; |
Jon Loeliger | 5c8aa97 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 99 | default: |
| 100 | puts("Unknown"); |
| 101 | break; |
| 102 | } |
| 103 | printf(", Version: %d.%d, (0x%08x)\n", major, minor, svr); |
| 104 | |
| 105 | get_sys_info(&sysinfo); |
| 106 | |
| 107 | puts(" Clocks: "); |
| 108 | printf("CPU:%4lu MHz, ", sysinfo.freqProcessor / 1000000); |
| 109 | printf("MPX:%4lu MHz, ", sysinfo.freqSystemBus / 1000000); |
| 110 | printf("DDR:%4lu MHz, ", sysinfo.freqSystemBus / 2000000); |
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) { |
| 113 | printf("LBC:%4lu MHz\n", sysinfo.freqLocalBus / 1000000); |
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 | |
Jon Loeliger | e65e32e | 2006-05-31 12:44:44 -0500 | [diff] [blame] | 119 | puts(" L2: "); |
Jon Loeliger | d68e2ba | 2006-05-30 17:47:00 -0500 | [diff] [blame] | 120 | if (get_l2cr() & 0x80000000) |
Jon Loeliger | e65e32e | 2006-05-31 12:44:44 -0500 | [diff] [blame] | 121 | puts("Enabled\n"); |
Jon Loeliger | d68e2ba | 2006-05-30 17:47:00 -0500 | [diff] [blame] | 122 | else |
Jon Loeliger | e65e32e | 2006-05-31 12:44:44 -0500 | [diff] [blame] | 123 | puts("Disabled\n"); |
Jon Loeliger | 465b9d8 | 2006-04-27 10:15:16 -0500 | [diff] [blame] | 124 | |
| 125 | return 0; |
Jon Loeliger | 5c8aa97 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 126 | } |
| 127 | |
| 128 | |
Jon Loeliger | 5c8aa97 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 129 | void |
Jon Loeliger | d68e2ba | 2006-05-30 17:47:00 -0500 | [diff] [blame] | 130 | do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) |
Jon Loeliger | 5c8aa97 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 131 | { |
Peter Tyser | 6945440 | 2009-02-05 11:25:25 -0600 | [diff] [blame^] | 132 | volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR; |
| 133 | volatile ccsr_gur_t *gur = &immap->im_gur; |
Jon Loeliger | 465b9d8 | 2006-04-27 10:15:16 -0500 | [diff] [blame] | 134 | |
Peter Tyser | 6945440 | 2009-02-05 11:25:25 -0600 | [diff] [blame^] | 135 | /* Attempt board-specific reset */ |
| 136 | board_reset(); |
Jon Loeliger | 465b9d8 | 2006-04-27 10:15:16 -0500 | [diff] [blame] | 137 | |
Peter Tyser | 6945440 | 2009-02-05 11:25:25 -0600 | [diff] [blame^] | 138 | /* Next try asserting HRESET_REQ */ |
| 139 | out_be32(&gur->rstcr, MPC86xx_RSTCR_HRST_REQ); |
Jon Loeliger | 465b9d8 | 2006-04-27 10:15:16 -0500 | [diff] [blame] | 140 | |
Peter Tyser | 6945440 | 2009-02-05 11:25:25 -0600 | [diff] [blame^] | 141 | while (1) |
| 142 | ; |
Jon Loeliger | 5c8aa97 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 143 | } |
| 144 | |
| 145 | |
Jon Loeliger | 5c8aa97 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 146 | /* |
| 147 | * Get timebase clock frequency |
| 148 | */ |
Jon Loeliger | a129544 | 2006-08-22 12:06:18 -0500 | [diff] [blame] | 149 | unsigned long |
| 150 | get_tbclk(void) |
Jon Loeliger | 5c8aa97 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 151 | { |
Jon Loeliger | a129544 | 2006-08-22 12:06:18 -0500 | [diff] [blame] | 152 | sys_info_t sys_info; |
Jon Loeliger | 5c8aa97 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 153 | |
| 154 | get_sys_info(&sys_info); |
Jon Loeliger | 465b9d8 | 2006-04-27 10:15:16 -0500 | [diff] [blame] | 155 | return (sys_info.freqSystemBus + 3L) / 4L; |
Jon Loeliger | 5c8aa97 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 156 | } |
| 157 | |
Jon Loeliger | 5c8aa97 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 158 | |
| 159 | #if defined(CONFIG_WATCHDOG) |
| 160 | void |
| 161 | watchdog_reset(void) |
| 162 | { |
Jason Jin | 6c71b94 | 2008-05-13 11:50:36 +0800 | [diff] [blame] | 163 | #if defined(CONFIG_MPC8610) |
| 164 | /* |
| 165 | * This actually feed the hard enabled watchdog. |
| 166 | */ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 167 | volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR; |
Jason Jin | 6c71b94 | 2008-05-13 11:50:36 +0800 | [diff] [blame] | 168 | volatile ccsr_wdt_t *wdt = &immap->im_wdt; |
| 169 | volatile ccsr_gur_t *gur = &immap->im_gur; |
| 170 | u32 tmp = gur->pordevsr; |
| 171 | |
| 172 | if (tmp & 0x4000) { |
| 173 | wdt->swsrr = 0x556c; |
| 174 | wdt->swsrr = 0xaa39; |
| 175 | } |
| 176 | #endif |
Jon Loeliger | 5c8aa97 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 177 | } |
| 178 | #endif /* CONFIG_WATCHDOG */ |
| 179 | |
Jon Loeliger | 5c8aa97 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 180 | |
| 181 | #if defined(CONFIG_DDR_ECC) |
Jon Loeliger | a129544 | 2006-08-22 12:06:18 -0500 | [diff] [blame] | 182 | void |
| 183 | dma_init(void) |
Jon Loeliger | 465b9d8 | 2006-04-27 10:15:16 -0500 | [diff] [blame] | 184 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 185 | volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR; |
Jon Loeliger | 5c8aa97 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 186 | volatile ccsr_dma_t *dma = &immap->im_dma; |
| 187 | |
| 188 | dma->satr0 = 0x00040000; |
| 189 | dma->datr0 = 0x00040000; |
| 190 | asm("sync; isync"); |
Jon Loeliger | 5c8aa97 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 191 | } |
| 192 | |
Jon Loeliger | a129544 | 2006-08-22 12:06:18 -0500 | [diff] [blame] | 193 | uint |
| 194 | dma_check(void) |
Jon Loeliger | 465b9d8 | 2006-04-27 10:15:16 -0500 | [diff] [blame] | 195 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 196 | volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR; |
Jon Loeliger | 5c8aa97 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 197 | volatile ccsr_dma_t *dma = &immap->im_dma; |
| 198 | volatile uint status = dma->sr0; |
| 199 | |
| 200 | /* While the channel is busy, spin */ |
Jon Loeliger | a129544 | 2006-08-22 12:06:18 -0500 | [diff] [blame] | 201 | while ((status & 4) == 4) { |
Jon Loeliger | 5c8aa97 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 202 | status = dma->sr0; |
| 203 | } |
| 204 | |
| 205 | if (status != 0) { |
Jon Loeliger | a129544 | 2006-08-22 12:06:18 -0500 | [diff] [blame] | 206 | printf("DMA Error: status = %x\n", status); |
Jon Loeliger | 5c8aa97 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 207 | } |
| 208 | return status; |
| 209 | } |
| 210 | |
Jon Loeliger | a129544 | 2006-08-22 12:06:18 -0500 | [diff] [blame] | 211 | int |
| 212 | dma_xfer(void *dest, uint count, void *src) |
Jon Loeliger | 465b9d8 | 2006-04-27 10:15:16 -0500 | [diff] [blame] | 213 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 214 | volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR; |
Jon Loeliger | 5c8aa97 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 215 | volatile ccsr_dma_t *dma = &immap->im_dma; |
| 216 | |
| 217 | dma->dar0 = (uint) dest; |
| 218 | dma->sar0 = (uint) src; |
| 219 | dma->bcr0 = count; |
| 220 | dma->mr0 = 0xf000004; |
| 221 | asm("sync;isync"); |
| 222 | dma->mr0 = 0xf000005; |
| 223 | asm("sync;isync"); |
| 224 | return dma_check(); |
| 225 | } |
Jon Loeliger | 465b9d8 | 2006-04-27 10:15:16 -0500 | [diff] [blame] | 226 | |
Jon Loeliger | 5c8aa97 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 227 | #endif /* CONFIG_DDR_ECC */ |
| 228 | |
Becky Bruce | b0b3094 | 2008-01-23 16:31:06 -0600 | [diff] [blame] | 229 | |
| 230 | /* |
| 231 | * Print out the state of various machine registers. |
Becky Bruce | 7e07c77 | 2008-05-08 19:02:51 -0500 | [diff] [blame] | 232 | * Currently prints out LAWs, BR0/OR0, and BATs |
Becky Bruce | b0b3094 | 2008-01-23 16:31:06 -0600 | [diff] [blame] | 233 | */ |
| 234 | void mpc86xx_reginfo(void) |
| 235 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 236 | immap_t *immap = (immap_t *)CONFIG_SYS_IMMR; |
Becky Bruce | b0b3094 | 2008-01-23 16:31:06 -0600 | [diff] [blame] | 237 | ccsr_lbc_t *lbc = &immap->im_lbc; |
| 238 | |
Becky Bruce | 7e07c77 | 2008-05-08 19:02:51 -0500 | [diff] [blame] | 239 | print_bats(); |
Becky Bruce | b0b3094 | 2008-01-23 16:31:06 -0600 | [diff] [blame] | 240 | print_laws(); |
| 241 | |
| 242 | printf ("Local Bus Controller Registers\n" |
| 243 | "\tBR0\t0x%08X\tOR0\t0x%08X \n", in_be32(&lbc->br0), in_be32(&lbc->or0)); |
| 244 | printf("\tBR1\t0x%08X\tOR1\t0x%08X \n", in_be32(&lbc->br1), in_be32(&lbc->or1)); |
| 245 | printf("\tBR2\t0x%08X\tOR2\t0x%08X \n", in_be32(&lbc->br2), in_be32(&lbc->or2)); |
| 246 | printf("\tBR3\t0x%08X\tOR3\t0x%08X \n", in_be32(&lbc->br3), in_be32(&lbc->or3)); |
| 247 | printf("\tBR4\t0x%08X\tOR4\t0x%08X \n", in_be32(&lbc->br4), in_be32(&lbc->or4)); |
| 248 | printf("\tBR5\t0x%08X\tOR5\t0x%08X \n", in_be32(&lbc->br5), in_be32(&lbc->or5)); |
| 249 | printf("\tBR6\t0x%08X\tOR6\t0x%08X \n", in_be32(&lbc->br6), in_be32(&lbc->or6)); |
| 250 | 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] | 251 | |
| 252 | } |
Ben Warren | d448a49 | 2008-06-23 22:57:27 -0700 | [diff] [blame] | 253 | |
Andy Fleming | fecff2b | 2008-08-31 16:33:26 -0500 | [diff] [blame] | 254 | /* |
| 255 | * Initializes on-chip ethernet controllers. |
| 256 | * to override, implement board_eth_init() |
Ben Warren | d448a49 | 2008-06-23 22:57:27 -0700 | [diff] [blame] | 257 | */ |
Ben Warren | d448a49 | 2008-06-23 22:57:27 -0700 | [diff] [blame] | 258 | int cpu_eth_init(bd_t *bis) |
| 259 | { |
Andy Fleming | fecff2b | 2008-08-31 16:33:26 -0500 | [diff] [blame] | 260 | #if defined(CONFIG_TSEC_ENET) |
| 261 | tsec_standard_init(bis); |
Ben Warren | d448a49 | 2008-06-23 22:57:27 -0700 | [diff] [blame] | 262 | #endif |
Andy Fleming | fecff2b | 2008-08-31 16:33:26 -0500 | [diff] [blame] | 263 | |
Ben Warren | d448a49 | 2008-06-23 22:57:27 -0700 | [diff] [blame] | 264 | return 0; |
| 265 | } |