wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 1 | /* |
wdenk | 97d80fc | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 2 | * Copyright 2004 Freescale Semiconductor. |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 3 | * (C) Copyright 2002, 2003 Motorola Inc. |
| 4 | * Xianghua Xiao (X.Xiao@motorola.com) |
| 5 | * |
| 6 | * (C) Copyright 2000 |
| 7 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
| 8 | * |
| 9 | * See file CREDITS for list of people who contributed to this |
| 10 | * project. |
| 11 | * |
| 12 | * This program is free software; you can redistribute it and/or |
| 13 | * modify it under the terms of the GNU General Public License as |
| 14 | * published by the Free Software Foundation; either version 2 of |
| 15 | * the License, or (at your option) any later version. |
| 16 | * |
| 17 | * This program is distributed in the hope that it will be useful, |
| 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 20 | * GNU General Public License for more details. |
| 21 | * |
| 22 | * You should have received a copy of the GNU General Public License |
| 23 | * along with this program; if not, write to the Free Software |
| 24 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 25 | * MA 02111-1307 USA |
| 26 | */ |
| 27 | |
| 28 | #include <common.h> |
| 29 | #include <watchdog.h> |
| 30 | #include <command.h> |
| 31 | #include <asm/cache.h> |
| 32 | |
| 33 | /* ------------------------------------------------------------------------- */ |
| 34 | |
| 35 | int checkcpu (void) |
| 36 | { |
wdenk | 97d80fc | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 37 | sys_info_t sysinfo; |
| 38 | uint lcrr; /* local bus clock ratio register */ |
| 39 | uint clkdiv; /* clock divider portion of lcrr */ |
| 40 | uint pvr, svr; |
Jon Loeliger | d9b94f2 | 2005-07-25 14:05:07 -0500 | [diff] [blame] | 41 | uint fam; |
wdenk | 97d80fc | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 42 | uint ver; |
| 43 | uint major, minor; |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 44 | |
wdenk | 97d80fc | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 45 | svr = get_svr(); |
| 46 | ver = SVR_VER(svr); |
| 47 | major = SVR_MAJ(svr); |
| 48 | minor = SVR_MIN(svr); |
| 49 | |
wdenk | 6c9e789 | 2005-03-15 22:56:53 +0000 | [diff] [blame] | 50 | puts("CPU: "); |
wdenk | 97d80fc | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 51 | switch (ver) { |
| 52 | case SVR_8540: |
| 53 | puts("8540"); |
| 54 | break; |
| 55 | case SVR_8541: |
| 56 | puts("8541"); |
| 57 | break; |
| 58 | case SVR_8555: |
| 59 | puts("8555"); |
| 60 | break; |
| 61 | case SVR_8560: |
| 62 | puts("8560"); |
| 63 | break; |
Jon Loeliger | d9b94f2 | 2005-07-25 14:05:07 -0500 | [diff] [blame] | 64 | case SVR_8548: |
| 65 | puts("8548"); |
| 66 | break; |
| 67 | case SVR_8548_E: |
| 68 | puts("8548_E"); |
| 69 | break; |
wdenk | 97d80fc | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 70 | default: |
| 71 | puts("Unknown"); |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 72 | break; |
| 73 | } |
wdenk | 97d80fc | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 74 | printf(", Version: %d.%d, (0x%08x)\n", major, minor, svr); |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 75 | |
wdenk | 6c9e789 | 2005-03-15 22:56:53 +0000 | [diff] [blame] | 76 | pvr = get_pvr(); |
Jon Loeliger | d9b94f2 | 2005-07-25 14:05:07 -0500 | [diff] [blame] | 77 | fam = PVR_FAM(pvr); |
wdenk | 6c9e789 | 2005-03-15 22:56:53 +0000 | [diff] [blame] | 78 | ver = PVR_VER(pvr); |
| 79 | major = PVR_MAJ(pvr); |
| 80 | minor = PVR_MIN(pvr); |
| 81 | |
| 82 | printf("Core: "); |
Jon Loeliger | d9b94f2 | 2005-07-25 14:05:07 -0500 | [diff] [blame] | 83 | switch (fam) { |
| 84 | case PVR_FAM(PVR_85xx): |
wdenk | 6c9e789 | 2005-03-15 22:56:53 +0000 | [diff] [blame] | 85 | puts("E500"); |
| 86 | break; |
| 87 | default: |
| 88 | puts("Unknown"); |
| 89 | break; |
| 90 | } |
| 91 | printf(", Version: %d.%d, (0x%08x)\n", major, minor, pvr); |
| 92 | |
wdenk | 97d80fc | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 93 | get_sys_info(&sysinfo); |
| 94 | |
Jon Loeliger | d9b94f2 | 2005-07-25 14:05:07 -0500 | [diff] [blame] | 95 | puts("Clock Configuration:\n"); |
wdenk | 6c9e789 | 2005-03-15 22:56:53 +0000 | [diff] [blame] | 96 | printf(" CPU:%4lu MHz, ", sysinfo.freqProcessor / 1000000); |
| 97 | printf("CCB:%4lu MHz,\n", sysinfo.freqSystemBus / 1000000); |
| 98 | printf(" DDR:%4lu MHz, ", sysinfo.freqSystemBus / 2000000); |
wdenk | 97d80fc | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 99 | |
| 100 | #if defined(CFG_LBC_LCRR) |
| 101 | lcrr = CFG_LBC_LCRR; |
| 102 | #else |
| 103 | { |
| 104 | volatile immap_t *immap = (immap_t *)CFG_IMMR; |
| 105 | volatile ccsr_lbc_t *lbc= &immap->im_lbc; |
| 106 | |
| 107 | lcrr = lbc->lcrr; |
| 108 | } |
| 109 | #endif |
| 110 | clkdiv = lcrr & 0x0f; |
| 111 | if (clkdiv == 2 || clkdiv == 4 || clkdiv == 8) { |
Jon Loeliger | d9b94f2 | 2005-07-25 14:05:07 -0500 | [diff] [blame] | 112 | #ifdef CONFIG_MPC8548 |
| 113 | /* |
| 114 | * Yes, the entire PQ38 family use the same |
| 115 | * bit-representation for twice the clock divider values. |
| 116 | */ |
| 117 | clkdiv *= 2; |
| 118 | #endif |
wdenk | 97d80fc | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 119 | printf("LBC:%4lu MHz\n", |
| 120 | sysinfo.freqSystemBus / 1000000 / clkdiv); |
| 121 | } else { |
wdenk | 6c9e789 | 2005-03-15 22:56:53 +0000 | [diff] [blame] | 122 | printf("LBC: unknown (lcrr: 0x%08x)\n", lcrr); |
wdenk | 97d80fc | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 123 | } |
| 124 | |
| 125 | if (ver == SVR_8560) { |
wdenk | 6c9e789 | 2005-03-15 22:56:53 +0000 | [diff] [blame] | 126 | printf("CPM: %lu Mhz\n", |
wdenk | 97d80fc | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 127 | sysinfo.freqSystemBus / 1000000); |
| 128 | } |
| 129 | |
wdenk | 6c9e789 | 2005-03-15 22:56:53 +0000 | [diff] [blame] | 130 | puts("L1: D-cache 32 kB enabled\n I-cache 32 kB enabled\n"); |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 131 | |
| 132 | return 0; |
| 133 | } |
| 134 | |
| 135 | |
| 136 | /* ------------------------------------------------------------------------- */ |
| 137 | |
| 138 | int do_reset (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]) |
| 139 | { |
| 140 | /* |
| 141 | * Initiate hard reset in debug control register DBCR0 |
| 142 | * Make sure MSR[DE] = 1 |
| 143 | */ |
wdenk | 97d80fc | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 144 | unsigned long val; |
| 145 | |
| 146 | val = mfspr(DBCR0); |
| 147 | val |= 0x70000000; |
| 148 | mtspr(DBCR0,val); |
| 149 | |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 150 | return 1; |
| 151 | } |
| 152 | |
| 153 | |
| 154 | /* |
| 155 | * Get timebase clock frequency |
| 156 | */ |
| 157 | unsigned long get_tbclk (void) |
| 158 | { |
| 159 | |
| 160 | sys_info_t sys_info; |
| 161 | |
| 162 | get_sys_info(&sys_info); |
wdenk | 2a8af18 | 2005-04-13 10:02:42 +0000 | [diff] [blame] | 163 | return ((sys_info.freqSystemBus + 7L) / 8L); |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 164 | } |
| 165 | |
| 166 | |
| 167 | #if defined(CONFIG_WATCHDOG) |
| 168 | void |
| 169 | watchdog_reset(void) |
| 170 | { |
| 171 | int re_enable = disable_interrupts(); |
| 172 | reset_85xx_watchdog(); |
| 173 | if (re_enable) enable_interrupts(); |
| 174 | } |
| 175 | |
| 176 | void |
| 177 | reset_85xx_watchdog(void) |
| 178 | { |
| 179 | /* |
| 180 | * Clear TSR(WIS) bit by writing 1 |
| 181 | */ |
| 182 | unsigned long val; |
| 183 | val = mfspr(tsr); |
| 184 | val |= 0x40000000; |
| 185 | mtspr(tsr, val); |
| 186 | } |
| 187 | #endif /* CONFIG_WATCHDOG */ |
| 188 | |
| 189 | #if defined(CONFIG_DDR_ECC) |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 190 | void dma_init(void) { |
| 191 | volatile immap_t *immap = (immap_t *)CFG_IMMR; |
| 192 | volatile ccsr_dma_t *dma = &immap->im_dma; |
| 193 | |
| 194 | dma->satr0 = 0x02c40000; |
| 195 | dma->datr0 = 0x02c40000; |
| 196 | asm("sync; isync; msync"); |
| 197 | return; |
| 198 | } |
| 199 | |
| 200 | uint dma_check(void) { |
| 201 | volatile immap_t *immap = (immap_t *)CFG_IMMR; |
| 202 | volatile ccsr_dma_t *dma = &immap->im_dma; |
| 203 | volatile uint status = dma->sr0; |
| 204 | |
| 205 | /* While the channel is busy, spin */ |
| 206 | while((status & 4) == 4) { |
| 207 | status = dma->sr0; |
| 208 | } |
| 209 | |
| 210 | if (status != 0) { |
| 211 | printf ("DMA Error: status = %x\n", status); |
| 212 | } |
| 213 | return status; |
| 214 | } |
| 215 | |
| 216 | int dma_xfer(void *dest, uint count, void *src) { |
| 217 | volatile immap_t *immap = (immap_t *)CFG_IMMR; |
| 218 | volatile ccsr_dma_t *dma = &immap->im_dma; |
| 219 | |
| 220 | dma->dar0 = (uint) dest; |
| 221 | dma->sar0 = (uint) src; |
| 222 | dma->bcr0 = count; |
| 223 | dma->mr0 = 0xf000004; |
| 224 | asm("sync;isync;msync"); |
| 225 | dma->mr0 = 0xf000005; |
| 226 | asm("sync;isync;msync"); |
| 227 | return dma_check(); |
| 228 | } |
| 229 | #endif |