1 #define DDR_PHY_TBL_CHG_ADDR 0xaeeddeea 2 #define DDR_PHY_TBL_END 0xaeededed 3 4 /** 5 * phyr030[18:16] - Ron PU (PHY side) 6 * phyr030[14:12] - Ron PD (PHY side) 7 * b'000 : disable 8 * b'001 : 240 ohm 9 * b'010 : 120 ohm 10 * b'011 : 80 ohm 11 * b'100 : 60 ohm 12 * b'101 : 48 ohm 13 * b'110 : 40 ohm 14 * b'111 : 34 ohm (default) 15 * 16 */ 17 #define PHY_RON ((0x7 << 16) | (0x7 << 12)) 18 19 /** 20 * phyr030[10:8] - ODT configuration (PHY side) 21 * b'000 : ODT disabled 22 * b'001 : 240 ohm 23 * b'010 : 120 ohm 24 * b'011 : 80 ohm (default) 25 * b'100 : 60 ohm 26 * b'101 : 48 ohm 27 * b'110 : 40 ohm 28 * b'111 : 34 ohm 29 */ 30 #if defined(CONFIG_ASPEED_DDR4_PHY_ODT40) 31 #define PHY_ODT (0x6 << 8) 32 #elif defined(CONFIG_ASPEED_DDR4_PHY_ODT48) 33 #define PHY_ODT (0x5 << 8) 34 #elif defined(CONFIG_ASPEED_DDR4_PHY_ODT60) 35 #define PHY_ODT (0x4 << 8) 36 #else 37 #define PHY_ODT (0x3 << 8) 38 #endif 39 40 /** 41 * MR1[2:1] output driver impedance 42 * b'00 : 34 ohm (default) 43 * b'01 : 48 ohm 44 */ 45 #ifdef ASPEED_DDR4_DRAM_RON_48 46 #define DRAM_RON (0x1 << 1) 47 #else 48 #define DRAM_RON (0x0 << 1) 49 #endif 50 51 /** 52 * DRAM ODT - synchronous ODT mode 53 * RTT_WR: disable 54 * RTT_NOM = RTT_PARK 55 * 56 * MR1[10:8] RTT_NOM 57 * b'000 : RTT_NOM disable 58 * b'001 : 60 ohm 59 * b'010 : 120 ohm 60 * b'011 : 40 ohm 61 * b'100 : 240 ohm 62 * b'101 : 48 ohm (default) 63 * b'110 : 80 ohm 64 * b'111 : 34 ohm 65 * 66 * MR5[8:6] RTT_PARK 67 * b'000 : RTT_PARK disable 68 * b'001 : 60 ohm 69 * b'010 : 120 ohm 70 * b'011 : 40 ohm 71 * b'100 : 240 ohm 72 * b'101 : 48 ohm (default) 73 * b'110 : 80 ohm 74 * b'111 : 34 ohm 75 * 76 * MR2[11:9] RTT_WR 77 * b'000 : Dynamic ODT off (default) 78 * b'001 : 120 ohm 79 * b'010 : 240 ohm 80 * b'011 : Hi-Z 81 * b'100 : 80 ohm 82 */ 83 #define RTT_WR (0x0 << 9) 84 85 #if defined(CONFIG_ASPEED_DDR4_DRAM_ODT60) 86 #define RTT_NOM (0x1 << 8) 87 #define RTT_PARK (0x1 << 6) 88 #elif defined(CONFIG_ASPEED_DDR4_DRAM_ODT48) 89 #define RTT_NOM (0x5 << 8) 90 #define RTT_PARK (0x5 << 6) 91 #else 92 #define RTT_NOM (0x3 << 8) 93 #define RTT_PARK (0x3 << 6) 94 #endif 95 96 /** 97 * MR6[6] VrefDQ training range 98 * b'0 : range 1 99 * b'1 : range 2 (default) 100 */ 101 #define VREFDQ_RANGE_2 BIT(6) 102 103 /** 104 * Latency setting: 105 * Force AL = PL = 0 106 * -> WL = AL + CWL + PL = CWL 107 * -> RL = AL + CL + PL = CL 108 */ 109 #define CONFIG_WL 9 110 #define CONFIG_RL 12 111 #define T_RDDATA_EN ((CONFIG_RL - 2) << 8) 112 #define T_PHY_WRLAT (CONFIG_WL - 2) 113 114 /* MR0 */ 115 #define MR0_CL_12 (BIT(4) | BIT(2)) /* new */ 116 #define MR0_WR12_RTP6 BIT(9) 117 #define MR0_DLL_RESET BIT(8) 118 #define MR0_VAL (MR0_CL_12 | MR0_WR12_RTP6 | MR0_DLL_RESET) 119 120 /* MR1 */ 121 #define MR1_VAL (0x0001 | RTT_NOM | DRAM_RON) 122 123 /* MR2 */ 124 #define MR2_CWL_9 0 125 #define MR2_VAL (0x0000 | RTT_WR | MR2_CWL_9) 126 127 /* MR3 ~ MR6 */ 128 #define MR3_VAL 0x0000 129 #define MR4_VAL 0x0000 130 #define MR5_VAL (0x0400 | RTT_PARK) 131 #define MR6_VAL 0x0400 132 133 #if defined(CONFIG_ASPEED_DDR4_800) 134 u32 ast2600_sdramphy_config[165] = { 135 0x1e6e0100, // start address 136 0x00000000, // phyr000 137 0x0c002062, // phyr004 138 0x1a7a0063, // phyr008 139 0x5a7a0063, // phyr00c 140 0x1a7a0063, // phyr010 141 0x1a7a0063, // phyr014 142 0x20000000, // phyr018 143 0x20000000, // phyr01c 144 0x20000000, // phyr020 145 0x20000000, // phyr024 146 0x00000008, // phyr028 147 0x00000000, // phyr02c 148 (PHY_RON | PHY_ODT), /* phyr030 */ 149 0x00000000, // phyr034 150 0x00000000, // phyr038 151 0x20000000, // phyr03c 152 0x50506000, // phyr040 153 0x50505050, // phyr044 154 0x00002f07, // phyr048 155 0x00003080, // phyr04c 156 0x04000000, // phyr050 157 ((MR3_VAL << 16) | MR2_VAL), /* phyr054 */ 158 ((MR0_VAL << 16) | MR1_VAL), /* phyr058 */ 159 ((MR5_VAL << 16) | MR4_VAL), /* phyr05c */ 160 ((0x0800 << 16) | MR6_VAL | VREFDQ_RANGE_2 | 0xe), /* phyr060 */ 161 0x00000000, // phyr064 162 0x00180008, // phyr068 163 0x00e00400, // phyr06c 164 0x00140206, // phyr070 165 0x1d4c0000, // phyr074 166 0x493e0107, // phyr078 167 0x08060404, // phyr07c 168 0x90000a00, // phyr080 169 0x06420618, // phyr084 170 0x00001002, // phyr088 171 0x05701016, // phyr08c 172 0x10000000, // phyr090 173 0xaeeddeea, // change address 174 0x1e6e019c, // new address 175 0x20202020, // phyr09c 176 0x20202020, // phyr0a0 177 0x00002020, // phyr0a4 178 0x00002020, // phyr0a8 179 0x00000001, // phyr0ac 180 0xaeeddeea, // change address 181 0x1e6e01cc, // new address 182 0x01010101, // phyr0cc 183 0x01010101, // phyr0d0 184 0x80808080, // phyr0d4 185 0x80808080, // phyr0d8 186 0xaeeddeea, // change address 187 0x1e6e0288, // new address 188 0x80808080, // phyr188 189 0x80808080, // phyr18c 190 0x80808080, // phyr190 191 0x80808080, // phyr194 192 0xaeeddeea, // change address 193 0x1e6e02f8, // new address 194 0x90909090, // phyr1f8 195 0x88888888, // phyr1fc 196 0xaeeddeea, // change address 197 0x1e6e0300, // new address 198 0x00000000, // phyr200 199 0xaeeddeea, // change address 200 0x1e6e0194, // new address 201 0x80118260, // phyr094 202 0xaeeddeea, // change address 203 0x1e6e019c, // new address 204 0x20202020, // phyr09c 205 0x20202020, // phyr0a0 206 0x00002020, // phyr0a4 207 0x80000000, // phyr0a8 208 0x00000001, // phyr0ac 209 0xaeeddeea, // change address 210 0x1e6e0318, // new address 211 0x09222719, // phyr218 212 0x00aa4403, // phyr21c 213 0xaeeddeea, // change address 214 0x1e6e0198, // new address 215 0x08060000, // phyr098 216 0xaeeddeea, // change address 217 0x1e6e01b0, // new address 218 0x00000000, // phyr0b0 219 0x00000000, // phyr0b4 220 0x00000000, // phyr0b8 221 0x00000000, // phyr0bc 222 0x00000000, // phyr0c0 223 0x00000000, // phyr0c4 224 0x000aff2c, // phyr0c8 225 0xaeeddeea, // change address 226 0x1e6e01dc, // new address 227 0x00080000, // phyr0dc 228 0x00000000, // phyr0e0 229 0xaa55aa55, // phyr0e4 230 0x55aa55aa, // phyr0e8 231 0xaaaa5555, // phyr0ec 232 0x5555aaaa, // phyr0f0 233 0xaa55aa55, // phyr0f4 234 0x55aa55aa, // phyr0f8 235 0xaaaa5555, // phyr0fc 236 0x5555aaaa, // phyr100 237 0xaa55aa55, // phyr104 238 0x55aa55aa, // phyr108 239 0xaaaa5555, // phyr10c 240 0x5555aaaa, // phyr110 241 0xaa55aa55, // phyr114 242 0x55aa55aa, // phyr118 243 0xaaaa5555, // phyr11c 244 0x5555aaaa, // phyr120 245 0x20202020, // phyr124 246 0x20202020, // phyr128 247 0x20202020, // phyr12c 248 0x20202020, // phyr130 249 0x20202020, // phyr134 250 0x20202020, // phyr138 251 0x20202020, // phyr13c 252 0x20202020, // phyr140 253 0x20202020, // phyr144 254 0x20202020, // phyr148 255 0x20202020, // phyr14c 256 0x20202020, // phyr150 257 0x20202020, // phyr154 258 0x20202020, // phyr158 259 0x20202020, // phyr15c 260 0x20202020, // phyr160 261 0x20202020, // phyr164 262 0x20202020, // phyr168 263 0x20202020, // phyr16c 264 0x20202020, // phyr170 265 0xaeeddeea, // change address 266 0x1e6e0298, // new address 267 0x20200800, // phyr198 268 0x20202020, // phyr19c 269 0x20202020, // phyr1a0 270 0x20202020, // phyr1a4 271 0x20202020, // phyr1a8 272 0x20202020, // phyr1ac 273 0x20202020, // phyr1b0 274 0x20202020, // phyr1b4 275 0x20202020, // phyr1b8 276 0x20202020, // phyr1bc 277 0x20202020, // phyr1c0 278 0x20202020, // phyr1c4 279 0x20202020, // phyr1c8 280 0x20202020, // phyr1cc 281 0x20202020, // phyr1d0 282 0x20202020, // phyr1d4 283 0x20202020, // phyr1d8 284 0x20202020, // phyr1dc 285 0x20202020, // phyr1e0 286 0x20202020, // phyr1e4 287 0x00002020, // phyr1e8 288 0xaeeddeea, // change address 289 0x1e6e0304, // new address 290 0x00000800, // phyr204 291 0xaeeddeea, // change address 292 0x1e6e027c, // new address 293 0x4e400000, // phyr17c 294 0x59595959, // phyr180 295 0x40404040, // phyr184 296 0xaeeddeea, // change address 297 0x1e6e02f4, // new address 298 0x00000059, // phyr1f4 299 0xaeededed, // end 300 }; 301 #else 302 u32 ast2600_sdramphy_config[165] = { 303 0x1e6e0100, // start address 304 0x00000000, // phyr000 305 0x0c002062, // phyr004 306 0x1a7a0063, // phyr008 307 0x5a7a0063, // phyr00c 308 0x1a7a0063, // phyr010 309 0x1a7a0063, // phyr014 310 0x20000000, // phyr018 311 0x20000000, // phyr01c 312 0x20000000, // phyr020 313 0x20000000, // phyr024 314 0x00000008, // phyr028 315 0x00000000, // phyr02c 316 (PHY_RON | PHY_ODT), /* phyr030 */ 317 0x00000000, // phyr034 318 0x00000000, // phyr038 319 0x20000000, // phyr03c 320 0x50506000, // phyr040 321 0x50505050, // phyr044 322 0x00002f07, // phyr048 323 0x00003080, // phyr04c 324 0x04000000, // phyr050 325 ((MR3_VAL << 16) | MR2_VAL), /* phyr054 */ 326 ((MR0_VAL << 16) | MR1_VAL), /* phyr058 */ 327 ((MR5_VAL << 16) | MR4_VAL), /* phyr05c */ 328 ((0x0800 << 16) | MR6_VAL | VREFDQ_RANGE_2 | 0xe), /* phyr060 */ 329 0x00000000, // phyr064 330 0x00180008, // phyr068 331 0x00e00400, // phyr06c 332 0x00140206, // phyr070 333 0x1d4c0000, // phyr074 334 0x493e0107, // phyr078 335 0x08060404, // phyr07c 336 0x90000a00, // phyr080 337 0x06420c30, // phyr084 338 0x00001002, // phyr088 339 0x05701016, // phyr08c 340 0x10000000, // phyr090 341 0xaeeddeea, // change address 342 0x1e6e019c, // new address 343 0x20202020, // phyr09c 344 0x20202020, // phyr0a0 345 0x00002020, // phyr0a4 346 0x00002020, // phyr0a8 347 0x00000001, // phyr0ac 348 0xaeeddeea, // change address 349 0x1e6e01cc, // new address 350 0x01010101, // phyr0cc 351 0x01010101, // phyr0d0 352 0x80808080, // phyr0d4 353 0x80808080, // phyr0d8 354 0xaeeddeea, // change address 355 0x1e6e0288, // new address 356 0x80808080, // phyr188 357 0x80808080, // phyr18c 358 0x80808080, // phyr190 359 0x80808080, // phyr194 360 0xaeeddeea, // change address 361 0x1e6e02f8, // new address 362 0x90909090, // phyr1f8 363 0x88888888, // phyr1fc 364 0xaeeddeea, // change address 365 0x1e6e0300, // new address 366 0x00000000, // phyr200 367 0xaeeddeea, // change address 368 0x1e6e0194, // new address 369 0x801112e0, // phyr094 - bit12=1,15=0,- write window is ok 370 0xaeeddeea, // change address 371 0x1e6e019c, // new address 372 0x20202020, // phyr09c 373 0x20202020, // phyr0a0 374 0x00002020, // phyr0a4 375 0x80000000, // phyr0a8 376 0x00000001, // phyr0ac 377 0xaeeddeea, // change address 378 0x1e6e0318, // new address 379 0x09222719, // phyr218 380 0x00aa4403, // phyr21c 381 0xaeeddeea, // change address 382 0x1e6e0198, // new address 383 0x08060000, // phyr098 384 0xaeeddeea, // change address 385 0x1e6e01b0, // new address 386 0x00000000, // phyr0b0 387 0x00000000, // phyr0b4 388 0x00000000, // phyr0b8 389 0x00000000, // phyr0bc 390 0x00000000, // phyr0c0 - ori 391 0x00000000, // phyr0c4 392 0x000aff2c, // phyr0c8 393 0xaeeddeea, // change address 394 0x1e6e01dc, // new address 395 0x00080000, // phyr0dc 396 0x00000000, // phyr0e0 397 0xaa55aa55, // phyr0e4 398 0x55aa55aa, // phyr0e8 399 0xaaaa5555, // phyr0ec 400 0x5555aaaa, // phyr0f0 401 0xaa55aa55, // phyr0f4 402 0x55aa55aa, // phyr0f8 403 0xaaaa5555, // phyr0fc 404 0x5555aaaa, // phyr100 405 0xaa55aa55, // phyr104 406 0x55aa55aa, // phyr108 407 0xaaaa5555, // phyr10c 408 0x5555aaaa, // phyr110 409 0xaa55aa55, // phyr114 410 0x55aa55aa, // phyr118 411 0xaaaa5555, // phyr11c 412 0x5555aaaa, // phyr120 413 0x20202020, // phyr124 414 0x20202020, // phyr128 415 0x20202020, // phyr12c 416 0x20202020, // phyr130 417 0x20202020, // phyr134 418 0x20202020, // phyr138 419 0x20202020, // phyr13c 420 0x20202020, // phyr140 421 0x20202020, // phyr144 422 0x20202020, // phyr148 423 0x20202020, // phyr14c 424 0x20202020, // phyr150 425 0x20202020, // phyr154 426 0x20202020, // phyr158 427 0x20202020, // phyr15c 428 0x20202020, // phyr160 429 0x20202020, // phyr164 430 0x20202020, // phyr168 431 0x20202020, // phyr16c 432 0x20202020, // phyr170 433 0xaeeddeea, // change address 434 0x1e6e0298, // new address 435 0x20200800, // phyr198 436 0x20202020, // phyr19c 437 0x20202020, // phyr1a0 438 0x20202020, // phyr1a4 439 0x20202020, // phyr1a8 440 0x20202020, // phyr1ac 441 0x20202020, // phyr1b0 442 0x20202020, // phyr1b4 443 0x20202020, // phyr1b8 444 0x20202020, // phyr1bc 445 0x20202020, // phyr1c0 446 0x20202020, // phyr1c4 447 0x20202020, // phyr1c8 448 0x20202020, // phyr1cc 449 0x20202020, // phyr1d0 450 0x20202020, // phyr1d4 451 0x20202020, // phyr1d8 452 0x20202020, // phyr1dc 453 0x20202020, // phyr1e0 454 0x20202020, // phyr1e4 455 0x00002020, // phyr1e8 456 0xaeeddeea, // change address 457 0x1e6e0304, // new address 458 0x00000800, // phyr204 459 0xaeeddeea, // change address 460 0x1e6e027c, // new address 461 0x4e400000, // phyr17c 462 0x59595959, // phyr180 463 0x40404040, // phyr184 464 0xaeeddeea, // change address 465 0x1e6e02f4, // new address 466 0x00000059, // phyr1f4 467 0xaeededed, // end 468 }; 469 #endif