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