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