ppc4xx-sdram.h 61 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402
  1. /*
  2. * (C) Copyright 2008
  3. * Stefan Roese, DENX Software Engineering, sr@denx.de.
  4. *
  5. * SPDX-License-Identifier: GPL-2.0+
  6. */
  7. #ifndef _PPC4xx_SDRAM_H_
  8. #define _PPC4xx_SDRAM_H_
  9. #if defined(CONFIG_SDRAM_PPC4xx_IBM_SDRAM)
  10. /*
  11. * SDRAM Controller
  12. */
  13. #ifndef CONFIG_405EP
  14. #define SDRAM0_BESR0 0x00 /* bus error syndrome reg a */
  15. #define SDRAM0_BESRS0 0x04 /* bus error syndrome reg set a */
  16. #define SDRAM0_BESR1 0x08 /* bus error syndrome reg b */
  17. #define SDRAM0_BESRS1 0x0c /* bus error syndrome reg set b */
  18. #define SDRAM0_BEAR 0x10 /* bus error address reg */
  19. #endif
  20. #define SDRAM0_CFG 0x20 /* memory controller options 1 */
  21. #define SDRAM0_STATUS 0x24 /* memory status */
  22. #define SDRAM0_RTR 0x30 /* refresh timer reg */
  23. #define SDRAM0_PMIT 0x34 /* power management idle timer */
  24. #define SDRAM0_B0CR 0x40 /* memory bank 0 configuration */
  25. #define SDRAM0_B1CR 0x44 /* memory bank 1 configuration */
  26. #ifndef CONFIG_405EP
  27. #define SDRAM0_B2CR 0x48 /* memory bank 2 configuration */
  28. #define SDRAM0_B3CR 0x4c /* memory bank 3 configuration */
  29. #endif
  30. #define SDRAM0_TR 0x80 /* timing reg 1 */
  31. #ifndef CONFIG_405EP
  32. #define SDRAM0_ECCCFG 0x94 /* ECC configuration */
  33. #define SDRAM0_ECCESR 0x98 /* ECC error status */
  34. #endif
  35. #endif /* CONFIG_SDRAM_PPC4xx_IBM_SDRAM */
  36. #if defined(CONFIG_SDRAM_PPC4xx_IBM_DDR)
  37. /*
  38. * Memory controller registers
  39. */
  40. #define SDRAM_CFG0 0x20 /* memory controller options 0 */
  41. #define SDRAM_CFG1 0x21 /* memory controller options 1 */
  42. #define SDRAM0_BESR0 0x0000 /* bus error status reg 0 */
  43. #define SDRAM0_BESR1 0x0008 /* bus error status reg 1 */
  44. #define SDRAM0_BEAR 0x0010 /* bus error address reg */
  45. #define SDRAM0_SLIO 0x0018 /* ddr sdram slave interface options */
  46. #define SDRAM0_CFG0 0x0020 /* ddr sdram options 0 */
  47. #define SDRAM0_CFG1 0x0021 /* ddr sdram options 1 */
  48. #define SDRAM0_DEVOPT 0x0022 /* ddr sdram device options */
  49. #define SDRAM0_MCSTS 0x0024 /* memory controller status */
  50. #define SDRAM0_RTR 0x0030 /* refresh timer register */
  51. #define SDRAM0_PMIT 0x0034 /* power management idle timer */
  52. #define SDRAM0_UABBA 0x0038 /* plb UABus base address */
  53. #define SDRAM0_B0CR 0x0040 /* ddr sdram bank 0 configuration */
  54. #define SDRAM0_B1CR 0x0044 /* ddr sdram bank 1 configuration */
  55. #define SDRAM0_B2CR 0x0048 /* ddr sdram bank 2 configuration */
  56. #define SDRAM0_B3CR 0x004c /* ddr sdram bank 3 configuration */
  57. #define SDRAM0_TR0 0x0080 /* sdram timing register 0 */
  58. #define SDRAM0_TR1 0x0081 /* sdram timing register 1 */
  59. #define SDRAM0_CLKTR 0x0082 /* ddr clock timing register */
  60. #define SDRAM0_WDDCTR 0x0083 /* write data/dm/dqs clock timing reg */
  61. #define SDRAM0_DLYCAL 0x0084 /* delay line calibration register */
  62. #define SDRAM0_ECCESR 0x0098 /* ECC error status */
  63. /*
  64. * Memory Controller Options 0
  65. */
  66. #define SDRAM_CFG0_DCEN 0x80000000 /* SDRAM Controller Enable */
  67. #define SDRAM_CFG0_MCHK_MASK 0x30000000 /* Memory data errchecking mask */
  68. #define SDRAM_CFG0_MCHK_NON 0x00000000 /* No ECC generation */
  69. #define SDRAM_CFG0_MCHK_GEN 0x20000000 /* ECC generation */
  70. #define SDRAM_CFG0_MCHK_CHK 0x30000000 /* ECC generation and checking */
  71. #define SDRAM_CFG0_RDEN 0x08000000 /* Registered DIMM enable */
  72. #define SDRAM_CFG0_PMUD 0x04000000 /* Page management unit */
  73. #define SDRAM_CFG0_DMWD_MASK 0x02000000 /* DRAM width mask */
  74. #define SDRAM_CFG0_DMWD_32 0x00000000 /* 32 bits */
  75. #define SDRAM_CFG0_DMWD_64 0x02000000 /* 64 bits */
  76. #define SDRAM_CFG0_UIOS_MASK 0x00C00000 /* Unused IO State */
  77. #define SDRAM_CFG0_PDP 0x00200000 /* Page deallocation policy */
  78. /*
  79. * Memory Controller Options 1
  80. */
  81. #define SDRAM_CFG1_SRE 0x80000000 /* Self-Refresh Entry */
  82. #define SDRAM_CFG1_PMEN 0x40000000 /* Power Management Enable */
  83. /*
  84. * SDRAM DEVPOT Options
  85. */
  86. #define SDRAM_DEVOPT_DLL 0x80000000
  87. #define SDRAM_DEVOPT_DS 0x40000000
  88. /*
  89. * SDRAM MCSTS Options
  90. */
  91. #define SDRAM_MCSTS_MRSC 0x80000000
  92. #define SDRAM_MCSTS_SRMS 0x40000000
  93. #define SDRAM_MCSTS_CIS 0x20000000
  94. #define SDRAM_MCSTS_IDLE_NOT 0x00000000 /* Mem contr not idle */
  95. /*
  96. * SDRAM Refresh Timer Register
  97. */
  98. #define SDRAM_RTR_RINT_MASK 0xFFFF0000
  99. #define SDRAM_RTR_RINT_ENCODE(n) (((n) << 16) & SDRAM_RTR_RINT_MASK)
  100. /*
  101. * SDRAM UABus Base Address Reg
  102. */
  103. #define SDRAM_UABBA_UBBA_MASK 0x0000000F
  104. /*
  105. * Memory Bank 0-7 configuration
  106. */
  107. #define SDRAM_BXCR_SDBA_MASK 0xff800000 /* Base address */
  108. #define SDRAM_BXCR_SDSZ_MASK 0x000e0000 /* Size */
  109. #define SDRAM_BXCR_SDSZ_8 0x00020000 /* 8M */
  110. #define SDRAM_BXCR_SDSZ_16 0x00040000 /* 16M */
  111. #define SDRAM_BXCR_SDSZ_32 0x00060000 /* 32M */
  112. #define SDRAM_BXCR_SDSZ_64 0x00080000 /* 64M */
  113. #define SDRAM_BXCR_SDSZ_128 0x000a0000 /* 128M */
  114. #define SDRAM_BXCR_SDSZ_256 0x000c0000 /* 256M */
  115. #define SDRAM_BXCR_SDSZ_512 0x000e0000 /* 512M */
  116. #define SDRAM_BXCR_SDAM_MASK 0x0000e000 /* Addressing mode */
  117. #define SDRAM_BXCR_SDAM_1 0x00000000 /* Mode 1 */
  118. #define SDRAM_BXCR_SDAM_2 0x00002000 /* Mode 2 */
  119. #define SDRAM_BXCR_SDAM_3 0x00004000 /* Mode 3 */
  120. #define SDRAM_BXCR_SDAM_4 0x00006000 /* Mode 4 */
  121. #define SDRAM_BXCR_SDBE 0x00000001 /* Memory Bank Enable */
  122. /*
  123. * SDRAM TR0 Options
  124. */
  125. #define SDRAM_TR0_SDWR_MASK 0x80000000
  126. #define SDRAM_TR0_SDWR_2_CLK 0x00000000
  127. #define SDRAM_TR0_SDWR_3_CLK 0x80000000
  128. #define SDRAM_TR0_SDWD_MASK 0x40000000
  129. #define SDRAM_TR0_SDWD_0_CLK 0x00000000
  130. #define SDRAM_TR0_SDWD_1_CLK 0x40000000
  131. #define SDRAM_TR0_SDCL_MASK 0x01800000
  132. #define SDRAM_TR0_SDCL_2_0_CLK 0x00800000
  133. #define SDRAM_TR0_SDCL_2_5_CLK 0x01000000
  134. #define SDRAM_TR0_SDCL_3_0_CLK 0x01800000
  135. #define SDRAM_TR0_SDPA_MASK 0x000C0000
  136. #define SDRAM_TR0_SDPA_2_CLK 0x00040000
  137. #define SDRAM_TR0_SDPA_3_CLK 0x00080000
  138. #define SDRAM_TR0_SDPA_4_CLK 0x000C0000
  139. #define SDRAM_TR0_SDCP_MASK 0x00030000
  140. #define SDRAM_TR0_SDCP_2_CLK 0x00000000
  141. #define SDRAM_TR0_SDCP_3_CLK 0x00010000
  142. #define SDRAM_TR0_SDCP_4_CLK 0x00020000
  143. #define SDRAM_TR0_SDCP_5_CLK 0x00030000
  144. #define SDRAM_TR0_SDLD_MASK 0x0000C000
  145. #define SDRAM_TR0_SDLD_1_CLK 0x00000000
  146. #define SDRAM_TR0_SDLD_2_CLK 0x00004000
  147. #define SDRAM_TR0_SDRA_MASK 0x0000001C
  148. #define SDRAM_TR0_SDRA_6_CLK 0x00000000
  149. #define SDRAM_TR0_SDRA_7_CLK 0x00000004
  150. #define SDRAM_TR0_SDRA_8_CLK 0x00000008
  151. #define SDRAM_TR0_SDRA_9_CLK 0x0000000C
  152. #define SDRAM_TR0_SDRA_10_CLK 0x00000010
  153. #define SDRAM_TR0_SDRA_11_CLK 0x00000014
  154. #define SDRAM_TR0_SDRA_12_CLK 0x00000018
  155. #define SDRAM_TR0_SDRA_13_CLK 0x0000001C
  156. #define SDRAM_TR0_SDRD_MASK 0x00000003
  157. #define SDRAM_TR0_SDRD_2_CLK 0x00000001
  158. #define SDRAM_TR0_SDRD_3_CLK 0x00000002
  159. #define SDRAM_TR0_SDRD_4_CLK 0x00000003
  160. /*
  161. * SDRAM TR1 Options
  162. */
  163. #define SDRAM_TR1_RDSS_MASK 0xC0000000
  164. #define SDRAM_TR1_RDSS_TR0 0x00000000
  165. #define SDRAM_TR1_RDSS_TR1 0x40000000
  166. #define SDRAM_TR1_RDSS_TR2 0x80000000
  167. #define SDRAM_TR1_RDSS_TR3 0xC0000000
  168. #define SDRAM_TR1_RDSL_MASK 0x00C00000
  169. #define SDRAM_TR1_RDSL_STAGE1 0x00000000
  170. #define SDRAM_TR1_RDSL_STAGE2 0x00400000
  171. #define SDRAM_TR1_RDSL_STAGE3 0x00800000
  172. #define SDRAM_TR1_RDCD_MASK 0x00000800
  173. #define SDRAM_TR1_RDCD_RCD_0_0 0x00000000
  174. #define SDRAM_TR1_RDCD_RCD_1_2 0x00000800
  175. #define SDRAM_TR1_RDCT_MASK 0x000001FF
  176. #define SDRAM_TR1_RDCT_ENCODE(x) (((x) << 0) & SDRAM_TR1_RDCT_MASK)
  177. #define SDRAM_TR1_RDCT_DECODE(x) (((x) & SDRAM_TR1_RDCT_MASK) >> 0)
  178. #define SDRAM_TR1_RDCT_MIN 0x00000000
  179. #define SDRAM_TR1_RDCT_MAX 0x000001FF
  180. /*
  181. * SDRAM WDDCTR Options
  182. */
  183. #define SDRAM_WDDCTR_WRCP_MASK 0xC0000000
  184. #define SDRAM_WDDCTR_WRCP_0DEG 0x00000000
  185. #define SDRAM_WDDCTR_WRCP_90DEG 0x40000000
  186. #define SDRAM_WDDCTR_WRCP_180DEG 0x80000000
  187. #define SDRAM_WDDCTR_DCD_MASK 0x000001FF
  188. /*
  189. * SDRAM CLKTR Options
  190. */
  191. #define SDRAM_CLKTR_CLKP_MASK 0xC0000000
  192. #define SDRAM_CLKTR_CLKP_0DEG 0x00000000
  193. #define SDRAM_CLKTR_CLKP_90DEG 0x40000000
  194. #define SDRAM_CLKTR_CLKP_180DEG 0x80000000
  195. #define SDRAM_CLKTR_DCDT_MASK 0x000001FF
  196. /*
  197. * SDRAM DLYCAL Options
  198. */
  199. #define SDRAM_DLYCAL_DLCV_MASK 0x000003FC
  200. #define SDRAM_DLYCAL_DLCV_ENCODE(x) (((x)<<2) & SDRAM_DLYCAL_DLCV_MASK)
  201. #define SDRAM_DLYCAL_DLCV_DECODE(x) (((x) & SDRAM_DLYCAL_DLCV_MASK)>>2)
  202. #endif /* CONFIG_SDRAM_PPC4xx_IBM_DDR */
  203. #if defined(CONFIG_SDRAM_PPC4xx_IBM_DDR2)
  204. #define SDRAM_DLYCAL_DLCV_MASK 0x000003FC
  205. #define SDRAM_DLYCAL_DLCV_ENCODE(x) (((x)<<2) & SDRAM_DLYCAL_DLCV_MASK)
  206. #define SDRAM_DLYCAL_DLCV_DECODE(x) (((x) & SDRAM_DLYCAL_DLCV_MASK)>>2)
  207. #if !defined(CONFIG_405EX)
  208. /*
  209. * Memory queue defines
  210. */
  211. #define SDRAMQ_DCR_BASE 0x040
  212. #define SDRAM_R0BAS (SDRAMQ_DCR_BASE+0x0) /* rank 0 base address & size */
  213. #define SDRAM_R1BAS (SDRAMQ_DCR_BASE+0x1) /* rank 1 base address & size */
  214. #define SDRAM_R2BAS (SDRAMQ_DCR_BASE+0x2) /* rank 2 base address & size */
  215. #define SDRAM_R3BAS (SDRAMQ_DCR_BASE+0x3) /* rank 3 base address & size */
  216. #define SDRAM_CONF1HB (SDRAMQ_DCR_BASE+0x5) /* configuration 1 HB */
  217. #define SDRAM_CONF1HB_AAFR 0x80000000 /* Address Ack on First Request - Bit 0 */
  218. #define SDRAM_CONF1HB_PRPD 0x00080000 /* PLB Read pipeline Disable - Bit 12 */
  219. #define SDRAM_CONF1HB_PWPD 0x00040000 /* PLB Write pipeline Disable - Bit 13 */
  220. #define SDRAM_CONF1HB_PRW 0x00020000 /* PLB Read Wait - Bit 14 */
  221. #define SDRAM_CONF1HB_RPLM 0x00001000 /* Read Passing Limit 1 - Bits 16..19 */
  222. #define SDRAM_CONF1HB_RPEN 0x00000800 /* Read Passing Enable - Bit 20 */
  223. #define SDRAM_CONF1HB_RFTE 0x00000400 /* Read Flow Through Enable - Bit 21 */
  224. #define SDRAM_CONF1HB_WRCL 0x00000080 /* MCIF Cycle Limit 1 - Bits 22..24 */
  225. #define SDRAM_CONF1HB_MASK 0x0000F380 /* RPLM & WRCL mask */
  226. #define SDRAM_ERRSTATHB (SDRAMQ_DCR_BASE+0x7) /* error status HB */
  227. #define SDRAM_ERRADDUHB (SDRAMQ_DCR_BASE+0x8) /* error address upper 32 HB */
  228. #define SDRAM_ERRADDLHB (SDRAMQ_DCR_BASE+0x9) /* error address lower 32 HB */
  229. #define SDRAM_PLBADDULL (SDRAMQ_DCR_BASE+0xA) /* PLB base address upper 32 LL */
  230. #define SDRAM_CONF1LL (SDRAMQ_DCR_BASE+0xB) /* configuration 1 LL */
  231. #define SDRAM_CONF1LL_AAFR 0x80000000 /* Address Ack on First Request - Bit 0 */
  232. #define SDRAM_CONF1LL_PRPD 0x00080000 /* PLB Read pipeline Disable - Bit 12 */
  233. #define SDRAM_CONF1LL_PWPD 0x00040000 /* PLB Write pipeline Disable - Bit 13 */
  234. #define SDRAM_CONF1LL_PRW 0x00020000 /* PLB Read Wait - Bit 14 */
  235. #define SDRAM_CONF1LL_RPLM 0x00001000 /* Read Passing Limit 1 - Bits 16..19 */
  236. #define SDRAM_CONF1LL_RPEN 0x00000800 /* Read Passing Enable - Bit 20 */
  237. #define SDRAM_CONF1LL_RFTE 0x00000400 /* Read Flow Through Enable - Bit 21 */
  238. #define SDRAM_CONF1LL_MASK 0x0000F000 /* RPLM mask */
  239. #define SDRAM_ERRSTATLL (SDRAMQ_DCR_BASE+0xC) /* error status LL */
  240. #define SDRAM_ERRADDULL (SDRAMQ_DCR_BASE+0xD) /* error address upper 32 LL */
  241. #define SDRAM_ERRADDLLL (SDRAMQ_DCR_BASE+0xE) /* error address lower 32 LL */
  242. #define SDRAM_CONFPATHB (SDRAMQ_DCR_BASE+0xF) /* configuration between paths */
  243. #define SDRAM_CONFPATHB_TPEN 0x08000000 /* Transaction Passing Enable - Bit 4 */
  244. #define SDRAM_PLBADDUHB (SDRAMQ_DCR_BASE+0x10) /* PLB base address upper 32 LL */
  245. /*
  246. * Memory Bank 0-7 configuration
  247. */
  248. #if defined(CONFIG_440SPE) || \
  249. defined(CONFIG_460EX) || defined(CONFIG_460GT) || \
  250. defined(CONFIG_460SX)
  251. #define SDRAM_RXBAS_SDBA_MASK 0xFFE00000 /* Base address */
  252. #define SDRAM_RXBAS_SDBA_ENCODE(n) ((u32)(((phys_size_t)(n) >> 2) & 0xFFE00000))
  253. #define SDRAM_RXBAS_SDBA_DECODE(n) ((((phys_size_t)(n)) & 0xFFE00000) << 2)
  254. #endif /* CONFIG_440SPE */
  255. #if defined(CONFIG_440SP)
  256. #define SDRAM_RXBAS_SDBA_MASK 0xFF800000 /* Base address */
  257. #define SDRAM_RXBAS_SDBA_ENCODE(n) ((((u32)(n))&0xFF800000))
  258. #define SDRAM_RXBAS_SDBA_DECODE(n) ((((u32)(n))&0xFF800000))
  259. #endif /* CONFIG_440SP */
  260. #define SDRAM_RXBAS_SDSZ_MASK 0x0000FFC0 /* Size */
  261. #define SDRAM_RXBAS_SDSZ_ENCODE(n) ((((u32)(n))&0x3FF)<<6)
  262. #define SDRAM_RXBAS_SDSZ_DECODE(n) ((((u32)(n))>>6)&0x3FF)
  263. #define SDRAM_RXBAS_SDSZ_0 0x00000000 /* 0M */
  264. #define SDRAM_RXBAS_SDSZ_8 0x0000FFC0 /* 8M */
  265. #define SDRAM_RXBAS_SDSZ_16 0x0000FF80 /* 16M */
  266. #define SDRAM_RXBAS_SDSZ_32 0x0000FF00 /* 32M */
  267. #define SDRAM_RXBAS_SDSZ_64 0x0000FE00 /* 64M */
  268. #define SDRAM_RXBAS_SDSZ_128 0x0000FC00 /* 128M */
  269. #define SDRAM_RXBAS_SDSZ_256 0x0000F800 /* 256M */
  270. #define SDRAM_RXBAS_SDSZ_512 0x0000F000 /* 512M */
  271. #define SDRAM_RXBAS_SDSZ_1024 0x0000E000 /* 1024M */
  272. #define SDRAM_RXBAS_SDSZ_2048 0x0000C000 /* 2048M */
  273. #define SDRAM_RXBAS_SDSZ_4096 0x00008000 /* 4096M */
  274. #else /* CONFIG_405EX */
  275. /*
  276. * XXX - ToDo:
  277. * Revisit this file to check if all these 405EX defines are correct and
  278. * can be used in the common 44x_spd_ddr2 code as well. sr, 2008-06-02
  279. */
  280. #define SDRAM_RXBAS_SDSZ_MASK PPC_REG_VAL(19, 0xF)
  281. #define SDRAM_RXBAS_SDSZ_4MB PPC_REG_VAL(19, 0x0)
  282. #define SDRAM_RXBAS_SDSZ_8MB PPC_REG_VAL(19, 0x1)
  283. #define SDRAM_RXBAS_SDSZ_16MB PPC_REG_VAL(19, 0x2)
  284. #define SDRAM_RXBAS_SDSZ_32MB PPC_REG_VAL(19, 0x3)
  285. #define SDRAM_RXBAS_SDSZ_64MB PPC_REG_VAL(19, 0x4)
  286. #define SDRAM_RXBAS_SDSZ_128MB PPC_REG_VAL(19, 0x5)
  287. #define SDRAM_RXBAS_SDSZ_256MB PPC_REG_VAL(19, 0x6)
  288. #define SDRAM_RXBAS_SDSZ_512MB PPC_REG_VAL(19, 0x7)
  289. #define SDRAM_RXBAS_SDSZ_1024MB PPC_REG_VAL(19, 0x8)
  290. #define SDRAM_RXBAS_SDSZ_2048MB PPC_REG_VAL(19, 0x9)
  291. #define SDRAM_RXBAS_SDSZ_4096MB PPC_REG_VAL(19, 0xA)
  292. #define SDRAM_RXBAS_SDSZ_8192MB PPC_REG_VAL(19, 0xB)
  293. #define SDRAM_RXBAS_SDSZ_8 SDRAM_RXBAS_SDSZ_8MB
  294. #define SDRAM_RXBAS_SDSZ_16 SDRAM_RXBAS_SDSZ_16MB
  295. #define SDRAM_RXBAS_SDSZ_32 SDRAM_RXBAS_SDSZ_32MB
  296. #define SDRAM_RXBAS_SDSZ_64 SDRAM_RXBAS_SDSZ_64MB
  297. #define SDRAM_RXBAS_SDSZ_128 SDRAM_RXBAS_SDSZ_128MB
  298. #define SDRAM_RXBAS_SDSZ_256 SDRAM_RXBAS_SDSZ_256MB
  299. #define SDRAM_RXBAS_SDSZ_512 SDRAM_RXBAS_SDSZ_512MB
  300. #define SDRAM_RXBAS_SDSZ_1024 SDRAM_RXBAS_SDSZ_1024MB
  301. #define SDRAM_RXBAS_SDSZ_2048 SDRAM_RXBAS_SDSZ_2048MB
  302. #define SDRAM_RXBAS_SDSZ_4096 SDRAM_RXBAS_SDSZ_4096MB
  303. #define SDRAM_RXBAS_SDSZ_8192 SDRAM_RXBAS_SDSZ_8192MB
  304. #endif /* CONFIG_405EX */
  305. /* The mode definitions are the same for all PPC4xx variants */
  306. #define SDRAM_RXBAS_SDAM_MODE0 PPC_REG_VAL(23, 0x0)
  307. #define SDRAM_RXBAS_SDAM_MODE1 PPC_REG_VAL(23, 0x1)
  308. #define SDRAM_RXBAS_SDAM_MODE2 PPC_REG_VAL(23, 0x2)
  309. #define SDRAM_RXBAS_SDAM_MODE3 PPC_REG_VAL(23, 0x3)
  310. #define SDRAM_RXBAS_SDAM_MODE4 PPC_REG_VAL(23, 0x4)
  311. #define SDRAM_RXBAS_SDAM_MODE5 PPC_REG_VAL(23, 0x5)
  312. #define SDRAM_RXBAS_SDAM_MODE6 PPC_REG_VAL(23, 0x6)
  313. #define SDRAM_RXBAS_SDAM_MODE7 PPC_REG_VAL(23, 0x7)
  314. #define SDRAM_RXBAS_SDAM_MODE8 PPC_REG_VAL(23, 0x8)
  315. #define SDRAM_RXBAS_SDAM_MODE9 PPC_REG_VAL(23, 0x9)
  316. #define SDRAM_RXBAS_SDBE_DISABLE PPC_REG_VAL(31, 0x0)
  317. #define SDRAM_RXBAS_SDBE_ENABLE PPC_REG_VAL(31, 0x1)
  318. /*
  319. * Memory controller registers
  320. */
  321. #if defined(CONFIG_405EX)
  322. #define SDRAM_BESR 0x00 /* PLB bus error status (read/clear) */
  323. #define SDRAM_BESRT 0x01 /* PLB bus error status (test/set) */
  324. #define SDRAM_BEARL 0x02 /* PLB bus error address low */
  325. #define SDRAM_BEARH 0x03 /* PLB bus error address high */
  326. #define SDRAM_WMIRQ 0x06 /* PLB write master interrupt (read/clear) */
  327. #define SDRAM_WMIRQT 0x07 /* PLB write master interrupt (test/set) */
  328. #define SDRAM_PLBOPT 0x08 /* PLB slave options */
  329. #define SDRAM_PUABA 0x09 /* PLB upper address base */
  330. #define SDRAM_MCSTAT 0x1F /* memory controller status */
  331. #else /* CONFIG_405EX */
  332. #define SDRAM_MCSTAT 0x14 /* memory controller status */
  333. #endif /* CONFIG_405EX */
  334. #define SDRAM_MCOPT1 0x20 /* memory controller options 1 */
  335. #define SDRAM_MCOPT2 0x21 /* memory controller options 2 */
  336. #define SDRAM_MODT0 0x22 /* on die termination for bank 0 */
  337. #define SDRAM_MODT1 0x23 /* on die termination for bank 1 */
  338. #define SDRAM_MODT2 0x24 /* on die termination for bank 2 */
  339. #define SDRAM_MODT3 0x25 /* on die termination for bank 3 */
  340. #define SDRAM_CODT 0x26 /* on die termination for controller */
  341. #define SDRAM_VVPR 0x27 /* variable VRef programmming */
  342. #define SDRAM_OPARS 0x28 /* on chip driver control setup */
  343. #define SDRAM_OPART 0x29 /* on chip driver control trigger */
  344. #define SDRAM_RTR 0x30 /* refresh timer */
  345. #define SDRAM_PMIT 0x34 /* power management idle timer */
  346. #define SDRAM_MB0CF 0x40 /* memory bank 0 configuration */
  347. #define SDRAM_MB1CF 0x44 /* memory bank 1 configuration */
  348. #define SDRAM_MB2CF 0x48
  349. #define SDRAM_MB3CF 0x4C
  350. #define SDRAM_INITPLR0 0x50 /* manual initialization control */
  351. #define SDRAM_INITPLR1 0x51 /* manual initialization control */
  352. #define SDRAM_INITPLR2 0x52 /* manual initialization control */
  353. #define SDRAM_INITPLR3 0x53 /* manual initialization control */
  354. #define SDRAM_INITPLR4 0x54 /* manual initialization control */
  355. #define SDRAM_INITPLR5 0x55 /* manual initialization control */
  356. #define SDRAM_INITPLR6 0x56 /* manual initialization control */
  357. #define SDRAM_INITPLR7 0x57 /* manual initialization control */
  358. #define SDRAM_INITPLR8 0x58 /* manual initialization control */
  359. #define SDRAM_INITPLR9 0x59 /* manual initialization control */
  360. #define SDRAM_INITPLR10 0x5a /* manual initialization control */
  361. #define SDRAM_INITPLR11 0x5b /* manual initialization control */
  362. #define SDRAM_INITPLR12 0x5c /* manual initialization control */
  363. #define SDRAM_INITPLR13 0x5d /* manual initialization control */
  364. #define SDRAM_INITPLR14 0x5e /* manual initialization control */
  365. #define SDRAM_INITPLR15 0x5f /* manual initialization control */
  366. #define SDRAM_RQDC 0x70 /* read DQS delay control */
  367. #define SDRAM_RFDC 0x74 /* read feedback delay control */
  368. #define SDRAM_RDCC 0x78 /* read data capture control */
  369. #define SDRAM_DLCR 0x7A /* delay line calibration */
  370. #define SDRAM_CLKTR 0x80 /* DDR clock timing */
  371. #define SDRAM_WRDTR 0x81 /* write data, DQS, DM clock, timing */
  372. #define SDRAM_SDTR1 0x85 /* DDR SDRAM timing 1 */
  373. #define SDRAM_SDTR2 0x86 /* DDR SDRAM timing 2 */
  374. #define SDRAM_SDTR3 0x87 /* DDR SDRAM timing 3 */
  375. #define SDRAM_MMODE 0x88 /* memory mode */
  376. #define SDRAM_MEMODE 0x89 /* memory extended mode */
  377. #define SDRAM_ECCES 0x98 /* ECC error status */
  378. #define SDRAM_CID 0xA4 /* core ID */
  379. #if !defined(CONFIG_405EX)
  380. #define SDRAM_RID 0xA8 /* revision ID */
  381. #endif
  382. #define SDRAM_FCSR 0xB0 /* feedback calibration status */
  383. #define SDRAM_RTSR 0xB1 /* run time status tracking */
  384. #if defined(CONFIG_405EX)
  385. #define SDRAM_RID 0xF8 /* revision ID */
  386. #endif
  387. /*
  388. * Memory Controller Bus Error Status
  389. */
  390. #define SDRAM_BESR_MASK PPC_REG_VAL(7, 0xFF)
  391. #define SDRAM_BESR_M0ID_MASK PPC_REG_VAL(3, 0xF)
  392. #define SDRAM_BESR_M0ID_ICU PPC_REG_VAL(3, 0x0)
  393. #define SDRAM_BESR_M0ID_PCIE0 PPC_REG_VAL(3, 0x1)
  394. #define SDRAM_BESR_M0ID_PCIE1 PPC_REG_VAL(3, 0x2)
  395. #define SDRAM_BESR_M0ID_DMA PPC_REG_VAL(3, 0x3)
  396. #define SDRAM_BESR_M0ID_DCU PPC_REG_VAL(3, 0x4)
  397. #define SDRAM_BESR_M0ID_OPB PPC_REG_VAL(3, 0x5)
  398. #define SDRAM_BESR_M0ID_MAL PPC_REG_VAL(3, 0x6)
  399. #define SDRAM_BESR_M0ID_SEC PPC_REG_VAL(3, 0x7)
  400. #define SDRAM_BESR_M0ET_MASK PPC_REG_VAL(6, 0x7)
  401. #define SDRAM_BESR_M0ET_NONE PPC_REG_VAL(6, 0x0)
  402. #define SDRAM_BESR_M0ET_ECC PPC_REG_VAL(6, 0x1)
  403. #define SDRAM_BESR_M0RW_WRITE PPC_REG_VAL(7, 0)
  404. #define SDRAM_BESR_M0RW_READ PPC_REG_VAL(8, 1)
  405. /*
  406. * Memory Controller Status
  407. */
  408. #define SDRAM_MCSTAT_MIC_MASK 0x80000000 /* Memory init status mask */
  409. #define SDRAM_MCSTAT_MIC_NOTCOMP 0x00000000 /* Mem init not complete */
  410. #define SDRAM_MCSTAT_MIC_COMP 0x80000000 /* Mem init complete */
  411. #define SDRAM_MCSTAT_SRMS_MASK 0x40000000 /* Mem self refresh stat mask */
  412. #define SDRAM_MCSTAT_SRMS_NOT_SF 0x00000000 /* Mem not in self refresh */
  413. #define SDRAM_MCSTAT_SRMS_SF 0x40000000 /* Mem in self refresh */
  414. #define SDRAM_MCSTAT_IDLE_MASK 0x20000000 /* Mem self refresh stat mask */
  415. #define SDRAM_MCSTAT_IDLE_NOT 0x00000000 /* Mem contr not idle */
  416. #define SDRAM_MCSTAT_IDLE 0x20000000 /* Mem contr idle */
  417. /*
  418. * Memory Controller Options 1
  419. */
  420. #define SDRAM_MCOPT1_MCHK_MASK 0x30000000 /* Memory data err check mask*/
  421. #define SDRAM_MCOPT1_MCHK_NON 0x00000000 /* No ECC generation */
  422. #define SDRAM_MCOPT1_MCHK_GEN 0x20000000 /* ECC generation */
  423. #define SDRAM_MCOPT1_MCHK_CHK 0x10000000 /* ECC generation and check */
  424. #define SDRAM_MCOPT1_MCHK_CHK_REP 0x30000000 /* ECC generation, chk, report*/
  425. #define SDRAM_MCOPT1_MCHK_CHK_DECODE(n) ((((u32)(n))>>28)&0x3)
  426. #define SDRAM_MCOPT1_RDEN_MASK 0x08000000 /* Registered DIMM mask */
  427. #define SDRAM_MCOPT1_RDEN 0x08000000 /* Registered DIMM enable */
  428. #define SDRAM_MCOPT1_PMU_MASK 0x06000000 /* Page management unit mask */
  429. #define SDRAM_MCOPT1_PMU_CLOSE 0x00000000 /* PMU Close */
  430. #define SDRAM_MCOPT1_PMU_OPEN 0x04000000 /* PMU Open */
  431. #define SDRAM_MCOPT1_PMU_AUTOCLOSE 0x02000000 /* PMU AutoClose */
  432. #define SDRAM_MCOPT1_DMWD_MASK 0x01000000 /* DRAM width mask */
  433. #define SDRAM_MCOPT1_DMWD_32 0x00000000 /* 32 bits */
  434. #define SDRAM_MCOPT1_DMWD_64 0x01000000 /* 64 bits */
  435. #define SDRAM_MCOPT1_UIOS_MASK 0x00C00000 /* Unused IO State */
  436. #define SDRAM_MCOPT1_BCNT_MASK 0x00200000 /* Bank count */
  437. #define SDRAM_MCOPT1_4_BANKS 0x00000000 /* 4 Banks */
  438. #define SDRAM_MCOPT1_8_BANKS 0x00200000 /* 8 Banks */
  439. #define SDRAM_MCOPT1_DDR_TYPE_MASK 0x00100000 /* DDR Memory Type mask */
  440. #define SDRAM_MCOPT1_DDR1_TYPE 0x00000000 /* DDR1 Memory Type */
  441. #define SDRAM_MCOPT1_DDR2_TYPE 0x00100000 /* DDR2 Memory Type */
  442. #define SDRAM_MCOPT1_QDEP 0x00020000 /* 4 commands deep */
  443. #define SDRAM_MCOPT1_RWOO_MASK 0x00008000 /* Out of Order Read mask */
  444. #define SDRAM_MCOPT1_RWOO_DISABLED 0x00000000 /* disabled */
  445. #define SDRAM_MCOPT1_RWOO_ENABLED 0x00008000 /* enabled */
  446. #define SDRAM_MCOPT1_WOOO_MASK 0x00004000 /* Out of Order Write mask */
  447. #define SDRAM_MCOPT1_WOOO_DISABLED 0x00000000 /* disabled */
  448. #define SDRAM_MCOPT1_WOOO_ENABLED 0x00004000 /* enabled */
  449. #define SDRAM_MCOPT1_DCOO_MASK 0x00002000 /* All Out of Order mask */
  450. #define SDRAM_MCOPT1_DCOO_DISABLED 0x00002000 /* disabled */
  451. #define SDRAM_MCOPT1_DCOO_ENABLED 0x00000000 /* enabled */
  452. #define SDRAM_MCOPT1_DREF_MASK 0x00001000 /* Deferred refresh mask */
  453. #define SDRAM_MCOPT1_DREF_NORMAL 0x00000000 /* normal refresh */
  454. #define SDRAM_MCOPT1_DREF_DEFER_4 0x00001000 /* defer up to 4 refresh cmd */
  455. /*
  456. * Memory Controller Options 2
  457. */
  458. #define SDRAM_MCOPT2_SREN_MASK 0x80000000 /* Self Test mask */
  459. #define SDRAM_MCOPT2_SREN_EXIT 0x00000000 /* Self Test exit */
  460. #define SDRAM_MCOPT2_SREN_ENTER 0x80000000 /* Self Test enter */
  461. #define SDRAM_MCOPT2_PMEN_MASK 0x40000000 /* Power Management mask */
  462. #define SDRAM_MCOPT2_PMEN_DISABLE 0x00000000 /* disable */
  463. #define SDRAM_MCOPT2_PMEN_ENABLE 0x40000000 /* enable */
  464. #define SDRAM_MCOPT2_IPTR_MASK 0x20000000 /* Init Trigger Reg mask */
  465. #define SDRAM_MCOPT2_IPTR_IDLE 0x00000000 /* idle */
  466. #define SDRAM_MCOPT2_IPTR_EXECUTE 0x20000000 /* execute preloaded init */
  467. #define SDRAM_MCOPT2_XSRP_MASK 0x10000000 /* Exit Self Refresh Prevent */
  468. #define SDRAM_MCOPT2_XSRP_ALLOW 0x00000000 /* allow self refresh exit */
  469. #define SDRAM_MCOPT2_XSRP_PREVENT 0x10000000 /* prevent self refresh exit */
  470. #define SDRAM_MCOPT2_DCEN_MASK 0x08000000 /* SDRAM Controller Enable */
  471. #define SDRAM_MCOPT2_DCEN_DISABLE 0x00000000 /* SDRAM Controller Enable */
  472. #define SDRAM_MCOPT2_DCEN_ENABLE 0x08000000 /* SDRAM Controller Enable */
  473. #define SDRAM_MCOPT2_ISIE_MASK 0x04000000 /* Init Seq Interruptable mas*/
  474. #define SDRAM_MCOPT2_ISIE_DISABLE 0x00000000 /* disable */
  475. #define SDRAM_MCOPT2_ISIE_ENABLE 0x04000000 /* enable */
  476. /*
  477. * SDRAM Refresh Timer Register
  478. */
  479. #define SDRAM_RTR_RINT_MASK 0xFFF80000
  480. #define SDRAM_RTR_RINT_ENCODE(n) ((((u32)(n))&0xFFF8)<<16)
  481. #define SDRAM_RTR_RINT_DECODE(n) ((((u32)(n))>>16)&0xFFF8)
  482. /*
  483. * SDRAM Read DQS Delay Control Register
  484. */
  485. #define SDRAM_RQDC_RQDE_MASK 0x80000000
  486. #define SDRAM_RQDC_RQDE_DISABLE 0x00000000
  487. #define SDRAM_RQDC_RQDE_ENABLE 0x80000000
  488. #define SDRAM_RQDC_RQFD_MASK 0x000001FF
  489. #define SDRAM_RQDC_RQFD_ENCODE(n) ((((u32)(n))&0x1FF)<<0)
  490. #define SDRAM_RQDC_RQFD_MAX 0x1FF
  491. /*
  492. * SDRAM Read Data Capture Control Register
  493. */
  494. #define SDRAM_RDCC_RDSS_MASK 0xC0000000
  495. #define SDRAM_RDCC_RDSS_T1 0x00000000
  496. #define SDRAM_RDCC_RDSS_T2 0x40000000
  497. #define SDRAM_RDCC_RDSS_T3 0x80000000
  498. #define SDRAM_RDCC_RDSS_T4 0xC0000000
  499. #define SDRAM_RDCC_RSAE_MASK 0x00000001
  500. #define SDRAM_RDCC_RSAE_DISABLE 0x00000001
  501. #define SDRAM_RDCC_RSAE_ENABLE 0x00000000
  502. #define SDRAM_RDCC_RDSS_ENCODE(n) ((((u32)(n))&0x03)<<30)
  503. #define SDRAM_RDCC_RDSS_DECODE(n) ((((u32)(n))>>30)&0x03)
  504. /*
  505. * SDRAM Read Feedback Delay Control Register
  506. */
  507. #define SDRAM_RFDC_ARSE_MASK 0x80000000
  508. #define SDRAM_RFDC_ARSE_DISABLE 0x80000000
  509. #define SDRAM_RFDC_ARSE_ENABLE 0x00000000
  510. #define SDRAM_RFDC_RFOS_MASK 0x007F0000
  511. #define SDRAM_RFDC_RFOS_ENCODE(n) ((((u32)(n))&0x7F)<<16)
  512. #define SDRAM_RFDC_RFFD_MASK 0x000007FF
  513. #define SDRAM_RFDC_RFFD_ENCODE(n) ((((u32)(n))&0x7FF)<<0)
  514. #define SDRAM_RFDC_RFFD_MAX 0x7FF
  515. /*
  516. * SDRAM Delay Line Calibration Register
  517. */
  518. #define SDRAM_DLCR_DCLM_MASK 0x80000000
  519. #define SDRAM_DLCR_DCLM_MANUAL 0x80000000
  520. #define SDRAM_DLCR_DCLM_AUTO 0x00000000
  521. #define SDRAM_DLCR_DLCR_MASK 0x08000000
  522. #define SDRAM_DLCR_DLCR_CALIBRATE 0x08000000
  523. #define SDRAM_DLCR_DLCR_IDLE 0x00000000
  524. #define SDRAM_DLCR_DLCS_MASK 0x07000000
  525. #define SDRAM_DLCR_DLCS_NOT_RUN 0x00000000
  526. #define SDRAM_DLCR_DLCS_IN_PROGRESS 0x01000000
  527. #define SDRAM_DLCR_DLCS_COMPLETE 0x02000000
  528. #define SDRAM_DLCR_DLCS_CONT_DONE 0x03000000
  529. #define SDRAM_DLCR_DLCS_ERROR 0x04000000
  530. #define SDRAM_DLCR_DLCV_MASK 0x000001FF
  531. #define SDRAM_DLCR_DLCV_ENCODE(n) ((((u32)(n))&0x1FF)<<0)
  532. #define SDRAM_DLCR_DLCV_DECODE(n) ((((u32)(n))>>0)&0x1FF)
  533. /*
  534. * SDRAM Memory On Die Terimination Control Register
  535. */
  536. #define SDRAM_MODT_ODTON_DISABLE PPC_REG_VAL(0, 0)
  537. #define SDRAM_MODT_ODTON_ENABLE PPC_REG_VAL(0, 1)
  538. #define SDRAM_MODT_EB1W_DISABLE PPC_REG_VAL(1, 0)
  539. #define SDRAM_MODT_EB1W_ENABLE PPC_REG_VAL(1, 1)
  540. #define SDRAM_MODT_EB1R_DISABLE PPC_REG_VAL(2, 0)
  541. #define SDRAM_MODT_EB1R_ENABLE PPC_REG_VAL(2, 1)
  542. #define SDRAM_MODT_EB0W_DISABLE PPC_REG_VAL(7, 0)
  543. #define SDRAM_MODT_EB0W_ENABLE PPC_REG_VAL(7, 1)
  544. #define SDRAM_MODT_EB0R_DISABLE PPC_REG_VAL(8, 0)
  545. #define SDRAM_MODT_EB0R_ENABLE PPC_REG_VAL(8, 1)
  546. /*
  547. * SDRAM Controller On Die Termination Register
  548. */
  549. #define SDRAM_CODT_ODT_ON PPC_REG_VAL(0, 1)
  550. #define SDRAM_CODT_ODT_OFF PPC_REG_VAL(0, 0)
  551. #define SDRAM_CODT_RK1W_ON PPC_REG_VAL(1, 1)
  552. #define SDRAM_CODT_RK1W_OFF PPC_REG_VAL(1, 0)
  553. #define SDRAM_CODT_RK1R_ON PPC_REG_VAL(2, 1)
  554. #define SDRAM_CODT_RK1R_OFF PPC_REG_VAL(2, 0)
  555. #define SDRAM_CODT_RK0W_ON PPC_REG_VAL(7, 1)
  556. #define SDRAM_CODT_RK0W_OFF PPC_REG_VAL(7, 0)
  557. #define SDRAM_CODT_RK0R_ON PPC_REG_VAL(8, 1)
  558. #define SDRAM_CODT_RK0R_OFF PPC_REG_VAL(8, 0)
  559. #define SDRAM_CODT_ODTSH_NORMAL PPC_REG_VAL(10, 0)
  560. #define SDRAM_CODT_ODTSH_REMOVE_ONE_AT_END PPC_REG_VAL(10, 1)
  561. #define SDRAM_CODT_ODTSH_ADD_ONE_AT_START PPC_REG_VAL(10, 2)
  562. #define SDRAM_CODT_ODTSH_SHIFT_ONE_EARLIER PPC_REG_VAL(10, 3)
  563. #define SDRAM_CODT_CODTZ_75OHM PPC_REG_VAL(11, 0)
  564. #define SDRAM_CODT_CKEG_ON PPC_REG_VAL(12, 1)
  565. #define SDRAM_CODT_CKEG_OFF PPC_REG_VAL(12, 0)
  566. #define SDRAM_CODT_CTLG_ON PPC_REG_VAL(13, 1)
  567. #define SDRAM_CODT_CTLG_OFF PPC_REG_VAL(13, 0)
  568. #define SDRAM_CODT_FBDG_ON PPC_REG_VAL(14, 1)
  569. #define SDRAM_CODT_FBDG_OFF PPC_REG_VAL(14, 0)
  570. #define SDRAM_CODT_FBRG_ON PPC_REG_VAL(15, 1)
  571. #define SDRAM_CODT_FBRG_OFF PPC_REG_VAL(15, 0)
  572. #define SDRAM_CODT_CKLZ_36OHM PPC_REG_VAL(18, 1)
  573. #define SDRAM_CODT_CKLZ_18OHM PPC_REG_VAL(18, 0)
  574. #define SDRAM_CODT_DQS_VOLTAGE_DDR_MASK PPC_REG_VAL(26, 1)
  575. #define SDRAM_CODT_DQS_2_5_V_DDR1 PPC_REG_VAL(26, 0)
  576. #define SDRAM_CODT_DQS_1_8_V_DDR2 PPC_REG_VAL(26, 1)
  577. #define SDRAM_CODT_DQS_MASK PPC_REG_VAL(27, 1)
  578. #define SDRAM_CODT_DQS_DIFFERENTIAL PPC_REG_VAL(27, 0)
  579. #define SDRAM_CODT_DQS_SINGLE_END PPC_REG_VAL(27, 1)
  580. #define SDRAM_CODT_CKSE_DIFFERENTIAL PPC_REG_VAL(28, 0)
  581. #define SDRAM_CODT_CKSE_SINGLE_END PPC_REG_VAL(28, 1)
  582. #define SDRAM_CODT_FEEBBACK_RCV_SINGLE_END PPC_REG_VAL(29, 1)
  583. #define SDRAM_CODT_FEEBBACK_DRV_SINGLE_END PPC_REG_VAL(30, 1)
  584. #define SDRAM_CODT_IO_HIZ PPC_REG_VAL(31, 0)
  585. #define SDRAM_CODT_IO_NMODE PPC_REG_VAL(31, 1)
  586. /*
  587. * SDRAM Initialization Preload Register
  588. */
  589. #define SDRAM_INITPLR_ENABLE PPC_REG_VAL(0, 1)
  590. #define SDRAM_INITPLR_DISABLE PPC_REG_VAL(0, 0)
  591. #define SDRAM_INITPLR_IMWT_MASK PPC_REG_VAL(8, 0xFF)
  592. #define SDRAM_INITPLR_IMWT_ENCODE(n) PPC_REG_VAL(8, \
  593. (static_cast(u32, \
  594. n)) \
  595. & 0xFF)
  596. #define SDRAM_INITPLR_ICMD_MASK PPC_REG_VAL(12, 0x7)
  597. #define SDRAM_INITPLR_ICMD_ENCODE(n) PPC_REG_VAL(12, \
  598. (static_cast(u32, \
  599. n)) \
  600. & 0x7)
  601. #define SDRAM_INITPLR_IBA_MASK PPC_REG_VAL(15, 0x7)
  602. #define SDRAM_INITPLR_IBA_ENCODE(n) PPC_REG_VAL(15, \
  603. (static_cast(u32, \
  604. n)) \
  605. & 0x7)
  606. #define SDRAM_INITPLR_IMA_MASK PPC_REG_VAL(31, 0x7FFF)
  607. #define SDRAM_INITPLR_IMA_ENCODE(n) PPC_REG_VAL(31, \
  608. (static_cast(u32, \
  609. n)) \
  610. & 0x7FFF)
  611. /*
  612. * JEDEC DDR Initialization Commands
  613. */
  614. #define JEDEC_CMD_NOP 7
  615. #define JEDEC_CMD_PRECHARGE 2
  616. #define JEDEC_CMD_REFRESH 1
  617. #define JEDEC_CMD_EMR 0
  618. #define JEDEC_CMD_READ 5
  619. #define JEDEC_CMD_WRITE 4
  620. /*
  621. * JEDEC Precharge Command Memory Address Arguments
  622. */
  623. #define JEDEC_MA_PRECHARGE_ONE (0 << 10)
  624. #define JEDEC_MA_PRECHARGE_ALL (1 << 10)
  625. /*
  626. * JEDEC DDR EMR Command Bank Address Arguments
  627. */
  628. #define JEDEC_BA_MR 0
  629. #define JEDEC_BA_EMR 1
  630. #define JEDEC_BA_EMR2 2
  631. #define JEDEC_BA_EMR3 3
  632. /*
  633. * JEDEC DDR Mode Register
  634. */
  635. #define JEDEC_MA_MR_PDMODE_FAST_EXIT (0 << 12)
  636. #define JEDEC_MA_MR_PDMODE_SLOW_EXIT (1 << 12)
  637. #define JEDEC_MA_MR_WR_MASK (0x7 << 9)
  638. #define JEDEC_MA_MR_WR_DDR1 (0x0 << 9)
  639. #define JEDEC_MA_MR_WR_DDR2_2_CYC (0x1 << 9)
  640. #define JEDEC_MA_MR_WR_DDR2_3_CYC (0x2 << 9)
  641. #define JEDEC_MA_MR_WR_DDR2_4_CYC (0x3 << 9)
  642. #define JEDEC_MA_MR_WR_DDR2_5_CYC (0x4 << 9)
  643. #define JEDEC_MA_MR_WR_DDR2_6_CYC (0x5 << 9)
  644. #define JEDEC_MA_MR_DLL_RESET (1 << 8)
  645. #define JEDEC_MA_MR_MODE_NORMAL (0 << 8)
  646. #define JEDEC_MA_MR_MODE_TEST (1 << 8)
  647. #define JEDEC_MA_MR_CL_MASK (0x7 << 4)
  648. #define JEDEC_MA_MR_CL_DDR1_2_0_CLK (0x2 << 4)
  649. #define JEDEC_MA_MR_CL_DDR1_2_5_CLK (0x6 << 4)
  650. #define JEDEC_MA_MR_CL_DDR1_3_0_CLK (0x3 << 4)
  651. #define JEDEC_MA_MR_CL_DDR2_2_0_CLK (0x2 << 4)
  652. #define JEDEC_MA_MR_CL_DDR2_3_0_CLK (0x3 << 4)
  653. #define JEDEC_MA_MR_CL_DDR2_4_0_CLK (0x4 << 4)
  654. #define JEDEC_MA_MR_CL_DDR2_5_0_CLK (0x5 << 4)
  655. #define JEDEC_MA_MR_CL_DDR2_6_0_CLK (0x6 << 4)
  656. #define JEDEC_MA_MR_CL_DDR2_7_0_CLK (0x7 << 4)
  657. #define JEDEC_MA_MR_BTYP_SEQUENTIAL (0 << 3)
  658. #define JEDEC_MA_MR_BTYP_INTERLEAVED (1 << 3)
  659. #define JEDEC_MA_MR_BLEN_MASK (0x7 << 0)
  660. #define JEDEC_MA_MR_BLEN_4 (2 << 0)
  661. #define JEDEC_MA_MR_BLEN_8 (3 << 0)
  662. /*
  663. * JEDEC DDR Extended Mode Register
  664. */
  665. #define JEDEC_MA_EMR_OUTPUT_MASK (1 << 12)
  666. #define JEDEC_MA_EMR_OUTPUT_ENABLE (0 << 12)
  667. #define JEDEC_MA_EMR_OUTPUT_DISABLE (1 << 12)
  668. #define JEDEC_MA_EMR_RQDS_MASK (1 << 11)
  669. #define JEDEC_MA_EMR_RDQS_DISABLE (0 << 11)
  670. #define JEDEC_MA_EMR_RDQS_ENABLE (1 << 11)
  671. #define JEDEC_MA_EMR_DQS_MASK (1 << 10)
  672. #define JEDEC_MA_EMR_DQS_DISABLE (1 << 10)
  673. #define JEDEC_MA_EMR_DQS_ENABLE (0 << 10)
  674. #define JEDEC_MA_EMR_OCD_MASK (0x7 << 7)
  675. #define JEDEC_MA_EMR_OCD_EXIT (0 << 7)
  676. #define JEDEC_MA_EMR_OCD_ENTER (7 << 7)
  677. #define JEDEC_MA_EMR_AL_DDR1_0_CYC (0 << 3)
  678. #define JEDEC_MA_EMR_AL_DDR2_1_CYC (1 << 3)
  679. #define JEDEC_MA_EMR_AL_DDR2_2_CYC (2 << 3)
  680. #define JEDEC_MA_EMR_AL_DDR2_3_CYC (3 << 3)
  681. #define JEDEC_MA_EMR_AL_DDR2_4_CYC (4 << 3)
  682. #define JEDEC_MA_EMR_RTT_MASK (0x11 << 2)
  683. #define JEDEC_MA_EMR_RTT_DISABLED (0x00 << 2)
  684. #define JEDEC_MA_EMR_RTT_75OHM (0x01 << 2)
  685. #define JEDEC_MA_EMR_RTT_150OHM (0x10 << 2)
  686. #define JEDEC_MA_EMR_RTT_50OHM (0x11 << 2)
  687. #define JEDEC_MA_EMR_ODS_MASK (1 << 1)
  688. #define JEDEC_MA_EMR_ODS_NORMAL (0 << 1)
  689. #define JEDEC_MA_EMR_ODS_WEAK (1 << 1)
  690. #define JEDEC_MA_EMR_DLL_MASK (1 << 0)
  691. #define JEDEC_MA_EMR_DLL_ENABLE (0 << 0)
  692. #define JEDEC_MA_EMR_DLL_DISABLE (1 << 0)
  693. /*
  694. * JEDEC DDR Extended Mode Register 2
  695. */
  696. #define JEDEC_MA_EMR2_TEMP_COMMERCIAL (0 << 7)
  697. #define JEDEC_MA_EMR2_TEMP_INDUSTRIAL (1 << 7)
  698. /*
  699. * SDRAM Mode Register (Corresponds 1:1 w/ JEDEC Mode Register)
  700. */
  701. #define SDRAM_MMODE_WR_MASK JEDEC_MA_MR_WR_MASK
  702. #define SDRAM_MMODE_WR_DDR1 JEDEC_MA_MR_WR_DDR1
  703. #define SDRAM_MMODE_WR_DDR2_2_CYC JEDEC_MA_MR_WR_DDR2_2_CYC
  704. #define SDRAM_MMODE_WR_DDR2_3_CYC JEDEC_MA_MR_WR_DDR2_3_CYC
  705. #define SDRAM_MMODE_WR_DDR2_4_CYC JEDEC_MA_MR_WR_DDR2_4_CYC
  706. #define SDRAM_MMODE_WR_DDR2_5_CYC JEDEC_MA_MR_WR_DDR2_5_CYC
  707. #define SDRAM_MMODE_WR_DDR2_6_CYC JEDEC_MA_MR_WR_DDR2_6_CYC
  708. #define SDRAM_MMODE_DCL_MASK JEDEC_MA_MR_CL_MASK
  709. #define SDRAM_MMODE_DCL_DDR1_2_0_CLK JEDEC_MA_MR_CL_DDR1_2_0_CLK
  710. #define SDRAM_MMODE_DCL_DDR1_2_5_CLK JEDEC_MA_MR_CL_DDR1_2_5_CLK
  711. #define SDRAM_MMODE_DCL_DDR1_3_0_CLK JEDEC_MA_MR_CL_DDR1_3_0_CLK
  712. #define SDRAM_MMODE_DCL_DDR2_2_0_CLK JEDEC_MA_MR_CL_DDR2_2_0_CLK
  713. #define SDRAM_MMODE_DCL_DDR2_3_0_CLK JEDEC_MA_MR_CL_DDR2_3_0_CLK
  714. #define SDRAM_MMODE_DCL_DDR2_4_0_CLK JEDEC_MA_MR_CL_DDR2_4_0_CLK
  715. #define SDRAM_MMODE_DCL_DDR2_5_0_CLK JEDEC_MA_MR_CL_DDR2_5_0_CLK
  716. #define SDRAM_MMODE_DCL_DDR2_6_0_CLK JEDEC_MA_MR_CL_DDR2_6_0_CLK
  717. #define SDRAM_MMODE_DCL_DDR2_7_0_CLK JEDEC_MA_MR_CL_DDR2_7_0_CLK
  718. #define SDRAM_MMODE_BTYP_SEQUENTIAL JEDEC_MA_MR_BTYP_SEQUENTIAL
  719. #define SDRAM_MMODE_BTYP_INTERLEAVED JEDEC_MA_MR_BTYP_INTERLEAVED
  720. #define SDRAM_MMODE_BLEN_MASK JEDEC_MA_MR_BLEN_MASK
  721. #define SDRAM_MMODE_BLEN_4 JEDEC_MA_MR_BLEN_4
  722. #define SDRAM_MMODE_BLEN_8 JEDEC_MA_MR_BLEN_8
  723. /*
  724. * SDRAM Extended Mode Register (Corresponds 1:1 w/ JEDEC Extended
  725. * Mode Register)
  726. */
  727. #define SDRAM_MEMODE_QOFF_MASK JEDEC_MA_EMR_OUTPUT_MASK
  728. #define SDRAM_MEMODE_QOFF_DISABLE JEDEC_MA_EMR_OUTPUT_DISABLE
  729. #define SDRAM_MEMODE_QOFF_ENABLE JEDEC_MA_EMR_OUTPUT_ENABLE
  730. #define SDRAM_MEMODE_RDQS_MASK JEDEC_MA_EMR_RQDS_MASK
  731. #define SDRAM_MEMODE_RDQS_DISABLE JEDEC_MA_EMR_RDQS_DISABLE
  732. #define SDRAM_MEMODE_RDQS_ENABLE JEDEC_MA_EMR_RDQS_ENABLE
  733. #define SDRAM_MEMODE_DQS_MASK JEDEC_MA_EMR_DQS_MASK
  734. #define SDRAM_MEMODE_DQS_DISABLE JEDEC_MA_EMR_DQS_DISABLE
  735. #define SDRAM_MEMODE_DQS_ENABLE JEDEC_MA_EMR_DQS_ENABLE
  736. #define SDRAM_MEMODE_AL_DDR1_0_CYC JEDEC_MA_EMR_AL_DDR1_0_CYC
  737. #define SDRAM_MEMODE_AL_DDR2_1_CYC JEDEC_MA_EMR_AL_DDR2_1_CYC
  738. #define SDRAM_MEMODE_AL_DDR2_2_CYC JEDEC_MA_EMR_AL_DDR2_2_CYC
  739. #define SDRAM_MEMODE_AL_DDR2_3_CYC JEDEC_MA_EMR_AL_DDR2_3_CYC
  740. #define SDRAM_MEMODE_AL_DDR2_4_CYC JEDEC_MA_EMR_AL_DDR2_4_CYC
  741. #define SDRAM_MEMODE_RTT_MASK JEDEC_MA_EMR_RTT_MASK
  742. #define SDRAM_MEMODE_RTT_DISABLED JEDEC_MA_EMR_RTT_DISABLED
  743. #define SDRAM_MEMODE_RTT_75OHM JEDEC_MA_EMR_RTT_75OHM
  744. #define SDRAM_MEMODE_RTT_150OHM JEDEC_MA_EMR_RTT_150OHM
  745. #define SDRAM_MEMODE_RTT_50OHM JEDEC_MA_EMR_RTT_50OHM
  746. #define SDRAM_MEMODE_DIC_MASK JEDEC_MA_EMR_ODS_MASK
  747. #define SDRAM_MEMODE_DIC_NORMAL JEDEC_MA_EMR_ODS_NORMAL
  748. #define SDRAM_MEMODE_DIC_WEAK JEDEC_MA_EMR_ODS_WEAK
  749. #define SDRAM_MEMODE_DLL_MASK JEDEC_MA_EMR_DLL_MASK
  750. #define SDRAM_MEMODE_DLL_DISABLE JEDEC_MA_EMR_DLL_DISABLE
  751. #define SDRAM_MEMODE_DLL_ENABLE JEDEC_MA_EMR_DLL_ENABLE
  752. /*
  753. * SDRAM Clock Timing Register
  754. */
  755. #define SDRAM_CLKTR_CLKP_MASK 0xC0000000
  756. #define SDRAM_CLKTR_CLKP_0_DEG 0x00000000
  757. #define SDRAM_CLKTR_CLKP_180_DEG_ADV 0x80000000
  758. #define SDRAM_CLKTR_CLKP_90_DEG_ADV 0x40000000
  759. #define SDRAM_CLKTR_CLKP_270_DEG_ADV 0xC0000000
  760. /*
  761. * SDRAM Write Timing Register
  762. */
  763. #define SDRAM_WRDTR_LLWP_MASK 0x10000000
  764. #define SDRAM_WRDTR_LLWP_DIS 0x10000000
  765. #define SDRAM_WRDTR_LLWP_1_CYC 0x00000000
  766. #define SDRAM_WRDTR_WTR_MASK 0x0E000000
  767. #define SDRAM_WRDTR_WTR_0_DEG 0x06000000
  768. #define SDRAM_WRDTR_WTR_90_DEG_ADV 0x04000000
  769. #define SDRAM_WRDTR_WTR_180_DEG_ADV 0x02000000
  770. #define SDRAM_WRDTR_WTR_270_DEG_ADV 0x00000000
  771. /*
  772. * SDRAM SDTR1 Options
  773. */
  774. #define SDRAM_SDTR1_LDOF_MASK 0x80000000
  775. #define SDRAM_SDTR1_LDOF_1_CLK 0x00000000
  776. #define SDRAM_SDTR1_LDOF_2_CLK 0x80000000
  777. #define SDRAM_SDTR1_RTW_MASK 0x00F00000
  778. #define SDRAM_SDTR1_RTW_2_CLK 0x00200000
  779. #define SDRAM_SDTR1_RTW_3_CLK 0x00300000
  780. #define SDRAM_SDTR1_WTWO_MASK 0x000F0000
  781. #define SDRAM_SDTR1_WTWO_0_CLK 0x00000000
  782. #define SDRAM_SDTR1_WTWO_1_CLK 0x00010000
  783. #define SDRAM_SDTR1_RTRO_MASK 0x0000F000
  784. #define SDRAM_SDTR1_RTRO_1_CLK 0x00001000
  785. #define SDRAM_SDTR1_RTRO_2_CLK 0x00002000
  786. /*
  787. * SDRAM SDTR2 Options
  788. */
  789. #define SDRAM_SDTR2_RCD_MASK 0xF0000000
  790. #define SDRAM_SDTR2_RCD_1_CLK 0x10000000
  791. #define SDRAM_SDTR2_RCD_2_CLK 0x20000000
  792. #define SDRAM_SDTR2_RCD_3_CLK 0x30000000
  793. #define SDRAM_SDTR2_RCD_4_CLK 0x40000000
  794. #define SDRAM_SDTR2_RCD_5_CLK 0x50000000
  795. #define SDRAM_SDTR2_WTR_MASK 0x0F000000
  796. #define SDRAM_SDTR2_WTR_1_CLK 0x01000000
  797. #define SDRAM_SDTR2_WTR_2_CLK 0x02000000
  798. #define SDRAM_SDTR2_WTR_3_CLK 0x03000000
  799. #define SDRAM_SDTR2_WTR_4_CLK 0x04000000
  800. #define SDRAM_SDTR3_WTR_ENCODE(n) ((((u32)(n))&0xF)<<24)
  801. #define SDRAM_SDTR2_XSNR_MASK 0x00FF0000
  802. #define SDRAM_SDTR2_XSNR_8_CLK 0x00080000
  803. #define SDRAM_SDTR2_XSNR_16_CLK 0x00100000
  804. #define SDRAM_SDTR2_XSNR_32_CLK 0x00200000
  805. #define SDRAM_SDTR2_XSNR_64_CLK 0x00400000
  806. #define SDRAM_SDTR2_WPC_MASK 0x0000F000
  807. #define SDRAM_SDTR2_WPC_2_CLK 0x00002000
  808. #define SDRAM_SDTR2_WPC_3_CLK 0x00003000
  809. #define SDRAM_SDTR2_WPC_4_CLK 0x00004000
  810. #define SDRAM_SDTR2_WPC_5_CLK 0x00005000
  811. #define SDRAM_SDTR2_WPC_6_CLK 0x00006000
  812. #define SDRAM_SDTR3_WPC_ENCODE(n) ((((u32)(n))&0xF)<<12)
  813. #define SDRAM_SDTR2_RPC_MASK 0x00000F00
  814. #define SDRAM_SDTR2_RPC_2_CLK 0x00000200
  815. #define SDRAM_SDTR2_RPC_3_CLK 0x00000300
  816. #define SDRAM_SDTR2_RPC_4_CLK 0x00000400
  817. #define SDRAM_SDTR2_RP_MASK 0x000000F0
  818. #define SDRAM_SDTR2_RP_3_CLK 0x00000030
  819. #define SDRAM_SDTR2_RP_4_CLK 0x00000040
  820. #define SDRAM_SDTR2_RP_5_CLK 0x00000050
  821. #define SDRAM_SDTR2_RP_6_CLK 0x00000060
  822. #define SDRAM_SDTR2_RP_7_CLK 0x00000070
  823. #define SDRAM_SDTR2_RRD_MASK 0x0000000F
  824. #define SDRAM_SDTR2_RRD_2_CLK 0x00000002
  825. #define SDRAM_SDTR2_RRD_3_CLK 0x00000003
  826. /*
  827. * SDRAM SDTR3 Options
  828. */
  829. #define SDRAM_SDTR3_RAS_MASK 0x1F000000
  830. #define SDRAM_SDTR3_RAS_ENCODE(n) ((((u32)(n))&0x1F)<<24)
  831. #define SDRAM_SDTR3_RC_MASK 0x001F0000
  832. #define SDRAM_SDTR3_RC_ENCODE(n) ((((u32)(n))&0x1F)<<16)
  833. #define SDRAM_SDTR3_XCS_MASK 0x00001F00
  834. #define SDRAM_SDTR3_XCS 0x00000D00
  835. #define SDRAM_SDTR3_RFC_MASK 0x0000003F
  836. #define SDRAM_SDTR3_RFC_ENCODE(n) ((((u32)(n))&0x3F)<<0)
  837. /*
  838. * ECC Error Status
  839. */
  840. #define SDRAM_ECCES_MASK PPC_REG_VAL(21, 0x3FFFFF)
  841. #define SDRAM_ECCES_BNCE_MASK PPC_REG_VAL(15, 0xFFFF)
  842. #define SDRAM_ECCES_BNCE_ENCODE(lane) PPC_REG_VAL(((lane) & 0xF), 1)
  843. #define SDRAM_ECCES_CKBER_MASK PPC_REG_VAL(17, 0x3)
  844. #define SDRAM_ECCES_CKBER_NONE PPC_REG_VAL(17, 0)
  845. #define SDRAM_ECCES_CKBER_16_ECC_0_3 PPC_REG_VAL(17, 2)
  846. #define SDRAM_ECCES_CKBER_32_ECC_0_3 PPC_REG_VAL(17, 1)
  847. #define SDRAM_ECCES_CKBER_32_ECC_4_8 PPC_REG_VAL(17, 2)
  848. #define SDRAM_ECCES_CKBER_32_ECC_0_8 PPC_REG_VAL(17, 3)
  849. #define SDRAM_ECCES_CE PPC_REG_VAL(18, 1)
  850. #define SDRAM_ECCES_UE PPC_REG_VAL(19, 1)
  851. #define SDRAM_ECCES_BKNER_MASK PPC_REG_VAL(21, 0x3)
  852. #define SDRAM_ECCES_BK0ER PPC_REG_VAL(20, 1)
  853. #define SDRAM_ECCES_BK1ER PPC_REG_VAL(21, 1)
  854. /*
  855. * Memory Bank 0-1 configuration
  856. */
  857. #define SDRAM_BXCF_M_AM_MASK 0x00000F00 /* Addressing mode */
  858. #define SDRAM_BXCF_M_AM_0 0x00000000 /* Mode 0 */
  859. #define SDRAM_BXCF_M_AM_1 0x00000100 /* Mode 1 */
  860. #define SDRAM_BXCF_M_AM_2 0x00000200 /* Mode 2 */
  861. #define SDRAM_BXCF_M_AM_3 0x00000300 /* Mode 3 */
  862. #define SDRAM_BXCF_M_AM_4 0x00000400 /* Mode 4 */
  863. #define SDRAM_BXCF_M_AM_5 0x00000500 /* Mode 5 */
  864. #define SDRAM_BXCF_M_AM_6 0x00000600 /* Mode 6 */
  865. #define SDRAM_BXCF_M_AM_7 0x00000700 /* Mode 7 */
  866. #define SDRAM_BXCF_M_AM_8 0x00000800 /* Mode 8 */
  867. #define SDRAM_BXCF_M_AM_9 0x00000900 /* Mode 9 */
  868. #define SDRAM_BXCF_M_BE_MASK 0x00000001 /* Memory Bank Enable */
  869. #define SDRAM_BXCF_M_BE_DISABLE 0x00000000 /* Memory Bank Enable */
  870. #define SDRAM_BXCF_M_BE_ENABLE 0x00000001 /* Memory Bank Enable */
  871. #define SDRAM_RTSR_TRK1SM_MASK 0xC0000000 /* Tracking State Mach 1*/
  872. #define SDRAM_RTSR_TRK1SM_ATBASE 0x00000000 /* atbase state */
  873. #define SDRAM_RTSR_TRK1SM_MISSED 0x40000000 /* missed state */
  874. #define SDRAM_RTSR_TRK1SM_ATPLS1 0x80000000 /* atpls1 state */
  875. #define SDRAM_RTSR_TRK1SM_RESET 0xC0000000 /* reset state */
  876. #endif /* CONFIG_SDRAM_PPC4xx_IBM_DDR2 */
  877. #if defined(CONFIG_SDRAM_PPC4xx_DENALI_DDR2)
  878. /*
  879. * SDRAM Controller
  880. */
  881. #define DDR0_00 0x00
  882. #define DDR0_00_INT_ACK_MASK 0x7F000000 /* Write only */
  883. #define DDR0_00_INT_ACK_ALL 0x7F000000
  884. #define DDR0_00_INT_ACK_ENCODE(n) ((((u32)(n))&0x7F)<<24)
  885. #define DDR0_00_INT_ACK_DECODE(n) ((((u32)(n))>>24)&0x7F)
  886. /* Status */
  887. #define DDR0_00_INT_STATUS_MASK 0x00FF0000 /* Read only */
  888. /* Bit0. A single access outside the defined PHYSICAL memory space detected. */
  889. #define DDR0_00_INT_STATUS_BIT0 0x00010000
  890. /* Bit1. Multiple accesses outside the defined PHYSICAL memory space detected. */
  891. #define DDR0_00_INT_STATUS_BIT1 0x00020000
  892. /* Bit2. Single correctable ECC event detected */
  893. #define DDR0_00_INT_STATUS_BIT2 0x00040000
  894. /* Bit3. Multiple correctable ECC events detected. */
  895. #define DDR0_00_INT_STATUS_BIT3 0x00080000
  896. /* Bit4. Single uncorrectable ECC event detected. */
  897. #define DDR0_00_INT_STATUS_BIT4 0x00100000
  898. /* Bit5. Multiple uncorrectable ECC events detected. */
  899. #define DDR0_00_INT_STATUS_BIT5 0x00200000
  900. /* Bit6. DRAM initialization complete. */
  901. #define DDR0_00_INT_STATUS_BIT6 0x00400000
  902. /* Bit7. Logical OR of all lower bits. */
  903. #define DDR0_00_INT_STATUS_BIT7 0x00800000
  904. #define DDR0_00_INT_STATUS_ENCODE(n) ((((u32)(n))&0xFF)<<16)
  905. #define DDR0_00_INT_STATUS_DECODE(n) ((((u32)(n))>>16)&0xFF)
  906. #define DDR0_00_DLL_INCREMENT_MASK 0x00007F00
  907. #define DDR0_00_DLL_INCREMENT_ENCODE(n) ((((u32)(n))&0x7F)<<8)
  908. #define DDR0_00_DLL_INCREMENT_DECODE(n) ((((u32)(n))>>8)&0x7F)
  909. #define DDR0_00_DLL_START_POINT_MASK 0x0000007F
  910. #define DDR0_00_DLL_START_POINT_ENCODE(n) ((((u32)(n))&0x7F)<<0)
  911. #define DDR0_00_DLL_START_POINT_DECODE(n) ((((u32)(n))>>0)&0x7F)
  912. #define DDR0_01 0x01
  913. #define DDR0_01_PLB0_DB_CS_LOWER_MASK 0x1F000000
  914. #define DDR0_01_PLB0_DB_CS_LOWER_ENCODE(n) ((((u32)(n))&0x1F)<<24)
  915. #define DDR0_01_PLB0_DB_CS_LOWER_DECODE(n) ((((u32)(n))>>24)&0x1F)
  916. #define DDR0_01_PLB0_DB_CS_UPPER_MASK 0x001F0000
  917. #define DDR0_01_PLB0_DB_CS_UPPER_ENCODE(n) ((((u32)(n))&0x1F)<<16)
  918. #define DDR0_01_PLB0_DB_CS_UPPER_DECODE(n) ((((u32)(n))>>16)&0x1F)
  919. #define DDR0_01_OUT_OF_RANGE_TYPE_MASK 0x00000700 /* Read only */
  920. #define DDR0_01_OUT_OF_RANGE_TYPE_ENCODE(n) ((((u32)(n))&0x7)<<8)
  921. #define DDR0_01_OUT_OF_RANGE_TYPE_DECODE(n) ((((u32)(n))>>8)&0x7)
  922. #define DDR0_01_INT_MASK_MASK 0x000000FF
  923. #define DDR0_01_INT_MASK_ENCODE(n) ((((u32)(n))&0xFF)<<0)
  924. #define DDR0_01_INT_MASK_DECODE(n) ((((u32)(n))>>0)&0xFF)
  925. #define DDR0_01_INT_MASK_ALL_ON 0x000000FF
  926. #define DDR0_01_INT_MASK_ALL_OFF 0x00000000
  927. #define DDR0_02 0x02
  928. #define DDR0_02_MAX_CS_REG_MASK 0x02000000 /* Read only */
  929. #define DDR0_02_MAX_CS_REG_ENCODE(n) ((((u32)(n))&0x2)<<24)
  930. #define DDR0_02_MAX_CS_REG_DECODE(n) ((((u32)(n))>>24)&0x2)
  931. #define DDR0_02_MAX_COL_REG_MASK 0x000F0000 /* Read only */
  932. #define DDR0_02_MAX_COL_REG_ENCODE(n) ((((u32)(n))&0xF)<<16)
  933. #define DDR0_02_MAX_COL_REG_DECODE(n) ((((u32)(n))>>16)&0xF)
  934. #define DDR0_02_MAX_ROW_REG_MASK 0x00000F00 /* Read only */
  935. #define DDR0_02_MAX_ROW_REG_ENCODE(n) ((((u32)(n))&0xF)<<8)
  936. #define DDR0_02_MAX_ROW_REG_DECODE(n) ((((u32)(n))>>8)&0xF)
  937. #define DDR0_02_START_MASK 0x00000001
  938. #define DDR0_02_START_ENCODE(n) ((((u32)(n))&0x1)<<0)
  939. #define DDR0_02_START_DECODE(n) ((((u32)(n))>>0)&0x1)
  940. #define DDR0_02_START_OFF 0x00000000
  941. #define DDR0_02_START_ON 0x00000001
  942. #define DDR0_03 0x03
  943. #define DDR0_03_BSTLEN_MASK 0x07000000
  944. #define DDR0_03_BSTLEN_ENCODE(n) ((((u32)(n))&0x7)<<24)
  945. #define DDR0_03_BSTLEN_DECODE(n) ((((u32)(n))>>24)&0x7)
  946. #define DDR0_03_CASLAT_MASK 0x00070000
  947. #define DDR0_03_CASLAT_ENCODE(n) ((((u32)(n))&0x7)<<16)
  948. #define DDR0_03_CASLAT_DECODE(n) ((((u32)(n))>>16)&0x7)
  949. #define DDR0_03_CASLAT_LIN_MASK 0x00000F00
  950. #define DDR0_03_CASLAT_LIN_ENCODE(n) ((((u32)(n))&0xF)<<8)
  951. #define DDR0_03_CASLAT_LIN_DECODE(n) ((((u32)(n))>>8)&0xF)
  952. #define DDR0_03_INITAREF_MASK 0x0000000F
  953. #define DDR0_03_INITAREF_ENCODE(n) ((((u32)(n))&0xF)<<0)
  954. #define DDR0_03_INITAREF_DECODE(n) ((((u32)(n))>>0)&0xF)
  955. #define DDR0_04 0x04
  956. #define DDR0_04_TRC_MASK 0x1F000000
  957. #define DDR0_04_TRC_ENCODE(n) ((((u32)(n))&0x1F)<<24)
  958. #define DDR0_04_TRC_DECODE(n) ((((u32)(n))>>24)&0x1F)
  959. #define DDR0_04_TRRD_MASK 0x00070000
  960. #define DDR0_04_TRRD_ENCODE(n) ((((u32)(n))&0x7)<<16)
  961. #define DDR0_04_TRRD_DECODE(n) ((((u32)(n))>>16)&0x7)
  962. #define DDR0_04_TRTP_MASK 0x00000700
  963. #define DDR0_04_TRTP_ENCODE(n) ((((u32)(n))&0x7)<<8)
  964. #define DDR0_04_TRTP_DECODE(n) ((((u32)(n))>>8)&0x7)
  965. #define DDR0_05 0x05
  966. #define DDR0_05_TMRD_MASK 0x1F000000
  967. #define DDR0_05_TMRD_ENCODE(n) ((((u32)(n))&0x1F)<<24)
  968. #define DDR0_05_TMRD_DECODE(n) ((((u32)(n))>>24)&0x1F)
  969. #define DDR0_05_TEMRS_MASK 0x00070000
  970. #define DDR0_05_TEMRS_ENCODE(n) ((((u32)(n))&0x7)<<16)
  971. #define DDR0_05_TEMRS_DECODE(n) ((((u32)(n))>>16)&0x7)
  972. #define DDR0_05_TRP_MASK 0x00000F00
  973. #define DDR0_05_TRP_ENCODE(n) ((((u32)(n))&0xF)<<8)
  974. #define DDR0_05_TRP_DECODE(n) ((((u32)(n))>>8)&0xF)
  975. #define DDR0_05_TRAS_MIN_MASK 0x000000FF
  976. #define DDR0_05_TRAS_MIN_ENCODE(n) ((((u32)(n))&0xFF)<<0)
  977. #define DDR0_05_TRAS_MIN_DECODE(n) ((((u32)(n))>>0)&0xFF)
  978. #define DDR0_06 0x06
  979. #define DDR0_06_WRITEINTERP_MASK 0x01000000
  980. #define DDR0_06_WRITEINTERP_ENCODE(n) ((((u32)(n))&0x1)<<24)
  981. #define DDR0_06_WRITEINTERP_DECODE(n) ((((u32)(n))>>24)&0x1)
  982. #define DDR0_06_TWTR_MASK 0x00070000
  983. #define DDR0_06_TWTR_ENCODE(n) ((((u32)(n))&0x7)<<16)
  984. #define DDR0_06_TWTR_DECODE(n) ((((u32)(n))>>16)&0x7)
  985. #define DDR0_06_TDLL_MASK 0x0000FF00
  986. #define DDR0_06_TDLL_ENCODE(n) ((((u32)(n))&0xFF)<<8)
  987. #define DDR0_06_TDLL_DECODE(n) ((((u32)(n))>>8)&0xFF)
  988. #define DDR0_06_TRFC_MASK 0x0000007F
  989. #define DDR0_06_TRFC_ENCODE(n) ((((u32)(n))&0x7F)<<0)
  990. #define DDR0_06_TRFC_DECODE(n) ((((u32)(n))>>0)&0x7F)
  991. #define DDR0_07 0x07
  992. #define DDR0_07_NO_CMD_INIT_MASK 0x01000000
  993. #define DDR0_07_NO_CMD_INIT_ENCODE(n) ((((u32)(n))&0x1)<<24)
  994. #define DDR0_07_NO_CMD_INIT_DECODE(n) ((((u32)(n))>>24)&0x1)
  995. #define DDR0_07_TFAW_MASK 0x001F0000
  996. #define DDR0_07_TFAW_ENCODE(n) ((((u32)(n))&0x1F)<<16)
  997. #define DDR0_07_TFAW_DECODE(n) ((((u32)(n))>>16)&0x1F)
  998. #define DDR0_07_AUTO_REFRESH_MODE_MASK 0x00000100
  999. #define DDR0_07_AUTO_REFRESH_MODE_ENCODE(n) ((((u32)(n))&0x1)<<8)
  1000. #define DDR0_07_AUTO_REFRESH_MODE_DECODE(n) ((((u32)(n))>>8)&0x1)
  1001. #define DDR0_07_AREFRESH_MASK 0x00000001
  1002. #define DDR0_07_AREFRESH_ENCODE(n) ((((u32)(n))&0x1)<<0)
  1003. #define DDR0_07_AREFRESH_DECODE(n) ((((u32)(n))>>0)&0x1)
  1004. #define DDR0_08 0x08
  1005. #define DDR0_08_WRLAT_MASK 0x07000000
  1006. #define DDR0_08_WRLAT_ENCODE(n) ((((u32)(n))&0x7)<<24)
  1007. #define DDR0_08_WRLAT_DECODE(n) ((((u32)(n))>>24)&0x7)
  1008. #define DDR0_08_TCPD_MASK 0x00FF0000
  1009. #define DDR0_08_TCPD_ENCODE(n) ((((u32)(n))&0xFF)<<16)
  1010. #define DDR0_08_TCPD_DECODE(n) ((((u32)(n))>>16)&0xFF)
  1011. #define DDR0_08_DQS_N_EN_MASK 0x00000100
  1012. #define DDR0_08_DQS_N_EN_ENCODE(n) ((((u32)(n))&0x1)<<8)
  1013. #define DDR0_08_DQS_N_EN_DECODE(n) ((((u32)(n))>>8)&0x1)
  1014. #define DDR0_08_DDRII_SDRAM_MODE_MASK 0x00000001
  1015. #define DDR0_08_DDRII_ENCODE(n) ((((u32)(n))&0x1)<<0)
  1016. #define DDR0_08_DDRII_DECODE(n) ((((u32)(n))>>0)&0x1)
  1017. #define DDR0_09 0x09
  1018. #define DDR0_09_OCD_ADJUST_PDN_CS_0_MASK 0x1F000000
  1019. #define DDR0_09_OCD_ADJUST_PDN_CS_0_ENCODE(n) ((((u32)(n))&0x1F)<<24)
  1020. #define DDR0_09_OCD_ADJUST_PDN_CS_0_DECODE(n) ((((u32)(n))>>24)&0x1F)
  1021. #define DDR0_09_RTT_0_MASK 0x00030000
  1022. #define DDR0_09_RTT_0_ENCODE(n) ((((u32)(n))&0x3)<<16)
  1023. #define DDR0_09_RTT_0_DECODE(n) ((((u32)(n))>>16)&0x3)
  1024. #define DDR0_09_WR_DQS_SHIFT_BYPASS_MASK 0x00007F00
  1025. #define DDR0_09_WR_DQS_SHIFT_BYPASS_ENCODE(n) ((((u32)(n))&0x7F)<<8)
  1026. #define DDR0_09_WR_DQS_SHIFT_BYPASS_DECODE(n) ((((u32)(n))>>8)&0x7F)
  1027. #define DDR0_09_WR_DQS_SHIFT_MASK 0x0000007F
  1028. #define DDR0_09_WR_DQS_SHIFT_ENCODE(n) ((((u32)(n))&0x7F)<<0)
  1029. #define DDR0_09_WR_DQS_SHIFT_DECODE(n) ((((u32)(n))>>0)&0x7F)
  1030. #define DDR0_10 0x0A
  1031. #define DDR0_10_WRITE_MODEREG_MASK 0x00010000 /* Write only */
  1032. #define DDR0_10_WRITE_MODEREG_ENCODE(n) ((((u32)(n))&0x1)<<16)
  1033. #define DDR0_10_WRITE_MODEREG_DECODE(n) ((((u32)(n))>>16)&0x1)
  1034. #define DDR0_10_CS_MAP_MASK 0x00000300
  1035. #define DDR0_10_CS_MAP_NO_MEM 0x00000000
  1036. #define DDR0_10_CS_MAP_RANK0_INSTALLED 0x00000100
  1037. #define DDR0_10_CS_MAP_RANK1_INSTALLED 0x00000200
  1038. #define DDR0_10_CS_MAP_ENCODE(n) ((((u32)(n))&0x3)<<8)
  1039. #define DDR0_10_CS_MAP_DECODE(n) ((((u32)(n))>>8)&0x3)
  1040. #define DDR0_10_OCD_ADJUST_PUP_CS_0_MASK 0x0000001F
  1041. #define DDR0_10_OCD_ADJUST_PUP_CS_0_ENCODE(n) ((((u32)(n))&0x1F)<<0)
  1042. #define DDR0_10_OCD_ADJUST_PUP_CS_0_DECODE(n) ((((u32)(n))>>0)&0x1F)
  1043. #define DDR0_11 0x0B
  1044. #define DDR0_11_SREFRESH_MASK 0x01000000
  1045. #define DDR0_11_SREFRESH_ENCODE(n) ((((u32)(n))&0x1)<<24)
  1046. #define DDR0_11_SREFRESH_DECODE(n) ((((u32)(n))>>24)&0x1F)
  1047. #define DDR0_11_TXSNR_MASK 0x00FF0000
  1048. #define DDR0_11_TXSNR_ENCODE(n) ((((u32)(n))&0xFF)<<16)
  1049. #define DDR0_11_TXSNR_DECODE(n) ((((u32)(n))>>16)&0xFF)
  1050. #define DDR0_11_TXSR_MASK 0x0000FF00
  1051. #define DDR0_11_TXSR_ENCODE(n) ((((u32)(n))&0xFF)<<8)
  1052. #define DDR0_11_TXSR_DECODE(n) ((((u32)(n))>>8)&0xFF)
  1053. #define DDR0_12 0x0C
  1054. #define DDR0_12_TCKE_MASK 0x0000007
  1055. #define DDR0_12_TCKE_ENCODE(n) ((((u32)(n))&0x7)<<0)
  1056. #define DDR0_12_TCKE_DECODE(n) ((((u32)(n))>>0)&0x7)
  1057. #define DDR0_14 0x0E
  1058. #define DDR0_14_DLL_BYPASS_MODE_MASK 0x01000000
  1059. #define DDR0_14_DLL_BYPASS_MODE_ENCODE(n) ((((u32)(n))&0x1)<<24)
  1060. #define DDR0_14_DLL_BYPASS_MODE_DECODE(n) ((((u32)(n))>>24)&0x1)
  1061. #define DDR0_14_REDUC_MASK 0x00010000
  1062. #define DDR0_14_REDUC_64BITS 0x00000000
  1063. #define DDR0_14_REDUC_32BITS 0x00010000
  1064. #define DDR0_14_REDUC_ENCODE(n) ((((u32)(n))&0x1)<<16)
  1065. #define DDR0_14_REDUC_DECODE(n) ((((u32)(n))>>16)&0x1)
  1066. #define DDR0_14_REG_DIMM_ENABLE_MASK 0x00000100
  1067. #define DDR0_14_REG_DIMM_ENABLE_ENCODE(n) ((((u32)(n))&0x1)<<8)
  1068. #define DDR0_14_REG_DIMM_ENABLE_DECODE(n) ((((u32)(n))>>8)&0x1)
  1069. #define DDR0_17 0x11
  1070. #define DDR0_17_DLL_DQS_DELAY_0_MASK 0x7F000000
  1071. #define DDR0_17_DLL_DQS_DELAY_0_ENCODE(n) ((((u32)(n))&0x7F)<<24)
  1072. #define DDR0_17_DLL_DQS_DELAY_0_DECODE(n) ((((u32)(n))>>24)&0x7F)
  1073. #define DDR0_17_DLLLOCKREG_MASK 0x00010000 /* Read only */
  1074. #define DDR0_17_DLLLOCKREG_LOCKED 0x00010000
  1075. #define DDR0_17_DLLLOCKREG_UNLOCKED 0x00000000
  1076. #define DDR0_17_DLLLOCKREG_ENCODE(n) ((((u32)(n))&0x1)<<16)
  1077. #define DDR0_17_DLLLOCKREG_DECODE(n) ((((u32)(n))>>16)&0x1)
  1078. #define DDR0_17_DLL_LOCK_MASK 0x00007F00 /* Read only */
  1079. #define DDR0_17_DLL_LOCK_ENCODE(n) ((((u32)(n))&0x7F)<<8)
  1080. #define DDR0_17_DLL_LOCK_DECODE(n) ((((u32)(n))>>8)&0x7F)
  1081. #define DDR0_18 0x12
  1082. #define DDR0_18_DLL_DQS_DELAY_X_MASK 0x7F7F7F7F
  1083. #define DDR0_18_DLL_DQS_DELAY_4_MASK 0x7F000000
  1084. #define DDR0_18_DLL_DQS_DELAY_4_ENCODE(n) ((((u32)(n))&0x7F)<<24)
  1085. #define DDR0_18_DLL_DQS_DELAY_4_DECODE(n) ((((u32)(n))>>24)&0x7F)
  1086. #define DDR0_18_DLL_DQS_DELAY_3_MASK 0x007F0000
  1087. #define DDR0_18_DLL_DQS_DELAY_3_ENCODE(n) ((((u32)(n))&0x7F)<<16)
  1088. #define DDR0_18_DLL_DQS_DELAY_3_DECODE(n) ((((u32)(n))>>16)&0x7F)
  1089. #define DDR0_18_DLL_DQS_DELAY_2_MASK 0x00007F00
  1090. #define DDR0_18_DLL_DQS_DELAY_2_ENCODE(n) ((((u32)(n))&0x7F)<<8)
  1091. #define DDR0_18_DLL_DQS_DELAY_2_DECODE(n) ((((u32)(n))>>8)&0x7F)
  1092. #define DDR0_18_DLL_DQS_DELAY_1_MASK 0x0000007F
  1093. #define DDR0_18_DLL_DQS_DELAY_1_ENCODE(n) ((((u32)(n))&0x7F)<<0)
  1094. #define DDR0_18_DLL_DQS_DELAY_1_DECODE(n) ((((u32)(n))>>0)&0x7F)
  1095. #define DDR0_19 0x13
  1096. #define DDR0_19_DLL_DQS_DELAY_X_MASK 0x7F7F7F7F
  1097. #define DDR0_19_DLL_DQS_DELAY_8_MASK 0x7F000000
  1098. #define DDR0_19_DLL_DQS_DELAY_8_ENCODE(n) ((((u32)(n))&0x7F)<<24)
  1099. #define DDR0_19_DLL_DQS_DELAY_8_DECODE(n) ((((u32)(n))>>24)&0x7F)
  1100. #define DDR0_19_DLL_DQS_DELAY_7_MASK 0x007F0000
  1101. #define DDR0_19_DLL_DQS_DELAY_7_ENCODE(n) ((((u32)(n))&0x7F)<<16)
  1102. #define DDR0_19_DLL_DQS_DELAY_7_DECODE(n) ((((u32)(n))>>16)&0x7F)
  1103. #define DDR0_19_DLL_DQS_DELAY_6_MASK 0x00007F00
  1104. #define DDR0_19_DLL_DQS_DELAY_6_ENCODE(n) ((((u32)(n))&0x7F)<<8)
  1105. #define DDR0_19_DLL_DQS_DELAY_6_DECODE(n) ((((u32)(n))>>8)&0x7F)
  1106. #define DDR0_19_DLL_DQS_DELAY_5_MASK 0x0000007F
  1107. #define DDR0_19_DLL_DQS_DELAY_5_ENCODE(n) ((((u32)(n))&0x7F)<<0)
  1108. #define DDR0_19_DLL_DQS_DELAY_5_DECODE(n) ((((u32)(n))>>0)&0x7F)
  1109. #define DDR0_20 0x14
  1110. #define DDR0_20_DLL_DQS_BYPASS_3_MASK 0x7F000000
  1111. #define DDR0_20_DLL_DQS_BYPASS_3_ENCODE(n) ((((u32)(n))&0x7F)<<24)
  1112. #define DDR0_20_DLL_DQS_BYPASS_3_DECODE(n) ((((u32)(n))>>24)&0x7F)
  1113. #define DDR0_20_DLL_DQS_BYPASS_2_MASK 0x007F0000
  1114. #define DDR0_20_DLL_DQS_BYPASS_2_ENCODE(n) ((((u32)(n))&0x7F)<<16)
  1115. #define DDR0_20_DLL_DQS_BYPASS_2_DECODE(n) ((((u32)(n))>>16)&0x7F)
  1116. #define DDR0_20_DLL_DQS_BYPASS_1_MASK 0x00007F00
  1117. #define DDR0_20_DLL_DQS_BYPASS_1_ENCODE(n) ((((u32)(n))&0x7F)<<8)
  1118. #define DDR0_20_DLL_DQS_BYPASS_1_DECODE(n) ((((u32)(n))>>8)&0x7F)
  1119. #define DDR0_20_DLL_DQS_BYPASS_0_MASK 0x0000007F
  1120. #define DDR0_20_DLL_DQS_BYPASS_0_ENCODE(n) ((((u32)(n))&0x7F)<<0)
  1121. #define DDR0_20_DLL_DQS_BYPASS_0_DECODE(n) ((((u32)(n))>>0)&0x7F)
  1122. #define DDR0_21 0x15
  1123. #define DDR0_21_DLL_DQS_BYPASS_7_MASK 0x7F000000
  1124. #define DDR0_21_DLL_DQS_BYPASS_7_ENCODE(n) ((((u32)(n))&0x7F)<<24)
  1125. #define DDR0_21_DLL_DQS_BYPASS_7_DECODE(n) ((((u32)(n))>>24)&0x7F)
  1126. #define DDR0_21_DLL_DQS_BYPASS_6_MASK 0x007F0000
  1127. #define DDR0_21_DLL_DQS_BYPASS_6_ENCODE(n) ((((u32)(n))&0x7F)<<16)
  1128. #define DDR0_21_DLL_DQS_BYPASS_6_DECODE(n) ((((u32)(n))>>16)&0x7F)
  1129. #define DDR0_21_DLL_DQS_BYPASS_5_MASK 0x00007F00
  1130. #define DDR0_21_DLL_DQS_BYPASS_5_ENCODE(n) ((((u32)(n))&0x7F)<<8)
  1131. #define DDR0_21_DLL_DQS_BYPASS_5_DECODE(n) ((((u32)(n))>>8)&0x7F)
  1132. #define DDR0_21_DLL_DQS_BYPASS_4_MASK 0x0000007F
  1133. #define DDR0_21_DLL_DQS_BYPASS_4_ENCODE(n) ((((u32)(n))&0x7F)<<0)
  1134. #define DDR0_21_DLL_DQS_BYPASS_4_DECODE(n) ((((u32)(n))>>0)&0x7F)
  1135. #define DDR0_22 0x16
  1136. #define DDR0_22_CTRL_RAW_MASK 0x03000000
  1137. #define DDR0_22_CTRL_RAW_ECC_DISABLE 0x00000000
  1138. #define DDR0_22_CTRL_RAW_ECC_CHECK_ONLY 0x01000000
  1139. #define DDR0_22_CTRL_RAW_NO_ECC_RAM 0x02000000
  1140. #define DDR0_22_CTRL_RAW_ECC_ENABLE 0x03000000
  1141. #define DDR0_22_CTRL_RAW_ENCODE(n) ((((u32)(n))&0x3)<<24)
  1142. #define DDR0_22_CTRL_RAW_DECODE(n) ((((u32)(n))>>24)&0x3)
  1143. #define DDR0_22_DQS_OUT_SHIFT_BYPASS_MASK 0x007F0000
  1144. #define DDR0_22_DQS_OUT_SHIFT_BYPASS_ENCODE(n) ((((u32)(n))&0x7F)<<16)
  1145. #define DDR0_22_DQS_OUT_SHIFT_BYPASS_DECODE(n) ((((u32)(n))>>16)&0x7F)
  1146. #define DDR0_22_DQS_OUT_SHIFT_MASK 0x00007F00
  1147. #define DDR0_22_DQS_OUT_SHIFT_ENCODE(n) ((((u32)(n))&0x7F)<<8)
  1148. #define DDR0_22_DQS_OUT_SHIFT_DECODE(n) ((((u32)(n))>>8)&0x7F)
  1149. #define DDR0_22_DLL_DQS_BYPASS_8_MASK 0x0000007F
  1150. #define DDR0_22_DLL_DQS_BYPASS_8_ENCODE(n) ((((u32)(n))&0x7F)<<0)
  1151. #define DDR0_22_DLL_DQS_BYPASS_8_DECODE(n) ((((u32)(n))>>0)&0x7F)
  1152. #define DDR0_23 0x17
  1153. #define DDR0_23_ODT_RD_MAP_CS0_MASK 0x03000000
  1154. #define DDR0_23_ODT_RD_MAP_CS0_ENCODE(n) ((((u32)(n))&0x3)<<24)
  1155. #define DDR0_23_ODT_RD_MAP_CS0_DECODE(n) ((((u32)(n))>>24)&0x3)
  1156. #define DDR0_23_ECC_C_SYND_MASK 0x00FF0000 /* Read only */
  1157. #define DDR0_23_ECC_C_SYND_ENCODE(n) ((((u32)(n))&0xFF)<<16)
  1158. #define DDR0_23_ECC_C_SYND_DECODE(n) ((((u32)(n))>>16)&0xFF)
  1159. #define DDR0_23_ECC_U_SYND_MASK 0x0000FF00 /* Read only */
  1160. #define DDR0_23_ECC_U_SYND_ENCODE(n) ((((u32)(n))&0xFF)<<8)
  1161. #define DDR0_23_ECC_U_SYND_DECODE(n) ((((u32)(n))>>8)&0xFF)
  1162. #define DDR0_23_FWC_MASK 0x00000001 /* Write only */
  1163. #define DDR0_23_FWC_ENCODE(n) ((((u32)(n))&0x1)<<0)
  1164. #define DDR0_23_FWC_DECODE(n) ((((u32)(n))>>0)&0x1)
  1165. #define DDR0_24 0x18
  1166. #define DDR0_24_RTT_PAD_TERMINATION_MASK 0x03000000
  1167. #define DDR0_24_RTT_PAD_TERMINATION_ENCODE(n) ((((u32)(n))&0x3)<<24)
  1168. #define DDR0_24_RTT_PAD_TERMINATION_DECODE(n) ((((u32)(n))>>24)&0x3)
  1169. #define DDR0_24_ODT_WR_MAP_CS1_MASK 0x00030000
  1170. #define DDR0_24_ODT_WR_MAP_CS1_ENCODE(n) ((((u32)(n))&0x3)<<16)
  1171. #define DDR0_24_ODT_WR_MAP_CS1_DECODE(n) ((((u32)(n))>>16)&0x3)
  1172. #define DDR0_24_ODT_RD_MAP_CS1_MASK 0x00000300
  1173. #define DDR0_24_ODT_RD_MAP_CS1_ENCODE(n) ((((u32)(n))&0x3)<<8)
  1174. #define DDR0_24_ODT_RD_MAP_CS1_DECODE(n) ((((u32)(n))>>8)&0x3)
  1175. #define DDR0_24_ODT_WR_MAP_CS0_MASK 0x00000003
  1176. #define DDR0_24_ODT_WR_MAP_CS0_ENCODE(n) ((((u32)(n))&0x3)<<0)
  1177. #define DDR0_24_ODT_WR_MAP_CS0_DECODE(n) ((((u32)(n))>>0)&0x3)
  1178. #define DDR0_25 0x19
  1179. #define DDR0_25_VERSION_MASK 0xFFFF0000 /* Read only */
  1180. #define DDR0_25_VERSION_ENCODE(n) ((((u32)(n))&0xFFFF)<<16)
  1181. #define DDR0_25_VERSION_DECODE(n) ((((u32)(n))>>16)&0xFFFF)
  1182. #define DDR0_25_OUT_OF_RANGE_LENGTH_MASK 0x000003FF /* Read only */
  1183. #define DDR0_25_OUT_OF_RANGE_LENGTH_ENCODE(n) ((((u32)(n))&0x3FF)<<0)
  1184. #define DDR0_25_OUT_OF_RANGE_LENGTH_DECODE(n) ((((u32)(n))>>0)&0x3FF)
  1185. #define DDR0_26 0x1A
  1186. #define DDR0_26_TRAS_MAX_MASK 0xFFFF0000
  1187. #define DDR0_26_TRAS_MAX_ENCODE(n) ((((u32)(n))&0xFFFF)<<16)
  1188. #define DDR0_26_TRAS_MAX_DECODE(n) ((((u32)(n))>>16)&0xFFFF)
  1189. #define DDR0_26_TREF_MASK 0x00003FFF
  1190. #define DDR0_26_TREF_ENCODE(n) ((((u32)(n))&0x3FFF)<<0)
  1191. #define DDR0_26_TREF_DECODE(n) ((((u32)(n))>>0)&0x3FFF)
  1192. #define DDR0_27 0x1B
  1193. #define DDR0_27_EMRS_DATA_MASK 0x3FFF0000
  1194. #define DDR0_27_EMRS_DATA_ENCODE(n) ((((u32)(n))&0x3FFF)<<16)
  1195. #define DDR0_27_EMRS_DATA_DECODE(n) ((((u32)(n))>>16)&0x3FFF)
  1196. #define DDR0_27_TINIT_MASK 0x0000FFFF
  1197. #define DDR0_27_TINIT_ENCODE(n) ((((u32)(n))&0xFFFF)<<0)
  1198. #define DDR0_27_TINIT_DECODE(n) ((((u32)(n))>>0)&0xFFFF)
  1199. #define DDR0_28 0x1C
  1200. #define DDR0_28_EMRS3_DATA_MASK 0x3FFF0000
  1201. #define DDR0_28_EMRS3_DATA_ENCODE(n) ((((u32)(n))&0x3FFF)<<16)
  1202. #define DDR0_28_EMRS3_DATA_DECODE(n) ((((u32)(n))>>16)&0x3FFF)
  1203. #define DDR0_28_EMRS2_DATA_MASK 0x00003FFF
  1204. #define DDR0_28_EMRS2_DATA_ENCODE(n) ((((u32)(n))&0x3FFF)<<0)
  1205. #define DDR0_28_EMRS2_DATA_DECODE(n) ((((u32)(n))>>0)&0x3FFF)
  1206. #define DDR0_31 0x1F
  1207. #define DDR0_31_XOR_CHECK_BITS_MASK 0x0000FFFF
  1208. #define DDR0_31_XOR_CHECK_BITS_ENCODE(n) ((((u32)(n))&0xFFFF)<<0)
  1209. #define DDR0_31_XOR_CHECK_BITS_DECODE(n) ((((u32)(n))>>0)&0xFFFF)
  1210. #define DDR0_32 0x20
  1211. #define DDR0_32_OUT_OF_RANGE_ADDR_MASK 0xFFFFFFFF /* Read only */
  1212. #define DDR0_32_OUT_OF_RANGE_ADDR_ENCODE(n) ((((u32)(n))&0xFFFFFFFF)<<0)
  1213. #define DDR0_32_OUT_OF_RANGE_ADDR_DECODE(n) ((((u32)(n))>>0)&0xFFFFFFFF)
  1214. #define DDR0_33 0x21
  1215. #define DDR0_33_OUT_OF_RANGE_ADDR_MASK 0x00000001 /* Read only */
  1216. #define DDR0_33_OUT_OF_RANGE_ADDR_ENCODE(n) ((((u32)(n))&0x1)<<0)
  1217. #define DDR0_33_OUT_OF_RANGE_ADDR_DECODE(n) ((((u32)(n))>>0)&0x1)
  1218. #define DDR0_34 0x22
  1219. #define DDR0_34_ECC_U_ADDR_MASK 0xFFFFFFFF /* Read only */
  1220. #define DDR0_34_ECC_U_ADDR_ENCODE(n) ((((u32)(n))&0xFFFFFFFF)<<0)
  1221. #define DDR0_34_ECC_U_ADDR_DECODE(n) ((((u32)(n))>>0)&0xFFFFFFFF)
  1222. #define DDR0_35 0x23
  1223. #define DDR0_35_ECC_U_ADDR_MASK 0x00000001 /* Read only */
  1224. #define DDR0_35_ECC_U_ADDR_ENCODE(n) ((((u32)(n))&0x1)<<0)
  1225. #define DDR0_35_ECC_U_ADDR_DECODE(n) ((((u32)(n))>>0)&0x1)
  1226. #define DDR0_36 0x24
  1227. #define DDR0_36_ECC_U_DATA_MASK 0xFFFFFFFF /* Read only */
  1228. #define DDR0_36_ECC_U_DATA_ENCODE(n) ((((u32)(n))&0xFFFFFFFF)<<0)
  1229. #define DDR0_36_ECC_U_DATA_DECODE(n) ((((u32)(n))>>0)&0xFFFFFFFF)
  1230. #define DDR0_37 0x25
  1231. #define DDR0_37_ECC_U_DATA_MASK 0xFFFFFFFF /* Read only */
  1232. #define DDR0_37_ECC_U_DATA_ENCODE(n) ((((u32)(n))&0xFFFFFFFF)<<0)
  1233. #define DDR0_37_ECC_U_DATA_DECODE(n) ((((u32)(n))>>0)&0xFFFFFFFF)
  1234. #define DDR0_38 0x26
  1235. #define DDR0_38_ECC_C_ADDR_MASK 0xFFFFFFFF /* Read only */
  1236. #define DDR0_38_ECC_C_ADDR_ENCODE(n) ((((u32)(n))&0xFFFFFFFF)<<0)
  1237. #define DDR0_38_ECC_C_ADDR_DECODE(n) ((((u32)(n))>>0)&0xFFFFFFFF)
  1238. #define DDR0_39 0x27
  1239. #define DDR0_39_ECC_C_ADDR_MASK 0x00000001 /* Read only */
  1240. #define DDR0_39_ECC_C_ADDR_ENCODE(n) ((((u32)(n))&0x1)<<0)
  1241. #define DDR0_39_ECC_C_ADDR_DECODE(n) ((((u32)(n))>>0)&0x1)
  1242. #define DDR0_40 0x28
  1243. #define DDR0_40_ECC_C_DATA_MASK 0xFFFFFFFF /* Read only */
  1244. #define DDR0_40_ECC_C_DATA_ENCODE(n) ((((u32)(n))&0xFFFFFFFF)<<0)
  1245. #define DDR0_40_ECC_C_DATA_DECODE(n) ((((u32)(n))>>0)&0xFFFFFFFF)
  1246. #define DDR0_41 0x29
  1247. #define DDR0_41_ECC_C_DATA_MASK 0xFFFFFFFF /* Read only */
  1248. #define DDR0_41_ECC_C_DATA_ENCODE(n) ((((u32)(n))&0xFFFFFFFF)<<0)
  1249. #define DDR0_41_ECC_C_DATA_DECODE(n) ((((u32)(n))>>0)&0xFFFFFFFF)
  1250. #define DDR0_42 0x2A
  1251. #define DDR0_42_ADDR_PINS_MASK 0x07000000
  1252. #define DDR0_42_ADDR_PINS_ENCODE(n) ((((u32)(n))&0x7)<<24)
  1253. #define DDR0_42_ADDR_PINS_DECODE(n) ((((u32)(n))>>24)&0x7)
  1254. #define DDR0_42_CASLAT_LIN_GATE_MASK 0x0000000F
  1255. #define DDR0_42_CASLAT_LIN_GATE_ENCODE(n) ((((u32)(n))&0xF)<<0)
  1256. #define DDR0_42_CASLAT_LIN_GATE_DECODE(n) ((((u32)(n))>>0)&0xF)
  1257. #define DDR0_43 0x2B
  1258. #define DDR0_43_TWR_MASK 0x07000000
  1259. #define DDR0_43_TWR_ENCODE(n) ((((u32)(n))&0x7)<<24)
  1260. #define DDR0_43_TWR_DECODE(n) ((((u32)(n))>>24)&0x7)
  1261. #define DDR0_43_APREBIT_MASK 0x000F0000
  1262. #define DDR0_43_APREBIT_ENCODE(n) ((((u32)(n))&0xF)<<16)
  1263. #define DDR0_43_APREBIT_DECODE(n) ((((u32)(n))>>16)&0xF)
  1264. #define DDR0_43_COLUMN_SIZE_MASK 0x00000700
  1265. #define DDR0_43_COLUMN_SIZE_ENCODE(n) ((((u32)(n))&0x7)<<8)
  1266. #define DDR0_43_COLUMN_SIZE_DECODE(n) ((((u32)(n))>>8)&0x7)
  1267. #define DDR0_43_EIGHT_BANK_MODE_MASK 0x00000001
  1268. #define DDR0_43_EIGHT_BANK_MODE_8_BANKS 0x00000001
  1269. #define DDR0_43_EIGHT_BANK_MODE_4_BANKS 0x00000000
  1270. #define DDR0_43_EIGHT_BANK_MODE_ENCODE(n) ((((u32)(n))&0x1)<<0)
  1271. #define DDR0_43_EIGHT_BANK_MODE_DECODE(n) ((((u32)(n))>>0)&0x1)
  1272. #define DDR0_44 0x2C
  1273. #define DDR0_44_TRCD_MASK 0x000000FF
  1274. #define DDR0_44_TRCD_ENCODE(n) ((((u32)(n))&0xFF)<<0)
  1275. #define DDR0_44_TRCD_DECODE(n) ((((u32)(n))>>0)&0xFF)
  1276. #endif /* CONFIG_SDRAM_PPC4xx_DENALI_DDR2 */
  1277. #ifndef __ASSEMBLY__
  1278. struct sdram_timing {
  1279. u32 wrdtr;
  1280. u32 clktr;
  1281. };
  1282. /*
  1283. * Prototypes
  1284. */
  1285. void ppc4xx_ibm_ddr2_register_dump(void);
  1286. u32 mfdcr_any(u32);
  1287. void mtdcr_any(u32, u32);
  1288. u32 ddr_wrdtr(u32);
  1289. u32 ddr_clktr(u32);
  1290. void spd_ddr_init_hang(void);
  1291. u32 DQS_autocalibration(void);
  1292. phys_size_t sdram_memsize(void);
  1293. void dcbz_area(u32 start_address, u32 num_bytes);
  1294. #endif /* __ASSEMBLY__ */
  1295. #endif /* _PPC4xx_SDRAM_H_ */