Eran Liberty | f046ccd | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 1 | /* |
Dave Liu | f6eda7f | 2006-10-25 14:41:21 -0500 | [diff] [blame] | 2 | * Copyright (C) 2004-2006 Freescale Semiconductor, Inc. |
Eran Liberty | f046ccd | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 3 | * |
| 4 | * See file CREDITS for list of people who contributed to this |
| 5 | * project. |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU General Public License as |
| 9 | * published by the Free Software Foundation; either version 2 of |
| 10 | * the License, or (at your option) any later version. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with this program; if not, write to the Free Software |
| 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 20 | * MA 02111-1307 USA |
Eran Liberty | f046ccd | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 21 | */ |
| 22 | |
| 23 | /* |
| 24 | * CPU specific code for the MPC83xx family. |
| 25 | * |
| 26 | * Derived from the MPC8260 and MPC85xx. |
| 27 | */ |
| 28 | |
| 29 | #include <common.h> |
| 30 | #include <watchdog.h> |
| 31 | #include <command.h> |
| 32 | #include <mpc83xx.h> |
| 33 | #include <asm/processor.h> |
Gerald Van Baren | 213bf8c | 2007-03-31 12:23:51 -0400 | [diff] [blame] | 34 | #if defined(CONFIG_OF_FLAT_TREE) |
| 35 | #include <ft_build.h> |
Jerry Van Baren | 26d02c9 | 2007-07-04 21:27:30 -0400 | [diff] [blame] | 36 | #elif defined(CONFIG_OF_LIBFDT) |
Gerald Van Baren | 213bf8c | 2007-03-31 12:23:51 -0400 | [diff] [blame] | 37 | #include <libfdt.h> |
Gerald Van Baren | 213bf8c | 2007-03-31 12:23:51 -0400 | [diff] [blame] | 38 | #endif |
Eran Liberty | f046ccd | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 39 | |
Wolfgang Denk | d87080b | 2006-03-31 18:32:53 +0200 | [diff] [blame] | 40 | DECLARE_GLOBAL_DATA_PTR; |
| 41 | |
Eran Liberty | f046ccd | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 42 | int checkcpu(void) |
| 43 | { |
Dave Liu | 5f82043 | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 44 | volatile immap_t *immr; |
Eran Liberty | f046ccd | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 45 | ulong clock = gd->cpu_clk; |
| 46 | u32 pvr = get_pvr(); |
Dave Liu | 5f82043 | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 47 | u32 spridr; |
Eran Liberty | f046ccd | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 48 | char buf[32]; |
| 49 | |
Timur Tabi | d239d74 | 2006-11-03 12:00:28 -0600 | [diff] [blame] | 50 | immr = (immap_t *)CFG_IMMR; |
Dave Liu | 5f82043 | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 51 | |
Kim Phillips | 54b2d43 | 2007-04-30 15:26:21 -0500 | [diff] [blame] | 52 | puts("CPU: "); |
Scott Wood | 95e7ef8 | 2007-04-16 14:34:16 -0500 | [diff] [blame] | 53 | |
| 54 | switch (pvr & 0xffff0000) { |
| 55 | case PVR_E300C1: |
| 56 | printf("e300c1, "); |
| 57 | break; |
| 58 | |
| 59 | case PVR_E300C2: |
| 60 | printf("e300c2, "); |
| 61 | break; |
| 62 | |
| 63 | case PVR_E300C3: |
| 64 | printf("e300c3, "); |
| 65 | break; |
| 66 | |
| 67 | default: |
| 68 | printf("Unknown core, "); |
Eran Liberty | f046ccd | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 69 | } |
| 70 | |
Dave Liu | 5f82043 | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 71 | spridr = immr->sysconf.spridr; |
Dave Liu | 5f82043 | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 72 | switch(spridr) { |
| 73 | case SPR_8349E_REV10: |
| 74 | case SPR_8349E_REV11: |
Xie Xiaobo | 8d172c0 | 2007-02-14 18:26:44 +0800 | [diff] [blame] | 75 | case SPR_8349E_REV31: |
Dave Liu | 5f82043 | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 76 | puts("MPC8349E, "); |
Eran Liberty | f046ccd | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 77 | break; |
Dave Liu | 5f82043 | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 78 | case SPR_8349_REV10: |
| 79 | case SPR_8349_REV11: |
Xie Xiaobo | 8d172c0 | 2007-02-14 18:26:44 +0800 | [diff] [blame] | 80 | case SPR_8349_REV31: |
Dave Liu | 5f82043 | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 81 | puts("MPC8349, "); |
| 82 | break; |
| 83 | case SPR_8347E_REV10_TBGA: |
| 84 | case SPR_8347E_REV11_TBGA: |
Xie Xiaobo | 8d172c0 | 2007-02-14 18:26:44 +0800 | [diff] [blame] | 85 | case SPR_8347E_REV31_TBGA: |
Dave Liu | 5f82043 | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 86 | case SPR_8347E_REV10_PBGA: |
| 87 | case SPR_8347E_REV11_PBGA: |
Xie Xiaobo | 8d172c0 | 2007-02-14 18:26:44 +0800 | [diff] [blame] | 88 | case SPR_8347E_REV31_PBGA: |
Dave Liu | 5f82043 | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 89 | puts("MPC8347E, "); |
| 90 | break; |
| 91 | case SPR_8347_REV10_TBGA: |
| 92 | case SPR_8347_REV11_TBGA: |
Xie Xiaobo | 8d172c0 | 2007-02-14 18:26:44 +0800 | [diff] [blame] | 93 | case SPR_8347_REV31_TBGA: |
Dave Liu | 5f82043 | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 94 | case SPR_8347_REV10_PBGA: |
| 95 | case SPR_8347_REV11_PBGA: |
Xie Xiaobo | 8d172c0 | 2007-02-14 18:26:44 +0800 | [diff] [blame] | 96 | case SPR_8347_REV31_PBGA: |
Dave Liu | 5f82043 | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 97 | puts("MPC8347, "); |
| 98 | break; |
| 99 | case SPR_8343E_REV10: |
| 100 | case SPR_8343E_REV11: |
Xie Xiaobo | 8d172c0 | 2007-02-14 18:26:44 +0800 | [diff] [blame] | 101 | case SPR_8343E_REV31: |
Dave Liu | 5f82043 | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 102 | puts("MPC8343E, "); |
| 103 | break; |
| 104 | case SPR_8343_REV10: |
| 105 | case SPR_8343_REV11: |
Xie Xiaobo | 8d172c0 | 2007-02-14 18:26:44 +0800 | [diff] [blame] | 106 | case SPR_8343_REV31: |
Dave Liu | 5f82043 | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 107 | puts("MPC8343, "); |
| 108 | break; |
| 109 | case SPR_8360E_REV10: |
| 110 | case SPR_8360E_REV11: |
| 111 | case SPR_8360E_REV12: |
Xie Xiaobo | b110f40 | 2007-02-14 18:27:06 +0800 | [diff] [blame] | 112 | case SPR_8360E_REV20: |
Lee Nipper | 1ded024 | 2007-06-14 20:07:33 -0500 | [diff] [blame] | 113 | case SPR_8360E_REV21: |
Dave Liu | 5f82043 | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 114 | puts("MPC8360E, "); |
| 115 | break; |
| 116 | case SPR_8360_REV10: |
| 117 | case SPR_8360_REV11: |
| 118 | case SPR_8360_REV12: |
Xie Xiaobo | b110f40 | 2007-02-14 18:27:06 +0800 | [diff] [blame] | 119 | case SPR_8360_REV20: |
Lee Nipper | 1ded024 | 2007-06-14 20:07:33 -0500 | [diff] [blame] | 120 | case SPR_8360_REV21: |
Dave Liu | 5f82043 | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 121 | puts("MPC8360, "); |
Eran Liberty | f046ccd | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 122 | break; |
Dave Liu | 24c3aca | 2006-12-07 21:13:15 +0800 | [diff] [blame] | 123 | case SPR_8323E_REV10: |
| 124 | case SPR_8323E_REV11: |
| 125 | puts("MPC8323E, "); |
| 126 | break; |
| 127 | case SPR_8323_REV10: |
| 128 | case SPR_8323_REV11: |
| 129 | puts("MPC8323, "); |
| 130 | break; |
| 131 | case SPR_8321E_REV10: |
| 132 | case SPR_8321E_REV11: |
| 133 | puts("MPC8321E, "); |
| 134 | break; |
| 135 | case SPR_8321_REV10: |
| 136 | case SPR_8321_REV11: |
| 137 | puts("MPC8321, "); |
| 138 | break; |
Scott Wood | a35b0c4 | 2007-04-16 14:34:15 -0500 | [diff] [blame] | 139 | case SPR_8311_REV10: |
| 140 | puts("MPC8311, "); |
| 141 | break; |
| 142 | case SPR_8311E_REV10: |
| 143 | puts("MPC8311E, "); |
| 144 | break; |
| 145 | case SPR_8313_REV10: |
| 146 | puts("MPC8313, "); |
| 147 | break; |
| 148 | case SPR_8313E_REV10: |
| 149 | puts("MPC8313E, "); |
| 150 | break; |
Eran Liberty | f046ccd | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 151 | default: |
Lee Nipper | 1ded024 | 2007-06-14 20:07:33 -0500 | [diff] [blame] | 152 | printf("Rev: Unknown revision number:%08x\n" |
| 153 | "Warning: Unsupported cpu revision!\n",spridr); |
Xie Xiaobo | 8d172c0 | 2007-02-14 18:26:44 +0800 | [diff] [blame] | 154 | return 0; |
Eran Liberty | f046ccd | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 155 | } |
Rafal Jaworowski | 6902df5 | 2005-10-17 02:39:53 +0200 | [diff] [blame] | 156 | |
Kumar Gala | 3e78a31 | 2007-01-30 14:08:30 -0600 | [diff] [blame] | 157 | #if defined(CONFIG_MPC834X) |
Xie Xiaobo | 8d172c0 | 2007-02-14 18:26:44 +0800 | [diff] [blame] | 158 | /* Multiple revisons of 834x processors may have the same SPRIDR value. |
| 159 | * So use PVR to identify the revision number. |
| 160 | */ |
Kim Phillips | 54b2d43 | 2007-04-30 15:26:21 -0500 | [diff] [blame] | 161 | printf("Rev: %02x at %s MHz", PVR_MAJ(pvr)<<4 | PVR_MIN(pvr), strmhz(buf, clock)); |
Dave Liu | 5f82043 | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 162 | #else |
Kim Phillips | 54b2d43 | 2007-04-30 15:26:21 -0500 | [diff] [blame] | 163 | printf("Rev: %02x at %s MHz", spridr & 0x0000FFFF, strmhz(buf, clock)); |
Dave Liu | 5f82043 | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 164 | #endif |
Kim Phillips | 54b2d43 | 2007-04-30 15:26:21 -0500 | [diff] [blame] | 165 | printf(", CSB: %4d MHz\n", gd->csb_clk / 1000000); |
| 166 | |
Eran Liberty | f046ccd | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 167 | return 0; |
| 168 | } |
| 169 | |
| 170 | |
Timur Tabi | be5e618 | 2006-11-03 19:15:00 -0600 | [diff] [blame] | 171 | /* |
Timur Tabi | 2ad6b51 | 2006-10-31 18:44:42 -0600 | [diff] [blame] | 172 | * Program a UPM with the code supplied in the table. |
| 173 | * |
| 174 | * The 'dummy' variable is used to increment the MAD. 'dummy' is |
| 175 | * supposed to be a pointer to the memory of the device being |
| 176 | * programmed by the UPM. The data in the MDR is written into |
| 177 | * memory and the MAD is incremented every time there's a read |
| 178 | * from 'dummy'. Unfortunately, the current prototype for this |
| 179 | * function doesn't allow for passing the address of this |
| 180 | * device, and changing the prototype will break a number lots |
| 181 | * of other code, so we need to use a round-about way of finding |
| 182 | * the value for 'dummy'. |
| 183 | * |
| 184 | * The value can be extracted from the base address bits of the |
| 185 | * Base Register (BR) associated with the specific UPM. To find |
| 186 | * that BR, we need to scan all 8 BRs until we find the one that |
| 187 | * has its MSEL bits matching the UPM we want. Once we know the |
| 188 | * right BR, we can extract the base address bits from it. |
| 189 | * |
| 190 | * The MxMR and the BR and OR of the chosen bank should all be |
| 191 | * configured before calling this function. |
| 192 | * |
| 193 | * Parameters: |
| 194 | * upm: 0=UPMA, 1=UPMB, 2=UPMC |
| 195 | * table: Pointer to an array of values to program |
| 196 | * size: Number of elements in the array. Must be 64 or less. |
Timur Tabi | be5e618 | 2006-11-03 19:15:00 -0600 | [diff] [blame] | 197 | */ |
Eran Liberty | f046ccd | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 198 | void upmconfig (uint upm, uint *table, uint size) |
| 199 | { |
Timur Tabi | 2ad6b51 | 2006-10-31 18:44:42 -0600 | [diff] [blame] | 200 | #if defined(CONFIG_MPC834X) |
Timur Tabi | d239d74 | 2006-11-03 12:00:28 -0600 | [diff] [blame] | 201 | volatile immap_t *immap = (immap_t *) CFG_IMMR; |
Timur Tabi | 2ad6b51 | 2006-10-31 18:44:42 -0600 | [diff] [blame] | 202 | volatile lbus83xx_t *lbus = &immap->lbus; |
| 203 | volatile uchar *dummy = NULL; |
| 204 | const u32 msel = (upm + 4) << BR_MSEL_SHIFT; /* What the MSEL field in BRn should be */ |
| 205 | volatile u32 *mxmr = &lbus->mamr + upm; /* Pointer to mamr, mbmr, or mcmr */ |
| 206 | uint i; |
| 207 | |
| 208 | /* Scan all the banks to determine the base address of the device */ |
| 209 | for (i = 0; i < 8; i++) { |
| 210 | if ((lbus->bank[i].br & BR_MSEL) == msel) { |
| 211 | dummy = (uchar *) (lbus->bank[i].br & BR_BA); |
| 212 | break; |
| 213 | } |
| 214 | } |
| 215 | |
| 216 | if (!dummy) { |
| 217 | printf("Error: %s() could not find matching BR\n", __FUNCTION__); |
| 218 | hang(); |
| 219 | } |
| 220 | |
| 221 | /* Set the OP field in the MxMR to "write" and the MAD field to 000000 */ |
| 222 | *mxmr = (*mxmr & 0xCFFFFFC0) | 0x10000000; |
| 223 | |
| 224 | for (i = 0; i < size; i++) { |
| 225 | lbus->mdr = table[i]; |
| 226 | __asm__ __volatile__ ("sync"); |
| 227 | *dummy; /* Write the value to memory and increment MAD */ |
| 228 | __asm__ __volatile__ ("sync"); |
| 229 | } |
| 230 | |
| 231 | /* Set the OP field in the MxMR to "normal" and the MAD field to 000000 */ |
| 232 | *mxmr &= 0xCFFFFFC0; |
| 233 | #else |
| 234 | printf("Error: %s() not defined for this configuration.\n", __FUNCTION__); |
| 235 | hang(); |
| 236 | #endif |
Eran Liberty | f046ccd | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 237 | } |
| 238 | |
| 239 | |
| 240 | int |
| 241 | do_reset (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) |
| 242 | { |
Wolfgang Denk | 07a2505 | 2005-08-05 19:49:35 +0200 | [diff] [blame] | 243 | ulong msr; |
| 244 | #ifndef MPC83xx_RESET |
| 245 | ulong addr; |
| 246 | #endif |
Eran Liberty | f046ccd | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 247 | |
Timur Tabi | d239d74 | 2006-11-03 12:00:28 -0600 | [diff] [blame] | 248 | volatile immap_t *immap = (immap_t *) CFG_IMMR; |
Eran Liberty | f046ccd | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 249 | |
| 250 | #ifdef MPC83xx_RESET |
| 251 | /* Interrupts and MMU off */ |
| 252 | __asm__ __volatile__ ("mfmsr %0":"=r" (msr):); |
| 253 | |
| 254 | msr &= ~( MSR_EE | MSR_IR | MSR_DR); |
| 255 | __asm__ __volatile__ ("mtmsr %0"::"r" (msr)); |
| 256 | |
| 257 | /* enable Reset Control Reg */ |
| 258 | immap->reset.rpr = 0x52535445; |
Marian Balakowicz | 6d8ae5a | 2006-03-14 16:12:48 +0100 | [diff] [blame] | 259 | __asm__ __volatile__ ("sync"); |
| 260 | __asm__ __volatile__ ("isync"); |
Eran Liberty | f046ccd | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 261 | |
| 262 | /* confirm Reset Control Reg is enabled */ |
| 263 | while(!((immap->reset.rcer) & RCER_CRE)); |
| 264 | |
| 265 | printf("Resetting the board."); |
| 266 | printf("\n"); |
| 267 | |
| 268 | udelay(200); |
| 269 | |
| 270 | /* perform reset, only one bit */ |
Wolfgang Denk | 07a2505 | 2005-08-05 19:49:35 +0200 | [diff] [blame] | 271 | immap->reset.rcr = RCR_SWHR; |
Eran Liberty | f046ccd | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 272 | |
Wolfgang Denk | 07a2505 | 2005-08-05 19:49:35 +0200 | [diff] [blame] | 273 | #else /* ! MPC83xx_RESET */ |
| 274 | |
| 275 | immap->reset.rmr = RMR_CSRE; /* Checkstop Reset enable */ |
| 276 | |
| 277 | /* Interrupts and MMU off */ |
| 278 | __asm__ __volatile__ ("mfmsr %0":"=r" (msr):); |
Eran Liberty | f046ccd | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 279 | |
| 280 | msr &= ~(MSR_ME | MSR_EE | MSR_IR | MSR_DR); |
| 281 | __asm__ __volatile__ ("mtmsr %0"::"r" (msr)); |
| 282 | |
| 283 | /* |
| 284 | * Trying to execute the next instruction at a non-existing address |
| 285 | * should cause a machine check, resulting in reset |
| 286 | */ |
| 287 | addr = CFG_RESET_ADDRESS; |
| 288 | |
| 289 | printf("resetting the board."); |
| 290 | printf("\n"); |
| 291 | ((void (*)(void)) addr) (); |
Wolfgang Denk | 07a2505 | 2005-08-05 19:49:35 +0200 | [diff] [blame] | 292 | #endif /* MPC83xx_RESET */ |
| 293 | |
Eran Liberty | f046ccd | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 294 | return 1; |
| 295 | } |
| 296 | |
| 297 | |
| 298 | /* |
| 299 | * Get timebase clock frequency (like cpu_clk in Hz) |
| 300 | */ |
| 301 | |
| 302 | unsigned long get_tbclk(void) |
| 303 | { |
Eran Liberty | f046ccd | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 304 | ulong tbclk; |
| 305 | |
| 306 | tbclk = (gd->bus_clk + 3L) / 4L; |
| 307 | |
| 308 | return tbclk; |
| 309 | } |
| 310 | |
| 311 | |
| 312 | #if defined(CONFIG_WATCHDOG) |
| 313 | void watchdog_reset (void) |
| 314 | { |
Timur Tabi | 2ad6b51 | 2006-10-31 18:44:42 -0600 | [diff] [blame] | 315 | int re_enable = disable_interrupts(); |
| 316 | |
| 317 | /* Reset the 83xx watchdog */ |
Timur Tabi | d239d74 | 2006-11-03 12:00:28 -0600 | [diff] [blame] | 318 | volatile immap_t *immr = (immap_t *) CFG_IMMR; |
Timur Tabi | 2ad6b51 | 2006-10-31 18:44:42 -0600 | [diff] [blame] | 319 | immr->wdt.swsrr = 0x556c; |
| 320 | immr->wdt.swsrr = 0xaa39; |
| 321 | |
| 322 | if (re_enable) |
| 323 | enable_interrupts (); |
Eran Liberty | f046ccd | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 324 | } |
Timur Tabi | 2ad6b51 | 2006-10-31 18:44:42 -0600 | [diff] [blame] | 325 | #endif |
Kumar Gala | 62ec641 | 2006-01-11 16:48:10 -0600 | [diff] [blame] | 326 | |
Gerald Van Baren | 213bf8c | 2007-03-31 12:23:51 -0400 | [diff] [blame] | 327 | #if defined(CONFIG_OF_LIBFDT) |
| 328 | |
| 329 | /* |
Gerald Van Baren | f35a53f | 2007-04-15 13:54:26 -0400 | [diff] [blame] | 330 | * "Setter" functions used to add/modify FDT entries. |
| 331 | */ |
Kim Phillips | f57ac7a | 2007-07-25 19:25:22 -0500 | [diff] [blame] | 332 | static int fdt_set_eth0(void *blob, int nodeoffset, const char *name, bd_t *bd) |
Gerald Van Baren | f35a53f | 2007-04-15 13:54:26 -0400 | [diff] [blame] | 333 | { |
Kim Phillips | 8f9e0e9 | 2007-08-15 22:30:19 -0500 | [diff] [blame] | 334 | /* Fix it up if it exists, don't create it if it doesn't exist */ |
Kim Phillips | f57ac7a | 2007-07-25 19:25:22 -0500 | [diff] [blame] | 335 | if (fdt_get_property(blob, nodeoffset, name, 0)) { |
| 336 | return fdt_setprop(blob, nodeoffset, name, bd->bi_enetaddr, 6); |
Gerald Van Baren | f35a53f | 2007-04-15 13:54:26 -0400 | [diff] [blame] | 337 | } |
Jerry Van Baren | 8be4044 | 2007-07-04 21:34:24 -0400 | [diff] [blame] | 338 | return 0; |
Gerald Van Baren | f35a53f | 2007-04-15 13:54:26 -0400 | [diff] [blame] | 339 | } |
| 340 | #ifdef CONFIG_HAS_ETH1 |
| 341 | /* second onboard ethernet port */ |
Kim Phillips | f57ac7a | 2007-07-25 19:25:22 -0500 | [diff] [blame] | 342 | static int fdt_set_eth1(void *blob, int nodeoffset, const char *name, bd_t *bd) |
Gerald Van Baren | f35a53f | 2007-04-15 13:54:26 -0400 | [diff] [blame] | 343 | { |
Kim Phillips | 8f9e0e9 | 2007-08-15 22:30:19 -0500 | [diff] [blame] | 344 | /* Fix it up if it exists, don't create it if it doesn't exist */ |
Kim Phillips | f57ac7a | 2007-07-25 19:25:22 -0500 | [diff] [blame] | 345 | if (fdt_get_property(blob, nodeoffset, name, 0)) { |
| 346 | return fdt_setprop(blob, nodeoffset, name, bd->bi_enet1addr, 6); |
Gerald Van Baren | f35a53f | 2007-04-15 13:54:26 -0400 | [diff] [blame] | 347 | } |
Jerry Van Baren | 8be4044 | 2007-07-04 21:34:24 -0400 | [diff] [blame] | 348 | return 0; |
Gerald Van Baren | f35a53f | 2007-04-15 13:54:26 -0400 | [diff] [blame] | 349 | } |
| 350 | #endif |
| 351 | #ifdef CONFIG_HAS_ETH2 |
| 352 | /* third onboard ethernet port */ |
Kim Phillips | f57ac7a | 2007-07-25 19:25:22 -0500 | [diff] [blame] | 353 | static int fdt_set_eth2(void *blob, int nodeoffset, const char *name, bd_t *bd) |
Gerald Van Baren | f35a53f | 2007-04-15 13:54:26 -0400 | [diff] [blame] | 354 | { |
Kim Phillips | 8f9e0e9 | 2007-08-15 22:30:19 -0500 | [diff] [blame] | 355 | /* Fix it up if it exists, don't create it if it doesn't exist */ |
Kim Phillips | f57ac7a | 2007-07-25 19:25:22 -0500 | [diff] [blame] | 356 | if (fdt_get_property(blob, nodeoffset, name, 0)) { |
| 357 | return fdt_setprop(blob, nodeoffset, name, bd->bi_enet2addr, 6); |
Gerald Van Baren | f35a53f | 2007-04-15 13:54:26 -0400 | [diff] [blame] | 358 | } |
Jerry Van Baren | 8be4044 | 2007-07-04 21:34:24 -0400 | [diff] [blame] | 359 | return 0; |
Gerald Van Baren | f35a53f | 2007-04-15 13:54:26 -0400 | [diff] [blame] | 360 | } |
| 361 | #endif |
| 362 | #ifdef CONFIG_HAS_ETH3 |
| 363 | /* fourth onboard ethernet port */ |
Kim Phillips | f57ac7a | 2007-07-25 19:25:22 -0500 | [diff] [blame] | 364 | static int fdt_set_eth3(void *blob, int nodeoffset, const char *name, bd_t *bd) |
Gerald Van Baren | f35a53f | 2007-04-15 13:54:26 -0400 | [diff] [blame] | 365 | { |
Kim Phillips | 8f9e0e9 | 2007-08-15 22:30:19 -0500 | [diff] [blame] | 366 | /* Fix it up if it exists, don't create it if it doesn't exist */ |
Kim Phillips | f57ac7a | 2007-07-25 19:25:22 -0500 | [diff] [blame] | 367 | if (fdt_get_property(blob, nodeoffset, name, 0)) { |
| 368 | return fdt_setprop(blob, nodeoffset, name, bd->bi_enet3addr, 6); |
Gerald Van Baren | f35a53f | 2007-04-15 13:54:26 -0400 | [diff] [blame] | 369 | } |
Jerry Van Baren | 8be4044 | 2007-07-04 21:34:24 -0400 | [diff] [blame] | 370 | return 0; |
Gerald Van Baren | f35a53f | 2007-04-15 13:54:26 -0400 | [diff] [blame] | 371 | } |
| 372 | #endif |
| 373 | |
Kim Phillips | f57ac7a | 2007-07-25 19:25:22 -0500 | [diff] [blame] | 374 | static int fdt_set_busfreq(void *blob, int nodeoffset, const char *name, bd_t *bd) |
Gerald Van Baren | f35a53f | 2007-04-15 13:54:26 -0400 | [diff] [blame] | 375 | { |
| 376 | u32 tmp; |
Kim Phillips | 8f9e0e9 | 2007-08-15 22:30:19 -0500 | [diff] [blame] | 377 | /* Create or update the property */ |
Gerald Van Baren | f35a53f | 2007-04-15 13:54:26 -0400 | [diff] [blame] | 378 | tmp = cpu_to_be32(bd->bi_busfreq); |
Kim Phillips | f57ac7a | 2007-07-25 19:25:22 -0500 | [diff] [blame] | 379 | return fdt_setprop(blob, nodeoffset, name, &tmp, sizeof(tmp)); |
Gerald Van Baren | f35a53f | 2007-04-15 13:54:26 -0400 | [diff] [blame] | 380 | } |
| 381 | |
Kim Phillips | f57ac7a | 2007-07-25 19:25:22 -0500 | [diff] [blame] | 382 | static int fdt_set_tbfreq(void *blob, int nodeoffset, const char *name, bd_t *bd) |
Jerry Van Baren | 8be4044 | 2007-07-04 21:34:24 -0400 | [diff] [blame] | 383 | { |
| 384 | u32 tmp; |
Kim Phillips | 8f9e0e9 | 2007-08-15 22:30:19 -0500 | [diff] [blame] | 385 | /* Create or update the property */ |
Jerry Van Baren | 8be4044 | 2007-07-04 21:34:24 -0400 | [diff] [blame] | 386 | tmp = cpu_to_be32(OF_TBCLK); |
Kim Phillips | f57ac7a | 2007-07-25 19:25:22 -0500 | [diff] [blame] | 387 | return fdt_setprop(blob, nodeoffset, name, &tmp, sizeof(tmp)); |
Jerry Van Baren | 8be4044 | 2007-07-04 21:34:24 -0400 | [diff] [blame] | 388 | } |
| 389 | |
| 390 | |
Kim Phillips | 8f9e0e9 | 2007-08-15 22:30:19 -0500 | [diff] [blame] | 391 | static int fdt_set_clockfreq(void *blob, int nodeoffset, const char *name, bd_t *bd) |
| 392 | { |
| 393 | u32 tmp; |
| 394 | /* Create or update the property */ |
| 395 | tmp = cpu_to_be32(gd->core_clk); |
| 396 | return fdt_setprop(blob, nodeoffset, name, &tmp, sizeof(tmp)); |
| 397 | } |
| 398 | |
| 399 | #ifdef CONFIG_QE |
| 400 | static int fdt_set_qe_busfreq(void *blob, int nodeoffset, const char *name, bd_t *bd) |
| 401 | { |
| 402 | u32 tmp; |
| 403 | /* Create or update the property */ |
| 404 | tmp = cpu_to_be32(gd->qe_clk); |
| 405 | return fdt_setprop(blob, nodeoffset, name, &tmp, sizeof(tmp)); |
| 406 | } |
| 407 | |
| 408 | static int fdt_set_qe_brgfreq(void *blob, int nodeoffset, const char *name, bd_t *bd) |
| 409 | { |
| 410 | u32 tmp; |
| 411 | /* Create or update the property */ |
| 412 | tmp = cpu_to_be32(gd->brg_clk); |
| 413 | return fdt_setprop(blob, nodeoffset, name, &tmp, sizeof(tmp)); |
| 414 | } |
| 415 | #endif |
| 416 | |
Gerald Van Baren | f35a53f | 2007-04-15 13:54:26 -0400 | [diff] [blame] | 417 | /* |
Jerry Van Baren | 8be4044 | 2007-07-04 21:34:24 -0400 | [diff] [blame] | 418 | * Fixups to the fdt. |
Gerald Van Baren | 213bf8c | 2007-03-31 12:23:51 -0400 | [diff] [blame] | 419 | */ |
Gerald Van Baren | 213bf8c | 2007-03-31 12:23:51 -0400 | [diff] [blame] | 420 | static const struct { |
Gerald Van Baren | 213bf8c | 2007-03-31 12:23:51 -0400 | [diff] [blame] | 421 | char *node; |
| 422 | char *prop; |
Kim Phillips | f57ac7a | 2007-07-25 19:25:22 -0500 | [diff] [blame] | 423 | int (*set_fn)(void *blob, int nodeoffset, const char *name, bd_t *bd); |
Gerald Van Baren | 213bf8c | 2007-03-31 12:23:51 -0400 | [diff] [blame] | 424 | } fixup_props[] = { |
Gerald Van Baren | f35a53f | 2007-04-15 13:54:26 -0400 | [diff] [blame] | 425 | { "/cpus/" OF_CPU, |
Jerry Van Baren | 8be4044 | 2007-07-04 21:34:24 -0400 | [diff] [blame] | 426 | "timebase-frequency", |
| 427 | fdt_set_tbfreq |
Gerald Van Baren | 213bf8c | 2007-03-31 12:23:51 -0400 | [diff] [blame] | 428 | }, |
Jerry Van Baren | 8be4044 | 2007-07-04 21:34:24 -0400 | [diff] [blame] | 429 | { "/cpus/" OF_CPU, |
Gerald Van Baren | f35a53f | 2007-04-15 13:54:26 -0400 | [diff] [blame] | 430 | "bus-frequency", |
| 431 | fdt_set_busfreq |
Gerald Van Baren | 213bf8c | 2007-03-31 12:23:51 -0400 | [diff] [blame] | 432 | }, |
Jerry Van Baren | 8be4044 | 2007-07-04 21:34:24 -0400 | [diff] [blame] | 433 | { "/cpus/" OF_CPU, |
Gerald Van Baren | f35a53f | 2007-04-15 13:54:26 -0400 | [diff] [blame] | 434 | "clock-frequency", |
Kim Phillips | 8f9e0e9 | 2007-08-15 22:30:19 -0500 | [diff] [blame] | 435 | fdt_set_clockfreq |
| 436 | }, |
| 437 | { "/" OF_SOC, |
| 438 | "bus-frequency", |
Gerald Van Baren | f35a53f | 2007-04-15 13:54:26 -0400 | [diff] [blame] | 439 | fdt_set_busfreq |
Gerald Van Baren | 213bf8c | 2007-03-31 12:23:51 -0400 | [diff] [blame] | 440 | }, |
Jerry Van Baren | 8be4044 | 2007-07-04 21:34:24 -0400 | [diff] [blame] | 441 | { "/" OF_SOC "/serial@4500", |
| 442 | "clock-frequency", |
| 443 | fdt_set_busfreq |
| 444 | }, |
| 445 | { "/" OF_SOC "/serial@4600", |
Gerald Van Baren | f35a53f | 2007-04-15 13:54:26 -0400 | [diff] [blame] | 446 | "clock-frequency", |
| 447 | fdt_set_busfreq |
Gerald Van Baren | 213bf8c | 2007-03-31 12:23:51 -0400 | [diff] [blame] | 448 | }, |
Kim Phillips | 255a3577 | 2007-05-16 16:52:19 -0500 | [diff] [blame] | 449 | #ifdef CONFIG_TSEC1 |
Jerry Van Baren | 8be4044 | 2007-07-04 21:34:24 -0400 | [diff] [blame] | 450 | { "/" OF_SOC "/ethernet@24000", |
Gerald Van Baren | 213bf8c | 2007-03-31 12:23:51 -0400 | [diff] [blame] | 451 | "mac-address", |
Gerald Van Baren | f35a53f | 2007-04-15 13:54:26 -0400 | [diff] [blame] | 452 | fdt_set_eth0 |
Gerald Van Baren | 213bf8c | 2007-03-31 12:23:51 -0400 | [diff] [blame] | 453 | }, |
Jerry Van Baren | 8be4044 | 2007-07-04 21:34:24 -0400 | [diff] [blame] | 454 | { "/" OF_SOC "/ethernet@24000", |
Gerald Van Baren | 213bf8c | 2007-03-31 12:23:51 -0400 | [diff] [blame] | 455 | "local-mac-address", |
Gerald Van Baren | f35a53f | 2007-04-15 13:54:26 -0400 | [diff] [blame] | 456 | fdt_set_eth0 |
Gerald Van Baren | 213bf8c | 2007-03-31 12:23:51 -0400 | [diff] [blame] | 457 | }, |
| 458 | #endif |
Kim Phillips | 255a3577 | 2007-05-16 16:52:19 -0500 | [diff] [blame] | 459 | #ifdef CONFIG_TSEC2 |
Jerry Van Baren | 8be4044 | 2007-07-04 21:34:24 -0400 | [diff] [blame] | 460 | { "/" OF_SOC "/ethernet@25000", |
Gerald Van Baren | 213bf8c | 2007-03-31 12:23:51 -0400 | [diff] [blame] | 461 | "mac-address", |
Gerald Van Baren | f35a53f | 2007-04-15 13:54:26 -0400 | [diff] [blame] | 462 | fdt_set_eth1 |
Gerald Van Baren | 213bf8c | 2007-03-31 12:23:51 -0400 | [diff] [blame] | 463 | }, |
Jerry Van Baren | 8be4044 | 2007-07-04 21:34:24 -0400 | [diff] [blame] | 464 | { "/" OF_SOC "/ethernet@25000", |
Gerald Van Baren | 213bf8c | 2007-03-31 12:23:51 -0400 | [diff] [blame] | 465 | "local-mac-address", |
Gerald Van Baren | f35a53f | 2007-04-15 13:54:26 -0400 | [diff] [blame] | 466 | fdt_set_eth1 |
Gerald Van Baren | 213bf8c | 2007-03-31 12:23:51 -0400 | [diff] [blame] | 467 | }, |
| 468 | #endif |
Kim Phillips | 8f9e0e9 | 2007-08-15 22:30:19 -0500 | [diff] [blame] | 469 | #ifdef CONFIG_QE |
| 470 | { "/" OF_QE, |
| 471 | "brg-frequency", |
| 472 | fdt_set_qe_brgfreq |
| 473 | }, |
| 474 | { "/" OF_QE, |
| 475 | "bus-frequency", |
| 476 | fdt_set_qe_busfreq |
| 477 | }, |
Gerald Van Baren | f35a53f | 2007-04-15 13:54:26 -0400 | [diff] [blame] | 478 | #ifdef CONFIG_UEC_ETH1 |
| 479 | #if CFG_UEC1_UCC_NUM == 0 /* UCC1 */ |
Jerry Van Baren | 8be4044 | 2007-07-04 21:34:24 -0400 | [diff] [blame] | 480 | { "/" OF_QE "/ucc@2000", |
Gerald Van Baren | f35a53f | 2007-04-15 13:54:26 -0400 | [diff] [blame] | 481 | "mac-address", |
| 482 | fdt_set_eth0 |
| 483 | }, |
Jerry Van Baren | 8be4044 | 2007-07-04 21:34:24 -0400 | [diff] [blame] | 484 | { "/" OF_QE "/ucc@2000", |
Gerald Van Baren | f35a53f | 2007-04-15 13:54:26 -0400 | [diff] [blame] | 485 | "local-mac-address", |
| 486 | fdt_set_eth0 |
| 487 | }, |
| 488 | #elif CFG_UEC1_UCC_NUM == 2 /* UCC3 */ |
Jerry Van Baren | 8be4044 | 2007-07-04 21:34:24 -0400 | [diff] [blame] | 489 | { "/" OF_QE "/ucc@2200", |
Gerald Van Baren | f35a53f | 2007-04-15 13:54:26 -0400 | [diff] [blame] | 490 | "mac-address", |
| 491 | fdt_set_eth0 |
| 492 | }, |
Jerry Van Baren | 8be4044 | 2007-07-04 21:34:24 -0400 | [diff] [blame] | 493 | { "/" OF_QE "/ucc@2200", |
Gerald Van Baren | f35a53f | 2007-04-15 13:54:26 -0400 | [diff] [blame] | 494 | "local-mac-address", |
| 495 | fdt_set_eth0 |
| 496 | }, |
| 497 | #endif |
Jerry Van Baren | 8be4044 | 2007-07-04 21:34:24 -0400 | [diff] [blame] | 498 | #endif /* CONFIG_UEC_ETH1 */ |
Gerald Van Baren | f35a53f | 2007-04-15 13:54:26 -0400 | [diff] [blame] | 499 | #ifdef CONFIG_UEC_ETH2 |
| 500 | #if CFG_UEC2_UCC_NUM == 1 /* UCC2 */ |
Jerry Van Baren | 8be4044 | 2007-07-04 21:34:24 -0400 | [diff] [blame] | 501 | { "/" OF_QE "/ucc@3000", |
Gerald Van Baren | f35a53f | 2007-04-15 13:54:26 -0400 | [diff] [blame] | 502 | "mac-address", |
| 503 | fdt_set_eth1 |
| 504 | }, |
Jerry Van Baren | 8be4044 | 2007-07-04 21:34:24 -0400 | [diff] [blame] | 505 | { "/" OF_QE "/ucc@3000", |
Gerald Van Baren | f35a53f | 2007-04-15 13:54:26 -0400 | [diff] [blame] | 506 | "local-mac-address", |
| 507 | fdt_set_eth1 |
| 508 | }, |
Kim Phillips | f4b2ac5 | 2007-08-15 22:30:12 -0500 | [diff] [blame] | 509 | #elif CFG_UEC2_UCC_NUM == 3 /* UCC4 */ |
Jerry Van Baren | 8be4044 | 2007-07-04 21:34:24 -0400 | [diff] [blame] | 510 | { "/" OF_QE "/ucc@3200", |
Gerald Van Baren | f35a53f | 2007-04-15 13:54:26 -0400 | [diff] [blame] | 511 | "mac-address", |
| 512 | fdt_set_eth1 |
| 513 | }, |
Jerry Van Baren | 8be4044 | 2007-07-04 21:34:24 -0400 | [diff] [blame] | 514 | { "/" OF_QE "/ucc@3200", |
Gerald Van Baren | f35a53f | 2007-04-15 13:54:26 -0400 | [diff] [blame] | 515 | "local-mac-address", |
| 516 | fdt_set_eth1 |
| 517 | }, |
| 518 | #endif |
Jerry Van Baren | 8be4044 | 2007-07-04 21:34:24 -0400 | [diff] [blame] | 519 | #endif /* CONFIG_UEC_ETH2 */ |
Kim Phillips | 8f9e0e9 | 2007-08-15 22:30:19 -0500 | [diff] [blame] | 520 | #endif /* CONFIG_QE */ |
Gerald Van Baren | 213bf8c | 2007-03-31 12:23:51 -0400 | [diff] [blame] | 521 | }; |
| 522 | |
| 523 | void |
| 524 | ft_cpu_setup(void *blob, bd_t *bd) |
| 525 | { |
Kim Phillips | 6a16e0d | 2007-08-15 22:30:26 -0500 | [diff] [blame^] | 526 | int nodeoffset; |
| 527 | int err; |
| 528 | int j; |
| 529 | int tmp[2]; |
Gerald Van Baren | 213bf8c | 2007-03-31 12:23:51 -0400 | [diff] [blame] | 530 | |
| 531 | for (j = 0; j < (sizeof(fixup_props) / sizeof(fixup_props[0])); j++) { |
Kim Phillips | f57ac7a | 2007-07-25 19:25:22 -0500 | [diff] [blame] | 532 | nodeoffset = fdt_find_node_by_path(blob, fixup_props[j].node); |
Gerald Van Baren | 213bf8c | 2007-03-31 12:23:51 -0400 | [diff] [blame] | 533 | if (nodeoffset >= 0) { |
Jerry Van Baren | 8be4044 | 2007-07-04 21:34:24 -0400 | [diff] [blame] | 534 | err = fixup_props[j].set_fn(blob, nodeoffset, |
| 535 | fixup_props[j].prop, bd); |
Gerald Van Baren | f35a53f | 2007-04-15 13:54:26 -0400 | [diff] [blame] | 536 | if (err < 0) |
Jerry Van Baren | 8be4044 | 2007-07-04 21:34:24 -0400 | [diff] [blame] | 537 | debug("Problem setting %s = %s: %s\n", |
Kim Phillips | 6a16e0d | 2007-08-15 22:30:26 -0500 | [diff] [blame^] | 538 | fixup_props[j].node, fixup_props[j].prop, |
| 539 | fdt_strerror(err)); |
Jerry Van Baren | 8be4044 | 2007-07-04 21:34:24 -0400 | [diff] [blame] | 540 | } else { |
| 541 | debug("Couldn't find %s: %s\n", |
Kim Phillips | 6a16e0d | 2007-08-15 22:30:26 -0500 | [diff] [blame^] | 542 | fixup_props[j].node, fdt_strerror(nodeoffset)); |
Gerald Van Baren | 213bf8c | 2007-03-31 12:23:51 -0400 | [diff] [blame] | 543 | } |
| 544 | } |
Kim Phillips | 6a16e0d | 2007-08-15 22:30:26 -0500 | [diff] [blame^] | 545 | |
| 546 | /* update, or add and update /memory node */ |
| 547 | nodeoffset = fdt_find_node_by_path(blob, "/memory"); |
| 548 | if (nodeoffset < 0) { |
| 549 | nodeoffset = fdt_add_subnode(blob, 0, "memory"); |
| 550 | if (nodeoffset < 0) |
| 551 | debug("failed to add /memory node: %s\n", |
| 552 | fdt_strerror(nodeoffset)); |
| 553 | } |
| 554 | if (nodeoffset >= 0) { |
| 555 | fdt_setprop(blob, nodeoffset, "device_type", |
| 556 | "memory", sizeof("memory")); |
| 557 | tmp[0] = cpu_to_be32(bd->bi_memstart); |
| 558 | tmp[1] = cpu_to_be32(bd->bi_memsize); |
| 559 | fdt_setprop(blob, nodeoffset, "reg", tmp, sizeof(tmp)); |
| 560 | } |
Gerald Van Baren | 213bf8c | 2007-03-31 12:23:51 -0400 | [diff] [blame] | 561 | } |
Jerry Van Baren | 26d02c9 | 2007-07-04 21:27:30 -0400 | [diff] [blame] | 562 | #elif defined(CONFIG_OF_FLAT_TREE) |
Kumar Gala | 62ec641 | 2006-01-11 16:48:10 -0600 | [diff] [blame] | 563 | void |
| 564 | ft_cpu_setup(void *blob, bd_t *bd) |
| 565 | { |
| 566 | u32 *p; |
| 567 | int len; |
| 568 | ulong clock; |
| 569 | |
| 570 | clock = bd->bi_busfreq; |
| 571 | p = ft_get_prop(blob, "/cpus/" OF_CPU "/bus-frequency", &len); |
| 572 | if (p != NULL) |
| 573 | *p = cpu_to_be32(clock); |
| 574 | |
| 575 | p = ft_get_prop(blob, "/" OF_SOC "/bus-frequency", &len); |
| 576 | if (p != NULL) |
| 577 | *p = cpu_to_be32(clock); |
| 578 | |
| 579 | p = ft_get_prop(blob, "/" OF_SOC "/serial@4500/clock-frequency", &len); |
| 580 | if (p != NULL) |
| 581 | *p = cpu_to_be32(clock); |
| 582 | |
| 583 | p = ft_get_prop(blob, "/" OF_SOC "/serial@4600/clock-frequency", &len); |
| 584 | if (p != NULL) |
| 585 | *p = cpu_to_be32(clock); |
| 586 | |
Kim Phillips | 255a3577 | 2007-05-16 16:52:19 -0500 | [diff] [blame] | 587 | #ifdef CONFIG_TSEC1 |
Timur Tabi | 61f4f91 | 2007-02-13 10:41:42 -0600 | [diff] [blame] | 588 | p = ft_get_prop(blob, "/" OF_SOC "/ethernet@24000/mac-address", &len); |
| 589 | if (p != NULL) |
| 590 | memcpy(p, bd->bi_enetaddr, 6); |
| 591 | |
Kim Phillips | 4804136 | 2006-11-01 00:07:25 -0600 | [diff] [blame] | 592 | p = ft_get_prop(blob, "/" OF_SOC "/ethernet@24000/local-mac-address", &len); |
Kim Phillips | b700474 | 2007-01-30 16:15:21 -0600 | [diff] [blame] | 593 | if (p != NULL) |
Kumar Gala | 62ec641 | 2006-01-11 16:48:10 -0600 | [diff] [blame] | 594 | memcpy(p, bd->bi_enetaddr, 6); |
| 595 | #endif |
| 596 | |
Kim Phillips | 255a3577 | 2007-05-16 16:52:19 -0500 | [diff] [blame] | 597 | #ifdef CONFIG_TSEC2 |
Timur Tabi | 61f4f91 | 2007-02-13 10:41:42 -0600 | [diff] [blame] | 598 | p = ft_get_prop(blob, "/" OF_SOC "/ethernet@25000/mac-address", &len); |
| 599 | if (p != NULL) |
| 600 | memcpy(p, bd->bi_enet1addr, 6); |
| 601 | |
Kim Phillips | 4804136 | 2006-11-01 00:07:25 -0600 | [diff] [blame] | 602 | p = ft_get_prop(blob, "/" OF_SOC "/ethernet@25000/local-mac-address", &len); |
Kim Phillips | b700474 | 2007-01-30 16:15:21 -0600 | [diff] [blame] | 603 | if (p != NULL) |
Kumar Gala | 62ec641 | 2006-01-11 16:48:10 -0600 | [diff] [blame] | 604 | memcpy(p, bd->bi_enet1addr, 6); |
| 605 | #endif |
Kim Phillips | d51b3cf | 2007-02-22 20:06:57 -0600 | [diff] [blame] | 606 | |
| 607 | #ifdef CONFIG_UEC_ETH1 |
| 608 | #if CFG_UEC1_UCC_NUM == 0 /* UCC1 */ |
| 609 | p = ft_get_prop(blob, "/" OF_QE "/ucc@2000/mac-address", &len); |
| 610 | if (p != NULL) |
| 611 | memcpy(p, bd->bi_enetaddr, 6); |
| 612 | |
| 613 | p = ft_get_prop(blob, "/" OF_QE "/ucc@2000/local-mac-address", &len); |
| 614 | if (p != NULL) |
| 615 | memcpy(p, bd->bi_enetaddr, 6); |
| 616 | #elif CFG_UEC1_UCC_NUM == 2 /* UCC3 */ |
| 617 | p = ft_get_prop(blob, "/" OF_QE "/ucc@2200/mac-address", &len); |
| 618 | if (p != NULL) |
| 619 | memcpy(p, bd->bi_enetaddr, 6); |
| 620 | |
| 621 | p = ft_get_prop(blob, "/" OF_QE "/ucc@2200/local-mac-address", &len); |
| 622 | if (p != NULL) |
| 623 | memcpy(p, bd->bi_enetaddr, 6); |
| 624 | #endif |
| 625 | #endif |
| 626 | |
| 627 | #ifdef CONFIG_UEC_ETH2 |
| 628 | #if CFG_UEC2_UCC_NUM == 1 /* UCC2 */ |
| 629 | p = ft_get_prop(blob, "/" OF_QE "/ucc@3000/mac-address", &len); |
| 630 | if (p != NULL) |
| 631 | memcpy(p, bd->bi_enet1addr, 6); |
| 632 | |
| 633 | p = ft_get_prop(blob, "/" OF_QE "/ucc@3000/local-mac-address", &len); |
| 634 | if (p != NULL) |
| 635 | memcpy(p, bd->bi_enet1addr, 6); |
| 636 | #elif CFG_UEC2_UCC_NUM == 3 /* UCC4 */ |
| 637 | p = ft_get_prop(blob, "/" OF_QE "/ucc@3200/mac-address", &len); |
| 638 | if (p != NULL) |
| 639 | memcpy(p, bd->bi_enet1addr, 6); |
| 640 | |
| 641 | p = ft_get_prop(blob, "/" OF_QE "/ucc@3200/local-mac-address", &len); |
| 642 | if (p != NULL) |
| 643 | memcpy(p, bd->bi_enet1addr, 6); |
| 644 | #endif |
| 645 | #endif |
Kumar Gala | 62ec641 | 2006-01-11 16:48:10 -0600 | [diff] [blame] | 646 | } |
| 647 | #endif |
Marian Balakowicz | 61f2515 | 2006-03-14 16:14:48 +0100 | [diff] [blame] | 648 | |
| 649 | #if defined(CONFIG_DDR_ECC) |
| 650 | void dma_init(void) |
| 651 | { |
Timur Tabi | d239d74 | 2006-11-03 12:00:28 -0600 | [diff] [blame] | 652 | volatile immap_t *immap = (immap_t *)CFG_IMMR; |
Dave Liu | f6eda7f | 2006-10-25 14:41:21 -0500 | [diff] [blame] | 653 | volatile dma83xx_t *dma = &immap->dma; |
Marian Balakowicz | 61f2515 | 2006-03-14 16:14:48 +0100 | [diff] [blame] | 654 | volatile u32 status = swab32(dma->dmasr0); |
| 655 | volatile u32 dmamr0 = swab32(dma->dmamr0); |
| 656 | |
| 657 | debug("DMA-init\n"); |
| 658 | |
| 659 | /* initialize DMASARn, DMADAR and DMAABCRn */ |
| 660 | dma->dmadar0 = (u32)0; |
| 661 | dma->dmasar0 = (u32)0; |
| 662 | dma->dmabcr0 = 0; |
| 663 | |
| 664 | __asm__ __volatile__ ("sync"); |
| 665 | __asm__ __volatile__ ("isync"); |
| 666 | |
| 667 | /* clear CS bit */ |
| 668 | dmamr0 &= ~DMA_CHANNEL_START; |
| 669 | dma->dmamr0 = swab32(dmamr0); |
| 670 | __asm__ __volatile__ ("sync"); |
| 671 | __asm__ __volatile__ ("isync"); |
| 672 | |
| 673 | /* while the channel is busy, spin */ |
| 674 | while(status & DMA_CHANNEL_BUSY) { |
| 675 | status = swab32(dma->dmasr0); |
| 676 | } |
| 677 | |
| 678 | debug("DMA-init end\n"); |
| 679 | } |
| 680 | |
| 681 | uint dma_check(void) |
| 682 | { |
Timur Tabi | d239d74 | 2006-11-03 12:00:28 -0600 | [diff] [blame] | 683 | volatile immap_t *immap = (immap_t *)CFG_IMMR; |
Dave Liu | f6eda7f | 2006-10-25 14:41:21 -0500 | [diff] [blame] | 684 | volatile dma83xx_t *dma = &immap->dma; |
Marian Balakowicz | 61f2515 | 2006-03-14 16:14:48 +0100 | [diff] [blame] | 685 | volatile u32 status = swab32(dma->dmasr0); |
| 686 | volatile u32 byte_count = swab32(dma->dmabcr0); |
| 687 | |
| 688 | /* while the channel is busy, spin */ |
| 689 | while (status & DMA_CHANNEL_BUSY) { |
| 690 | status = swab32(dma->dmasr0); |
| 691 | } |
| 692 | |
| 693 | if (status & DMA_CHANNEL_TRANSFER_ERROR) { |
| 694 | printf ("DMA Error: status = %x @ %d\n", status, byte_count); |
| 695 | } |
| 696 | |
| 697 | return status; |
| 698 | } |
| 699 | |
| 700 | int dma_xfer(void *dest, u32 count, void *src) |
| 701 | { |
Timur Tabi | d239d74 | 2006-11-03 12:00:28 -0600 | [diff] [blame] | 702 | volatile immap_t *immap = (immap_t *)CFG_IMMR; |
Dave Liu | f6eda7f | 2006-10-25 14:41:21 -0500 | [diff] [blame] | 703 | volatile dma83xx_t *dma = &immap->dma; |
Marian Balakowicz | 61f2515 | 2006-03-14 16:14:48 +0100 | [diff] [blame] | 704 | volatile u32 dmamr0; |
| 705 | |
| 706 | /* initialize DMASARn, DMADAR and DMAABCRn */ |
| 707 | dma->dmadar0 = swab32((u32)dest); |
| 708 | dma->dmasar0 = swab32((u32)src); |
| 709 | dma->dmabcr0 = swab32(count); |
| 710 | |
| 711 | __asm__ __volatile__ ("sync"); |
| 712 | __asm__ __volatile__ ("isync"); |
| 713 | |
| 714 | /* init direct transfer, clear CS bit */ |
| 715 | dmamr0 = (DMA_CHANNEL_TRANSFER_MODE_DIRECT | |
| 716 | DMA_CHANNEL_SOURCE_ADDRESS_HOLD_8B | |
| 717 | DMA_CHANNEL_SOURCE_ADRESSS_HOLD_EN); |
Wolfgang Denk | cf48eb9 | 2006-04-16 10:51:58 +0200 | [diff] [blame] | 718 | |
Marian Balakowicz | 61f2515 | 2006-03-14 16:14:48 +0100 | [diff] [blame] | 719 | dma->dmamr0 = swab32(dmamr0); |
| 720 | |
| 721 | __asm__ __volatile__ ("sync"); |
| 722 | __asm__ __volatile__ ("isync"); |
| 723 | |
| 724 | /* set CS to start DMA transfer */ |
| 725 | dmamr0 |= DMA_CHANNEL_START; |
| 726 | dma->dmamr0 = swab32(dmamr0); |
| 727 | __asm__ __volatile__ ("sync"); |
| 728 | __asm__ __volatile__ ("isync"); |
| 729 | |
| 730 | return ((int)dma_check()); |
| 731 | } |
| 732 | #endif /*CONFIG_DDR_ECC*/ |