Kumar Gala | 124b082 | 2008-08-26 15:01:29 -0500 | [diff] [blame] | 1 | /* |
York Sun | e8dc17b | 2012-08-17 08:22:39 +0000 | [diff] [blame] | 2 | * Copyright 2008, 2010-2012 Freescale Semiconductor, Inc. |
Kumar Gala | 124b082 | 2008-08-26 15:01:29 -0500 | [diff] [blame] | 3 | * |
Wolfgang Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 4 | * SPDX-License-Identifier: GPL-2.0+ |
Kumar Gala | 124b082 | 2008-08-26 15:01:29 -0500 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #include <common.h> |
Kumar Gala | 6404209 | 2010-07-14 10:04:21 -0500 | [diff] [blame] | 8 | #include <hwconfig.h> |
Kumar Gala | 124b082 | 2008-08-26 15:01:29 -0500 | [diff] [blame] | 9 | #include <asm/fsl_ddr_sdram.h> |
| 10 | |
| 11 | #include "ddr.h" |
| 12 | |
Kumar Gala | 7230160 | 2011-01-09 11:37:00 -0600 | [diff] [blame] | 13 | /* |
| 14 | * Use our own stack based buffer before relocation to allow accessing longer |
| 15 | * hwconfig strings that might be in the environment before we've relocated. |
| 16 | * This is pretty fragile on both the use of stack and if the buffer is big |
| 17 | * enough. However we will get a warning from getenv_f for the later. |
| 18 | */ |
Kumar Gala | 7230160 | 2011-01-09 11:37:00 -0600 | [diff] [blame] | 19 | |
Kumar Gala | 124b082 | 2008-08-26 15:01:29 -0500 | [diff] [blame] | 20 | /* Board-specific functions defined in each board's ddr.c */ |
| 21 | extern void fsl_ddr_board_options(memctl_options_t *popts, |
Haiying Wang | fa44036 | 2008-10-03 12:36:55 -0400 | [diff] [blame] | 22 | dimm_params_t *pdimm, |
Kumar Gala | 124b082 | 2008-08-26 15:01:29 -0500 | [diff] [blame] | 23 | unsigned int ctrl_num); |
| 24 | |
York Sun | 454f507 | 2011-08-26 11:32:43 -0700 | [diff] [blame] | 25 | struct dynamic_odt { |
York Sun | ba0c2eb | 2011-01-10 12:03:00 +0000 | [diff] [blame] | 26 | unsigned int odt_rd_cfg; |
| 27 | unsigned int odt_wr_cfg; |
| 28 | unsigned int odt_rtt_norm; |
| 29 | unsigned int odt_rtt_wr; |
York Sun | 454f507 | 2011-08-26 11:32:43 -0700 | [diff] [blame] | 30 | }; |
York Sun | ba0c2eb | 2011-01-10 12:03:00 +0000 | [diff] [blame] | 31 | |
York Sun | 454f507 | 2011-08-26 11:32:43 -0700 | [diff] [blame] | 32 | #ifdef CONFIG_FSL_DDR3 |
| 33 | static const struct dynamic_odt single_Q[4] = { |
York Sun | ba0c2eb | 2011-01-10 12:03:00 +0000 | [diff] [blame] | 34 | { /* cs0 */ |
| 35 | FSL_DDR_ODT_NEVER, |
| 36 | FSL_DDR_ODT_CS_AND_OTHER_DIMM, |
| 37 | DDR3_RTT_20_OHM, |
| 38 | DDR3_RTT_120_OHM |
| 39 | }, |
| 40 | { /* cs1 */ |
| 41 | FSL_DDR_ODT_NEVER, |
| 42 | FSL_DDR_ODT_NEVER, /* tied high */ |
| 43 | DDR3_RTT_OFF, |
| 44 | DDR3_RTT_120_OHM |
| 45 | }, |
| 46 | { /* cs2 */ |
| 47 | FSL_DDR_ODT_NEVER, |
| 48 | FSL_DDR_ODT_CS_AND_OTHER_DIMM, |
| 49 | DDR3_RTT_20_OHM, |
| 50 | DDR3_RTT_120_OHM |
| 51 | }, |
| 52 | { /* cs3 */ |
| 53 | FSL_DDR_ODT_NEVER, |
| 54 | FSL_DDR_ODT_NEVER, /* tied high */ |
| 55 | DDR3_RTT_OFF, |
| 56 | DDR3_RTT_120_OHM |
| 57 | } |
| 58 | }; |
| 59 | |
York Sun | 454f507 | 2011-08-26 11:32:43 -0700 | [diff] [blame] | 60 | static const struct dynamic_odt single_D[4] = { |
York Sun | ba0c2eb | 2011-01-10 12:03:00 +0000 | [diff] [blame] | 61 | { /* cs0 */ |
| 62 | FSL_DDR_ODT_NEVER, |
| 63 | FSL_DDR_ODT_ALL, |
| 64 | DDR3_RTT_40_OHM, |
| 65 | DDR3_RTT_OFF |
| 66 | }, |
| 67 | { /* cs1 */ |
| 68 | FSL_DDR_ODT_NEVER, |
| 69 | FSL_DDR_ODT_NEVER, |
| 70 | DDR3_RTT_OFF, |
| 71 | DDR3_RTT_OFF |
| 72 | }, |
| 73 | {0, 0, 0, 0}, |
| 74 | {0, 0, 0, 0} |
| 75 | }; |
| 76 | |
York Sun | 454f507 | 2011-08-26 11:32:43 -0700 | [diff] [blame] | 77 | static const struct dynamic_odt single_S[4] = { |
York Sun | ba0c2eb | 2011-01-10 12:03:00 +0000 | [diff] [blame] | 78 | { /* cs0 */ |
| 79 | FSL_DDR_ODT_NEVER, |
| 80 | FSL_DDR_ODT_ALL, |
| 81 | DDR3_RTT_40_OHM, |
| 82 | DDR3_RTT_OFF |
| 83 | }, |
| 84 | {0, 0, 0, 0}, |
| 85 | {0, 0, 0, 0}, |
| 86 | {0, 0, 0, 0}, |
| 87 | }; |
| 88 | |
York Sun | 454f507 | 2011-08-26 11:32:43 -0700 | [diff] [blame] | 89 | static const struct dynamic_odt dual_DD[4] = { |
York Sun | ba0c2eb | 2011-01-10 12:03:00 +0000 | [diff] [blame] | 90 | { /* cs0 */ |
| 91 | FSL_DDR_ODT_NEVER, |
| 92 | FSL_DDR_ODT_SAME_DIMM, |
| 93 | DDR3_RTT_120_OHM, |
| 94 | DDR3_RTT_OFF |
| 95 | }, |
| 96 | { /* cs1 */ |
| 97 | FSL_DDR_ODT_OTHER_DIMM, |
| 98 | FSL_DDR_ODT_OTHER_DIMM, |
| 99 | DDR3_RTT_30_OHM, |
| 100 | DDR3_RTT_OFF |
| 101 | }, |
| 102 | { /* cs2 */ |
| 103 | FSL_DDR_ODT_NEVER, |
| 104 | FSL_DDR_ODT_SAME_DIMM, |
| 105 | DDR3_RTT_120_OHM, |
| 106 | DDR3_RTT_OFF |
| 107 | }, |
| 108 | { /* cs3 */ |
| 109 | FSL_DDR_ODT_OTHER_DIMM, |
| 110 | FSL_DDR_ODT_OTHER_DIMM, |
| 111 | DDR3_RTT_30_OHM, |
| 112 | DDR3_RTT_OFF |
| 113 | } |
| 114 | }; |
| 115 | |
York Sun | 454f507 | 2011-08-26 11:32:43 -0700 | [diff] [blame] | 116 | static const struct dynamic_odt dual_DS[4] = { |
York Sun | ba0c2eb | 2011-01-10 12:03:00 +0000 | [diff] [blame] | 117 | { /* cs0 */ |
| 118 | FSL_DDR_ODT_NEVER, |
| 119 | FSL_DDR_ODT_SAME_DIMM, |
| 120 | DDR3_RTT_120_OHM, |
| 121 | DDR3_RTT_OFF |
| 122 | }, |
| 123 | { /* cs1 */ |
| 124 | FSL_DDR_ODT_OTHER_DIMM, |
| 125 | FSL_DDR_ODT_OTHER_DIMM, |
| 126 | DDR3_RTT_30_OHM, |
| 127 | DDR3_RTT_OFF |
| 128 | }, |
| 129 | { /* cs2 */ |
| 130 | FSL_DDR_ODT_OTHER_DIMM, |
| 131 | FSL_DDR_ODT_ALL, |
| 132 | DDR3_RTT_20_OHM, |
| 133 | DDR3_RTT_120_OHM |
| 134 | }, |
| 135 | {0, 0, 0, 0} |
| 136 | }; |
York Sun | 454f507 | 2011-08-26 11:32:43 -0700 | [diff] [blame] | 137 | static const struct dynamic_odt dual_SD[4] = { |
York Sun | ba0c2eb | 2011-01-10 12:03:00 +0000 | [diff] [blame] | 138 | { /* cs0 */ |
| 139 | FSL_DDR_ODT_OTHER_DIMM, |
| 140 | FSL_DDR_ODT_ALL, |
| 141 | DDR3_RTT_20_OHM, |
| 142 | DDR3_RTT_120_OHM |
| 143 | }, |
| 144 | {0, 0, 0, 0}, |
| 145 | { /* cs2 */ |
| 146 | FSL_DDR_ODT_NEVER, |
| 147 | FSL_DDR_ODT_SAME_DIMM, |
| 148 | DDR3_RTT_120_OHM, |
| 149 | DDR3_RTT_OFF |
| 150 | }, |
| 151 | { /* cs3 */ |
| 152 | FSL_DDR_ODT_OTHER_DIMM, |
| 153 | FSL_DDR_ODT_OTHER_DIMM, |
| 154 | DDR3_RTT_20_OHM, |
| 155 | DDR3_RTT_OFF |
| 156 | } |
| 157 | }; |
| 158 | |
York Sun | 454f507 | 2011-08-26 11:32:43 -0700 | [diff] [blame] | 159 | static const struct dynamic_odt dual_SS[4] = { |
York Sun | ba0c2eb | 2011-01-10 12:03:00 +0000 | [diff] [blame] | 160 | { /* cs0 */ |
| 161 | FSL_DDR_ODT_OTHER_DIMM, |
| 162 | FSL_DDR_ODT_ALL, |
| 163 | DDR3_RTT_30_OHM, |
| 164 | DDR3_RTT_120_OHM |
| 165 | }, |
| 166 | {0, 0, 0, 0}, |
| 167 | { /* cs2 */ |
| 168 | FSL_DDR_ODT_OTHER_DIMM, |
| 169 | FSL_DDR_ODT_ALL, |
| 170 | DDR3_RTT_30_OHM, |
| 171 | DDR3_RTT_120_OHM |
| 172 | }, |
| 173 | {0, 0, 0, 0} |
| 174 | }; |
| 175 | |
York Sun | 454f507 | 2011-08-26 11:32:43 -0700 | [diff] [blame] | 176 | static const struct dynamic_odt dual_D0[4] = { |
York Sun | ba0c2eb | 2011-01-10 12:03:00 +0000 | [diff] [blame] | 177 | { /* cs0 */ |
| 178 | FSL_DDR_ODT_NEVER, |
| 179 | FSL_DDR_ODT_SAME_DIMM, |
| 180 | DDR3_RTT_40_OHM, |
| 181 | DDR3_RTT_OFF |
| 182 | }, |
| 183 | { /* cs1 */ |
| 184 | FSL_DDR_ODT_NEVER, |
| 185 | FSL_DDR_ODT_NEVER, |
| 186 | DDR3_RTT_OFF, |
| 187 | DDR3_RTT_OFF |
| 188 | }, |
| 189 | {0, 0, 0, 0}, |
| 190 | {0, 0, 0, 0} |
| 191 | }; |
| 192 | |
York Sun | 454f507 | 2011-08-26 11:32:43 -0700 | [diff] [blame] | 193 | static const struct dynamic_odt dual_0D[4] = { |
York Sun | ba0c2eb | 2011-01-10 12:03:00 +0000 | [diff] [blame] | 194 | {0, 0, 0, 0}, |
| 195 | {0, 0, 0, 0}, |
| 196 | { /* cs2 */ |
| 197 | FSL_DDR_ODT_NEVER, |
| 198 | FSL_DDR_ODT_SAME_DIMM, |
| 199 | DDR3_RTT_40_OHM, |
| 200 | DDR3_RTT_OFF |
| 201 | }, |
| 202 | { /* cs3 */ |
| 203 | FSL_DDR_ODT_NEVER, |
| 204 | FSL_DDR_ODT_NEVER, |
| 205 | DDR3_RTT_OFF, |
| 206 | DDR3_RTT_OFF |
| 207 | } |
| 208 | }; |
| 209 | |
York Sun | 454f507 | 2011-08-26 11:32:43 -0700 | [diff] [blame] | 210 | static const struct dynamic_odt dual_S0[4] = { |
York Sun | ba0c2eb | 2011-01-10 12:03:00 +0000 | [diff] [blame] | 211 | { /* cs0 */ |
| 212 | FSL_DDR_ODT_NEVER, |
| 213 | FSL_DDR_ODT_CS, |
| 214 | DDR3_RTT_40_OHM, |
| 215 | DDR3_RTT_OFF |
| 216 | }, |
| 217 | {0, 0, 0, 0}, |
| 218 | {0, 0, 0, 0}, |
| 219 | {0, 0, 0, 0} |
| 220 | |
| 221 | }; |
| 222 | |
York Sun | 454f507 | 2011-08-26 11:32:43 -0700 | [diff] [blame] | 223 | static const struct dynamic_odt dual_0S[4] = { |
York Sun | ba0c2eb | 2011-01-10 12:03:00 +0000 | [diff] [blame] | 224 | {0, 0, 0, 0}, |
| 225 | {0, 0, 0, 0}, |
| 226 | { /* cs2 */ |
| 227 | FSL_DDR_ODT_NEVER, |
| 228 | FSL_DDR_ODT_CS, |
| 229 | DDR3_RTT_40_OHM, |
| 230 | DDR3_RTT_OFF |
| 231 | }, |
| 232 | {0, 0, 0, 0} |
| 233 | |
| 234 | }; |
| 235 | |
York Sun | 454f507 | 2011-08-26 11:32:43 -0700 | [diff] [blame] | 236 | static const struct dynamic_odt odt_unknown[4] = { |
York Sun | ba0c2eb | 2011-01-10 12:03:00 +0000 | [diff] [blame] | 237 | { /* cs0 */ |
| 238 | FSL_DDR_ODT_NEVER, |
| 239 | FSL_DDR_ODT_CS, |
| 240 | DDR3_RTT_120_OHM, |
| 241 | DDR3_RTT_OFF |
| 242 | }, |
| 243 | { /* cs1 */ |
| 244 | FSL_DDR_ODT_NEVER, |
| 245 | FSL_DDR_ODT_CS, |
| 246 | DDR3_RTT_120_OHM, |
| 247 | DDR3_RTT_OFF |
| 248 | }, |
| 249 | { /* cs2 */ |
| 250 | FSL_DDR_ODT_NEVER, |
| 251 | FSL_DDR_ODT_CS, |
| 252 | DDR3_RTT_120_OHM, |
| 253 | DDR3_RTT_OFF |
| 254 | }, |
| 255 | { /* cs3 */ |
| 256 | FSL_DDR_ODT_NEVER, |
| 257 | FSL_DDR_ODT_CS, |
| 258 | DDR3_RTT_120_OHM, |
| 259 | DDR3_RTT_OFF |
| 260 | } |
| 261 | }; |
York Sun | 454f507 | 2011-08-26 11:32:43 -0700 | [diff] [blame] | 262 | #else /* CONFIG_FSL_DDR3 */ |
| 263 | static const struct dynamic_odt single_Q[4] = { |
| 264 | {0, 0, 0, 0}, |
| 265 | {0, 0, 0, 0}, |
| 266 | {0, 0, 0, 0}, |
| 267 | {0, 0, 0, 0} |
| 268 | }; |
| 269 | |
| 270 | static const struct dynamic_odt single_D[4] = { |
| 271 | { /* cs0 */ |
| 272 | FSL_DDR_ODT_NEVER, |
| 273 | FSL_DDR_ODT_ALL, |
| 274 | DDR2_RTT_150_OHM, |
| 275 | DDR2_RTT_OFF |
| 276 | }, |
| 277 | { /* cs1 */ |
| 278 | FSL_DDR_ODT_NEVER, |
| 279 | FSL_DDR_ODT_NEVER, |
| 280 | DDR2_RTT_OFF, |
| 281 | DDR2_RTT_OFF |
| 282 | }, |
| 283 | {0, 0, 0, 0}, |
| 284 | {0, 0, 0, 0} |
| 285 | }; |
| 286 | |
| 287 | static const struct dynamic_odt single_S[4] = { |
| 288 | { /* cs0 */ |
| 289 | FSL_DDR_ODT_NEVER, |
| 290 | FSL_DDR_ODT_ALL, |
| 291 | DDR2_RTT_150_OHM, |
| 292 | DDR2_RTT_OFF |
| 293 | }, |
| 294 | {0, 0, 0, 0}, |
| 295 | {0, 0, 0, 0}, |
| 296 | {0, 0, 0, 0}, |
| 297 | }; |
| 298 | |
| 299 | static const struct dynamic_odt dual_DD[4] = { |
| 300 | { /* cs0 */ |
| 301 | FSL_DDR_ODT_OTHER_DIMM, |
| 302 | FSL_DDR_ODT_OTHER_DIMM, |
| 303 | DDR2_RTT_75_OHM, |
| 304 | DDR2_RTT_OFF |
| 305 | }, |
| 306 | { /* cs1 */ |
| 307 | FSL_DDR_ODT_NEVER, |
| 308 | FSL_DDR_ODT_NEVER, |
| 309 | DDR2_RTT_OFF, |
| 310 | DDR2_RTT_OFF |
| 311 | }, |
| 312 | { /* cs2 */ |
| 313 | FSL_DDR_ODT_OTHER_DIMM, |
| 314 | FSL_DDR_ODT_OTHER_DIMM, |
| 315 | DDR2_RTT_75_OHM, |
| 316 | DDR2_RTT_OFF |
| 317 | }, |
| 318 | { /* cs3 */ |
| 319 | FSL_DDR_ODT_NEVER, |
| 320 | FSL_DDR_ODT_NEVER, |
| 321 | DDR2_RTT_OFF, |
| 322 | DDR2_RTT_OFF |
| 323 | } |
| 324 | }; |
| 325 | |
| 326 | static const struct dynamic_odt dual_DS[4] = { |
| 327 | { /* cs0 */ |
| 328 | FSL_DDR_ODT_OTHER_DIMM, |
| 329 | FSL_DDR_ODT_OTHER_DIMM, |
| 330 | DDR2_RTT_75_OHM, |
| 331 | DDR2_RTT_OFF |
| 332 | }, |
| 333 | { /* cs1 */ |
| 334 | FSL_DDR_ODT_NEVER, |
| 335 | FSL_DDR_ODT_NEVER, |
| 336 | DDR2_RTT_OFF, |
| 337 | DDR2_RTT_OFF |
| 338 | }, |
| 339 | { /* cs2 */ |
| 340 | FSL_DDR_ODT_OTHER_DIMM, |
| 341 | FSL_DDR_ODT_OTHER_DIMM, |
| 342 | DDR2_RTT_75_OHM, |
| 343 | DDR2_RTT_OFF |
| 344 | }, |
| 345 | {0, 0, 0, 0} |
| 346 | }; |
| 347 | |
| 348 | static const struct dynamic_odt dual_SD[4] = { |
| 349 | { /* cs0 */ |
| 350 | FSL_DDR_ODT_OTHER_DIMM, |
| 351 | FSL_DDR_ODT_OTHER_DIMM, |
| 352 | DDR2_RTT_75_OHM, |
| 353 | DDR2_RTT_OFF |
| 354 | }, |
| 355 | {0, 0, 0, 0}, |
| 356 | { /* cs2 */ |
| 357 | FSL_DDR_ODT_OTHER_DIMM, |
| 358 | FSL_DDR_ODT_OTHER_DIMM, |
| 359 | DDR2_RTT_75_OHM, |
| 360 | DDR2_RTT_OFF |
| 361 | }, |
| 362 | { /* cs3 */ |
| 363 | FSL_DDR_ODT_NEVER, |
| 364 | FSL_DDR_ODT_NEVER, |
| 365 | DDR2_RTT_OFF, |
| 366 | DDR2_RTT_OFF |
| 367 | } |
| 368 | }; |
| 369 | |
| 370 | static const struct dynamic_odt dual_SS[4] = { |
| 371 | { /* cs0 */ |
| 372 | FSL_DDR_ODT_OTHER_DIMM, |
| 373 | FSL_DDR_ODT_OTHER_DIMM, |
| 374 | DDR2_RTT_75_OHM, |
| 375 | DDR2_RTT_OFF |
| 376 | }, |
| 377 | {0, 0, 0, 0}, |
| 378 | { /* cs2 */ |
| 379 | FSL_DDR_ODT_OTHER_DIMM, |
| 380 | FSL_DDR_ODT_OTHER_DIMM, |
| 381 | DDR2_RTT_75_OHM, |
| 382 | DDR2_RTT_OFF |
| 383 | }, |
| 384 | {0, 0, 0, 0} |
| 385 | }; |
| 386 | |
| 387 | static const struct dynamic_odt dual_D0[4] = { |
| 388 | { /* cs0 */ |
| 389 | FSL_DDR_ODT_NEVER, |
| 390 | FSL_DDR_ODT_ALL, |
| 391 | DDR2_RTT_150_OHM, |
| 392 | DDR2_RTT_OFF |
| 393 | }, |
| 394 | { /* cs1 */ |
| 395 | FSL_DDR_ODT_NEVER, |
| 396 | FSL_DDR_ODT_NEVER, |
| 397 | DDR2_RTT_OFF, |
| 398 | DDR2_RTT_OFF |
| 399 | }, |
| 400 | {0, 0, 0, 0}, |
| 401 | {0, 0, 0, 0} |
| 402 | }; |
| 403 | |
| 404 | static const struct dynamic_odt dual_0D[4] = { |
| 405 | {0, 0, 0, 0}, |
| 406 | {0, 0, 0, 0}, |
| 407 | { /* cs2 */ |
| 408 | FSL_DDR_ODT_NEVER, |
| 409 | FSL_DDR_ODT_ALL, |
| 410 | DDR2_RTT_150_OHM, |
| 411 | DDR2_RTT_OFF |
| 412 | }, |
| 413 | { /* cs3 */ |
| 414 | FSL_DDR_ODT_NEVER, |
| 415 | FSL_DDR_ODT_NEVER, |
| 416 | DDR2_RTT_OFF, |
| 417 | DDR2_RTT_OFF |
| 418 | } |
| 419 | }; |
York Sun | ba0c2eb | 2011-01-10 12:03:00 +0000 | [diff] [blame] | 420 | |
York Sun | 454f507 | 2011-08-26 11:32:43 -0700 | [diff] [blame] | 421 | static const struct dynamic_odt dual_S0[4] = { |
| 422 | { /* cs0 */ |
| 423 | FSL_DDR_ODT_NEVER, |
| 424 | FSL_DDR_ODT_CS, |
| 425 | DDR2_RTT_150_OHM, |
| 426 | DDR2_RTT_OFF |
| 427 | }, |
| 428 | {0, 0, 0, 0}, |
| 429 | {0, 0, 0, 0}, |
| 430 | {0, 0, 0, 0} |
| 431 | |
| 432 | }; |
| 433 | |
| 434 | static const struct dynamic_odt dual_0S[4] = { |
| 435 | {0, 0, 0, 0}, |
| 436 | {0, 0, 0, 0}, |
| 437 | { /* cs2 */ |
| 438 | FSL_DDR_ODT_NEVER, |
| 439 | FSL_DDR_ODT_CS, |
| 440 | DDR2_RTT_150_OHM, |
| 441 | DDR2_RTT_OFF |
| 442 | }, |
| 443 | {0, 0, 0, 0} |
| 444 | |
| 445 | }; |
| 446 | |
| 447 | static const struct dynamic_odt odt_unknown[4] = { |
| 448 | { /* cs0 */ |
| 449 | FSL_DDR_ODT_NEVER, |
| 450 | FSL_DDR_ODT_CS, |
| 451 | DDR2_RTT_75_OHM, |
| 452 | DDR2_RTT_OFF |
| 453 | }, |
| 454 | { /* cs1 */ |
| 455 | FSL_DDR_ODT_NEVER, |
| 456 | FSL_DDR_ODT_NEVER, |
| 457 | DDR2_RTT_OFF, |
| 458 | DDR2_RTT_OFF |
| 459 | }, |
| 460 | { /* cs2 */ |
| 461 | FSL_DDR_ODT_NEVER, |
| 462 | FSL_DDR_ODT_CS, |
| 463 | DDR2_RTT_75_OHM, |
| 464 | DDR2_RTT_OFF |
| 465 | }, |
| 466 | { /* cs3 */ |
| 467 | FSL_DDR_ODT_NEVER, |
| 468 | FSL_DDR_ODT_NEVER, |
| 469 | DDR2_RTT_OFF, |
| 470 | DDR2_RTT_OFF |
| 471 | } |
| 472 | }; |
| 473 | #endif |
York Sun | d01babd | 2012-10-08 07:44:27 +0000 | [diff] [blame] | 474 | |
| 475 | /* |
| 476 | * Automatically seleect bank interleaving mode based on DIMMs |
| 477 | * in this order: cs0_cs1_cs2_cs3, cs0_cs1, null. |
| 478 | * This function only deal with one or two slots per controller. |
| 479 | */ |
| 480 | static inline unsigned int auto_bank_intlv(dimm_params_t *pdimm) |
| 481 | { |
| 482 | #if (CONFIG_DIMM_SLOTS_PER_CTLR == 1) |
| 483 | if (pdimm[0].n_ranks == 4) |
| 484 | return FSL_DDR_CS0_CS1_CS2_CS3; |
| 485 | else if (pdimm[0].n_ranks == 2) |
| 486 | return FSL_DDR_CS0_CS1; |
| 487 | #elif (CONFIG_DIMM_SLOTS_PER_CTLR == 2) |
| 488 | #ifdef CONFIG_FSL_DDR_FIRST_SLOT_QUAD_CAPABLE |
| 489 | if (pdimm[0].n_ranks == 4) |
| 490 | return FSL_DDR_CS0_CS1_CS2_CS3; |
| 491 | #endif |
| 492 | if (pdimm[0].n_ranks == 2) { |
| 493 | if (pdimm[1].n_ranks == 2) |
| 494 | return FSL_DDR_CS0_CS1_CS2_CS3; |
| 495 | else |
| 496 | return FSL_DDR_CS0_CS1; |
| 497 | } |
| 498 | #endif |
| 499 | return 0; |
| 500 | } |
| 501 | |
Kumar Gala | 124b082 | 2008-08-26 15:01:29 -0500 | [diff] [blame] | 502 | unsigned int populate_memctl_options(int all_DIMMs_registered, |
| 503 | memctl_options_t *popts, |
Haiying Wang | fa44036 | 2008-10-03 12:36:55 -0400 | [diff] [blame] | 504 | dimm_params_t *pdimm, |
Kumar Gala | 124b082 | 2008-08-26 15:01:29 -0500 | [diff] [blame] | 505 | unsigned int ctrl_num) |
| 506 | { |
| 507 | unsigned int i; |
Kumar Gala | 7230160 | 2011-01-09 11:37:00 -0600 | [diff] [blame] | 508 | char buffer[HWCONFIG_BUFFER_SIZE]; |
| 509 | char *buf = NULL; |
Kumar Gala | 59cb44c | 2011-11-09 10:05:21 -0600 | [diff] [blame] | 510 | #if defined(CONFIG_FSL_DDR3) || defined(CONFIG_FSL_DDR2) |
York Sun | 454f507 | 2011-08-26 11:32:43 -0700 | [diff] [blame] | 511 | const struct dynamic_odt *pdodt = odt_unknown; |
Kumar Gala | 59cb44c | 2011-11-09 10:05:21 -0600 | [diff] [blame] | 512 | #endif |
York Sun | f0345e2 | 2011-08-24 09:40:26 -0700 | [diff] [blame] | 513 | ulong ddr_freq; |
Kumar Gala | 7230160 | 2011-01-09 11:37:00 -0600 | [diff] [blame] | 514 | |
| 515 | /* |
| 516 | * Extract hwconfig from environment since we have not properly setup |
| 517 | * the environment but need it for ddr config params |
| 518 | */ |
| 519 | if (getenv_f("hwconfig", buffer, sizeof(buffer)) > 0) |
| 520 | buf = buffer; |
Kumar Gala | 124b082 | 2008-08-26 15:01:29 -0500 | [diff] [blame] | 521 | |
Kumar Gala | 59cb44c | 2011-11-09 10:05:21 -0600 | [diff] [blame] | 522 | #if defined(CONFIG_FSL_DDR3) || defined(CONFIG_FSL_DDR2) |
Kumar Gala | 124b082 | 2008-08-26 15:01:29 -0500 | [diff] [blame] | 523 | /* Chip select options. */ |
York Sun | ba0c2eb | 2011-01-10 12:03:00 +0000 | [diff] [blame] | 524 | if (CONFIG_DIMM_SLOTS_PER_CTLR == 1) { |
| 525 | switch (pdimm[0].n_ranks) { |
| 526 | case 1: |
| 527 | pdodt = single_S; |
| 528 | break; |
| 529 | case 2: |
| 530 | pdodt = single_D; |
| 531 | break; |
| 532 | case 4: |
| 533 | pdodt = single_Q; |
| 534 | break; |
| 535 | } |
| 536 | } else if (CONFIG_DIMM_SLOTS_PER_CTLR == 2) { |
| 537 | switch (pdimm[0].n_ranks) { |
York Sun | 98df4d1 | 2012-10-08 07:44:23 +0000 | [diff] [blame] | 538 | #ifdef CONFIG_FSL_DDR_FIRST_SLOT_QUAD_CAPABLE |
| 539 | case 4: |
| 540 | pdodt = single_Q; |
| 541 | if (pdimm[1].n_ranks) |
| 542 | printf("Error: Quad- and Dual-rank DIMMs " |
| 543 | "cannot be used together\n"); |
| 544 | break; |
| 545 | #endif |
York Sun | ba0c2eb | 2011-01-10 12:03:00 +0000 | [diff] [blame] | 546 | case 2: |
| 547 | switch (pdimm[1].n_ranks) { |
| 548 | case 2: |
| 549 | pdodt = dual_DD; |
| 550 | break; |
| 551 | case 1: |
| 552 | pdodt = dual_DS; |
| 553 | break; |
| 554 | case 0: |
| 555 | pdodt = dual_D0; |
| 556 | break; |
| 557 | } |
| 558 | break; |
| 559 | case 1: |
| 560 | switch (pdimm[1].n_ranks) { |
| 561 | case 2: |
| 562 | pdodt = dual_SD; |
| 563 | break; |
| 564 | case 1: |
| 565 | pdodt = dual_SS; |
| 566 | break; |
| 567 | case 0: |
| 568 | pdodt = dual_S0; |
| 569 | break; |
| 570 | } |
| 571 | break; |
| 572 | case 0: |
| 573 | switch (pdimm[1].n_ranks) { |
| 574 | case 2: |
| 575 | pdodt = dual_0D; |
| 576 | break; |
| 577 | case 1: |
| 578 | pdodt = dual_0S; |
| 579 | break; |
| 580 | } |
| 581 | break; |
| 582 | } |
| 583 | } |
Kumar Gala | 59cb44c | 2011-11-09 10:05:21 -0600 | [diff] [blame] | 584 | #endif |
Kumar Gala | 124b082 | 2008-08-26 15:01:29 -0500 | [diff] [blame] | 585 | |
| 586 | /* Pick chip-select local options. */ |
| 587 | for (i = 0; i < CONFIG_CHIP_SELECTS_PER_CTRL; i++) { |
York Sun | 454f507 | 2011-08-26 11:32:43 -0700 | [diff] [blame] | 588 | #if defined(CONFIG_FSL_DDR3) || defined(CONFIG_FSL_DDR2) |
York Sun | ba0c2eb | 2011-01-10 12:03:00 +0000 | [diff] [blame] | 589 | popts->cs_local_opts[i].odt_rd_cfg = pdodt[i].odt_rd_cfg; |
| 590 | popts->cs_local_opts[i].odt_wr_cfg = pdodt[i].odt_wr_cfg; |
| 591 | popts->cs_local_opts[i].odt_rtt_norm = pdodt[i].odt_rtt_norm; |
| 592 | popts->cs_local_opts[i].odt_rtt_wr = pdodt[i].odt_rtt_wr; |
| 593 | #else |
| 594 | popts->cs_local_opts[i].odt_rd_cfg = FSL_DDR_ODT_NEVER; |
| 595 | popts->cs_local_opts[i].odt_wr_cfg = FSL_DDR_ODT_CS; |
| 596 | #endif |
Kumar Gala | 124b082 | 2008-08-26 15:01:29 -0500 | [diff] [blame] | 597 | popts->cs_local_opts[i].auto_precharge = 0; |
| 598 | } |
| 599 | |
| 600 | /* Pick interleaving mode. */ |
| 601 | |
| 602 | /* |
| 603 | * 0 = no interleaving |
| 604 | * 1 = interleaving between 2 controllers |
| 605 | */ |
| 606 | popts->memctl_interleaving = 0; |
| 607 | |
| 608 | /* |
| 609 | * 0 = cacheline |
| 610 | * 1 = page |
| 611 | * 2 = (logical) bank |
| 612 | * 3 = superbank (only if CS interleaving is enabled) |
| 613 | */ |
| 614 | popts->memctl_interleaving_mode = 0; |
| 615 | |
| 616 | /* |
| 617 | * 0: cacheline: bit 30 of the 36-bit physical addr selects the memctl |
| 618 | * 1: page: bit to the left of the column bits selects the memctl |
| 619 | * 2: bank: bit to the left of the bank bits selects the memctl |
| 620 | * 3: superbank: bit to the left of the chip select selects the memctl |
| 621 | * |
| 622 | * NOTE: ba_intlv (rank interleaving) is independent of memory |
| 623 | * controller interleaving; it is only within a memory controller. |
| 624 | * Must use superbank interleaving if rank interleaving is used and |
| 625 | * memory controller interleaving is enabled. |
| 626 | */ |
| 627 | |
| 628 | /* |
| 629 | * 0 = no |
| 630 | * 0x40 = CS0,CS1 |
| 631 | * 0x20 = CS2,CS3 |
| 632 | * 0x60 = CS0,CS1 + CS2,CS3 |
| 633 | * 0x04 = CS0,CS1,CS2,CS3 |
| 634 | */ |
| 635 | popts->ba_intlv_ctl = 0; |
| 636 | |
| 637 | /* Memory Organization Parameters */ |
| 638 | popts->registered_dimm_en = all_DIMMs_registered; |
| 639 | |
| 640 | /* Operational Mode Paramters */ |
| 641 | |
| 642 | /* Pick ECC modes */ |
Kumar Gala | 124b082 | 2008-08-26 15:01:29 -0500 | [diff] [blame] | 643 | popts->ECC_mode = 0; /* 0 = disabled, 1 = enabled */ |
York Sun | 0ac71ea | 2011-01-10 12:02:57 +0000 | [diff] [blame] | 644 | #ifdef CONFIG_DDR_ECC |
| 645 | if (hwconfig_sub_f("fsl_ddr", "ecc", buf)) { |
| 646 | if (hwconfig_subarg_cmp_f("fsl_ddr", "ecc", "on", buf)) |
| 647 | popts->ECC_mode = 1; |
| 648 | } else |
| 649 | popts->ECC_mode = 1; |
Kumar Gala | 124b082 | 2008-08-26 15:01:29 -0500 | [diff] [blame] | 650 | #endif |
| 651 | popts->ECC_init_using_memctl = 1; /* 0 = use DMA, 1 = use memctl */ |
| 652 | |
| 653 | /* |
| 654 | * Choose DQS config |
| 655 | * 0 for DDR1 |
| 656 | * 1 for DDR2 |
| 657 | */ |
| 658 | #if defined(CONFIG_FSL_DDR1) |
| 659 | popts->DQS_config = 0; |
Dave Liu | 4be87b2 | 2009-03-14 12:48:30 +0800 | [diff] [blame] | 660 | #elif defined(CONFIG_FSL_DDR2) || defined(CONFIG_FSL_DDR3) |
Kumar Gala | 124b082 | 2008-08-26 15:01:29 -0500 | [diff] [blame] | 661 | popts->DQS_config = 1; |
Kumar Gala | 124b082 | 2008-08-26 15:01:29 -0500 | [diff] [blame] | 662 | #endif |
| 663 | |
| 664 | /* Choose self-refresh during sleep. */ |
| 665 | popts->self_refresh_in_sleep = 1; |
| 666 | |
| 667 | /* Choose dynamic power management mode. */ |
| 668 | popts->dynamic_power = 0; |
| 669 | |
York Sun | 5fb9f6f | 2011-05-27 07:25:48 +0800 | [diff] [blame] | 670 | /* |
| 671 | * check first dimm for primary sdram width |
| 672 | * presuming all dimms are similar |
| 673 | * 0 = 64-bit, 1 = 32-bit, 2 = 16-bit |
| 674 | */ |
York Sun | 3c5ffd4 | 2011-06-27 13:35:25 -0700 | [diff] [blame] | 675 | #if defined(CONFIG_FSL_DDR1) || defined(CONFIG_FSL_DDR2) |
| 676 | if (pdimm[0].n_ranks != 0) { |
| 677 | if ((pdimm[0].data_width >= 64) && \ |
| 678 | (pdimm[0].data_width <= 72)) |
| 679 | popts->data_bus_width = 0; |
| 680 | else if ((pdimm[0].data_width >= 32) || \ |
| 681 | (pdimm[0].data_width <= 40)) |
| 682 | popts->data_bus_width = 1; |
| 683 | else { |
| 684 | panic("Error: data width %u is invalid!\n", |
| 685 | pdimm[0].data_width); |
| 686 | } |
| 687 | } |
| 688 | #else |
| 689 | if (pdimm[0].n_ranks != 0) { |
| 690 | if (pdimm[0].primary_sdram_width == 64) |
| 691 | popts->data_bus_width = 0; |
| 692 | else if (pdimm[0].primary_sdram_width == 32) |
| 693 | popts->data_bus_width = 1; |
| 694 | else if (pdimm[0].primary_sdram_width == 16) |
| 695 | popts->data_bus_width = 2; |
| 696 | else { |
| 697 | panic("Error: primary sdram width %u is invalid!\n", |
| 698 | pdimm[0].primary_sdram_width); |
| 699 | } |
| 700 | } |
| 701 | #endif |
Kumar Gala | 124b082 | 2008-08-26 15:01:29 -0500 | [diff] [blame] | 702 | |
| 703 | /* Choose burst length. */ |
Dave Liu | 4be87b2 | 2009-03-14 12:48:30 +0800 | [diff] [blame] | 704 | #if defined(CONFIG_FSL_DDR3) |
Dave Liu | 707aa5c | 2010-03-05 12:22:00 +0800 | [diff] [blame] | 705 | #if defined(CONFIG_E500MC) |
| 706 | popts->OTF_burst_chop_en = 0; /* on-the-fly burst chop disable */ |
| 707 | popts->burst_length = DDR_BL8; /* Fixed 8-beat burst len */ |
| 708 | #else |
York Sun | dd803dd | 2011-05-27 07:25:51 +0800 | [diff] [blame] | 709 | if ((popts->data_bus_width == 1) || (popts->data_bus_width == 2)) { |
| 710 | /* 32-bit or 16-bit bus */ |
York Sun | 5fb9f6f | 2011-05-27 07:25:48 +0800 | [diff] [blame] | 711 | popts->OTF_burst_chop_en = 0; |
| 712 | popts->burst_length = DDR_BL8; |
| 713 | } else { |
| 714 | popts->OTF_burst_chop_en = 1; /* on-the-fly burst chop */ |
| 715 | popts->burst_length = DDR_OTF; /* on-the-fly BC4 and BL8 */ |
| 716 | } |
Dave Liu | 707aa5c | 2010-03-05 12:22:00 +0800 | [diff] [blame] | 717 | #endif |
Dave Liu | 4be87b2 | 2009-03-14 12:48:30 +0800 | [diff] [blame] | 718 | #else |
| 719 | popts->burst_length = DDR_BL4; /* has to be 4 for DDR2 */ |
| 720 | #endif |
| 721 | |
| 722 | /* Choose ddr controller address mirror mode */ |
| 723 | #if defined(CONFIG_FSL_DDR3) |
| 724 | popts->mirrored_dimm = pdimm[0].mirrored_dimm; |
| 725 | #endif |
Kumar Gala | 124b082 | 2008-08-26 15:01:29 -0500 | [diff] [blame] | 726 | |
| 727 | /* Global Timing Parameters. */ |
| 728 | debug("mclk_ps = %u ps\n", get_memory_clk_period_ps()); |
| 729 | |
| 730 | /* Pick a caslat override. */ |
| 731 | popts->cas_latency_override = 0; |
| 732 | popts->cas_latency_override_value = 3; |
| 733 | if (popts->cas_latency_override) { |
| 734 | debug("using caslat override value = %u\n", |
| 735 | popts->cas_latency_override_value); |
| 736 | } |
| 737 | |
| 738 | /* Decide whether to use the computed derated latency */ |
| 739 | popts->use_derated_caslat = 0; |
| 740 | |
| 741 | /* Choose an additive latency. */ |
| 742 | popts->additive_latency_override = 0; |
| 743 | popts->additive_latency_override_value = 3; |
| 744 | if (popts->additive_latency_override) { |
| 745 | debug("using additive latency override value = %u\n", |
| 746 | popts->additive_latency_override_value); |
| 747 | } |
| 748 | |
| 749 | /* |
| 750 | * 2T_EN setting |
| 751 | * |
| 752 | * Factors to consider for 2T_EN: |
| 753 | * - number of DIMMs installed |
| 754 | * - number of components, number of active ranks |
| 755 | * - how much time you want to spend playing around |
| 756 | */ |
Dave Liu | a06d74c | 2008-11-21 16:31:43 +0800 | [diff] [blame] | 757 | popts->twoT_en = 0; |
Kumar Gala | 124b082 | 2008-08-26 15:01:29 -0500 | [diff] [blame] | 758 | popts->threeT_en = 0; |
| 759 | |
York Sun | ba0c2eb | 2011-01-10 12:03:00 +0000 | [diff] [blame] | 760 | /* for RDIMM, address parity enable */ |
| 761 | popts->ap_en = 1; |
| 762 | |
Kumar Gala | 124b082 | 2008-08-26 15:01:29 -0500 | [diff] [blame] | 763 | /* |
| 764 | * BSTTOPRE precharge interval |
| 765 | * |
| 766 | * Set this to 0 for global auto precharge |
| 767 | * |
| 768 | * FIXME: Should this be configured in picoseconds? |
| 769 | * Why it should be in ps: better understanding of this |
| 770 | * relative to actual DRAM timing parameters such as tRAS. |
| 771 | * e.g. tRAS(min) = 40 ns |
| 772 | */ |
| 773 | popts->bstopre = 0x100; |
| 774 | |
| 775 | /* Minimum CKE pulse width -- tCKE(MIN) */ |
| 776 | popts->tCKE_clock_pulse_width_ps |
| 777 | = mclk_to_picos(FSL_DDR_MIN_TCKE_PULSE_WIDTH_DDR); |
| 778 | |
| 779 | /* |
| 780 | * Window for four activates -- tFAW |
| 781 | * |
| 782 | * FIXME: UM: applies only to DDR2/DDR3 with eight logical banks only |
| 783 | * FIXME: varies depending upon number of column addresses or data |
| 784 | * FIXME: width, was considering looking at pdimm->primary_sdram_width |
| 785 | */ |
| 786 | #if defined(CONFIG_FSL_DDR1) |
| 787 | popts->tFAW_window_four_activates_ps = mclk_to_picos(1); |
| 788 | |
| 789 | #elif defined(CONFIG_FSL_DDR2) |
| 790 | /* |
| 791 | * x4/x8; some datasheets have 35000 |
| 792 | * x16 wide columns only? Use 50000? |
| 793 | */ |
| 794 | popts->tFAW_window_four_activates_ps = 37500; |
| 795 | |
| 796 | #elif defined(CONFIG_FSL_DDR3) |
Dave Liu | 4be87b2 | 2009-03-14 12:48:30 +0800 | [diff] [blame] | 797 | popts->tFAW_window_four_activates_ps = pdimm[0].tFAW_ps; |
| 798 | #endif |
| 799 | popts->zq_en = 0; |
| 800 | popts->wrlvl_en = 0; |
| 801 | #if defined(CONFIG_FSL_DDR3) |
| 802 | /* |
| 803 | * due to ddr3 dimm is fly-by topology |
| 804 | * we suggest to enable write leveling to |
| 805 | * meet the tQDSS under different loading. |
| 806 | */ |
| 807 | popts->wrlvl_en = 1; |
york | 1714e49 | 2010-07-02 22:25:56 +0000 | [diff] [blame] | 808 | popts->zq_en = 1; |
Dave Liu | 64ee7df | 2009-12-16 10:24:37 -0600 | [diff] [blame] | 809 | popts->wrlvl_override = 0; |
Kumar Gala | 124b082 | 2008-08-26 15:01:29 -0500 | [diff] [blame] | 810 | #endif |
| 811 | |
Kumar Gala | 124b082 | 2008-08-26 15:01:29 -0500 | [diff] [blame] | 812 | /* |
Haiying Wang | b834f92 | 2008-10-03 12:37:10 -0400 | [diff] [blame] | 813 | * Check interleaving configuration from environment. |
| 814 | * Please refer to doc/README.fsl-ddr for the detail. |
Kumar Gala | 124b082 | 2008-08-26 15:01:29 -0500 | [diff] [blame] | 815 | * |
| 816 | * If memory controller interleaving is enabled, then the data |
york | 93799ca | 2010-07-02 22:25:52 +0000 | [diff] [blame] | 817 | * bus widths must be programmed identically for all memory controllers. |
Haiying Wang | b834f92 | 2008-10-03 12:37:10 -0400 | [diff] [blame] | 818 | * |
york | 93799ca | 2010-07-02 22:25:52 +0000 | [diff] [blame] | 819 | * XXX: Attempt to set all controllers to the same chip select |
Haiying Wang | b834f92 | 2008-10-03 12:37:10 -0400 | [diff] [blame] | 820 | * interleaving mode. It will do a best effort to get the |
| 821 | * requested ranks interleaved together such that the result |
| 822 | * should be a subset of the requested configuration. |
Kumar Gala | 124b082 | 2008-08-26 15:01:29 -0500 | [diff] [blame] | 823 | */ |
Kumar Gala | c0f3b3c | 2009-02-06 09:56:34 -0600 | [diff] [blame] | 824 | #if (CONFIG_NUM_DDR_CONTROLLERS > 1) |
York Sun | e8dc17b | 2012-08-17 08:22:39 +0000 | [diff] [blame] | 825 | if (!hwconfig_sub_f("fsl_ddr", "ctlr_intlv", buf)) |
| 826 | goto done; |
| 827 | |
| 828 | if (pdimm[0].n_ranks == 0) { |
| 829 | printf("There is no rank on CS0 for controller %d.\n", ctrl_num); |
| 830 | popts->memctl_interleaving = 0; |
| 831 | goto done; |
| 832 | } |
| 833 | popts->memctl_interleaving = 1; |
| 834 | /* |
| 835 | * test null first. if CONFIG_HWCONFIG is not defined |
| 836 | * hwconfig_arg_cmp returns non-zero |
| 837 | */ |
| 838 | if (hwconfig_subarg_cmp_f("fsl_ddr", "ctlr_intlv", |
| 839 | "null", buf)) { |
| 840 | popts->memctl_interleaving = 0; |
| 841 | debug("memory controller interleaving disabled.\n"); |
| 842 | } else if (hwconfig_subarg_cmp_f("fsl_ddr", |
| 843 | "ctlr_intlv", |
| 844 | "cacheline", buf)) { |
| 845 | popts->memctl_interleaving_mode = |
| 846 | ((CONFIG_NUM_DDR_CONTROLLERS == 3) && ctrl_num == 2) ? |
| 847 | 0 : FSL_DDR_CACHE_LINE_INTERLEAVING; |
| 848 | popts->memctl_interleaving = |
| 849 | ((CONFIG_NUM_DDR_CONTROLLERS == 3) && ctrl_num == 2) ? |
| 850 | 0 : 1; |
| 851 | } else if (hwconfig_subarg_cmp_f("fsl_ddr", |
| 852 | "ctlr_intlv", |
| 853 | "page", buf)) { |
| 854 | popts->memctl_interleaving_mode = |
| 855 | ((CONFIG_NUM_DDR_CONTROLLERS == 3) && ctrl_num == 2) ? |
| 856 | 0 : FSL_DDR_PAGE_INTERLEAVING; |
| 857 | popts->memctl_interleaving = |
| 858 | ((CONFIG_NUM_DDR_CONTROLLERS == 3) && ctrl_num == 2) ? |
| 859 | 0 : 1; |
| 860 | } else if (hwconfig_subarg_cmp_f("fsl_ddr", |
| 861 | "ctlr_intlv", |
| 862 | "bank", buf)) { |
| 863 | popts->memctl_interleaving_mode = |
| 864 | ((CONFIG_NUM_DDR_CONTROLLERS == 3) && ctrl_num == 2) ? |
| 865 | 0 : FSL_DDR_BANK_INTERLEAVING; |
| 866 | popts->memctl_interleaving = |
| 867 | ((CONFIG_NUM_DDR_CONTROLLERS == 3) && ctrl_num == 2) ? |
| 868 | 0 : 1; |
| 869 | } else if (hwconfig_subarg_cmp_f("fsl_ddr", |
| 870 | "ctlr_intlv", |
| 871 | "superbank", buf)) { |
| 872 | popts->memctl_interleaving_mode = |
| 873 | ((CONFIG_NUM_DDR_CONTROLLERS == 3) && ctrl_num == 2) ? |
| 874 | 0 : FSL_DDR_SUPERBANK_INTERLEAVING; |
| 875 | popts->memctl_interleaving = |
| 876 | ((CONFIG_NUM_DDR_CONTROLLERS == 3) && ctrl_num == 2) ? |
| 877 | 0 : 1; |
| 878 | #if (CONFIG_NUM_DDR_CONTROLLERS == 3) |
| 879 | } else if (hwconfig_subarg_cmp_f("fsl_ddr", |
| 880 | "ctlr_intlv", |
| 881 | "3way_1KB", buf)) { |
| 882 | popts->memctl_interleaving_mode = |
| 883 | FSL_DDR_3WAY_1KB_INTERLEAVING; |
| 884 | } else if (hwconfig_subarg_cmp_f("fsl_ddr", |
| 885 | "ctlr_intlv", |
| 886 | "3way_4KB", buf)) { |
| 887 | popts->memctl_interleaving_mode = |
| 888 | FSL_DDR_3WAY_4KB_INTERLEAVING; |
| 889 | } else if (hwconfig_subarg_cmp_f("fsl_ddr", |
| 890 | "ctlr_intlv", |
| 891 | "3way_8KB", buf)) { |
| 892 | popts->memctl_interleaving_mode = |
| 893 | FSL_DDR_3WAY_8KB_INTERLEAVING; |
| 894 | #elif (CONFIG_NUM_DDR_CONTROLLERS == 4) |
| 895 | } else if (hwconfig_subarg_cmp_f("fsl_ddr", |
| 896 | "ctlr_intlv", |
| 897 | "4way_1KB", buf)) { |
| 898 | popts->memctl_interleaving_mode = |
| 899 | FSL_DDR_4WAY_1KB_INTERLEAVING; |
| 900 | } else if (hwconfig_subarg_cmp_f("fsl_ddr", |
| 901 | "ctlr_intlv", |
| 902 | "4way_4KB", buf)) { |
| 903 | popts->memctl_interleaving_mode = |
| 904 | FSL_DDR_4WAY_4KB_INTERLEAVING; |
| 905 | } else if (hwconfig_subarg_cmp_f("fsl_ddr", |
| 906 | "ctlr_intlv", |
| 907 | "4way_8KB", buf)) { |
| 908 | popts->memctl_interleaving_mode = |
| 909 | FSL_DDR_4WAY_8KB_INTERLEAVING; |
| 910 | #endif |
| 911 | } else { |
| 912 | popts->memctl_interleaving = 0; |
| 913 | printf("hwconfig has unrecognized parameter for ctlr_intlv.\n"); |
Haiying Wang | b834f92 | 2008-10-03 12:37:10 -0400 | [diff] [blame] | 914 | } |
York Sun | e8dc17b | 2012-08-17 08:22:39 +0000 | [diff] [blame] | 915 | done: |
Dave Liu | 0f9318f | 2009-11-12 07:26:37 +0800 | [diff] [blame] | 916 | #endif |
Kumar Gala | 7230160 | 2011-01-09 11:37:00 -0600 | [diff] [blame] | 917 | if ((hwconfig_sub_f("fsl_ddr", "bank_intlv", buf)) && |
Dave Liu | 0f9318f | 2009-11-12 07:26:37 +0800 | [diff] [blame] | 918 | (CONFIG_CHIP_SELECTS_PER_CTRL > 1)) { |
Kumar Gala | 6404209 | 2010-07-14 10:04:21 -0500 | [diff] [blame] | 919 | /* test null first. if CONFIG_HWCONFIG is not defined, |
Kumar Gala | 7230160 | 2011-01-09 11:37:00 -0600 | [diff] [blame] | 920 | * hwconfig_subarg_cmp_f returns non-zero */ |
| 921 | if (hwconfig_subarg_cmp_f("fsl_ddr", "bank_intlv", |
| 922 | "null", buf)) |
york | 93799ca | 2010-07-02 22:25:52 +0000 | [diff] [blame] | 923 | debug("bank interleaving disabled.\n"); |
Kumar Gala | 7230160 | 2011-01-09 11:37:00 -0600 | [diff] [blame] | 924 | else if (hwconfig_subarg_cmp_f("fsl_ddr", "bank_intlv", |
| 925 | "cs0_cs1", buf)) |
Haiying Wang | b834f92 | 2008-10-03 12:37:10 -0400 | [diff] [blame] | 926 | popts->ba_intlv_ctl = FSL_DDR_CS0_CS1; |
Kumar Gala | 7230160 | 2011-01-09 11:37:00 -0600 | [diff] [blame] | 927 | else if (hwconfig_subarg_cmp_f("fsl_ddr", "bank_intlv", |
| 928 | "cs2_cs3", buf)) |
Haiying Wang | b834f92 | 2008-10-03 12:37:10 -0400 | [diff] [blame] | 929 | popts->ba_intlv_ctl = FSL_DDR_CS2_CS3; |
Kumar Gala | 7230160 | 2011-01-09 11:37:00 -0600 | [diff] [blame] | 930 | else if (hwconfig_subarg_cmp_f("fsl_ddr", "bank_intlv", |
| 931 | "cs0_cs1_and_cs2_cs3", buf)) |
Haiying Wang | b834f92 | 2008-10-03 12:37:10 -0400 | [diff] [blame] | 932 | popts->ba_intlv_ctl = FSL_DDR_CS0_CS1_AND_CS2_CS3; |
Kumar Gala | 7230160 | 2011-01-09 11:37:00 -0600 | [diff] [blame] | 933 | else if (hwconfig_subarg_cmp_f("fsl_ddr", "bank_intlv", |
| 934 | "cs0_cs1_cs2_cs3", buf)) |
Haiying Wang | b834f92 | 2008-10-03 12:37:10 -0400 | [diff] [blame] | 935 | popts->ba_intlv_ctl = FSL_DDR_CS0_CS1_CS2_CS3; |
York Sun | d01babd | 2012-10-08 07:44:27 +0000 | [diff] [blame] | 936 | else if (hwconfig_subarg_cmp_f("fsl_ddr", "bank_intlv", |
| 937 | "auto", buf)) |
| 938 | popts->ba_intlv_ctl = auto_bank_intlv(pdimm); |
Haiying Wang | b834f92 | 2008-10-03 12:37:10 -0400 | [diff] [blame] | 939 | else |
york | 93799ca | 2010-07-02 22:25:52 +0000 | [diff] [blame] | 940 | printf("hwconfig has unrecognized parameter for bank_intlv.\n"); |
Haiying Wang | b834f92 | 2008-10-03 12:37:10 -0400 | [diff] [blame] | 941 | switch (popts->ba_intlv_ctl & FSL_DDR_CS0_CS1_CS2_CS3) { |
| 942 | case FSL_DDR_CS0_CS1_CS2_CS3: |
york | 93799ca | 2010-07-02 22:25:52 +0000 | [diff] [blame] | 943 | #if (CONFIG_DIMM_SLOTS_PER_CTLR == 1) |
york | f4f93c6 | 2010-07-02 22:25:53 +0000 | [diff] [blame] | 944 | if (pdimm[0].n_ranks < 4) { |
york | 93799ca | 2010-07-02 22:25:52 +0000 | [diff] [blame] | 945 | popts->ba_intlv_ctl = 0; |
| 946 | printf("Not enough bank(chip-select) for " |
| 947 | "CS0+CS1+CS2+CS3 on controller %d, " |
York Sun | e8dc17b | 2012-08-17 08:22:39 +0000 | [diff] [blame] | 948 | "interleaving disabled!\n", ctrl_num); |
york | 93799ca | 2010-07-02 22:25:52 +0000 | [diff] [blame] | 949 | } |
| 950 | #elif (CONFIG_DIMM_SLOTS_PER_CTLR == 2) |
York Sun | 98df4d1 | 2012-10-08 07:44:23 +0000 | [diff] [blame] | 951 | #ifdef CONFIG_FSL_DDR_FIRST_SLOT_QUAD_CAPABLE |
| 952 | if (pdimm[0].n_ranks == 4) |
| 953 | break; |
| 954 | #endif |
york | f4f93c6 | 2010-07-02 22:25:53 +0000 | [diff] [blame] | 955 | if ((pdimm[0].n_ranks < 2) && (pdimm[1].n_ranks < 2)) { |
york | 93799ca | 2010-07-02 22:25:52 +0000 | [diff] [blame] | 956 | popts->ba_intlv_ctl = 0; |
| 957 | printf("Not enough bank(chip-select) for " |
| 958 | "CS0+CS1+CS2+CS3 on controller %d, " |
York Sun | e8dc17b | 2012-08-17 08:22:39 +0000 | [diff] [blame] | 959 | "interleaving disabled!\n", ctrl_num); |
york | 93799ca | 2010-07-02 22:25:52 +0000 | [diff] [blame] | 960 | } |
| 961 | if (pdimm[0].capacity != pdimm[1].capacity) { |
| 962 | popts->ba_intlv_ctl = 0; |
| 963 | printf("Not identical DIMM size for " |
| 964 | "CS0+CS1+CS2+CS3 on controller %d, " |
York Sun | e8dc17b | 2012-08-17 08:22:39 +0000 | [diff] [blame] | 965 | "interleaving disabled!\n", ctrl_num); |
york | 93799ca | 2010-07-02 22:25:52 +0000 | [diff] [blame] | 966 | } |
| 967 | #endif |
| 968 | break; |
Haiying Wang | b834f92 | 2008-10-03 12:37:10 -0400 | [diff] [blame] | 969 | case FSL_DDR_CS0_CS1: |
york | f4f93c6 | 2010-07-02 22:25:53 +0000 | [diff] [blame] | 970 | if (pdimm[0].n_ranks < 2) { |
Haiying Wang | b834f92 | 2008-10-03 12:37:10 -0400 | [diff] [blame] | 971 | popts->ba_intlv_ctl = 0; |
Ed Swarthout | b135d93 | 2008-10-29 09:21:44 -0500 | [diff] [blame] | 972 | printf("Not enough bank(chip-select) for " |
york | 93799ca | 2010-07-02 22:25:52 +0000 | [diff] [blame] | 973 | "CS0+CS1 on controller %d, " |
York Sun | e8dc17b | 2012-08-17 08:22:39 +0000 | [diff] [blame] | 974 | "interleaving disabled!\n", ctrl_num); |
Haiying Wang | b834f92 | 2008-10-03 12:37:10 -0400 | [diff] [blame] | 975 | } |
| 976 | break; |
| 977 | case FSL_DDR_CS2_CS3: |
york | 93799ca | 2010-07-02 22:25:52 +0000 | [diff] [blame] | 978 | #if (CONFIG_DIMM_SLOTS_PER_CTLR == 1) |
york | f4f93c6 | 2010-07-02 22:25:53 +0000 | [diff] [blame] | 979 | if (pdimm[0].n_ranks < 4) { |
Haiying Wang | b834f92 | 2008-10-03 12:37:10 -0400 | [diff] [blame] | 980 | popts->ba_intlv_ctl = 0; |
york | 93799ca | 2010-07-02 22:25:52 +0000 | [diff] [blame] | 981 | printf("Not enough bank(chip-select) for CS2+CS3 " |
York Sun | e8dc17b | 2012-08-17 08:22:39 +0000 | [diff] [blame] | 982 | "on controller %d, interleaving disabled!\n", ctrl_num); |
Haiying Wang | b834f92 | 2008-10-03 12:37:10 -0400 | [diff] [blame] | 983 | } |
york | 93799ca | 2010-07-02 22:25:52 +0000 | [diff] [blame] | 984 | #elif (CONFIG_DIMM_SLOTS_PER_CTLR == 2) |
york | f4f93c6 | 2010-07-02 22:25:53 +0000 | [diff] [blame] | 985 | if (pdimm[1].n_ranks < 2) { |
york | 93799ca | 2010-07-02 22:25:52 +0000 | [diff] [blame] | 986 | popts->ba_intlv_ctl = 0; |
| 987 | printf("Not enough bank(chip-select) for CS2+CS3 " |
York Sun | e8dc17b | 2012-08-17 08:22:39 +0000 | [diff] [blame] | 988 | "on controller %d, interleaving disabled!\n", ctrl_num); |
york | 93799ca | 2010-07-02 22:25:52 +0000 | [diff] [blame] | 989 | } |
| 990 | #endif |
Haiying Wang | b834f92 | 2008-10-03 12:37:10 -0400 | [diff] [blame] | 991 | break; |
| 992 | case FSL_DDR_CS0_CS1_AND_CS2_CS3: |
york | 93799ca | 2010-07-02 22:25:52 +0000 | [diff] [blame] | 993 | #if (CONFIG_DIMM_SLOTS_PER_CTLR == 1) |
york | f4f93c6 | 2010-07-02 22:25:53 +0000 | [diff] [blame] | 994 | if (pdimm[0].n_ranks < 4) { |
york | 93799ca | 2010-07-02 22:25:52 +0000 | [diff] [blame] | 995 | popts->ba_intlv_ctl = 0; |
| 996 | printf("Not enough bank(CS) for CS0+CS1 and " |
| 997 | "CS2+CS3 on controller %d, " |
York Sun | e8dc17b | 2012-08-17 08:22:39 +0000 | [diff] [blame] | 998 | "interleaving disabled!\n", ctrl_num); |
york | 93799ca | 2010-07-02 22:25:52 +0000 | [diff] [blame] | 999 | } |
| 1000 | #elif (CONFIG_DIMM_SLOTS_PER_CTLR == 2) |
york | f4f93c6 | 2010-07-02 22:25:53 +0000 | [diff] [blame] | 1001 | if ((pdimm[0].n_ranks < 2) || (pdimm[1].n_ranks < 2)) { |
Haiying Wang | b834f92 | 2008-10-03 12:37:10 -0400 | [diff] [blame] | 1002 | popts->ba_intlv_ctl = 0; |
york | 93799ca | 2010-07-02 22:25:52 +0000 | [diff] [blame] | 1003 | printf("Not enough bank(CS) for CS0+CS1 and " |
| 1004 | "CS2+CS3 on controller %d, " |
York Sun | e8dc17b | 2012-08-17 08:22:39 +0000 | [diff] [blame] | 1005 | "interleaving disabled!\n", ctrl_num); |
Haiying Wang | b834f92 | 2008-10-03 12:37:10 -0400 | [diff] [blame] | 1006 | } |
york | 93799ca | 2010-07-02 22:25:52 +0000 | [diff] [blame] | 1007 | #endif |
Haiying Wang | b834f92 | 2008-10-03 12:37:10 -0400 | [diff] [blame] | 1008 | break; |
| 1009 | default: |
| 1010 | popts->ba_intlv_ctl = 0; |
| 1011 | break; |
| 1012 | } |
| 1013 | } |
Kumar Gala | 124b082 | 2008-08-26 15:01:29 -0500 | [diff] [blame] | 1014 | |
Kumar Gala | 7230160 | 2011-01-09 11:37:00 -0600 | [diff] [blame] | 1015 | if (hwconfig_sub_f("fsl_ddr", "addr_hash", buf)) { |
| 1016 | if (hwconfig_subarg_cmp_f("fsl_ddr", "addr_hash", "null", buf)) |
york | 4260372 | 2010-07-02 22:25:54 +0000 | [diff] [blame] | 1017 | popts->addr_hash = 0; |
Kumar Gala | 7230160 | 2011-01-09 11:37:00 -0600 | [diff] [blame] | 1018 | else if (hwconfig_subarg_cmp_f("fsl_ddr", "addr_hash", |
| 1019 | "true", buf)) |
york | 4260372 | 2010-07-02 22:25:54 +0000 | [diff] [blame] | 1020 | popts->addr_hash = 1; |
| 1021 | } |
| 1022 | |
york | f4f93c6 | 2010-07-02 22:25:53 +0000 | [diff] [blame] | 1023 | if (pdimm[0].n_ranks == 4) |
| 1024 | popts->quad_rank_present = 1; |
| 1025 | |
York Sun | f0345e2 | 2011-08-24 09:40:26 -0700 | [diff] [blame] | 1026 | ddr_freq = get_ddr_freq(0) / 1000000; |
| 1027 | if (popts->registered_dimm_en) { |
| 1028 | popts->rcw_override = 1; |
| 1029 | popts->rcw_1 = 0x000a5a00; |
| 1030 | if (ddr_freq <= 800) |
| 1031 | popts->rcw_2 = 0x00000000; |
| 1032 | else if (ddr_freq <= 1066) |
| 1033 | popts->rcw_2 = 0x00100000; |
| 1034 | else if (ddr_freq <= 1333) |
| 1035 | popts->rcw_2 = 0x00200000; |
| 1036 | else |
| 1037 | popts->rcw_2 = 0x00300000; |
| 1038 | } |
| 1039 | |
Haiying Wang | fa44036 | 2008-10-03 12:36:55 -0400 | [diff] [blame] | 1040 | fsl_ddr_board_options(popts, pdimm, ctrl_num); |
Kumar Gala | 124b082 | 2008-08-26 15:01:29 -0500 | [diff] [blame] | 1041 | |
| 1042 | return 0; |
| 1043 | } |
york | 93799ca | 2010-07-02 22:25:52 +0000 | [diff] [blame] | 1044 | |
| 1045 | void check_interleaving_options(fsl_ddr_info_t *pinfo) |
| 1046 | { |
York Sun | e8dc17b | 2012-08-17 08:22:39 +0000 | [diff] [blame] | 1047 | int i, j, k, check_n_ranks, intlv_invalid = 0; |
| 1048 | unsigned int check_intlv, check_n_row_addr, check_n_col_addr; |
york | 93799ca | 2010-07-02 22:25:52 +0000 | [diff] [blame] | 1049 | unsigned long long check_rank_density; |
York Sun | e8dc17b | 2012-08-17 08:22:39 +0000 | [diff] [blame] | 1050 | struct dimm_params_s *dimm; |
york | 93799ca | 2010-07-02 22:25:52 +0000 | [diff] [blame] | 1051 | /* |
| 1052 | * Check if all controllers are configured for memory |
| 1053 | * controller interleaving. Identical dimms are recommended. At least |
York Sun | e8dc17b | 2012-08-17 08:22:39 +0000 | [diff] [blame] | 1054 | * the size, row and col address should be checked. |
york | 93799ca | 2010-07-02 22:25:52 +0000 | [diff] [blame] | 1055 | */ |
| 1056 | j = 0; |
| 1057 | check_n_ranks = pinfo->dimm_params[0][0].n_ranks; |
| 1058 | check_rank_density = pinfo->dimm_params[0][0].rank_density; |
York Sun | e8dc17b | 2012-08-17 08:22:39 +0000 | [diff] [blame] | 1059 | check_n_row_addr = pinfo->dimm_params[0][0].n_row_addr; |
| 1060 | check_n_col_addr = pinfo->dimm_params[0][0].n_col_addr; |
| 1061 | check_intlv = pinfo->memctl_opts[0].memctl_interleaving_mode; |
york | 93799ca | 2010-07-02 22:25:52 +0000 | [diff] [blame] | 1062 | for (i = 0; i < CONFIG_NUM_DDR_CONTROLLERS; i++) { |
York Sun | e8dc17b | 2012-08-17 08:22:39 +0000 | [diff] [blame] | 1063 | dimm = &pinfo->dimm_params[i][0]; |
| 1064 | if (!pinfo->memctl_opts[i].memctl_interleaving) { |
| 1065 | continue; |
| 1066 | } else if (((check_rank_density != dimm->rank_density) || |
| 1067 | (check_n_ranks != dimm->n_ranks) || |
| 1068 | (check_n_row_addr != dimm->n_row_addr) || |
| 1069 | (check_n_col_addr != dimm->n_col_addr) || |
| 1070 | (check_intlv != |
| 1071 | pinfo->memctl_opts[i].memctl_interleaving_mode))){ |
| 1072 | intlv_invalid = 1; |
| 1073 | break; |
| 1074 | } else { |
york | 93799ca | 2010-07-02 22:25:52 +0000 | [diff] [blame] | 1075 | j++; |
| 1076 | } |
York Sun | e8dc17b | 2012-08-17 08:22:39 +0000 | [diff] [blame] | 1077 | |
york | 93799ca | 2010-07-02 22:25:52 +0000 | [diff] [blame] | 1078 | } |
York Sun | e8dc17b | 2012-08-17 08:22:39 +0000 | [diff] [blame] | 1079 | if (intlv_invalid) { |
york | 93799ca | 2010-07-02 22:25:52 +0000 | [diff] [blame] | 1080 | for (i = 0; i < CONFIG_NUM_DDR_CONTROLLERS; i++) |
York Sun | e8dc17b | 2012-08-17 08:22:39 +0000 | [diff] [blame] | 1081 | pinfo->memctl_opts[i].memctl_interleaving = 0; |
| 1082 | printf("Not all DIMMs are identical. " |
| 1083 | "Memory controller interleaving disabled.\n"); |
| 1084 | } else { |
| 1085 | switch (check_intlv) { |
| 1086 | case FSL_DDR_CACHE_LINE_INTERLEAVING: |
| 1087 | case FSL_DDR_PAGE_INTERLEAVING: |
| 1088 | case FSL_DDR_BANK_INTERLEAVING: |
| 1089 | case FSL_DDR_SUPERBANK_INTERLEAVING: |
| 1090 | if (3 == CONFIG_NUM_DDR_CONTROLLERS) |
| 1091 | k = 2; |
| 1092 | else |
| 1093 | k = CONFIG_NUM_DDR_CONTROLLERS; |
| 1094 | break; |
| 1095 | case FSL_DDR_3WAY_1KB_INTERLEAVING: |
| 1096 | case FSL_DDR_3WAY_4KB_INTERLEAVING: |
| 1097 | case FSL_DDR_3WAY_8KB_INTERLEAVING: |
| 1098 | case FSL_DDR_4WAY_1KB_INTERLEAVING: |
| 1099 | case FSL_DDR_4WAY_4KB_INTERLEAVING: |
| 1100 | case FSL_DDR_4WAY_8KB_INTERLEAVING: |
| 1101 | default: |
| 1102 | k = CONFIG_NUM_DDR_CONTROLLERS; |
| 1103 | break; |
| 1104 | } |
| 1105 | debug("%d of %d controllers are interleaving.\n", j, k); |
York Sun | d01babd | 2012-10-08 07:44:27 +0000 | [diff] [blame] | 1106 | if (j && (j != k)) { |
York Sun | e8dc17b | 2012-08-17 08:22:39 +0000 | [diff] [blame] | 1107 | for (i = 0; i < CONFIG_NUM_DDR_CONTROLLERS; i++) |
york | 93799ca | 2010-07-02 22:25:52 +0000 | [diff] [blame] | 1108 | pinfo->memctl_opts[i].memctl_interleaving = 0; |
York Sun | e8dc17b | 2012-08-17 08:22:39 +0000 | [diff] [blame] | 1109 | printf("Not all controllers have compatible " |
| 1110 | "interleaving mode. All disabled.\n"); |
| 1111 | } |
york | 93799ca | 2010-07-02 22:25:52 +0000 | [diff] [blame] | 1112 | } |
York Sun | e8dc17b | 2012-08-17 08:22:39 +0000 | [diff] [blame] | 1113 | debug("Checking interleaving options completed\n"); |
york | 93799ca | 2010-07-02 22:25:52 +0000 | [diff] [blame] | 1114 | } |
Kumar Gala | f582d98 | 2011-01-09 14:06:28 -0600 | [diff] [blame] | 1115 | |
| 1116 | int fsl_use_spd(void) |
| 1117 | { |
| 1118 | int use_spd = 0; |
| 1119 | |
| 1120 | #ifdef CONFIG_DDR_SPD |
Kumar Gala | 7230160 | 2011-01-09 11:37:00 -0600 | [diff] [blame] | 1121 | char buffer[HWCONFIG_BUFFER_SIZE]; |
| 1122 | char *buf = NULL; |
| 1123 | |
| 1124 | /* |
| 1125 | * Extract hwconfig from environment since we have not properly setup |
| 1126 | * the environment but need it for ddr config params |
| 1127 | */ |
| 1128 | if (getenv_f("hwconfig", buffer, sizeof(buffer)) > 0) |
| 1129 | buf = buffer; |
| 1130 | |
Kumar Gala | f582d98 | 2011-01-09 14:06:28 -0600 | [diff] [blame] | 1131 | /* if hwconfig is not enabled, or "sdram" is not defined, use spd */ |
Kumar Gala | 7230160 | 2011-01-09 11:37:00 -0600 | [diff] [blame] | 1132 | if (hwconfig_sub_f("fsl_ddr", "sdram", buf)) { |
| 1133 | if (hwconfig_subarg_cmp_f("fsl_ddr", "sdram", "spd", buf)) |
Kumar Gala | f582d98 | 2011-01-09 14:06:28 -0600 | [diff] [blame] | 1134 | use_spd = 1; |
Kumar Gala | 7230160 | 2011-01-09 11:37:00 -0600 | [diff] [blame] | 1135 | else if (hwconfig_subarg_cmp_f("fsl_ddr", "sdram", |
| 1136 | "fixed", buf)) |
Kumar Gala | f582d98 | 2011-01-09 14:06:28 -0600 | [diff] [blame] | 1137 | use_spd = 0; |
| 1138 | else |
| 1139 | use_spd = 1; |
| 1140 | } else |
| 1141 | use_spd = 1; |
| 1142 | #endif |
| 1143 | |
| 1144 | return use_spd; |
| 1145 | } |