ppc4xx-sdram.h 51 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161
  1. /*
  2. * (C) Copyright 2008
  3. * Stefan Roese, DENX Software Engineering, sr@denx.de.
  4. *
  5. * See file CREDITS for list of people who contributed to this
  6. * project.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  21. * MA 02111-1307 USA
  22. */
  23. #ifndef _PPC4xx_SDRAM_H_
  24. #define _PPC4xx_SDRAM_H_
  25. #if defined(CONFIG_SDRAM_PPC4xx_IBM_SDRAM)
  26. /*
  27. * SDRAM Controller
  28. */
  29. /*
  30. * XXX - ToDo: Revisit file to change all these lower case defines into
  31. * upper case. Also needs to be done in the controller setup code too
  32. * of course. sr, 2008-06-02
  33. */
  34. #ifndef CONFIG_405EP
  35. #define mem_besra 0x00 /* bus error syndrome reg a */
  36. #define mem_besrsa 0x04 /* bus error syndrome reg set a */
  37. #define mem_besrb 0x08 /* bus error syndrome reg b */
  38. #define mem_besrsb 0x0c /* bus error syndrome reg set b */
  39. #define mem_bear 0x10 /* bus error address reg */
  40. #endif
  41. #define mem_mcopt1 0x20 /* memory controller options 1 */
  42. #define mem_status 0x24 /* memory status */
  43. #define mem_rtr 0x30 /* refresh timer reg */
  44. #define mem_pmit 0x34 /* power management idle timer */
  45. #define mem_mb0cf 0x40 /* memory bank 0 configuration */
  46. #define mem_mb1cf 0x44 /* memory bank 1 configuration */
  47. #ifndef CONFIG_405EP
  48. #define mem_mb2cf 0x48 /* memory bank 2 configuration */
  49. #define mem_mb3cf 0x4c /* memory bank 3 configuration */
  50. #endif
  51. #define mem_sdtr1 0x80 /* timing reg 1 */
  52. #ifndef CONFIG_405EP
  53. #define mem_ecccf 0x94 /* ECC configuration */
  54. #define mem_eccerr 0x98 /* ECC error status */
  55. #endif
  56. #endif /* CONFIG_SDRAM_PPC4xx_IBM_SDRAM */
  57. #if defined(CONFIG_SDRAM_PPC4xx_IBM_DDR)
  58. /*
  59. * Memory controller registers
  60. */
  61. #define SDRAM_CFG0 0x20 /* memory controller options 0 */
  62. #define SDRAM_CFG1 0x21 /* memory controller options 1 */
  63. /*
  64. * XXX - ToDo: Revisit file to change all these lower case defines into
  65. * upper case. Also needs to be done in the controller setup code too
  66. * of course. sr, 2008-06-02
  67. */
  68. #define mem_besr0_clr 0x0000 /* bus error status reg 0 (clr) */
  69. #define mem_besr0_set 0x0004 /* bus error status reg 0 (set) */
  70. #define mem_besr1_clr 0x0008 /* bus error status reg 1 (clr) */
  71. #define mem_besr1_set 0x000c /* bus error status reg 1 (set) */
  72. #define mem_bear 0x0010 /* bus error address reg */
  73. #define mem_mirq_clr 0x0011 /* bus master interrupt (clr) */
  74. #define mem_mirq_set 0x0012 /* bus master interrupt (set) */
  75. #define mem_slio 0x0018 /* ddr sdram slave interface options */
  76. #define mem_cfg0 0x0020 /* ddr sdram options 0 */
  77. #define mem_cfg1 0x0021 /* ddr sdram options 1 */
  78. #define mem_devopt 0x0022 /* ddr sdram device options */
  79. #define mem_mcsts 0x0024 /* memory controller status */
  80. #define mem_rtr 0x0030 /* refresh timer register */
  81. #define mem_pmit 0x0034 /* power management idle timer */
  82. #define mem_uabba 0x0038 /* plb UABus base address */
  83. #define mem_b0cr 0x0040 /* ddr sdram bank 0 configuration */
  84. #define mem_b1cr 0x0044 /* ddr sdram bank 1 configuration */
  85. #define mem_b2cr 0x0048 /* ddr sdram bank 2 configuration */
  86. #define mem_b3cr 0x004c /* ddr sdram bank 3 configuration */
  87. #define mem_tr0 0x0080 /* sdram timing register 0 */
  88. #define mem_tr1 0x0081 /* sdram timing register 1 */
  89. #define mem_clktr 0x0082 /* ddr clock timing register */
  90. #define mem_wddctr 0x0083 /* write data/dm/dqs clock timing reg */
  91. #define mem_dlycal 0x0084 /* delay line calibration register */
  92. #define mem_eccesr 0x0098 /* ECC error status */
  93. /*
  94. * Memory Controller Options 0
  95. */
  96. #define SDRAM_CFG0_DCEN 0x80000000 /* SDRAM Controller Enable */
  97. #define SDRAM_CFG0_MCHK_MASK 0x30000000 /* Memory data errchecking mask */
  98. #define SDRAM_CFG0_MCHK_NON 0x00000000 /* No ECC generation */
  99. #define SDRAM_CFG0_MCHK_GEN 0x20000000 /* ECC generation */
  100. #define SDRAM_CFG0_MCHK_CHK 0x30000000 /* ECC generation and checking */
  101. #define SDRAM_CFG0_RDEN 0x08000000 /* Registered DIMM enable */
  102. #define SDRAM_CFG0_PMUD 0x04000000 /* Page management unit */
  103. #define SDRAM_CFG0_DMWD_MASK 0x02000000 /* DRAM width mask */
  104. #define SDRAM_CFG0_DMWD_32 0x00000000 /* 32 bits */
  105. #define SDRAM_CFG0_DMWD_64 0x02000000 /* 64 bits */
  106. #define SDRAM_CFG0_UIOS_MASK 0x00C00000 /* Unused IO State */
  107. #define SDRAM_CFG0_PDP 0x00200000 /* Page deallocation policy */
  108. /*
  109. * Memory Controller Options 1
  110. */
  111. #define SDRAM_CFG1_SRE 0x80000000 /* Self-Refresh Entry */
  112. #define SDRAM_CFG1_PMEN 0x40000000 /* Power Management Enable */
  113. /*
  114. * SDRAM DEVPOT Options
  115. */
  116. #define SDRAM_DEVOPT_DLL 0x80000000
  117. #define SDRAM_DEVOPT_DS 0x40000000
  118. /*
  119. * SDRAM MCSTS Options
  120. */
  121. #define SDRAM_MCSTS_MRSC 0x80000000
  122. #define SDRAM_MCSTS_SRMS 0x40000000
  123. #define SDRAM_MCSTS_CIS 0x20000000
  124. /*
  125. * SDRAM Refresh Timer Register
  126. */
  127. #define SDRAM_RTR_RINT_MASK 0xFFFF0000
  128. #define SDRAM_RTR_RINT_ENCODE(n) (((n) << 16) & SDRAM_RTR_RINT_MASK)
  129. /*
  130. * SDRAM UABus Base Address Reg
  131. */
  132. #define SDRAM_UABBA_UBBA_MASK 0x0000000F
  133. /*
  134. * Memory Bank 0-7 configuration
  135. */
  136. #define SDRAM_BXCR_SDBA_MASK 0xff800000 /* Base address */
  137. #define SDRAM_BXCR_SDSZ_MASK 0x000e0000 /* Size */
  138. #define SDRAM_BXCR_SDSZ_8 0x00020000 /* 8M */
  139. #define SDRAM_BXCR_SDSZ_16 0x00040000 /* 16M */
  140. #define SDRAM_BXCR_SDSZ_32 0x00060000 /* 32M */
  141. #define SDRAM_BXCR_SDSZ_64 0x00080000 /* 64M */
  142. #define SDRAM_BXCR_SDSZ_128 0x000a0000 /* 128M */
  143. #define SDRAM_BXCR_SDSZ_256 0x000c0000 /* 256M */
  144. #define SDRAM_BXCR_SDSZ_512 0x000e0000 /* 512M */
  145. #define SDRAM_BXCR_SDAM_MASK 0x0000e000 /* Addressing mode */
  146. #define SDRAM_BXCR_SDAM_1 0x00000000 /* Mode 1 */
  147. #define SDRAM_BXCR_SDAM_2 0x00002000 /* Mode 2 */
  148. #define SDRAM_BXCR_SDAM_3 0x00004000 /* Mode 3 */
  149. #define SDRAM_BXCR_SDAM_4 0x00006000 /* Mode 4 */
  150. #define SDRAM_BXCR_SDBE 0x00000001 /* Memory Bank Enable */
  151. /*
  152. * SDRAM TR0 Options
  153. */
  154. #define SDRAM_TR0_SDWR_MASK 0x80000000
  155. #define SDRAM_TR0_SDWR_2_CLK 0x00000000
  156. #define SDRAM_TR0_SDWR_3_CLK 0x80000000
  157. #define SDRAM_TR0_SDWD_MASK 0x40000000
  158. #define SDRAM_TR0_SDWD_0_CLK 0x00000000
  159. #define SDRAM_TR0_SDWD_1_CLK 0x40000000
  160. #define SDRAM_TR0_SDCL_MASK 0x01800000
  161. #define SDRAM_TR0_SDCL_2_0_CLK 0x00800000
  162. #define SDRAM_TR0_SDCL_2_5_CLK 0x01000000
  163. #define SDRAM_TR0_SDCL_3_0_CLK 0x01800000
  164. #define SDRAM_TR0_SDPA_MASK 0x000C0000
  165. #define SDRAM_TR0_SDPA_2_CLK 0x00040000
  166. #define SDRAM_TR0_SDPA_3_CLK 0x00080000
  167. #define SDRAM_TR0_SDPA_4_CLK 0x000C0000
  168. #define SDRAM_TR0_SDCP_MASK 0x00030000
  169. #define SDRAM_TR0_SDCP_2_CLK 0x00000000
  170. #define SDRAM_TR0_SDCP_3_CLK 0x00010000
  171. #define SDRAM_TR0_SDCP_4_CLK 0x00020000
  172. #define SDRAM_TR0_SDCP_5_CLK 0x00030000
  173. #define SDRAM_TR0_SDLD_MASK 0x0000C000
  174. #define SDRAM_TR0_SDLD_1_CLK 0x00000000
  175. #define SDRAM_TR0_SDLD_2_CLK 0x00004000
  176. #define SDRAM_TR0_SDRA_MASK 0x0000001C
  177. #define SDRAM_TR0_SDRA_6_CLK 0x00000000
  178. #define SDRAM_TR0_SDRA_7_CLK 0x00000004
  179. #define SDRAM_TR0_SDRA_8_CLK 0x00000008
  180. #define SDRAM_TR0_SDRA_9_CLK 0x0000000C
  181. #define SDRAM_TR0_SDRA_10_CLK 0x00000010
  182. #define SDRAM_TR0_SDRA_11_CLK 0x00000014
  183. #define SDRAM_TR0_SDRA_12_CLK 0x00000018
  184. #define SDRAM_TR0_SDRA_13_CLK 0x0000001C
  185. #define SDRAM_TR0_SDRD_MASK 0x00000003
  186. #define SDRAM_TR0_SDRD_2_CLK 0x00000001
  187. #define SDRAM_TR0_SDRD_3_CLK 0x00000002
  188. #define SDRAM_TR0_SDRD_4_CLK 0x00000003
  189. /*
  190. * SDRAM TR1 Options
  191. */
  192. #define SDRAM_TR1_RDSS_MASK 0xC0000000
  193. #define SDRAM_TR1_RDSS_TR0 0x00000000
  194. #define SDRAM_TR1_RDSS_TR1 0x40000000
  195. #define SDRAM_TR1_RDSS_TR2 0x80000000
  196. #define SDRAM_TR1_RDSS_TR3 0xC0000000
  197. #define SDRAM_TR1_RDSL_MASK 0x00C00000
  198. #define SDRAM_TR1_RDSL_STAGE1 0x00000000
  199. #define SDRAM_TR1_RDSL_STAGE2 0x00400000
  200. #define SDRAM_TR1_RDSL_STAGE3 0x00800000
  201. #define SDRAM_TR1_RDCD_MASK 0x00000800
  202. #define SDRAM_TR1_RDCD_RCD_0_0 0x00000000
  203. #define SDRAM_TR1_RDCD_RCD_1_2 0x00000800
  204. #define SDRAM_TR1_RDCT_MASK 0x000001FF
  205. #define SDRAM_TR1_RDCT_ENCODE(x) (((x) << 0) & SDRAM_TR1_RDCT_MASK)
  206. #define SDRAM_TR1_RDCT_DECODE(x) (((x) & SDRAM_TR1_RDCT_MASK) >> 0)
  207. #define SDRAM_TR1_RDCT_MIN 0x00000000
  208. #define SDRAM_TR1_RDCT_MAX 0x000001FF
  209. /*
  210. * SDRAM WDDCTR Options
  211. */
  212. #define SDRAM_WDDCTR_WRCP_MASK 0xC0000000
  213. #define SDRAM_WDDCTR_WRCP_0DEG 0x00000000
  214. #define SDRAM_WDDCTR_WRCP_90DEG 0x40000000
  215. #define SDRAM_WDDCTR_WRCP_180DEG 0x80000000
  216. #define SDRAM_WDDCTR_DCD_MASK 0x000001FF
  217. /*
  218. * SDRAM CLKTR Options
  219. */
  220. #define SDRAM_CLKTR_CLKP_MASK 0xC0000000
  221. #define SDRAM_CLKTR_CLKP_0DEG 0x00000000
  222. #define SDRAM_CLKTR_CLKP_90DEG 0x40000000
  223. #define SDRAM_CLKTR_CLKP_180DEG 0x80000000
  224. #define SDRAM_CLKTR_DCDT_MASK 0x000001FF
  225. /*
  226. * SDRAM DLYCAL Options
  227. */
  228. #define SDRAM_DLYCAL_DLCV_MASK 0x000003FC
  229. #define SDRAM_DLYCAL_DLCV_ENCODE(x) (((x)<<2) & SDRAM_DLYCAL_DLCV_MASK)
  230. #define SDRAM_DLYCAL_DLCV_DECODE(x) (((x) & SDRAM_DLYCAL_DLCV_MASK)>>2)
  231. #endif /* CONFIG_SDRAM_PPC4xx_IBM_DDR */
  232. #if defined(CONFIG_SDRAM_PPC4xx_IBM_DDR2)
  233. #define SDRAM_DLYCAL_DLCV_MASK 0x000003FC
  234. #define SDRAM_DLYCAL_DLCV_ENCODE(x) (((x)<<2) & SDRAM_DLYCAL_DLCV_MASK)
  235. #define SDRAM_DLYCAL_DLCV_DECODE(x) (((x) & SDRAM_DLYCAL_DLCV_MASK)>>2)
  236. /*
  237. * Memory queue defines
  238. */
  239. #define SDRAMQ_DCR_BASE 0x040
  240. #define SDRAM_R0BAS (SDRAMQ_DCR_BASE+0x0) /* rank 0 base address & size */
  241. #define SDRAM_R1BAS (SDRAMQ_DCR_BASE+0x1) /* rank 1 base address & size */
  242. #define SDRAM_R2BAS (SDRAMQ_DCR_BASE+0x2) /* rank 2 base address & size */
  243. #define SDRAM_R3BAS (SDRAMQ_DCR_BASE+0x3) /* rank 3 base address & size */
  244. #define SDRAM_CONF1HB (SDRAMQ_DCR_BASE+0x5) /* configuration 1 HB */
  245. #define SDRAM_ERRSTATHB (SDRAMQ_DCR_BASE+0x7) /* error status HB */
  246. #define SDRAM_ERRADDUHB (SDRAMQ_DCR_BASE+0x8) /* error address upper 32 HB */
  247. #define SDRAM_ERRADDLHB (SDRAMQ_DCR_BASE+0x9) /* error address lower 32 HB */
  248. #define SDRAM_PLBADDULL (SDRAMQ_DCR_BASE+0xA) /* PLB base address upper 32 LL */
  249. #define SDRAM_CONF1LL (SDRAMQ_DCR_BASE+0xB) /* configuration 1 LL */
  250. #define SDRAM_ERRSTATLL (SDRAMQ_DCR_BASE+0xC) /* error status LL */
  251. #define SDRAM_ERRADDULL (SDRAMQ_DCR_BASE+0xD) /* error address upper 32 LL */
  252. #define SDRAM_ERRADDLLL (SDRAMQ_DCR_BASE+0xE) /* error address lower 32 LL */
  253. #define SDRAM_CONFPATHB (SDRAMQ_DCR_BASE+0xF) /* configuration between paths */
  254. #define SDRAM_PLBADDUHB (SDRAMQ_DCR_BASE+0x10) /* PLB base address upper 32 LL */
  255. #if !defined(CONFIG_405EX)
  256. /*
  257. * Memory Bank 0-7 configuration
  258. */
  259. #if defined(CONFIG_440SPE) || \
  260. defined(CONFIG_460EX) || defined(CONFIG_460GT) || \
  261. defined(CONFIG_460SX)
  262. #define SDRAM_RXBAS_SDBA_MASK 0xFFE00000 /* Base address */
  263. #define SDRAM_RXBAS_SDBA_ENCODE(n) ((u32)(((phys_size_t)(n) >> 2) & 0xFFE00000))
  264. #define SDRAM_RXBAS_SDBA_DECODE(n) ((((phys_size_t)(n)) & 0xFFE00000) << 2)
  265. #endif /* CONFIG_440SPE */
  266. #if defined(CONFIG_440SP)
  267. #define SDRAM_RXBAS_SDBA_MASK 0xFF800000 /* Base address */
  268. #define SDRAM_RXBAS_SDBA_ENCODE(n) ((((u32)(n))&0xFF800000))
  269. #define SDRAM_RXBAS_SDBA_DECODE(n) ((((u32)(n))&0xFF800000))
  270. #endif /* CONFIG_440SP */
  271. #define SDRAM_RXBAS_SDSZ_MASK 0x0000FFC0 /* Size */
  272. #define SDRAM_RXBAS_SDSZ_ENCODE(n) ((((u32)(n))&0x3FF)<<6)
  273. #define SDRAM_RXBAS_SDSZ_DECODE(n) ((((u32)(n))>>6)&0x3FF)
  274. #define SDRAM_RXBAS_SDSZ_0 0x00000000 /* 0M */
  275. #define SDRAM_RXBAS_SDSZ_8 0x0000FFC0 /* 8M */
  276. #define SDRAM_RXBAS_SDSZ_16 0x0000FF80 /* 16M */
  277. #define SDRAM_RXBAS_SDSZ_32 0x0000FF00 /* 32M */
  278. #define SDRAM_RXBAS_SDSZ_64 0x0000FE00 /* 64M */
  279. #define SDRAM_RXBAS_SDSZ_128 0x0000FC00 /* 128M */
  280. #define SDRAM_RXBAS_SDSZ_256 0x0000F800 /* 256M */
  281. #define SDRAM_RXBAS_SDSZ_512 0x0000F000 /* 512M */
  282. #define SDRAM_RXBAS_SDSZ_1024 0x0000E000 /* 1024M */
  283. #define SDRAM_RXBAS_SDSZ_2048 0x0000C000 /* 2048M */
  284. #define SDRAM_RXBAS_SDSZ_4096 0x00008000 /* 4096M */
  285. #else /* CONFIG_405EX */
  286. /*
  287. * XXX - ToDo:
  288. * Revisit this file to check if all these 405EX defines are correct and
  289. * can be used in the common 44x_spd_ddr2 code as well. sr, 2008-06-02
  290. */
  291. #define SDRAM_RXBAS_SDSZ_MASK PPC_REG_VAL(19, 0xF)
  292. #define SDRAM_RXBAS_SDSZ_4MB PPC_REG_VAL(19, 0x0)
  293. #define SDRAM_RXBAS_SDSZ_8MB PPC_REG_VAL(19, 0x1)
  294. #define SDRAM_RXBAS_SDSZ_16MB PPC_REG_VAL(19, 0x2)
  295. #define SDRAM_RXBAS_SDSZ_32MB PPC_REG_VAL(19, 0x3)
  296. #define SDRAM_RXBAS_SDSZ_64MB PPC_REG_VAL(19, 0x4)
  297. #define SDRAM_RXBAS_SDSZ_128MB PPC_REG_VAL(19, 0x5)
  298. #define SDRAM_RXBAS_SDSZ_256MB PPC_REG_VAL(19, 0x6)
  299. #define SDRAM_RXBAS_SDSZ_512MB PPC_REG_VAL(19, 0x7)
  300. #define SDRAM_RXBAS_SDSZ_1024MB PPC_REG_VAL(19, 0x8)
  301. #define SDRAM_RXBAS_SDSZ_2048MB PPC_REG_VAL(19, 0x9)
  302. #define SDRAM_RXBAS_SDSZ_4096MB PPC_REG_VAL(19, 0xA)
  303. #define SDRAM_RXBAS_SDSZ_8192MB PPC_REG_VAL(19, 0xB)
  304. #define SDRAM_RXBAS_SDSZ_8 SDRAM_RXBAS_SDSZ_8MB
  305. #define SDRAM_RXBAS_SDSZ_16 SDRAM_RXBAS_SDSZ_16MB
  306. #define SDRAM_RXBAS_SDSZ_32 SDRAM_RXBAS_SDSZ_32MB
  307. #define SDRAM_RXBAS_SDSZ_64 SDRAM_RXBAS_SDSZ_64MB
  308. #define SDRAM_RXBAS_SDSZ_128 SDRAM_RXBAS_SDSZ_128MB
  309. #define SDRAM_RXBAS_SDSZ_256 SDRAM_RXBAS_SDSZ_256MB
  310. #define SDRAM_RXBAS_SDSZ_512 SDRAM_RXBAS_SDSZ_512MB
  311. #define SDRAM_RXBAS_SDSZ_1024 SDRAM_RXBAS_SDSZ_1024MB
  312. #define SDRAM_RXBAS_SDSZ_2048 SDRAM_RXBAS_SDSZ_2048MB
  313. #define SDRAM_RXBAS_SDSZ_4096 SDRAM_RXBAS_SDSZ_4096MB
  314. #define SDRAM_RXBAS_SDSZ_8192 SDRAM_RXBAS_SDSZ_8192MB
  315. #define SDRAM_RXBAS_SDAM_MODE0 PPC_REG_VAL(23, 0x0)
  316. #define SDRAM_RXBAS_SDAM_MODE1 PPC_REG_VAL(23, 0x1)
  317. #define SDRAM_RXBAS_SDAM_MODE2 PPC_REG_VAL(23, 0x2)
  318. #define SDRAM_RXBAS_SDAM_MODE3 PPC_REG_VAL(23, 0x3)
  319. #define SDRAM_RXBAS_SDAM_MODE4 PPC_REG_VAL(23, 0x4)
  320. #define SDRAM_RXBAS_SDAM_MODE5 PPC_REG_VAL(23, 0x5)
  321. #define SDRAM_RXBAS_SDAM_MODE6 PPC_REG_VAL(23, 0x6)
  322. #define SDRAM_RXBAS_SDAM_MODE7 PPC_REG_VAL(23, 0x7)
  323. #define SDRAM_RXBAS_SDAM_MODE8 PPC_REG_VAL(23, 0x8)
  324. #define SDRAM_RXBAS_SDAM_MODE9 PPC_REG_VAL(23, 0x9)
  325. #define SDRAM_RXBAS_SDBE_DISABLE PPC_REG_VAL(31, 0x0)
  326. #define SDRAM_RXBAS_SDBE_ENABLE PPC_REG_VAL(31, 0x1)
  327. #endif /* CONFIG_405EX */
  328. /*
  329. * Memory controller registers
  330. */
  331. #ifndef CONFIG_405EX
  332. #define SDRAM_MCSTAT 0x14 /* memory controller status */
  333. #else
  334. #define SDRAM_MCSTAT 0x1F /* memory controller status */
  335. #endif
  336. #define SDRAM_MCOPT1 0x20 /* memory controller options 1 */
  337. #define SDRAM_MCOPT2 0x21 /* memory controller options 2 */
  338. #define SDRAM_MODT0 0x22 /* on die termination for bank 0 */
  339. #define SDRAM_MODT1 0x23 /* on die termination for bank 1 */
  340. #define SDRAM_MODT2 0x24 /* on die termination for bank 2 */
  341. #define SDRAM_MODT3 0x25 /* on die termination for bank 3 */
  342. #define SDRAM_CODT 0x26 /* on die termination for controller */
  343. #define SDRAM_VVPR 0x27 /* variable VRef programmming */
  344. #define SDRAM_OPARS 0x28 /* on chip driver control setup */
  345. #define SDRAM_OPART 0x29 /* on chip driver control trigger */
  346. #define SDRAM_RTR 0x30 /* refresh timer */
  347. #define SDRAM_PMIT 0x34 /* power management idle timer */
  348. #define SDRAM_MB0CF 0x40 /* memory bank 0 configuration */
  349. #define SDRAM_MB1CF 0x44 /* memory bank 1 configuration */
  350. #define SDRAM_MB2CF 0x48
  351. #define SDRAM_MB3CF 0x4C
  352. #define SDRAM_INITPLR0 0x50 /* manual initialization control */
  353. #define SDRAM_INITPLR1 0x51 /* manual initialization control */
  354. #define SDRAM_INITPLR2 0x52 /* manual initialization control */
  355. #define SDRAM_INITPLR3 0x53 /* manual initialization control */
  356. #define SDRAM_INITPLR4 0x54 /* manual initialization control */
  357. #define SDRAM_INITPLR5 0x55 /* manual initialization control */
  358. #define SDRAM_INITPLR6 0x56 /* manual initialization control */
  359. #define SDRAM_INITPLR7 0x57 /* manual initialization control */
  360. #define SDRAM_INITPLR8 0x58 /* manual initialization control */
  361. #define SDRAM_INITPLR9 0x59 /* manual initialization control */
  362. #define SDRAM_INITPLR10 0x5a /* manual initialization control */
  363. #define SDRAM_INITPLR11 0x5b /* manual initialization control */
  364. #define SDRAM_INITPLR12 0x5c /* manual initialization control */
  365. #define SDRAM_INITPLR13 0x5d /* manual initialization control */
  366. #define SDRAM_INITPLR14 0x5e /* manual initialization control */
  367. #define SDRAM_INITPLR15 0x5f /* manual initialization control */
  368. #define SDRAM_RQDC 0x70 /* read DQS delay control */
  369. #define SDRAM_RFDC 0x74 /* read feedback delay control */
  370. #define SDRAM_RDCC 0x78 /* read data capture control */
  371. #define SDRAM_DLCR 0x7A /* delay line calibration */
  372. #define SDRAM_CLKTR 0x80 /* DDR clock timing */
  373. #define SDRAM_WRDTR 0x81 /* write data, DQS, DM clock, timing */
  374. #define SDRAM_SDTR1 0x85 /* DDR SDRAM timing 1 */
  375. #define SDRAM_SDTR2 0x86 /* DDR SDRAM timing 2 */
  376. #define SDRAM_SDTR3 0x87 /* DDR SDRAM timing 3 */
  377. #define SDRAM_MMODE 0x88 /* memory mode */
  378. #define SDRAM_MEMODE 0x89 /* memory extended mode */
  379. #define SDRAM_ECCCR 0x98 /* ECC error status */
  380. #define SDRAM_CID 0xA4 /* core ID */
  381. #define SDRAM_RID 0xA8 /* revision ID */
  382. #define SDRAM_RTSR 0xB1 /* run time status tracking */
  383. /*
  384. * Memory Controller Status
  385. */
  386. #define SDRAM_MCSTAT_MIC_MASK 0x80000000 /* Memory init status mask */
  387. #define SDRAM_MCSTAT_MIC_NOTCOMP 0x00000000 /* Mem init not complete */
  388. #define SDRAM_MCSTAT_MIC_COMP 0x80000000 /* Mem init complete */
  389. #define SDRAM_MCSTAT_SRMS_MASK 0x40000000 /* Mem self refresh stat mask */
  390. #define SDRAM_MCSTAT_SRMS_NOT_SF 0x00000000 /* Mem not in self refresh */
  391. #define SDRAM_MCSTAT_SRMS_SF 0x40000000 /* Mem in self refresh */
  392. #define SDRAM_MCSTAT_IDLE_MASK 0x20000000 /* Mem self refresh stat mask */
  393. #define SDRAM_MCSTAT_IDLE_NOT 0x00000000 /* Mem contr not idle */
  394. #define SDRAM_MCSTAT_IDLE 0x20000000 /* Mem contr idle */
  395. /*
  396. * Memory Controller Options 1
  397. */
  398. #define SDRAM_MCOPT1_MCHK_MASK 0x30000000 /* Memory data err check mask*/
  399. #define SDRAM_MCOPT1_MCHK_NON 0x00000000 /* No ECC generation */
  400. #define SDRAM_MCOPT1_MCHK_GEN 0x20000000 /* ECC generation */
  401. #define SDRAM_MCOPT1_MCHK_CHK 0x10000000 /* ECC generation and check */
  402. #define SDRAM_MCOPT1_MCHK_CHK_REP 0x30000000 /* ECC generation, chk, report*/
  403. #define SDRAM_MCOPT1_MCHK_CHK_DECODE(n) ((((u32)(n))>>28)&0x3)
  404. #define SDRAM_MCOPT1_RDEN_MASK 0x08000000 /* Registered DIMM mask */
  405. #define SDRAM_MCOPT1_RDEN 0x08000000 /* Registered DIMM enable */
  406. #define SDRAM_MCOPT1_PMU_MASK 0x06000000 /* Page management unit mask */
  407. #define SDRAM_MCOPT1_PMU_CLOSE 0x00000000 /* PMU Close */
  408. #define SDRAM_MCOPT1_PMU_OPEN 0x04000000 /* PMU Open */
  409. #define SDRAM_MCOPT1_PMU_AUTOCLOSE 0x02000000 /* PMU AutoClose */
  410. #define SDRAM_MCOPT1_DMWD_MASK 0x01000000 /* DRAM width mask */
  411. #define SDRAM_MCOPT1_DMWD_32 0x00000000 /* 32 bits */
  412. #define SDRAM_MCOPT1_DMWD_64 0x01000000 /* 64 bits */
  413. #define SDRAM_MCOPT1_UIOS_MASK 0x00C00000 /* Unused IO State */
  414. #define SDRAM_MCOPT1_BCNT_MASK 0x00200000 /* Bank count */
  415. #define SDRAM_MCOPT1_4_BANKS 0x00000000 /* 4 Banks */
  416. #define SDRAM_MCOPT1_8_BANKS 0x00200000 /* 8 Banks */
  417. #define SDRAM_MCOPT1_DDR_TYPE_MASK 0x00100000 /* DDR Memory Type mask */
  418. #define SDRAM_MCOPT1_DDR1_TYPE 0x00000000 /* DDR1 Memory Type */
  419. #define SDRAM_MCOPT1_DDR2_TYPE 0x00100000 /* DDR2 Memory Type */
  420. #define SDRAM_MCOPT1_QDEP 0x00020000 /* 4 commands deep */
  421. #define SDRAM_MCOPT1_RWOO_MASK 0x00008000 /* Out of Order Read mask */
  422. #define SDRAM_MCOPT1_RWOO_DISABLED 0x00000000 /* disabled */
  423. #define SDRAM_MCOPT1_RWOO_ENABLED 0x00008000 /* enabled */
  424. #define SDRAM_MCOPT1_WOOO_MASK 0x00004000 /* Out of Order Write mask */
  425. #define SDRAM_MCOPT1_WOOO_DISABLED 0x00000000 /* disabled */
  426. #define SDRAM_MCOPT1_WOOO_ENABLED 0x00004000 /* enabled */
  427. #define SDRAM_MCOPT1_DCOO_MASK 0x00002000 /* All Out of Order mask */
  428. #define SDRAM_MCOPT1_DCOO_DISABLED 0x00002000 /* disabled */
  429. #define SDRAM_MCOPT1_DCOO_ENABLED 0x00000000 /* enabled */
  430. #define SDRAM_MCOPT1_DREF_MASK 0x00001000 /* Deferred refresh mask */
  431. #define SDRAM_MCOPT1_DREF_NORMAL 0x00000000 /* normal refresh */
  432. #define SDRAM_MCOPT1_DREF_DEFER_4 0x00001000 /* defer up to 4 refresh cmd */
  433. /*
  434. * Memory Controller Options 2
  435. */
  436. #define SDRAM_MCOPT2_SREN_MASK 0x80000000 /* Self Test mask */
  437. #define SDRAM_MCOPT2_SREN_EXIT 0x00000000 /* Self Test exit */
  438. #define SDRAM_MCOPT2_SREN_ENTER 0x80000000 /* Self Test enter */
  439. #define SDRAM_MCOPT2_PMEN_MASK 0x40000000 /* Power Management mask */
  440. #define SDRAM_MCOPT2_PMEN_DISABLE 0x00000000 /* disable */
  441. #define SDRAM_MCOPT2_PMEN_ENABLE 0x40000000 /* enable */
  442. #define SDRAM_MCOPT2_IPTR_MASK 0x20000000 /* Init Trigger Reg mask */
  443. #define SDRAM_MCOPT2_IPTR_IDLE 0x00000000 /* idle */
  444. #define SDRAM_MCOPT2_IPTR_EXECUTE 0x20000000 /* execute preloaded init */
  445. #define SDRAM_MCOPT2_XSRP_MASK 0x10000000 /* Exit Self Refresh Prevent */
  446. #define SDRAM_MCOPT2_XSRP_ALLOW 0x00000000 /* allow self refresh exit */
  447. #define SDRAM_MCOPT2_XSRP_PREVENT 0x10000000 /* prevent self refresh exit */
  448. #define SDRAM_MCOPT2_DCEN_MASK 0x08000000 /* SDRAM Controller Enable */
  449. #define SDRAM_MCOPT2_DCEN_DISABLE 0x00000000 /* SDRAM Controller Enable */
  450. #define SDRAM_MCOPT2_DCEN_ENABLE 0x08000000 /* SDRAM Controller Enable */
  451. #define SDRAM_MCOPT2_ISIE_MASK 0x04000000 /* Init Seq Interruptable mas*/
  452. #define SDRAM_MCOPT2_ISIE_DISABLE 0x00000000 /* disable */
  453. #define SDRAM_MCOPT2_ISIE_ENABLE 0x04000000 /* enable */
  454. /*
  455. * SDRAM Refresh Timer Register
  456. */
  457. #define SDRAM_RTR_RINT_MASK 0xFFF80000
  458. #define SDRAM_RTR_RINT_ENCODE(n) ((((u32)(n))&0xFFF8)<<16)
  459. #define SDRAM_RTR_RINT_DECODE(n) ((((u32)(n))>>16)&0xFFF8)
  460. /*
  461. * SDRAM Read DQS Delay Control Register
  462. */
  463. #define SDRAM_RQDC_RQDE_MASK 0x80000000
  464. #define SDRAM_RQDC_RQDE_DISABLE 0x00000000
  465. #define SDRAM_RQDC_RQDE_ENABLE 0x80000000
  466. #define SDRAM_RQDC_RQFD_MASK 0x000001FF
  467. #define SDRAM_RQDC_RQFD_ENCODE(n) ((((u32)(n))&0x1FF)<<0)
  468. #define SDRAM_RQDC_RQFD_MAX 0x1FF
  469. /*
  470. * SDRAM Read Data Capture Control Register
  471. */
  472. #define SDRAM_RDCC_RDSS_MASK 0xC0000000
  473. #define SDRAM_RDCC_RDSS_T1 0x00000000
  474. #define SDRAM_RDCC_RDSS_T2 0x40000000
  475. #define SDRAM_RDCC_RDSS_T3 0x80000000
  476. #define SDRAM_RDCC_RDSS_T4 0xC0000000
  477. #define SDRAM_RDCC_RSAE_MASK 0x00000001
  478. #define SDRAM_RDCC_RSAE_DISABLE 0x00000001
  479. #define SDRAM_RDCC_RSAE_ENABLE 0x00000000
  480. /*
  481. * SDRAM Read Feedback Delay Control Register
  482. */
  483. #define SDRAM_RFDC_ARSE_MASK 0x80000000
  484. #define SDRAM_RFDC_ARSE_DISABLE 0x80000000
  485. #define SDRAM_RFDC_ARSE_ENABLE 0x00000000
  486. #define SDRAM_RFDC_RFOS_MASK 0x007F0000
  487. #define SDRAM_RFDC_RFOS_ENCODE(n) ((((u32)(n))&0x7F)<<16)
  488. #define SDRAM_RFDC_RFFD_MASK 0x000007FF
  489. #define SDRAM_RFDC_RFFD_ENCODE(n) ((((u32)(n))&0x7FF)<<0)
  490. #define SDRAM_RFDC_RFFD_MAX 0x7FF
  491. /*
  492. * SDRAM Delay Line Calibration Register
  493. */
  494. #define SDRAM_DLCR_DCLM_MASK 0x80000000
  495. #define SDRAM_DLCR_DCLM_MANUEL 0x80000000
  496. #define SDRAM_DLCR_DCLM_AUTO 0x00000000
  497. #define SDRAM_DLCR_DLCR_MASK 0x08000000
  498. #define SDRAM_DLCR_DLCR_CALIBRATE 0x08000000
  499. #define SDRAM_DLCR_DLCR_IDLE 0x00000000
  500. #define SDRAM_DLCR_DLCS_MASK 0x07000000
  501. #define SDRAM_DLCR_DLCS_NOT_RUN 0x00000000
  502. #define SDRAM_DLCR_DLCS_IN_PROGRESS 0x01000000
  503. #define SDRAM_DLCR_DLCS_COMPLETE 0x02000000
  504. #define SDRAM_DLCR_DLCS_CONT_DONE 0x03000000
  505. #define SDRAM_DLCR_DLCS_ERROR 0x04000000
  506. #define SDRAM_DLCR_DLCV_MASK 0x000001FF
  507. #define SDRAM_DLCR_DLCV_ENCODE(n) ((((u32)(n))&0x1FF)<<0)
  508. #define SDRAM_DLCR_DLCV_DECODE(n) ((((u32)(n))>>0)&0x1FF)
  509. /*
  510. * SDRAM Controller On Die Termination Register
  511. */
  512. #define SDRAM_CODT_ODT_ON 0x80000000
  513. #define SDRAM_CODT_ODT_OFF 0x00000000
  514. #define SDRAM_CODT_DQS_VOLTAGE_DDR_MASK 0x00000020
  515. #define SDRAM_CODT_DQS_2_5_V_DDR1 0x00000000
  516. #define SDRAM_CODT_DQS_1_8_V_DDR2 0x00000020
  517. #define SDRAM_CODT_DQS_MASK 0x00000010
  518. #define SDRAM_CODT_DQS_DIFFERENTIAL 0x00000000
  519. #define SDRAM_CODT_DQS_SINGLE_END 0x00000010
  520. #define SDRAM_CODT_CKSE_DIFFERENTIAL 0x00000000
  521. #define SDRAM_CODT_CKSE_SINGLE_END 0x00000008
  522. #define SDRAM_CODT_FEEBBACK_RCV_SINGLE_END 0x00000004
  523. #define SDRAM_CODT_FEEBBACK_DRV_SINGLE_END 0x00000002
  524. #define SDRAM_CODT_IO_HIZ 0x00000000
  525. #define SDRAM_CODT_IO_NMODE 0x00000001
  526. /*
  527. * SDRAM Mode Register
  528. */
  529. #define SDRAM_MMODE_WR_MASK 0x00000E00
  530. #define SDRAM_MMODE_WR_DDR1 0x00000000
  531. #define SDRAM_MMODE_WR_DDR2_3_CYC 0x00000400
  532. #define SDRAM_MMODE_WR_DDR2_4_CYC 0x00000600
  533. #define SDRAM_MMODE_WR_DDR2_5_CYC 0x00000800
  534. #define SDRAM_MMODE_WR_DDR2_6_CYC 0x00000A00
  535. #define SDRAM_MMODE_DCL_MASK 0x00000070
  536. #define SDRAM_MMODE_DCL_DDR1_2_0_CLK 0x00000020
  537. #define SDRAM_MMODE_DCL_DDR1_2_5_CLK 0x00000060
  538. #define SDRAM_MMODE_DCL_DDR1_3_0_CLK 0x00000030
  539. #define SDRAM_MMODE_DCL_DDR2_2_0_CLK 0x00000020
  540. #define SDRAM_MMODE_DCL_DDR2_3_0_CLK 0x00000030
  541. #define SDRAM_MMODE_DCL_DDR2_4_0_CLK 0x00000040
  542. #define SDRAM_MMODE_DCL_DDR2_5_0_CLK 0x00000050
  543. #define SDRAM_MMODE_DCL_DDR2_6_0_CLK 0x00000060
  544. #define SDRAM_MMODE_DCL_DDR2_7_0_CLK 0x00000070
  545. /*
  546. * SDRAM Extended Mode Register
  547. */
  548. #define SDRAM_MEMODE_DIC_MASK 0x00000002
  549. #define SDRAM_MEMODE_DIC_NORMAL 0x00000000
  550. #define SDRAM_MEMODE_DIC_WEAK 0x00000002
  551. #define SDRAM_MEMODE_DLL_MASK 0x00000001
  552. #define SDRAM_MEMODE_DLL_DISABLE 0x00000001
  553. #define SDRAM_MEMODE_DLL_ENABLE 0x00000000
  554. #define SDRAM_MEMODE_RTT_MASK 0x00000044
  555. #define SDRAM_MEMODE_RTT_DISABLED 0x00000000
  556. #define SDRAM_MEMODE_RTT_75OHM 0x00000004
  557. #define SDRAM_MEMODE_RTT_150OHM 0x00000040
  558. #define SDRAM_MEMODE_DQS_MASK 0x00000400
  559. #define SDRAM_MEMODE_DQS_DISABLE 0x00000400
  560. #define SDRAM_MEMODE_DQS_ENABLE 0x00000000
  561. /*
  562. * SDRAM Clock Timing Register
  563. */
  564. #define SDRAM_CLKTR_CLKP_MASK 0xC0000000
  565. #define SDRAM_CLKTR_CLKP_0_DEG 0x00000000
  566. #define SDRAM_CLKTR_CLKP_180_DEG_ADV 0x80000000
  567. #define SDRAM_CLKTR_CLKP_90_DEG_ADV 0x40000000
  568. #define SDRAM_CLKTR_CLKP_270_DEG_ADV 0xC0000000
  569. /*
  570. * SDRAM Write Timing Register
  571. */
  572. #define SDRAM_WRDTR_LLWP_MASK 0x10000000
  573. #define SDRAM_WRDTR_LLWP_DIS 0x10000000
  574. #define SDRAM_WRDTR_LLWP_1_CYC 0x00000000
  575. #define SDRAM_WRDTR_WTR_MASK 0x0E000000
  576. #define SDRAM_WRDTR_WTR_0_DEG 0x06000000
  577. #define SDRAM_WRDTR_WTR_90_DEG_ADV 0x04000000
  578. #define SDRAM_WRDTR_WTR_180_DEG_ADV 0x02000000
  579. #define SDRAM_WRDTR_WTR_270_DEG_ADV 0x00000000
  580. /*
  581. * SDRAM SDTR1 Options
  582. */
  583. #define SDRAM_SDTR1_LDOF_MASK 0x80000000
  584. #define SDRAM_SDTR1_LDOF_1_CLK 0x00000000
  585. #define SDRAM_SDTR1_LDOF_2_CLK 0x80000000
  586. #define SDRAM_SDTR1_RTW_MASK 0x00F00000
  587. #define SDRAM_SDTR1_RTW_2_CLK 0x00200000
  588. #define SDRAM_SDTR1_RTW_3_CLK 0x00300000
  589. #define SDRAM_SDTR1_WTWO_MASK 0x000F0000
  590. #define SDRAM_SDTR1_WTWO_0_CLK 0x00000000
  591. #define SDRAM_SDTR1_WTWO_1_CLK 0x00010000
  592. #define SDRAM_SDTR1_RTRO_MASK 0x0000F000
  593. #define SDRAM_SDTR1_RTRO_1_CLK 0x00001000
  594. #define SDRAM_SDTR1_RTRO_2_CLK 0x00002000
  595. /*
  596. * SDRAM SDTR2 Options
  597. */
  598. #define SDRAM_SDTR2_RCD_MASK 0xF0000000
  599. #define SDRAM_SDTR2_RCD_1_CLK 0x10000000
  600. #define SDRAM_SDTR2_RCD_2_CLK 0x20000000
  601. #define SDRAM_SDTR2_RCD_3_CLK 0x30000000
  602. #define SDRAM_SDTR2_RCD_4_CLK 0x40000000
  603. #define SDRAM_SDTR2_RCD_5_CLK 0x50000000
  604. #define SDRAM_SDTR2_WTR_MASK 0x0F000000
  605. #define SDRAM_SDTR2_WTR_1_CLK 0x01000000
  606. #define SDRAM_SDTR2_WTR_2_CLK 0x02000000
  607. #define SDRAM_SDTR2_WTR_3_CLK 0x03000000
  608. #define SDRAM_SDTR2_WTR_4_CLK 0x04000000
  609. #define SDRAM_SDTR3_WTR_ENCODE(n) ((((u32)(n))&0xF)<<24)
  610. #define SDRAM_SDTR2_XSNR_MASK 0x00FF0000
  611. #define SDRAM_SDTR2_XSNR_8_CLK 0x00080000
  612. #define SDRAM_SDTR2_XSNR_16_CLK 0x00100000
  613. #define SDRAM_SDTR2_XSNR_32_CLK 0x00200000
  614. #define SDRAM_SDTR2_XSNR_64_CLK 0x00400000
  615. #define SDRAM_SDTR2_WPC_MASK 0x0000F000
  616. #define SDRAM_SDTR2_WPC_2_CLK 0x00002000
  617. #define SDRAM_SDTR2_WPC_3_CLK 0x00003000
  618. #define SDRAM_SDTR2_WPC_4_CLK 0x00004000
  619. #define SDRAM_SDTR2_WPC_5_CLK 0x00005000
  620. #define SDRAM_SDTR2_WPC_6_CLK 0x00006000
  621. #define SDRAM_SDTR3_WPC_ENCODE(n) ((((u32)(n))&0xF)<<12)
  622. #define SDRAM_SDTR2_RPC_MASK 0x00000F00
  623. #define SDRAM_SDTR2_RPC_2_CLK 0x00000200
  624. #define SDRAM_SDTR2_RPC_3_CLK 0x00000300
  625. #define SDRAM_SDTR2_RPC_4_CLK 0x00000400
  626. #define SDRAM_SDTR2_RP_MASK 0x000000F0
  627. #define SDRAM_SDTR2_RP_3_CLK 0x00000030
  628. #define SDRAM_SDTR2_RP_4_CLK 0x00000040
  629. #define SDRAM_SDTR2_RP_5_CLK 0x00000050
  630. #define SDRAM_SDTR2_RP_6_CLK 0x00000060
  631. #define SDRAM_SDTR2_RP_7_CLK 0x00000070
  632. #define SDRAM_SDTR2_RRD_MASK 0x0000000F
  633. #define SDRAM_SDTR2_RRD_2_CLK 0x00000002
  634. #define SDRAM_SDTR2_RRD_3_CLK 0x00000003
  635. /*
  636. * SDRAM SDTR3 Options
  637. */
  638. #define SDRAM_SDTR3_RAS_MASK 0x1F000000
  639. #define SDRAM_SDTR3_RAS_ENCODE(n) ((((u32)(n))&0x1F)<<24)
  640. #define SDRAM_SDTR3_RC_MASK 0x001F0000
  641. #define SDRAM_SDTR3_RC_ENCODE(n) ((((u32)(n))&0x1F)<<16)
  642. #define SDRAM_SDTR3_XCS_MASK 0x00001F00
  643. #define SDRAM_SDTR3_XCS 0x00000D00
  644. #define SDRAM_SDTR3_RFC_MASK 0x0000003F
  645. #define SDRAM_SDTR3_RFC_ENCODE(n) ((((u32)(n))&0x3F)<<0)
  646. /*
  647. * Memory Bank 0-1 configuration
  648. */
  649. #define SDRAM_BXCF_M_AM_MASK 0x00000F00 /* Addressing mode */
  650. #define SDRAM_BXCF_M_AM_0 0x00000000 /* Mode 0 */
  651. #define SDRAM_BXCF_M_AM_1 0x00000100 /* Mode 1 */
  652. #define SDRAM_BXCF_M_AM_2 0x00000200 /* Mode 2 */
  653. #define SDRAM_BXCF_M_AM_3 0x00000300 /* Mode 3 */
  654. #define SDRAM_BXCF_M_AM_4 0x00000400 /* Mode 4 */
  655. #define SDRAM_BXCF_M_AM_5 0x00000500 /* Mode 5 */
  656. #define SDRAM_BXCF_M_AM_6 0x00000600 /* Mode 6 */
  657. #define SDRAM_BXCF_M_AM_7 0x00000700 /* Mode 7 */
  658. #define SDRAM_BXCF_M_AM_8 0x00000800 /* Mode 8 */
  659. #define SDRAM_BXCF_M_AM_9 0x00000900 /* Mode 9 */
  660. #define SDRAM_BXCF_M_BE_MASK 0x00000001 /* Memory Bank Enable */
  661. #define SDRAM_BXCF_M_BE_DISABLE 0x00000000 /* Memory Bank Enable */
  662. #define SDRAM_BXCF_M_BE_ENABLE 0x00000001 /* Memory Bank Enable */
  663. #define SDRAM_RTSR_TRK1SM_MASK 0xC0000000 /* Tracking State Mach 1*/
  664. #define SDRAM_RTSR_TRK1SM_ATBASE 0x00000000 /* atbase state */
  665. #define SDRAM_RTSR_TRK1SM_MISSED 0x40000000 /* missed state */
  666. #define SDRAM_RTSR_TRK1SM_ATPLS1 0x80000000 /* atpls1 state */
  667. #define SDRAM_RTSR_TRK1SM_RESET 0xC0000000 /* reset state */
  668. #define SDR0_MFR_FIXD 0x10000000 /* Workaround for PCI/DMA */
  669. #endif /* CONFIG_SDRAM_PPC4xx_IBM_DDR2 */
  670. #if defined(CONFIG_SDRAM_PPC4xx_DENALI_DDR2)
  671. /*
  672. * SDRAM Controller
  673. */
  674. #define DDR0_00 0x00
  675. #define DDR0_00_INT_ACK_MASK 0x7F000000 /* Write only */
  676. #define DDR0_00_INT_ACK_ALL 0x7F000000
  677. #define DDR0_00_INT_ACK_ENCODE(n) ((((u32)(n))&0x7F)<<24)
  678. #define DDR0_00_INT_ACK_DECODE(n) ((((u32)(n))>>24)&0x7F)
  679. /* Status */
  680. #define DDR0_00_INT_STATUS_MASK 0x00FF0000 /* Read only */
  681. /* Bit0. A single access outside the defined PHYSICAL memory space detected. */
  682. #define DDR0_00_INT_STATUS_BIT0 0x00010000
  683. /* Bit1. Multiple accesses outside the defined PHYSICAL memory space detected. */
  684. #define DDR0_00_INT_STATUS_BIT1 0x00020000
  685. /* Bit2. Single correctable ECC event detected */
  686. #define DDR0_00_INT_STATUS_BIT2 0x00040000
  687. /* Bit3. Multiple correctable ECC events detected. */
  688. #define DDR0_00_INT_STATUS_BIT3 0x00080000
  689. /* Bit4. Single uncorrectable ECC event detected. */
  690. #define DDR0_00_INT_STATUS_BIT4 0x00100000
  691. /* Bit5. Multiple uncorrectable ECC events detected. */
  692. #define DDR0_00_INT_STATUS_BIT5 0x00200000
  693. /* Bit6. DRAM initialization complete. */
  694. #define DDR0_00_INT_STATUS_BIT6 0x00400000
  695. /* Bit7. Logical OR of all lower bits. */
  696. #define DDR0_00_INT_STATUS_BIT7 0x00800000
  697. #define DDR0_00_INT_STATUS_ENCODE(n) ((((u32)(n))&0xFF)<<16)
  698. #define DDR0_00_INT_STATUS_DECODE(n) ((((u32)(n))>>16)&0xFF)
  699. #define DDR0_00_DLL_INCREMENT_MASK 0x00007F00
  700. #define DDR0_00_DLL_INCREMENT_ENCODE(n) ((((u32)(n))&0x7F)<<8)
  701. #define DDR0_00_DLL_INCREMENT_DECODE(n) ((((u32)(n))>>8)&0x7F)
  702. #define DDR0_00_DLL_START_POINT_MASK 0x0000007F
  703. #define DDR0_00_DLL_START_POINT_ENCODE(n) ((((u32)(n))&0x7F)<<0)
  704. #define DDR0_00_DLL_START_POINT_DECODE(n) ((((u32)(n))>>0)&0x7F)
  705. #define DDR0_01 0x01
  706. #define DDR0_01_PLB0_DB_CS_LOWER_MASK 0x1F000000
  707. #define DDR0_01_PLB0_DB_CS_LOWER_ENCODE(n) ((((u32)(n))&0x1F)<<24)
  708. #define DDR0_01_PLB0_DB_CS_LOWER_DECODE(n) ((((u32)(n))>>24)&0x1F)
  709. #define DDR0_01_PLB0_DB_CS_UPPER_MASK 0x001F0000
  710. #define DDR0_01_PLB0_DB_CS_UPPER_ENCODE(n) ((((u32)(n))&0x1F)<<16)
  711. #define DDR0_01_PLB0_DB_CS_UPPER_DECODE(n) ((((u32)(n))>>16)&0x1F)
  712. #define DDR0_01_OUT_OF_RANGE_TYPE_MASK 0x00000700 /* Read only */
  713. #define DDR0_01_OUT_OF_RANGE_TYPE_ENCODE(n) ((((u32)(n))&0x7)<<8)
  714. #define DDR0_01_OUT_OF_RANGE_TYPE_DECODE(n) ((((u32)(n))>>8)&0x7)
  715. #define DDR0_01_INT_MASK_MASK 0x000000FF
  716. #define DDR0_01_INT_MASK_ENCODE(n) ((((u32)(n))&0xFF)<<0)
  717. #define DDR0_01_INT_MASK_DECODE(n) ((((u32)(n))>>0)&0xFF)
  718. #define DDR0_01_INT_MASK_ALL_ON 0x000000FF
  719. #define DDR0_01_INT_MASK_ALL_OFF 0x00000000
  720. #define DDR0_02 0x02
  721. #define DDR0_02_MAX_CS_REG_MASK 0x02000000 /* Read only */
  722. #define DDR0_02_MAX_CS_REG_ENCODE(n) ((((u32)(n))&0x2)<<24)
  723. #define DDR0_02_MAX_CS_REG_DECODE(n) ((((u32)(n))>>24)&0x2)
  724. #define DDR0_02_MAX_COL_REG_MASK 0x000F0000 /* Read only */
  725. #define DDR0_02_MAX_COL_REG_ENCODE(n) ((((u32)(n))&0xF)<<16)
  726. #define DDR0_02_MAX_COL_REG_DECODE(n) ((((u32)(n))>>16)&0xF)
  727. #define DDR0_02_MAX_ROW_REG_MASK 0x00000F00 /* Read only */
  728. #define DDR0_02_MAX_ROW_REG_ENCODE(n) ((((u32)(n))&0xF)<<8)
  729. #define DDR0_02_MAX_ROW_REG_DECODE(n) ((((u32)(n))>>8)&0xF)
  730. #define DDR0_02_START_MASK 0x00000001
  731. #define DDR0_02_START_ENCODE(n) ((((u32)(n))&0x1)<<0)
  732. #define DDR0_02_START_DECODE(n) ((((u32)(n))>>0)&0x1)
  733. #define DDR0_02_START_OFF 0x00000000
  734. #define DDR0_02_START_ON 0x00000001
  735. #define DDR0_03 0x03
  736. #define DDR0_03_BSTLEN_MASK 0x07000000
  737. #define DDR0_03_BSTLEN_ENCODE(n) ((((u32)(n))&0x7)<<24)
  738. #define DDR0_03_BSTLEN_DECODE(n) ((((u32)(n))>>24)&0x7)
  739. #define DDR0_03_CASLAT_MASK 0x00070000
  740. #define DDR0_03_CASLAT_ENCODE(n) ((((u32)(n))&0x7)<<16)
  741. #define DDR0_03_CASLAT_DECODE(n) ((((u32)(n))>>16)&0x7)
  742. #define DDR0_03_CASLAT_LIN_MASK 0x00000F00
  743. #define DDR0_03_CASLAT_LIN_ENCODE(n) ((((u32)(n))&0xF)<<8)
  744. #define DDR0_03_CASLAT_LIN_DECODE(n) ((((u32)(n))>>8)&0xF)
  745. #define DDR0_03_INITAREF_MASK 0x0000000F
  746. #define DDR0_03_INITAREF_ENCODE(n) ((((u32)(n))&0xF)<<0)
  747. #define DDR0_03_INITAREF_DECODE(n) ((((u32)(n))>>0)&0xF)
  748. #define DDR0_04 0x04
  749. #define DDR0_04_TRC_MASK 0x1F000000
  750. #define DDR0_04_TRC_ENCODE(n) ((((u32)(n))&0x1F)<<24)
  751. #define DDR0_04_TRC_DECODE(n) ((((u32)(n))>>24)&0x1F)
  752. #define DDR0_04_TRRD_MASK 0x00070000
  753. #define DDR0_04_TRRD_ENCODE(n) ((((u32)(n))&0x7)<<16)
  754. #define DDR0_04_TRRD_DECODE(n) ((((u32)(n))>>16)&0x7)
  755. #define DDR0_04_TRTP_MASK 0x00000700
  756. #define DDR0_04_TRTP_ENCODE(n) ((((u32)(n))&0x7)<<8)
  757. #define DDR0_04_TRTP_DECODE(n) ((((u32)(n))>>8)&0x7)
  758. #define DDR0_05 0x05
  759. #define DDR0_05_TMRD_MASK 0x1F000000
  760. #define DDR0_05_TMRD_ENCODE(n) ((((u32)(n))&0x1F)<<24)
  761. #define DDR0_05_TMRD_DECODE(n) ((((u32)(n))>>24)&0x1F)
  762. #define DDR0_05_TEMRS_MASK 0x00070000
  763. #define DDR0_05_TEMRS_ENCODE(n) ((((u32)(n))&0x7)<<16)
  764. #define DDR0_05_TEMRS_DECODE(n) ((((u32)(n))>>16)&0x7)
  765. #define DDR0_05_TRP_MASK 0x00000F00
  766. #define DDR0_05_TRP_ENCODE(n) ((((u32)(n))&0xF)<<8)
  767. #define DDR0_05_TRP_DECODE(n) ((((u32)(n))>>8)&0xF)
  768. #define DDR0_05_TRAS_MIN_MASK 0x000000FF
  769. #define DDR0_05_TRAS_MIN_ENCODE(n) ((((u32)(n))&0xFF)<<0)
  770. #define DDR0_05_TRAS_MIN_DECODE(n) ((((u32)(n))>>0)&0xFF)
  771. #define DDR0_06 0x06
  772. #define DDR0_06_WRITEINTERP_MASK 0x01000000
  773. #define DDR0_06_WRITEINTERP_ENCODE(n) ((((u32)(n))&0x1)<<24)
  774. #define DDR0_06_WRITEINTERP_DECODE(n) ((((u32)(n))>>24)&0x1)
  775. #define DDR0_06_TWTR_MASK 0x00070000
  776. #define DDR0_06_TWTR_ENCODE(n) ((((u32)(n))&0x7)<<16)
  777. #define DDR0_06_TWTR_DECODE(n) ((((u32)(n))>>16)&0x7)
  778. #define DDR0_06_TDLL_MASK 0x0000FF00
  779. #define DDR0_06_TDLL_ENCODE(n) ((((u32)(n))&0xFF)<<8)
  780. #define DDR0_06_TDLL_DECODE(n) ((((u32)(n))>>8)&0xFF)
  781. #define DDR0_06_TRFC_MASK 0x0000007F
  782. #define DDR0_06_TRFC_ENCODE(n) ((((u32)(n))&0x7F)<<0)
  783. #define DDR0_06_TRFC_DECODE(n) ((((u32)(n))>>0)&0x7F)
  784. #define DDR0_07 0x07
  785. #define DDR0_07_NO_CMD_INIT_MASK 0x01000000
  786. #define DDR0_07_NO_CMD_INIT_ENCODE(n) ((((u32)(n))&0x1)<<24)
  787. #define DDR0_07_NO_CMD_INIT_DECODE(n) ((((u32)(n))>>24)&0x1)
  788. #define DDR0_07_TFAW_MASK 0x001F0000
  789. #define DDR0_07_TFAW_ENCODE(n) ((((u32)(n))&0x1F)<<16)
  790. #define DDR0_07_TFAW_DECODE(n) ((((u32)(n))>>16)&0x1F)
  791. #define DDR0_07_AUTO_REFRESH_MODE_MASK 0x00000100
  792. #define DDR0_07_AUTO_REFRESH_MODE_ENCODE(n) ((((u32)(n))&0x1)<<8)
  793. #define DDR0_07_AUTO_REFRESH_MODE_DECODE(n) ((((u32)(n))>>8)&0x1)
  794. #define DDR0_07_AREFRESH_MASK 0x00000001
  795. #define DDR0_07_AREFRESH_ENCODE(n) ((((u32)(n))&0x1)<<0)
  796. #define DDR0_07_AREFRESH_DECODE(n) ((((u32)(n))>>0)&0x1)
  797. #define DDR0_08 0x08
  798. #define DDR0_08_WRLAT_MASK 0x07000000
  799. #define DDR0_08_WRLAT_ENCODE(n) ((((u32)(n))&0x7)<<24)
  800. #define DDR0_08_WRLAT_DECODE(n) ((((u32)(n))>>24)&0x7)
  801. #define DDR0_08_TCPD_MASK 0x00FF0000
  802. #define DDR0_08_TCPD_ENCODE(n) ((((u32)(n))&0xFF)<<16)
  803. #define DDR0_08_TCPD_DECODE(n) ((((u32)(n))>>16)&0xFF)
  804. #define DDR0_08_DQS_N_EN_MASK 0x00000100
  805. #define DDR0_08_DQS_N_EN_ENCODE(n) ((((u32)(n))&0x1)<<8)
  806. #define DDR0_08_DQS_N_EN_DECODE(n) ((((u32)(n))>>8)&0x1)
  807. #define DDR0_08_DDRII_SDRAM_MODE_MASK 0x00000001
  808. #define DDR0_08_DDRII_ENCODE(n) ((((u32)(n))&0x1)<<0)
  809. #define DDR0_08_DDRII_DECODE(n) ((((u32)(n))>>0)&0x1)
  810. #define DDR0_09 0x09
  811. #define DDR0_09_OCD_ADJUST_PDN_CS_0_MASK 0x1F000000
  812. #define DDR0_09_OCD_ADJUST_PDN_CS_0_ENCODE(n) ((((u32)(n))&0x1F)<<24)
  813. #define DDR0_09_OCD_ADJUST_PDN_CS_0_DECODE(n) ((((u32)(n))>>24)&0x1F)
  814. #define DDR0_09_RTT_0_MASK 0x00030000
  815. #define DDR0_09_RTT_0_ENCODE(n) ((((u32)(n))&0x3)<<16)
  816. #define DDR0_09_RTT_0_DECODE(n) ((((u32)(n))>>16)&0x3)
  817. #define DDR0_09_WR_DQS_SHIFT_BYPASS_MASK 0x00007F00
  818. #define DDR0_09_WR_DQS_SHIFT_BYPASS_ENCODE(n) ((((u32)(n))&0x7F)<<8)
  819. #define DDR0_09_WR_DQS_SHIFT_BYPASS_DECODE(n) ((((u32)(n))>>8)&0x7F)
  820. #define DDR0_09_WR_DQS_SHIFT_MASK 0x0000007F
  821. #define DDR0_09_WR_DQS_SHIFT_ENCODE(n) ((((u32)(n))&0x7F)<<0)
  822. #define DDR0_09_WR_DQS_SHIFT_DECODE(n) ((((u32)(n))>>0)&0x7F)
  823. #define DDR0_10 0x0A
  824. #define DDR0_10_WRITE_MODEREG_MASK 0x00010000 /* Write only */
  825. #define DDR0_10_WRITE_MODEREG_ENCODE(n) ((((u32)(n))&0x1)<<16)
  826. #define DDR0_10_WRITE_MODEREG_DECODE(n) ((((u32)(n))>>16)&0x1)
  827. #define DDR0_10_CS_MAP_MASK 0x00000300
  828. #define DDR0_10_CS_MAP_NO_MEM 0x00000000
  829. #define DDR0_10_CS_MAP_RANK0_INSTALLED 0x00000100
  830. #define DDR0_10_CS_MAP_RANK1_INSTALLED 0x00000200
  831. #define DDR0_10_CS_MAP_ENCODE(n) ((((u32)(n))&0x3)<<8)
  832. #define DDR0_10_CS_MAP_DECODE(n) ((((u32)(n))>>8)&0x3)
  833. #define DDR0_10_OCD_ADJUST_PUP_CS_0_MASK 0x0000001F
  834. #define DDR0_10_OCD_ADJUST_PUP_CS_0_ENCODE(n) ((((u32)(n))&0x1F)<<0)
  835. #define DDR0_10_OCD_ADJUST_PUP_CS_0_DECODE(n) ((((u32)(n))>>0)&0x1F)
  836. #define DDR0_11 0x0B
  837. #define DDR0_11_SREFRESH_MASK 0x01000000
  838. #define DDR0_11_SREFRESH_ENCODE(n) ((((u32)(n))&0x1)<<24)
  839. #define DDR0_11_SREFRESH_DECODE(n) ((((u32)(n))>>24)&0x1F)
  840. #define DDR0_11_TXSNR_MASK 0x00FF0000
  841. #define DDR0_11_TXSNR_ENCODE(n) ((((u32)(n))&0xFF)<<16)
  842. #define DDR0_11_TXSNR_DECODE(n) ((((u32)(n))>>16)&0xFF)
  843. #define DDR0_11_TXSR_MASK 0x0000FF00
  844. #define DDR0_11_TXSR_ENCODE(n) ((((u32)(n))&0xFF)<<8)
  845. #define DDR0_11_TXSR_DECODE(n) ((((u32)(n))>>8)&0xFF)
  846. #define DDR0_12 0x0C
  847. #define DDR0_12_TCKE_MASK 0x0000007
  848. #define DDR0_12_TCKE_ENCODE(n) ((((u32)(n))&0x7)<<0)
  849. #define DDR0_12_TCKE_DECODE(n) ((((u32)(n))>>0)&0x7)
  850. #define DDR0_14 0x0E
  851. #define DDR0_14_DLL_BYPASS_MODE_MASK 0x01000000
  852. #define DDR0_14_DLL_BYPASS_MODE_ENCODE(n) ((((u32)(n))&0x1)<<24)
  853. #define DDR0_14_DLL_BYPASS_MODE_DECODE(n) ((((u32)(n))>>24)&0x1)
  854. #define DDR0_14_REDUC_MASK 0x00010000
  855. #define DDR0_14_REDUC_64BITS 0x00000000
  856. #define DDR0_14_REDUC_32BITS 0x00010000
  857. #define DDR0_14_REDUC_ENCODE(n) ((((u32)(n))&0x1)<<16)
  858. #define DDR0_14_REDUC_DECODE(n) ((((u32)(n))>>16)&0x1)
  859. #define DDR0_14_REG_DIMM_ENABLE_MASK 0x00000100
  860. #define DDR0_14_REG_DIMM_ENABLE_ENCODE(n) ((((u32)(n))&0x1)<<8)
  861. #define DDR0_14_REG_DIMM_ENABLE_DECODE(n) ((((u32)(n))>>8)&0x1)
  862. #define DDR0_17 0x11
  863. #define DDR0_17_DLL_DQS_DELAY_0_MASK 0x7F000000
  864. #define DDR0_17_DLL_DQS_DELAY_0_ENCODE(n) ((((u32)(n))&0x7F)<<24)
  865. #define DDR0_17_DLL_DQS_DELAY_0_DECODE(n) ((((u32)(n))>>24)&0x7F)
  866. #define DDR0_17_DLLLOCKREG_MASK 0x00010000 /* Read only */
  867. #define DDR0_17_DLLLOCKREG_LOCKED 0x00010000
  868. #define DDR0_17_DLLLOCKREG_UNLOCKED 0x00000000
  869. #define DDR0_17_DLLLOCKREG_ENCODE(n) ((((u32)(n))&0x1)<<16)
  870. #define DDR0_17_DLLLOCKREG_DECODE(n) ((((u32)(n))>>16)&0x1)
  871. #define DDR0_17_DLL_LOCK_MASK 0x00007F00 /* Read only */
  872. #define DDR0_17_DLL_LOCK_ENCODE(n) ((((u32)(n))&0x7F)<<8)
  873. #define DDR0_17_DLL_LOCK_DECODE(n) ((((u32)(n))>>8)&0x7F)
  874. #define DDR0_18 0x12
  875. #define DDR0_18_DLL_DQS_DELAY_X_MASK 0x7F7F7F7F
  876. #define DDR0_18_DLL_DQS_DELAY_4_MASK 0x7F000000
  877. #define DDR0_18_DLL_DQS_DELAY_4_ENCODE(n) ((((u32)(n))&0x7F)<<24)
  878. #define DDR0_18_DLL_DQS_DELAY_4_DECODE(n) ((((u32)(n))>>24)&0x7F)
  879. #define DDR0_18_DLL_DQS_DELAY_3_MASK 0x007F0000
  880. #define DDR0_18_DLL_DQS_DELAY_3_ENCODE(n) ((((u32)(n))&0x7F)<<16)
  881. #define DDR0_18_DLL_DQS_DELAY_3_DECODE(n) ((((u32)(n))>>16)&0x7F)
  882. #define DDR0_18_DLL_DQS_DELAY_2_MASK 0x00007F00
  883. #define DDR0_18_DLL_DQS_DELAY_2_ENCODE(n) ((((u32)(n))&0x7F)<<8)
  884. #define DDR0_18_DLL_DQS_DELAY_2_DECODE(n) ((((u32)(n))>>8)&0x7F)
  885. #define DDR0_18_DLL_DQS_DELAY_1_MASK 0x0000007F
  886. #define DDR0_18_DLL_DQS_DELAY_1_ENCODE(n) ((((u32)(n))&0x7F)<<0)
  887. #define DDR0_18_DLL_DQS_DELAY_1_DECODE(n) ((((u32)(n))>>0)&0x7F)
  888. #define DDR0_19 0x13
  889. #define DDR0_19_DLL_DQS_DELAY_X_MASK 0x7F7F7F7F
  890. #define DDR0_19_DLL_DQS_DELAY_8_MASK 0x7F000000
  891. #define DDR0_19_DLL_DQS_DELAY_8_ENCODE(n) ((((u32)(n))&0x7F)<<24)
  892. #define DDR0_19_DLL_DQS_DELAY_8_DECODE(n) ((((u32)(n))>>24)&0x7F)
  893. #define DDR0_19_DLL_DQS_DELAY_7_MASK 0x007F0000
  894. #define DDR0_19_DLL_DQS_DELAY_7_ENCODE(n) ((((u32)(n))&0x7F)<<16)
  895. #define DDR0_19_DLL_DQS_DELAY_7_DECODE(n) ((((u32)(n))>>16)&0x7F)
  896. #define DDR0_19_DLL_DQS_DELAY_6_MASK 0x00007F00
  897. #define DDR0_19_DLL_DQS_DELAY_6_ENCODE(n) ((((u32)(n))&0x7F)<<8)
  898. #define DDR0_19_DLL_DQS_DELAY_6_DECODE(n) ((((u32)(n))>>8)&0x7F)
  899. #define DDR0_19_DLL_DQS_DELAY_5_MASK 0x0000007F
  900. #define DDR0_19_DLL_DQS_DELAY_5_ENCODE(n) ((((u32)(n))&0x7F)<<0)
  901. #define DDR0_19_DLL_DQS_DELAY_5_DECODE(n) ((((u32)(n))>>0)&0x7F)
  902. #define DDR0_20 0x14
  903. #define DDR0_20_DLL_DQS_BYPASS_3_MASK 0x7F000000
  904. #define DDR0_20_DLL_DQS_BYPASS_3_ENCODE(n) ((((u32)(n))&0x7F)<<24)
  905. #define DDR0_20_DLL_DQS_BYPASS_3_DECODE(n) ((((u32)(n))>>24)&0x7F)
  906. #define DDR0_20_DLL_DQS_BYPASS_2_MASK 0x007F0000
  907. #define DDR0_20_DLL_DQS_BYPASS_2_ENCODE(n) ((((u32)(n))&0x7F)<<16)
  908. #define DDR0_20_DLL_DQS_BYPASS_2_DECODE(n) ((((u32)(n))>>16)&0x7F)
  909. #define DDR0_20_DLL_DQS_BYPASS_1_MASK 0x00007F00
  910. #define DDR0_20_DLL_DQS_BYPASS_1_ENCODE(n) ((((u32)(n))&0x7F)<<8)
  911. #define DDR0_20_DLL_DQS_BYPASS_1_DECODE(n) ((((u32)(n))>>8)&0x7F)
  912. #define DDR0_20_DLL_DQS_BYPASS_0_MASK 0x0000007F
  913. #define DDR0_20_DLL_DQS_BYPASS_0_ENCODE(n) ((((u32)(n))&0x7F)<<0)
  914. #define DDR0_20_DLL_DQS_BYPASS_0_DECODE(n) ((((u32)(n))>>0)&0x7F)
  915. #define DDR0_21 0x15
  916. #define DDR0_21_DLL_DQS_BYPASS_7_MASK 0x7F000000
  917. #define DDR0_21_DLL_DQS_BYPASS_7_ENCODE(n) ((((u32)(n))&0x7F)<<24)
  918. #define DDR0_21_DLL_DQS_BYPASS_7_DECODE(n) ((((u32)(n))>>24)&0x7F)
  919. #define DDR0_21_DLL_DQS_BYPASS_6_MASK 0x007F0000
  920. #define DDR0_21_DLL_DQS_BYPASS_6_ENCODE(n) ((((u32)(n))&0x7F)<<16)
  921. #define DDR0_21_DLL_DQS_BYPASS_6_DECODE(n) ((((u32)(n))>>16)&0x7F)
  922. #define DDR0_21_DLL_DQS_BYPASS_5_MASK 0x00007F00
  923. #define DDR0_21_DLL_DQS_BYPASS_5_ENCODE(n) ((((u32)(n))&0x7F)<<8)
  924. #define DDR0_21_DLL_DQS_BYPASS_5_DECODE(n) ((((u32)(n))>>8)&0x7F)
  925. #define DDR0_21_DLL_DQS_BYPASS_4_MASK 0x0000007F
  926. #define DDR0_21_DLL_DQS_BYPASS_4_ENCODE(n) ((((u32)(n))&0x7F)<<0)
  927. #define DDR0_21_DLL_DQS_BYPASS_4_DECODE(n) ((((u32)(n))>>0)&0x7F)
  928. #define DDR0_22 0x16
  929. #define DDR0_22_CTRL_RAW_MASK 0x03000000
  930. #define DDR0_22_CTRL_RAW_ECC_DISABLE 0x00000000
  931. #define DDR0_22_CTRL_RAW_ECC_CHECK_ONLY 0x01000000
  932. #define DDR0_22_CTRL_RAW_NO_ECC_RAM 0x02000000
  933. #define DDR0_22_CTRL_RAW_ECC_ENABLE 0x03000000
  934. #define DDR0_22_CTRL_RAW_ENCODE(n) ((((u32)(n))&0x3)<<24)
  935. #define DDR0_22_CTRL_RAW_DECODE(n) ((((u32)(n))>>24)&0x3)
  936. #define DDR0_22_DQS_OUT_SHIFT_BYPASS_MASK 0x007F0000
  937. #define DDR0_22_DQS_OUT_SHIFT_BYPASS_ENCODE(n) ((((u32)(n))&0x7F)<<16)
  938. #define DDR0_22_DQS_OUT_SHIFT_BYPASS_DECODE(n) ((((u32)(n))>>16)&0x7F)
  939. #define DDR0_22_DQS_OUT_SHIFT_MASK 0x00007F00
  940. #define DDR0_22_DQS_OUT_SHIFT_ENCODE(n) ((((u32)(n))&0x7F)<<8)
  941. #define DDR0_22_DQS_OUT_SHIFT_DECODE(n) ((((u32)(n))>>8)&0x7F)
  942. #define DDR0_22_DLL_DQS_BYPASS_8_MASK 0x0000007F
  943. #define DDR0_22_DLL_DQS_BYPASS_8_ENCODE(n) ((((u32)(n))&0x7F)<<0)
  944. #define DDR0_22_DLL_DQS_BYPASS_8_DECODE(n) ((((u32)(n))>>0)&0x7F)
  945. #define DDR0_23 0x17
  946. #define DDR0_23_ODT_RD_MAP_CS0_MASK 0x03000000
  947. #define DDR0_23_ODT_RD_MAP_CS0_ENCODE(n) ((((u32)(n))&0x3)<<24)
  948. #define DDR0_23_ODT_RD_MAP_CS0_DECODE(n) ((((u32)(n))>>24)&0x3)
  949. #define DDR0_23_ECC_C_SYND_MASK 0x00FF0000 /* Read only */
  950. #define DDR0_23_ECC_C_SYND_ENCODE(n) ((((u32)(n))&0xFF)<<16)
  951. #define DDR0_23_ECC_C_SYND_DECODE(n) ((((u32)(n))>>16)&0xFF)
  952. #define DDR0_23_ECC_U_SYND_MASK 0x0000FF00 /* Read only */
  953. #define DDR0_23_ECC_U_SYND_ENCODE(n) ((((u32)(n))&0xFF)<<8)
  954. #define DDR0_23_ECC_U_SYND_DECODE(n) ((((u32)(n))>>8)&0xFF)
  955. #define DDR0_23_FWC_MASK 0x00000001 /* Write only */
  956. #define DDR0_23_FWC_ENCODE(n) ((((u32)(n))&0x1)<<0)
  957. #define DDR0_23_FWC_DECODE(n) ((((u32)(n))>>0)&0x1)
  958. #define DDR0_24 0x18
  959. #define DDR0_24_RTT_PAD_TERMINATION_MASK 0x03000000
  960. #define DDR0_24_RTT_PAD_TERMINATION_ENCODE(n) ((((u32)(n))&0x3)<<24)
  961. #define DDR0_24_RTT_PAD_TERMINATION_DECODE(n) ((((u32)(n))>>24)&0x3)
  962. #define DDR0_24_ODT_WR_MAP_CS1_MASK 0x00030000
  963. #define DDR0_24_ODT_WR_MAP_CS1_ENCODE(n) ((((u32)(n))&0x3)<<16)
  964. #define DDR0_24_ODT_WR_MAP_CS1_DECODE(n) ((((u32)(n))>>16)&0x3)
  965. #define DDR0_24_ODT_RD_MAP_CS1_MASK 0x00000300
  966. #define DDR0_24_ODT_RD_MAP_CS1_ENCODE(n) ((((u32)(n))&0x3)<<8)
  967. #define DDR0_24_ODT_RD_MAP_CS1_DECODE(n) ((((u32)(n))>>8)&0x3)
  968. #define DDR0_24_ODT_WR_MAP_CS0_MASK 0x00000003
  969. #define DDR0_24_ODT_WR_MAP_CS0_ENCODE(n) ((((u32)(n))&0x3)<<0)
  970. #define DDR0_24_ODT_WR_MAP_CS0_DECODE(n) ((((u32)(n))>>0)&0x3)
  971. #define DDR0_25 0x19
  972. #define DDR0_25_VERSION_MASK 0xFFFF0000 /* Read only */
  973. #define DDR0_25_VERSION_ENCODE(n) ((((u32)(n))&0xFFFF)<<16)
  974. #define DDR0_25_VERSION_DECODE(n) ((((u32)(n))>>16)&0xFFFF)
  975. #define DDR0_25_OUT_OF_RANGE_LENGTH_MASK 0x000003FF /* Read only */
  976. #define DDR0_25_OUT_OF_RANGE_LENGTH_ENCODE(n) ((((u32)(n))&0x3FF)<<0)
  977. #define DDR0_25_OUT_OF_RANGE_LENGTH_DECODE(n) ((((u32)(n))>>0)&0x3FF)
  978. #define DDR0_26 0x1A
  979. #define DDR0_26_TRAS_MAX_MASK 0xFFFF0000
  980. #define DDR0_26_TRAS_MAX_ENCODE(n) ((((u32)(n))&0xFFFF)<<16)
  981. #define DDR0_26_TRAS_MAX_DECODE(n) ((((u32)(n))>>16)&0xFFFF)
  982. #define DDR0_26_TREF_MASK 0x00003FFF
  983. #define DDR0_26_TREF_ENCODE(n) ((((u32)(n))&0x3FFF)<<0)
  984. #define DDR0_26_TREF_DECODE(n) ((((u32)(n))>>0)&0x3FFF)
  985. #define DDR0_27 0x1B
  986. #define DDR0_27_EMRS_DATA_MASK 0x3FFF0000
  987. #define DDR0_27_EMRS_DATA_ENCODE(n) ((((u32)(n))&0x3FFF)<<16)
  988. #define DDR0_27_EMRS_DATA_DECODE(n) ((((u32)(n))>>16)&0x3FFF)
  989. #define DDR0_27_TINIT_MASK 0x0000FFFF
  990. #define DDR0_27_TINIT_ENCODE(n) ((((u32)(n))&0xFFFF)<<0)
  991. #define DDR0_27_TINIT_DECODE(n) ((((u32)(n))>>0)&0xFFFF)
  992. #define DDR0_28 0x1C
  993. #define DDR0_28_EMRS3_DATA_MASK 0x3FFF0000
  994. #define DDR0_28_EMRS3_DATA_ENCODE(n) ((((u32)(n))&0x3FFF)<<16)
  995. #define DDR0_28_EMRS3_DATA_DECODE(n) ((((u32)(n))>>16)&0x3FFF)
  996. #define DDR0_28_EMRS2_DATA_MASK 0x00003FFF
  997. #define DDR0_28_EMRS2_DATA_ENCODE(n) ((((u32)(n))&0x3FFF)<<0)
  998. #define DDR0_28_EMRS2_DATA_DECODE(n) ((((u32)(n))>>0)&0x3FFF)
  999. #define DDR0_31 0x1F
  1000. #define DDR0_31_XOR_CHECK_BITS_MASK 0x0000FFFF
  1001. #define DDR0_31_XOR_CHECK_BITS_ENCODE(n) ((((u32)(n))&0xFFFF)<<0)
  1002. #define DDR0_31_XOR_CHECK_BITS_DECODE(n) ((((u32)(n))>>0)&0xFFFF)
  1003. #define DDR0_32 0x20
  1004. #define DDR0_32_OUT_OF_RANGE_ADDR_MASK 0xFFFFFFFF /* Read only */
  1005. #define DDR0_32_OUT_OF_RANGE_ADDR_ENCODE(n) ((((u32)(n))&0xFFFFFFFF)<<0)
  1006. #define DDR0_32_OUT_OF_RANGE_ADDR_DECODE(n) ((((u32)(n))>>0)&0xFFFFFFFF)
  1007. #define DDR0_33 0x21
  1008. #define DDR0_33_OUT_OF_RANGE_ADDR_MASK 0x00000001 /* Read only */
  1009. #define DDR0_33_OUT_OF_RANGE_ADDR_ENCODE(n) ((((u32)(n))&0x1)<<0)
  1010. #define DDR0_33_OUT_OF_RANGE_ADDR_DECODE(n) ((((u32)(n))>>0)&0x1)
  1011. #define DDR0_34 0x22
  1012. #define DDR0_34_ECC_U_ADDR_MASK 0xFFFFFFFF /* Read only */
  1013. #define DDR0_34_ECC_U_ADDR_ENCODE(n) ((((u32)(n))&0xFFFFFFFF)<<0)
  1014. #define DDR0_34_ECC_U_ADDR_DECODE(n) ((((u32)(n))>>0)&0xFFFFFFFF)
  1015. #define DDR0_35 0x23
  1016. #define DDR0_35_ECC_U_ADDR_MASK 0x00000001 /* Read only */
  1017. #define DDR0_35_ECC_U_ADDR_ENCODE(n) ((((u32)(n))&0x1)<<0)
  1018. #define DDR0_35_ECC_U_ADDR_DECODE(n) ((((u32)(n))>>0)&0x1)
  1019. #define DDR0_36 0x24
  1020. #define DDR0_36_ECC_U_DATA_MASK 0xFFFFFFFF /* Read only */
  1021. #define DDR0_36_ECC_U_DATA_ENCODE(n) ((((u32)(n))&0xFFFFFFFF)<<0)
  1022. #define DDR0_36_ECC_U_DATA_DECODE(n) ((((u32)(n))>>0)&0xFFFFFFFF)
  1023. #define DDR0_37 0x25
  1024. #define DDR0_37_ECC_U_DATA_MASK 0xFFFFFFFF /* Read only */
  1025. #define DDR0_37_ECC_U_DATA_ENCODE(n) ((((u32)(n))&0xFFFFFFFF)<<0)
  1026. #define DDR0_37_ECC_U_DATA_DECODE(n) ((((u32)(n))>>0)&0xFFFFFFFF)
  1027. #define DDR0_38 0x26
  1028. #define DDR0_38_ECC_C_ADDR_MASK 0xFFFFFFFF /* Read only */
  1029. #define DDR0_38_ECC_C_ADDR_ENCODE(n) ((((u32)(n))&0xFFFFFFFF)<<0)
  1030. #define DDR0_38_ECC_C_ADDR_DECODE(n) ((((u32)(n))>>0)&0xFFFFFFFF)
  1031. #define DDR0_39 0x27
  1032. #define DDR0_39_ECC_C_ADDR_MASK 0x00000001 /* Read only */
  1033. #define DDR0_39_ECC_C_ADDR_ENCODE(n) ((((u32)(n))&0x1)<<0)
  1034. #define DDR0_39_ECC_C_ADDR_DECODE(n) ((((u32)(n))>>0)&0x1)
  1035. #define DDR0_40 0x28
  1036. #define DDR0_40_ECC_C_DATA_MASK 0xFFFFFFFF /* Read only */
  1037. #define DDR0_40_ECC_C_DATA_ENCODE(n) ((((u32)(n))&0xFFFFFFFF)<<0)
  1038. #define DDR0_40_ECC_C_DATA_DECODE(n) ((((u32)(n))>>0)&0xFFFFFFFF)
  1039. #define DDR0_41 0x29
  1040. #define DDR0_41_ECC_C_DATA_MASK 0xFFFFFFFF /* Read only */
  1041. #define DDR0_41_ECC_C_DATA_ENCODE(n) ((((u32)(n))&0xFFFFFFFF)<<0)
  1042. #define DDR0_41_ECC_C_DATA_DECODE(n) ((((u32)(n))>>0)&0xFFFFFFFF)
  1043. #define DDR0_42 0x2A
  1044. #define DDR0_42_ADDR_PINS_MASK 0x07000000
  1045. #define DDR0_42_ADDR_PINS_ENCODE(n) ((((u32)(n))&0x7)<<24)
  1046. #define DDR0_42_ADDR_PINS_DECODE(n) ((((u32)(n))>>24)&0x7)
  1047. #define DDR0_42_CASLAT_LIN_GATE_MASK 0x0000000F
  1048. #define DDR0_42_CASLAT_LIN_GATE_ENCODE(n) ((((u32)(n))&0xF)<<0)
  1049. #define DDR0_42_CASLAT_LIN_GATE_DECODE(n) ((((u32)(n))>>0)&0xF)
  1050. #define DDR0_43 0x2B
  1051. #define DDR0_43_TWR_MASK 0x07000000
  1052. #define DDR0_43_TWR_ENCODE(n) ((((u32)(n))&0x7)<<24)
  1053. #define DDR0_43_TWR_DECODE(n) ((((u32)(n))>>24)&0x7)
  1054. #define DDR0_43_APREBIT_MASK 0x000F0000
  1055. #define DDR0_43_APREBIT_ENCODE(n) ((((u32)(n))&0xF)<<16)
  1056. #define DDR0_43_APREBIT_DECODE(n) ((((u32)(n))>>16)&0xF)
  1057. #define DDR0_43_COLUMN_SIZE_MASK 0x00000700
  1058. #define DDR0_43_COLUMN_SIZE_ENCODE(n) ((((u32)(n))&0x7)<<8)
  1059. #define DDR0_43_COLUMN_SIZE_DECODE(n) ((((u32)(n))>>8)&0x7)
  1060. #define DDR0_43_EIGHT_BANK_MODE_MASK 0x00000001
  1061. #define DDR0_43_EIGHT_BANK_MODE_8_BANKS 0x00000001
  1062. #define DDR0_43_EIGHT_BANK_MODE_4_BANKS 0x00000000
  1063. #define DDR0_43_EIGHT_BANK_MODE_ENCODE(n) ((((u32)(n))&0x1)<<0)
  1064. #define DDR0_43_EIGHT_BANK_MODE_DECODE(n) ((((u32)(n))>>0)&0x1)
  1065. #define DDR0_44 0x2C
  1066. #define DDR0_44_TRCD_MASK 0x000000FF
  1067. #define DDR0_44_TRCD_ENCODE(n) ((((u32)(n))&0xFF)<<0)
  1068. #define DDR0_44_TRCD_DECODE(n) ((((u32)(n))>>0)&0xFF)
  1069. #endif /* CONFIG_SDRAM_PPC4xx_DENALI_DDR2 */
  1070. #endif /* _PPC4xx_SDRAM_H_ */