emif.h 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035
  1. /*
  2. * OMAP44xx EMIF header
  3. *
  4. * Copyright (C) 2009-2010 Texas Instruments, Inc.
  5. *
  6. * Aneesh V <aneesh@ti.com>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License version 2 as
  10. * published by the Free Software Foundation.
  11. */
  12. #ifndef _EMIF_H_
  13. #define _EMIF_H_
  14. #include <asm/types.h>
  15. #include <common.h>
  16. /* Base address */
  17. #define EMIF1_BASE 0x4c000000
  18. #define EMIF2_BASE 0x4d000000
  19. /* Registers shifts and masks */
  20. /* EMIF_MOD_ID_REV */
  21. #define EMIF_REG_SCHEME_SHIFT 30
  22. #define EMIF_REG_SCHEME_MASK (0x3 << 30)
  23. #define EMIF_REG_MODULE_ID_SHIFT 16
  24. #define EMIF_REG_MODULE_ID_MASK (0xfff << 16)
  25. #define EMIF_REG_RTL_VERSION_SHIFT 11
  26. #define EMIF_REG_RTL_VERSION_MASK (0x1f << 11)
  27. #define EMIF_REG_MAJOR_REVISION_SHIFT 8
  28. #define EMIF_REG_MAJOR_REVISION_MASK (0x7 << 8)
  29. #define EMIF_REG_MINOR_REVISION_SHIFT 0
  30. #define EMIF_REG_MINOR_REVISION_MASK (0x3f << 0)
  31. /* STATUS */
  32. #define EMIF_REG_BE_SHIFT 31
  33. #define EMIF_REG_BE_MASK (1 << 31)
  34. #define EMIF_REG_DUAL_CLK_MODE_SHIFT 30
  35. #define EMIF_REG_DUAL_CLK_MODE_MASK (1 << 30)
  36. #define EMIF_REG_FAST_INIT_SHIFT 29
  37. #define EMIF_REG_FAST_INIT_MASK (1 << 29)
  38. #define EMIF_REG_PHY_DLL_READY_SHIFT 2
  39. #define EMIF_REG_PHY_DLL_READY_MASK (1 << 2)
  40. /* SDRAM_CONFIG */
  41. #define EMIF_REG_SDRAM_TYPE_SHIFT 29
  42. #define EMIF_REG_SDRAM_TYPE_MASK (0x7 << 29)
  43. #define EMIF_REG_IBANK_POS_SHIFT 27
  44. #define EMIF_REG_IBANK_POS_MASK (0x3 << 27)
  45. #define EMIF_REG_DDR_TERM_SHIFT 24
  46. #define EMIF_REG_DDR_TERM_MASK (0x7 << 24)
  47. #define EMIF_REG_DDR2_DDQS_SHIFT 23
  48. #define EMIF_REG_DDR2_DDQS_MASK (1 << 23)
  49. #define EMIF_REG_DYN_ODT_SHIFT 21
  50. #define EMIF_REG_DYN_ODT_MASK (0x3 << 21)
  51. #define EMIF_REG_DDR_DISABLE_DLL_SHIFT 20
  52. #define EMIF_REG_DDR_DISABLE_DLL_MASK (1 << 20)
  53. #define EMIF_REG_SDRAM_DRIVE_SHIFT 18
  54. #define EMIF_REG_SDRAM_DRIVE_MASK (0x3 << 18)
  55. #define EMIF_REG_CWL_SHIFT 16
  56. #define EMIF_REG_CWL_MASK (0x3 << 16)
  57. #define EMIF_REG_NARROW_MODE_SHIFT 14
  58. #define EMIF_REG_NARROW_MODE_MASK (0x3 << 14)
  59. #define EMIF_REG_CL_SHIFT 10
  60. #define EMIF_REG_CL_MASK (0xf << 10)
  61. #define EMIF_REG_ROWSIZE_SHIFT 7
  62. #define EMIF_REG_ROWSIZE_MASK (0x7 << 7)
  63. #define EMIF_REG_IBANK_SHIFT 4
  64. #define EMIF_REG_IBANK_MASK (0x7 << 4)
  65. #define EMIF_REG_EBANK_SHIFT 3
  66. #define EMIF_REG_EBANK_MASK (1 << 3)
  67. #define EMIF_REG_PAGESIZE_SHIFT 0
  68. #define EMIF_REG_PAGESIZE_MASK (0x7 << 0)
  69. /* SDRAM_CONFIG_2 */
  70. #define EMIF_REG_CS1NVMEN_SHIFT 30
  71. #define EMIF_REG_CS1NVMEN_MASK (1 << 30)
  72. #define EMIF_REG_EBANK_POS_SHIFT 27
  73. #define EMIF_REG_EBANK_POS_MASK (1 << 27)
  74. #define EMIF_REG_RDBNUM_SHIFT 4
  75. #define EMIF_REG_RDBNUM_MASK (0x3 << 4)
  76. #define EMIF_REG_RDBSIZE_SHIFT 0
  77. #define EMIF_REG_RDBSIZE_MASK (0x7 << 0)
  78. /* SDRAM_REF_CTRL */
  79. #define EMIF_REG_INITREF_DIS_SHIFT 31
  80. #define EMIF_REG_INITREF_DIS_MASK (1 << 31)
  81. #define EMIF_REG_SRT_SHIFT 29
  82. #define EMIF_REG_SRT_MASK (1 << 29)
  83. #define EMIF_REG_ASR_SHIFT 28
  84. #define EMIF_REG_ASR_MASK (1 << 28)
  85. #define EMIF_REG_PASR_SHIFT 24
  86. #define EMIF_REG_PASR_MASK (0x7 << 24)
  87. #define EMIF_REG_REFRESH_RATE_SHIFT 0
  88. #define EMIF_REG_REFRESH_RATE_MASK (0xffff << 0)
  89. /* SDRAM_REF_CTRL_SHDW */
  90. #define EMIF_REG_REFRESH_RATE_SHDW_SHIFT 0
  91. #define EMIF_REG_REFRESH_RATE_SHDW_MASK (0xffff << 0)
  92. /* SDRAM_TIM_1 */
  93. #define EMIF_REG_T_RP_SHIFT 25
  94. #define EMIF_REG_T_RP_MASK (0xf << 25)
  95. #define EMIF_REG_T_RCD_SHIFT 21
  96. #define EMIF_REG_T_RCD_MASK (0xf << 21)
  97. #define EMIF_REG_T_WR_SHIFT 17
  98. #define EMIF_REG_T_WR_MASK (0xf << 17)
  99. #define EMIF_REG_T_RAS_SHIFT 12
  100. #define EMIF_REG_T_RAS_MASK (0x1f << 12)
  101. #define EMIF_REG_T_RC_SHIFT 6
  102. #define EMIF_REG_T_RC_MASK (0x3f << 6)
  103. #define EMIF_REG_T_RRD_SHIFT 3
  104. #define EMIF_REG_T_RRD_MASK (0x7 << 3)
  105. #define EMIF_REG_T_WTR_SHIFT 0
  106. #define EMIF_REG_T_WTR_MASK (0x7 << 0)
  107. /* SDRAM_TIM_1_SHDW */
  108. #define EMIF_REG_T_RP_SHDW_SHIFT 25
  109. #define EMIF_REG_T_RP_SHDW_MASK (0xf << 25)
  110. #define EMIF_REG_T_RCD_SHDW_SHIFT 21
  111. #define EMIF_REG_T_RCD_SHDW_MASK (0xf << 21)
  112. #define EMIF_REG_T_WR_SHDW_SHIFT 17
  113. #define EMIF_REG_T_WR_SHDW_MASK (0xf << 17)
  114. #define EMIF_REG_T_RAS_SHDW_SHIFT 12
  115. #define EMIF_REG_T_RAS_SHDW_MASK (0x1f << 12)
  116. #define EMIF_REG_T_RC_SHDW_SHIFT 6
  117. #define EMIF_REG_T_RC_SHDW_MASK (0x3f << 6)
  118. #define EMIF_REG_T_RRD_SHDW_SHIFT 3
  119. #define EMIF_REG_T_RRD_SHDW_MASK (0x7 << 3)
  120. #define EMIF_REG_T_WTR_SHDW_SHIFT 0
  121. #define EMIF_REG_T_WTR_SHDW_MASK (0x7 << 0)
  122. /* SDRAM_TIM_2 */
  123. #define EMIF_REG_T_XP_SHIFT 28
  124. #define EMIF_REG_T_XP_MASK (0x7 << 28)
  125. #define EMIF_REG_T_ODT_SHIFT 25
  126. #define EMIF_REG_T_ODT_MASK (0x7 << 25)
  127. #define EMIF_REG_T_XSNR_SHIFT 16
  128. #define EMIF_REG_T_XSNR_MASK (0x1ff << 16)
  129. #define EMIF_REG_T_XSRD_SHIFT 6
  130. #define EMIF_REG_T_XSRD_MASK (0x3ff << 6)
  131. #define EMIF_REG_T_RTP_SHIFT 3
  132. #define EMIF_REG_T_RTP_MASK (0x7 << 3)
  133. #define EMIF_REG_T_CKE_SHIFT 0
  134. #define EMIF_REG_T_CKE_MASK (0x7 << 0)
  135. /* SDRAM_TIM_2_SHDW */
  136. #define EMIF_REG_T_XP_SHDW_SHIFT 28
  137. #define EMIF_REG_T_XP_SHDW_MASK (0x7 << 28)
  138. #define EMIF_REG_T_ODT_SHDW_SHIFT 25
  139. #define EMIF_REG_T_ODT_SHDW_MASK (0x7 << 25)
  140. #define EMIF_REG_T_XSNR_SHDW_SHIFT 16
  141. #define EMIF_REG_T_XSNR_SHDW_MASK (0x1ff << 16)
  142. #define EMIF_REG_T_XSRD_SHDW_SHIFT 6
  143. #define EMIF_REG_T_XSRD_SHDW_MASK (0x3ff << 6)
  144. #define EMIF_REG_T_RTP_SHDW_SHIFT 3
  145. #define EMIF_REG_T_RTP_SHDW_MASK (0x7 << 3)
  146. #define EMIF_REG_T_CKE_SHDW_SHIFT 0
  147. #define EMIF_REG_T_CKE_SHDW_MASK (0x7 << 0)
  148. /* SDRAM_TIM_3 */
  149. #define EMIF_REG_T_CKESR_SHIFT 21
  150. #define EMIF_REG_T_CKESR_MASK (0x7 << 21)
  151. #define EMIF_REG_ZQ_ZQCS_SHIFT 15
  152. #define EMIF_REG_ZQ_ZQCS_MASK (0x3f << 15)
  153. #define EMIF_REG_T_TDQSCKMAX_SHIFT 13
  154. #define EMIF_REG_T_TDQSCKMAX_MASK (0x3 << 13)
  155. #define EMIF_REG_T_RFC_SHIFT 4
  156. #define EMIF_REG_T_RFC_MASK (0x1ff << 4)
  157. #define EMIF_REG_T_RAS_MAX_SHIFT 0
  158. #define EMIF_REG_T_RAS_MAX_MASK (0xf << 0)
  159. /* SDRAM_TIM_3_SHDW */
  160. #define EMIF_REG_T_CKESR_SHDW_SHIFT 21
  161. #define EMIF_REG_T_CKESR_SHDW_MASK (0x7 << 21)
  162. #define EMIF_REG_ZQ_ZQCS_SHDW_SHIFT 15
  163. #define EMIF_REG_ZQ_ZQCS_SHDW_MASK (0x3f << 15)
  164. #define EMIF_REG_T_TDQSCKMAX_SHDW_SHIFT 13
  165. #define EMIF_REG_T_TDQSCKMAX_SHDW_MASK (0x3 << 13)
  166. #define EMIF_REG_T_RFC_SHDW_SHIFT 4
  167. #define EMIF_REG_T_RFC_SHDW_MASK (0x1ff << 4)
  168. #define EMIF_REG_T_RAS_MAX_SHDW_SHIFT 0
  169. #define EMIF_REG_T_RAS_MAX_SHDW_MASK (0xf << 0)
  170. /* LPDDR2_NVM_TIM */
  171. #define EMIF_REG_NVM_T_XP_SHIFT 28
  172. #define EMIF_REG_NVM_T_XP_MASK (0x7 << 28)
  173. #define EMIF_REG_NVM_T_WTR_SHIFT 24
  174. #define EMIF_REG_NVM_T_WTR_MASK (0x7 << 24)
  175. #define EMIF_REG_NVM_T_RP_SHIFT 20
  176. #define EMIF_REG_NVM_T_RP_MASK (0xf << 20)
  177. #define EMIF_REG_NVM_T_WRA_SHIFT 16
  178. #define EMIF_REG_NVM_T_WRA_MASK (0xf << 16)
  179. #define EMIF_REG_NVM_T_RRD_SHIFT 8
  180. #define EMIF_REG_NVM_T_RRD_MASK (0xff << 8)
  181. #define EMIF_REG_NVM_T_RCDMIN_SHIFT 0
  182. #define EMIF_REG_NVM_T_RCDMIN_MASK (0xff << 0)
  183. /* LPDDR2_NVM_TIM_SHDW */
  184. #define EMIF_REG_NVM_T_XP_SHDW_SHIFT 28
  185. #define EMIF_REG_NVM_T_XP_SHDW_MASK (0x7 << 28)
  186. #define EMIF_REG_NVM_T_WTR_SHDW_SHIFT 24
  187. #define EMIF_REG_NVM_T_WTR_SHDW_MASK (0x7 << 24)
  188. #define EMIF_REG_NVM_T_RP_SHDW_SHIFT 20
  189. #define EMIF_REG_NVM_T_RP_SHDW_MASK (0xf << 20)
  190. #define EMIF_REG_NVM_T_WRA_SHDW_SHIFT 16
  191. #define EMIF_REG_NVM_T_WRA_SHDW_MASK (0xf << 16)
  192. #define EMIF_REG_NVM_T_RRD_SHDW_SHIFT 8
  193. #define EMIF_REG_NVM_T_RRD_SHDW_MASK (0xff << 8)
  194. #define EMIF_REG_NVM_T_RCDMIN_SHDW_SHIFT 0
  195. #define EMIF_REG_NVM_T_RCDMIN_SHDW_MASK (0xff << 0)
  196. /* PWR_MGMT_CTRL */
  197. #define EMIF_REG_IDLEMODE_SHIFT 30
  198. #define EMIF_REG_IDLEMODE_MASK (0x3 << 30)
  199. #define EMIF_REG_PD_TIM_SHIFT 12
  200. #define EMIF_REG_PD_TIM_MASK (0xf << 12)
  201. #define EMIF_REG_DPD_EN_SHIFT 11
  202. #define EMIF_REG_DPD_EN_MASK (1 << 11)
  203. #define EMIF_REG_LP_MODE_SHIFT 8
  204. #define EMIF_REG_LP_MODE_MASK (0x7 << 8)
  205. #define EMIF_REG_SR_TIM_SHIFT 4
  206. #define EMIF_REG_SR_TIM_MASK (0xf << 4)
  207. #define EMIF_REG_CS_TIM_SHIFT 0
  208. #define EMIF_REG_CS_TIM_MASK (0xf << 0)
  209. /* PWR_MGMT_CTRL_SHDW */
  210. #define EMIF_REG_PD_TIM_SHDW_SHIFT 8
  211. #define EMIF_REG_PD_TIM_SHDW_MASK (0xf << 8)
  212. #define EMIF_REG_SR_TIM_SHDW_SHIFT 4
  213. #define EMIF_REG_SR_TIM_SHDW_MASK (0xf << 4)
  214. #define EMIF_REG_CS_TIM_SHDW_SHIFT 0
  215. #define EMIF_REG_CS_TIM_SHDW_MASK (0xf << 0)
  216. /* LPDDR2_MODE_REG_DATA */
  217. #define EMIF_REG_VALUE_0_SHIFT 0
  218. #define EMIF_REG_VALUE_0_MASK (0x7f << 0)
  219. /* LPDDR2_MODE_REG_CFG */
  220. #define EMIF_REG_CS_SHIFT 31
  221. #define EMIF_REG_CS_MASK (1 << 31)
  222. #define EMIF_REG_REFRESH_EN_SHIFT 30
  223. #define EMIF_REG_REFRESH_EN_MASK (1 << 30)
  224. #define EMIF_REG_ADDRESS_SHIFT 0
  225. #define EMIF_REG_ADDRESS_MASK (0xff << 0)
  226. /* OCP_CONFIG */
  227. #define EMIF_REG_SYS_THRESH_MAX_SHIFT 24
  228. #define EMIF_REG_SYS_THRESH_MAX_MASK (0xf << 24)
  229. #define EMIF_REG_MPU_THRESH_MAX_SHIFT 20
  230. #define EMIF_REG_MPU_THRESH_MAX_MASK (0xf << 20)
  231. #define EMIF_REG_LL_THRESH_MAX_SHIFT 16
  232. #define EMIF_REG_LL_THRESH_MAX_MASK (0xf << 16)
  233. #define EMIF_REG_PR_OLD_COUNT_SHIFT 0
  234. #define EMIF_REG_PR_OLD_COUNT_MASK (0xff << 0)
  235. /* OCP_CFG_VAL_1 */
  236. #define EMIF_REG_SYS_BUS_WIDTH_SHIFT 30
  237. #define EMIF_REG_SYS_BUS_WIDTH_MASK (0x3 << 30)
  238. #define EMIF_REG_LL_BUS_WIDTH_SHIFT 28
  239. #define EMIF_REG_LL_BUS_WIDTH_MASK (0x3 << 28)
  240. #define EMIF_REG_WR_FIFO_DEPTH_SHIFT 8
  241. #define EMIF_REG_WR_FIFO_DEPTH_MASK (0xff << 8)
  242. #define EMIF_REG_CMD_FIFO_DEPTH_SHIFT 0
  243. #define EMIF_REG_CMD_FIFO_DEPTH_MASK (0xff << 0)
  244. /* OCP_CFG_VAL_2 */
  245. #define EMIF_REG_RREG_FIFO_DEPTH_SHIFT 16
  246. #define EMIF_REG_RREG_FIFO_DEPTH_MASK (0xff << 16)
  247. #define EMIF_REG_RSD_FIFO_DEPTH_SHIFT 8
  248. #define EMIF_REG_RSD_FIFO_DEPTH_MASK (0xff << 8)
  249. #define EMIF_REG_RCMD_FIFO_DEPTH_SHIFT 0
  250. #define EMIF_REG_RCMD_FIFO_DEPTH_MASK (0xff << 0)
  251. /* IODFT_TLGC */
  252. #define EMIF_REG_TLEC_SHIFT 16
  253. #define EMIF_REG_TLEC_MASK (0xffff << 16)
  254. #define EMIF_REG_MT_SHIFT 14
  255. #define EMIF_REG_MT_MASK (1 << 14)
  256. #define EMIF_REG_ACT_CAP_EN_SHIFT 13
  257. #define EMIF_REG_ACT_CAP_EN_MASK (1 << 13)
  258. #define EMIF_REG_OPG_LD_SHIFT 12
  259. #define EMIF_REG_OPG_LD_MASK (1 << 12)
  260. #define EMIF_REG_RESET_PHY_SHIFT 10
  261. #define EMIF_REG_RESET_PHY_MASK (1 << 10)
  262. #define EMIF_REG_MMS_SHIFT 8
  263. #define EMIF_REG_MMS_MASK (1 << 8)
  264. #define EMIF_REG_MC_SHIFT 4
  265. #define EMIF_REG_MC_MASK (0x3 << 4)
  266. #define EMIF_REG_PC_SHIFT 1
  267. #define EMIF_REG_PC_MASK (0x7 << 1)
  268. #define EMIF_REG_TM_SHIFT 0
  269. #define EMIF_REG_TM_MASK (1 << 0)
  270. /* IODFT_CTRL_MISR_RSLT */
  271. #define EMIF_REG_DQM_TLMR_SHIFT 16
  272. #define EMIF_REG_DQM_TLMR_MASK (0x3ff << 16)
  273. #define EMIF_REG_CTL_TLMR_SHIFT 0
  274. #define EMIF_REG_CTL_TLMR_MASK (0x7ff << 0)
  275. /* IODFT_ADDR_MISR_RSLT */
  276. #define EMIF_REG_ADDR_TLMR_SHIFT 0
  277. #define EMIF_REG_ADDR_TLMR_MASK (0x1fffff << 0)
  278. /* IODFT_DATA_MISR_RSLT_1 */
  279. #define EMIF_REG_DATA_TLMR_31_0_SHIFT 0
  280. #define EMIF_REG_DATA_TLMR_31_0_MASK (0xffffffff << 0)
  281. /* IODFT_DATA_MISR_RSLT_2 */
  282. #define EMIF_REG_DATA_TLMR_63_32_SHIFT 0
  283. #define EMIF_REG_DATA_TLMR_63_32_MASK (0xffffffff << 0)
  284. /* IODFT_DATA_MISR_RSLT_3 */
  285. #define EMIF_REG_DATA_TLMR_66_64_SHIFT 0
  286. #define EMIF_REG_DATA_TLMR_66_64_MASK (0x7 << 0)
  287. /* PERF_CNT_1 */
  288. #define EMIF_REG_COUNTER1_SHIFT 0
  289. #define EMIF_REG_COUNTER1_MASK (0xffffffff << 0)
  290. /* PERF_CNT_2 */
  291. #define EMIF_REG_COUNTER2_SHIFT 0
  292. #define EMIF_REG_COUNTER2_MASK (0xffffffff << 0)
  293. /* PERF_CNT_CFG */
  294. #define EMIF_REG_CNTR2_MCONNID_EN_SHIFT 31
  295. #define EMIF_REG_CNTR2_MCONNID_EN_MASK (1 << 31)
  296. #define EMIF_REG_CNTR2_REGION_EN_SHIFT 30
  297. #define EMIF_REG_CNTR2_REGION_EN_MASK (1 << 30)
  298. #define EMIF_REG_CNTR2_CFG_SHIFT 16
  299. #define EMIF_REG_CNTR2_CFG_MASK (0xf << 16)
  300. #define EMIF_REG_CNTR1_MCONNID_EN_SHIFT 15
  301. #define EMIF_REG_CNTR1_MCONNID_EN_MASK (1 << 15)
  302. #define EMIF_REG_CNTR1_REGION_EN_SHIFT 14
  303. #define EMIF_REG_CNTR1_REGION_EN_MASK (1 << 14)
  304. #define EMIF_REG_CNTR1_CFG_SHIFT 0
  305. #define EMIF_REG_CNTR1_CFG_MASK (0xf << 0)
  306. /* PERF_CNT_SEL */
  307. #define EMIF_REG_MCONNID2_SHIFT 24
  308. #define EMIF_REG_MCONNID2_MASK (0xff << 24)
  309. #define EMIF_REG_REGION_SEL2_SHIFT 16
  310. #define EMIF_REG_REGION_SEL2_MASK (0x3 << 16)
  311. #define EMIF_REG_MCONNID1_SHIFT 8
  312. #define EMIF_REG_MCONNID1_MASK (0xff << 8)
  313. #define EMIF_REG_REGION_SEL1_SHIFT 0
  314. #define EMIF_REG_REGION_SEL1_MASK (0x3 << 0)
  315. /* PERF_CNT_TIM */
  316. #define EMIF_REG_TOTAL_TIME_SHIFT 0
  317. #define EMIF_REG_TOTAL_TIME_MASK (0xffffffff << 0)
  318. /* READ_IDLE_CTRL */
  319. #define EMIF_REG_READ_IDLE_LEN_SHIFT 16
  320. #define EMIF_REG_READ_IDLE_LEN_MASK (0xf << 16)
  321. #define EMIF_REG_READ_IDLE_INTERVAL_SHIFT 0
  322. #define EMIF_REG_READ_IDLE_INTERVAL_MASK (0x1ff << 0)
  323. /* READ_IDLE_CTRL_SHDW */
  324. #define EMIF_REG_READ_IDLE_LEN_SHDW_SHIFT 16
  325. #define EMIF_REG_READ_IDLE_LEN_SHDW_MASK (0xf << 16)
  326. #define EMIF_REG_READ_IDLE_INTERVAL_SHDW_SHIFT 0
  327. #define EMIF_REG_READ_IDLE_INTERVAL_SHDW_MASK (0x1ff << 0)
  328. /* IRQ_EOI */
  329. #define EMIF_REG_EOI_SHIFT 0
  330. #define EMIF_REG_EOI_MASK (1 << 0)
  331. /* IRQSTATUS_RAW_SYS */
  332. #define EMIF_REG_DNV_SYS_SHIFT 2
  333. #define EMIF_REG_DNV_SYS_MASK (1 << 2)
  334. #define EMIF_REG_TA_SYS_SHIFT 1
  335. #define EMIF_REG_TA_SYS_MASK (1 << 1)
  336. #define EMIF_REG_ERR_SYS_SHIFT 0
  337. #define EMIF_REG_ERR_SYS_MASK (1 << 0)
  338. /* IRQSTATUS_RAW_LL */
  339. #define EMIF_REG_DNV_LL_SHIFT 2
  340. #define EMIF_REG_DNV_LL_MASK (1 << 2)
  341. #define EMIF_REG_TA_LL_SHIFT 1
  342. #define EMIF_REG_TA_LL_MASK (1 << 1)
  343. #define EMIF_REG_ERR_LL_SHIFT 0
  344. #define EMIF_REG_ERR_LL_MASK (1 << 0)
  345. /* IRQSTATUS_SYS */
  346. /* IRQSTATUS_LL */
  347. /* IRQENABLE_SET_SYS */
  348. #define EMIF_REG_EN_DNV_SYS_SHIFT 2
  349. #define EMIF_REG_EN_DNV_SYS_MASK (1 << 2)
  350. #define EMIF_REG_EN_TA_SYS_SHIFT 1
  351. #define EMIF_REG_EN_TA_SYS_MASK (1 << 1)
  352. #define EMIF_REG_EN_ERR_SYS_SHIFT 0
  353. #define EMIF_REG_EN_ERR_SYS_MASK (1 << 0)
  354. /* IRQENABLE_SET_LL */
  355. #define EMIF_REG_EN_DNV_LL_SHIFT 2
  356. #define EMIF_REG_EN_DNV_LL_MASK (1 << 2)
  357. #define EMIF_REG_EN_TA_LL_SHIFT 1
  358. #define EMIF_REG_EN_TA_LL_MASK (1 << 1)
  359. #define EMIF_REG_EN_ERR_LL_SHIFT 0
  360. #define EMIF_REG_EN_ERR_LL_MASK (1 << 0)
  361. /* IRQENABLE_CLR_SYS */
  362. /* IRQENABLE_CLR_LL */
  363. /* ZQ_CONFIG */
  364. #define EMIF_REG_ZQ_CS1EN_SHIFT 31
  365. #define EMIF_REG_ZQ_CS1EN_MASK (1 << 31)
  366. #define EMIF_REG_ZQ_CS0EN_SHIFT 30
  367. #define EMIF_REG_ZQ_CS0EN_MASK (1 << 30)
  368. #define EMIF_REG_ZQ_DUALCALEN_SHIFT 29
  369. #define EMIF_REG_ZQ_DUALCALEN_MASK (1 << 29)
  370. #define EMIF_REG_ZQ_SFEXITEN_SHIFT 28
  371. #define EMIF_REG_ZQ_SFEXITEN_MASK (1 << 28)
  372. #define EMIF_REG_ZQ_ZQINIT_MULT_SHIFT 18
  373. #define EMIF_REG_ZQ_ZQINIT_MULT_MASK (0x3 << 18)
  374. #define EMIF_REG_ZQ_ZQCL_MULT_SHIFT 16
  375. #define EMIF_REG_ZQ_ZQCL_MULT_MASK (0x3 << 16)
  376. #define EMIF_REG_ZQ_REFINTERVAL_SHIFT 0
  377. #define EMIF_REG_ZQ_REFINTERVAL_MASK (0xffff << 0)
  378. /* TEMP_ALERT_CONFIG */
  379. #define EMIF_REG_TA_CS1EN_SHIFT 31
  380. #define EMIF_REG_TA_CS1EN_MASK (1 << 31)
  381. #define EMIF_REG_TA_CS0EN_SHIFT 30
  382. #define EMIF_REG_TA_CS0EN_MASK (1 << 30)
  383. #define EMIF_REG_TA_SFEXITEN_SHIFT 28
  384. #define EMIF_REG_TA_SFEXITEN_MASK (1 << 28)
  385. #define EMIF_REG_TA_DEVWDT_SHIFT 26
  386. #define EMIF_REG_TA_DEVWDT_MASK (0x3 << 26)
  387. #define EMIF_REG_TA_DEVCNT_SHIFT 24
  388. #define EMIF_REG_TA_DEVCNT_MASK (0x3 << 24)
  389. #define EMIF_REG_TA_REFINTERVAL_SHIFT 0
  390. #define EMIF_REG_TA_REFINTERVAL_MASK (0x3fffff << 0)
  391. /* OCP_ERR_LOG */
  392. #define EMIF_REG_MADDRSPACE_SHIFT 14
  393. #define EMIF_REG_MADDRSPACE_MASK (0x3 << 14)
  394. #define EMIF_REG_MBURSTSEQ_SHIFT 11
  395. #define EMIF_REG_MBURSTSEQ_MASK (0x7 << 11)
  396. #define EMIF_REG_MCMD_SHIFT 8
  397. #define EMIF_REG_MCMD_MASK (0x7 << 8)
  398. #define EMIF_REG_MCONNID_SHIFT 0
  399. #define EMIF_REG_MCONNID_MASK (0xff << 0)
  400. /* DDR_PHY_CTRL_1 */
  401. #define EMIF_REG_DDR_PHY_CTRL_1_SHIFT 4
  402. #define EMIF_REG_DDR_PHY_CTRL_1_MASK (0xfffffff << 4)
  403. #define EMIF_REG_READ_LATENCY_SHIFT 0
  404. #define EMIF_REG_READ_LATENCY_MASK (0xf << 0)
  405. #define EMIF_REG_DLL_SLAVE_DLY_CTRL_SHIFT 4
  406. #define EMIF_REG_DLL_SLAVE_DLY_CTRL_MASK (0xFF << 4)
  407. #define EMIF_EMIF_DDR_PHY_CTRL_1_BASE_VAL_SHIFT 12
  408. #define EMIF_EMIF_DDR_PHY_CTRL_1_BASE_VAL_MASK (0xFFFFF << 12)
  409. /* DDR_PHY_CTRL_1_SHDW */
  410. #define EMIF_REG_DDR_PHY_CTRL_1_SHDW_SHIFT 4
  411. #define EMIF_REG_DDR_PHY_CTRL_1_SHDW_MASK (0xfffffff << 4)
  412. #define EMIF_REG_READ_LATENCY_SHDW_SHIFT 0
  413. #define EMIF_REG_READ_LATENCY_SHDW_MASK (0xf << 0)
  414. #define EMIF_REG_DLL_SLAVE_DLY_CTRL_SHDW_SHIFT 4
  415. #define EMIF_REG_DLL_SLAVE_DLY_CTRL_SHDW_MASK (0xFF << 4)
  416. #define EMIF_EMIF_DDR_PHY_CTRL_1_BASE_VAL_SHDW_SHIFT 12
  417. #define EMIF_EMIF_DDR_PHY_CTRL_1_BASE_VAL_SHDW_MASK (0xFFFFF << 12)
  418. /* DDR_PHY_CTRL_2 */
  419. #define EMIF_REG_DDR_PHY_CTRL_2_SHIFT 0
  420. #define EMIF_REG_DDR_PHY_CTRL_2_MASK (0xffffffff << 0)
  421. /* DMM */
  422. #define DMM_BASE 0x4E000040
  423. /* Memory Adapter */
  424. #define MA_BASE 0x482AF040
  425. /* DMM_LISA_MAP */
  426. #define EMIF_SYS_ADDR_SHIFT 24
  427. #define EMIF_SYS_ADDR_MASK (0xff << 24)
  428. #define EMIF_SYS_SIZE_SHIFT 20
  429. #define EMIF_SYS_SIZE_MASK (0x7 << 20)
  430. #define EMIF_SDRC_INTL_SHIFT 18
  431. #define EMIF_SDRC_INTL_MASK (0x3 << 18)
  432. #define EMIF_SDRC_ADDRSPC_SHIFT 16
  433. #define EMIF_SDRC_ADDRSPC_MASK (0x3 << 16)
  434. #define EMIF_SDRC_MAP_SHIFT 8
  435. #define EMIF_SDRC_MAP_MASK (0x3 << 8)
  436. #define EMIF_SDRC_ADDR_SHIFT 0
  437. #define EMIF_SDRC_ADDR_MASK (0xff << 0)
  438. /* DMM_LISA_MAP fields */
  439. #define DMM_SDRC_MAP_UNMAPPED 0
  440. #define DMM_SDRC_MAP_EMIF1_ONLY 1
  441. #define DMM_SDRC_MAP_EMIF2_ONLY 2
  442. #define DMM_SDRC_MAP_EMIF1_AND_EMIF2 3
  443. #define DMM_SDRC_INTL_NONE 0
  444. #define DMM_SDRC_INTL_128B 1
  445. #define DMM_SDRC_INTL_256B 2
  446. #define DMM_SDRC_INTL_512 3
  447. #define DMM_SDRC_ADDR_SPC_SDRAM 0
  448. #define DMM_SDRC_ADDR_SPC_NVM 1
  449. #define DMM_SDRC_ADDR_SPC_INVALID 2
  450. #define DMM_LISA_MAP_INTERLEAVED_BASE_VAL (\
  451. (DMM_SDRC_MAP_EMIF1_AND_EMIF2 << EMIF_SDRC_MAP_SHIFT) |\
  452. (DMM_SDRC_ADDR_SPC_SDRAM << EMIF_SDRC_ADDRSPC_SHIFT) |\
  453. (DMM_SDRC_INTL_128B << EMIF_SDRC_INTL_SHIFT) |\
  454. (CONFIG_SYS_SDRAM_BASE << EMIF_SYS_ADDR_SHIFT))
  455. #define DMM_LISA_MAP_EMIF1_ONLY_BASE_VAL (\
  456. (DMM_SDRC_MAP_EMIF1_ONLY << EMIF_SDRC_MAP_SHIFT)|\
  457. (DMM_SDRC_ADDR_SPC_SDRAM << EMIF_SDRC_ADDRSPC_SHIFT)|\
  458. (DMM_SDRC_INTL_NONE << EMIF_SDRC_INTL_SHIFT))
  459. #define DMM_LISA_MAP_EMIF2_ONLY_BASE_VAL (\
  460. (DMM_SDRC_MAP_EMIF2_ONLY << EMIF_SDRC_MAP_SHIFT)|\
  461. (DMM_SDRC_ADDR_SPC_SDRAM << EMIF_SDRC_ADDRSPC_SHIFT)|\
  462. (DMM_SDRC_INTL_NONE << EMIF_SDRC_INTL_SHIFT))
  463. /* Trap for invalid TILER PAT entries */
  464. #define DMM_LISA_MAP_0_INVAL_ADDR_TRAP (\
  465. (0 << EMIF_SDRC_ADDR_SHIFT) |\
  466. (DMM_SDRC_MAP_EMIF1_ONLY << EMIF_SDRC_MAP_SHIFT)|\
  467. (DMM_SDRC_ADDR_SPC_INVALID << EMIF_SDRC_ADDRSPC_SHIFT)|\
  468. (DMM_SDRC_INTL_NONE << EMIF_SDRC_INTL_SHIFT)|\
  469. (0xFF << EMIF_SYS_ADDR_SHIFT))
  470. /* Reg mapping structure */
  471. struct emif_reg_struct {
  472. u32 emif_mod_id_rev;
  473. u32 emif_status;
  474. u32 emif_sdram_config;
  475. u32 emif_lpddr2_nvm_config;
  476. u32 emif_sdram_ref_ctrl;
  477. u32 emif_sdram_ref_ctrl_shdw;
  478. u32 emif_sdram_tim_1;
  479. u32 emif_sdram_tim_1_shdw;
  480. u32 emif_sdram_tim_2;
  481. u32 emif_sdram_tim_2_shdw;
  482. u32 emif_sdram_tim_3;
  483. u32 emif_sdram_tim_3_shdw;
  484. u32 emif_lpddr2_nvm_tim;
  485. u32 emif_lpddr2_nvm_tim_shdw;
  486. u32 emif_pwr_mgmt_ctrl;
  487. u32 emif_pwr_mgmt_ctrl_shdw;
  488. u32 emif_lpddr2_mode_reg_data;
  489. u32 padding1[1];
  490. u32 emif_lpddr2_mode_reg_data_es2;
  491. u32 padding11[1];
  492. u32 emif_lpddr2_mode_reg_cfg;
  493. u32 emif_l3_config;
  494. u32 emif_l3_cfg_val_1;
  495. u32 emif_l3_cfg_val_2;
  496. u32 emif_iodft_tlgc;
  497. u32 padding2[7];
  498. u32 emif_perf_cnt_1;
  499. u32 emif_perf_cnt_2;
  500. u32 emif_perf_cnt_cfg;
  501. u32 emif_perf_cnt_sel;
  502. u32 emif_perf_cnt_tim;
  503. u32 padding3;
  504. u32 emif_read_idlectrl;
  505. u32 emif_read_idlectrl_shdw;
  506. u32 padding4;
  507. u32 emif_irqstatus_raw_sys;
  508. u32 emif_irqstatus_raw_ll;
  509. u32 emif_irqstatus_sys;
  510. u32 emif_irqstatus_ll;
  511. u32 emif_irqenable_set_sys;
  512. u32 emif_irqenable_set_ll;
  513. u32 emif_irqenable_clr_sys;
  514. u32 emif_irqenable_clr_ll;
  515. u32 padding5;
  516. u32 emif_zq_config;
  517. u32 emif_temp_alert_config;
  518. u32 emif_l3_err_log;
  519. u32 padding6[4];
  520. u32 emif_ddr_phy_ctrl_1;
  521. u32 emif_ddr_phy_ctrl_1_shdw;
  522. u32 emif_ddr_phy_ctrl_2;
  523. };
  524. struct dmm_lisa_map_regs {
  525. u32 dmm_lisa_map_0;
  526. u32 dmm_lisa_map_1;
  527. u32 dmm_lisa_map_2;
  528. u32 dmm_lisa_map_3;
  529. };
  530. #define CS0 0
  531. #define CS1 1
  532. /* The maximum frequency at which the LPDDR2 interface can operate in Hz*/
  533. #define MAX_LPDDR2_FREQ 400000000 /* 400 MHz */
  534. /*
  535. * The period of DDR clk is represented as numerator and denominator for
  536. * better accuracy in integer based calculations. However, if the numerator
  537. * and denominator are very huge there may be chances of overflow in
  538. * calculations. So, as a trade-off keep denominator(and consequently
  539. * numerator) within a limit sacrificing some accuracy - but not much
  540. * If denominator and numerator are already small (such as at 400 MHz)
  541. * no adjustment is needed
  542. */
  543. #define EMIF_PERIOD_DEN_LIMIT 1000
  544. /*
  545. * Maximum number of different frequencies supported by EMIF driver
  546. * Determines the number of entries in the pointer array for register
  547. * cache
  548. */
  549. #define EMIF_MAX_NUM_FREQUENCIES 6
  550. /*
  551. * Indices into the Addressing Table array.
  552. * One entry each for all the different types of devices with different
  553. * addressing schemes
  554. */
  555. #define ADDR_TABLE_INDEX64M 0
  556. #define ADDR_TABLE_INDEX128M 1
  557. #define ADDR_TABLE_INDEX256M 2
  558. #define ADDR_TABLE_INDEX512M 3
  559. #define ADDR_TABLE_INDEX1GS4 4
  560. #define ADDR_TABLE_INDEX2GS4 5
  561. #define ADDR_TABLE_INDEX4G 6
  562. #define ADDR_TABLE_INDEX8G 7
  563. #define ADDR_TABLE_INDEX1GS2 8
  564. #define ADDR_TABLE_INDEX2GS2 9
  565. #define ADDR_TABLE_INDEXMAX 10
  566. /* Number of Row bits */
  567. #define ROW_9 0
  568. #define ROW_10 1
  569. #define ROW_11 2
  570. #define ROW_12 3
  571. #define ROW_13 4
  572. #define ROW_14 5
  573. #define ROW_15 6
  574. #define ROW_16 7
  575. /* Number of Column bits */
  576. #define COL_8 0
  577. #define COL_9 1
  578. #define COL_10 2
  579. #define COL_11 3
  580. #define COL_7 4 /*Not supported by OMAP included for completeness */
  581. /* Number of Banks*/
  582. #define BANKS1 0
  583. #define BANKS2 1
  584. #define BANKS4 2
  585. #define BANKS8 3
  586. /* Refresh rate in micro seconds x 10 */
  587. #define T_REFI_15_6 156
  588. #define T_REFI_7_8 78
  589. #define T_REFI_3_9 39
  590. #define EBANK_CS1_DIS 0
  591. #define EBANK_CS1_EN 1
  592. /* Read Latency used by the device at reset */
  593. #define RL_BOOT 3
  594. /* Read Latency for the highest frequency you want to use */
  595. #ifdef CONFIG_OMAP54XX
  596. #define RL_FINAL 8
  597. #else
  598. #define RL_FINAL 6
  599. #endif
  600. /* Interleaving policies at EMIF level- between banks and Chip Selects */
  601. #define EMIF_INTERLEAVING_POLICY_MAX_INTERLEAVING 0
  602. #define EMIF_INTERLEAVING_POLICY_NO_BANK_INTERLEAVING 3
  603. /*
  604. * Interleaving policy to be used
  605. * Currently set to MAX interleaving for better performance
  606. */
  607. #define EMIF_INTERLEAVING_POLICY EMIF_INTERLEAVING_POLICY_MAX_INTERLEAVING
  608. /* State of the core voltage:
  609. * This is important for some parameters such as read idle control and
  610. * ZQ calibration timings. Timings are much stricter when voltage ramp
  611. * is happening compared to when the voltage is stable.
  612. * We need to calculate two sets of values for these parameters and use
  613. * them accordingly
  614. */
  615. #define LPDDR2_VOLTAGE_STABLE 0
  616. #define LPDDR2_VOLTAGE_RAMPING 1
  617. /* Length of the forced read idle period in terms of cycles */
  618. #define EMIF_REG_READ_IDLE_LEN_VAL 5
  619. /* Interval between forced 'read idles' */
  620. /* To be used when voltage is changed for DPS/DVFS - 1us */
  621. #define READ_IDLE_INTERVAL_DVFS (1*1000)
  622. /*
  623. * To be used when voltage is not scaled except by Smart Reflex
  624. * 50us - or maximum value will do
  625. */
  626. #define READ_IDLE_INTERVAL_NORMAL (50*1000)
  627. /*
  628. * Unless voltage is changing due to DVFS one ZQCS command every 50ms should
  629. * be enough. This shoule be enough also in the case when voltage is changing
  630. * due to smart-reflex.
  631. */
  632. #define EMIF_ZQCS_INTERVAL_NORMAL_IN_US (50*1000)
  633. /*
  634. * If voltage is changing due to DVFS ZQCS should be performed more
  635. * often(every 50us)
  636. */
  637. #define EMIF_ZQCS_INTERVAL_DVFS_IN_US 50
  638. /* The interval between ZQCL commands as a multiple of ZQCS interval */
  639. #define REG_ZQ_ZQCL_MULT 4
  640. /* The interval between ZQINIT commands as a multiple of ZQCL interval */
  641. #define REG_ZQ_ZQINIT_MULT 3
  642. /* Enable ZQ Calibration on exiting Self-refresh */
  643. #define REG_ZQ_SFEXITEN_ENABLE 1
  644. /*
  645. * ZQ Calibration simultaneously on both chip-selects:
  646. * Needs one calibration resistor per CS
  647. * None of the boards that we know of have this capability
  648. * So disabled by default
  649. */
  650. #define REG_ZQ_DUALCALEN_DISABLE 0
  651. /*
  652. * Enable ZQ Calibration by default on CS0. If we are asked to program
  653. * the EMIF there will be something connected to CS0 for sure
  654. */
  655. #define REG_ZQ_CS0EN_ENABLE 1
  656. /* EMIF_PWR_MGMT_CTRL register */
  657. /* Low power modes */
  658. #define LP_MODE_DISABLE 0
  659. #define LP_MODE_CLOCK_STOP 1
  660. #define LP_MODE_SELF_REFRESH 2
  661. #define LP_MODE_PWR_DN 3
  662. /* REG_DPD_EN */
  663. #define DPD_DISABLE 0
  664. #define DPD_ENABLE 1
  665. /* Maximum delay before Low Power Modes */
  666. #define REG_CS_TIM 0xF
  667. #define REG_SR_TIM 0xF
  668. #define REG_PD_TIM 0xF
  669. /* EMIF_PWR_MGMT_CTRL register */
  670. #define EMIF_PWR_MGMT_CTRL (\
  671. ((REG_CS_TIM << EMIF_REG_CS_TIM_SHIFT) & EMIF_REG_CS_TIM_MASK)|\
  672. ((REG_SR_TIM << EMIF_REG_SR_TIM_SHIFT) & EMIF_REG_SR_TIM_MASK)|\
  673. ((REG_PD_TIM << EMIF_REG_PD_TIM_SHIFT) & EMIF_REG_PD_TIM_MASK)|\
  674. ((REG_PD_TIM << EMIF_REG_PD_TIM_SHIFT) & EMIF_REG_PD_TIM_MASK)|\
  675. ((LP_MODE_DISABLE << EMIF_REG_LP_MODE_SHIFT)\
  676. & EMIF_REG_LP_MODE_MASK) |\
  677. ((DPD_DISABLE << EMIF_REG_DPD_EN_SHIFT)\
  678. & EMIF_REG_DPD_EN_MASK))\
  679. #define EMIF_PWR_MGMT_CTRL_SHDW (\
  680. ((REG_CS_TIM << EMIF_REG_CS_TIM_SHDW_SHIFT)\
  681. & EMIF_REG_CS_TIM_SHDW_MASK) |\
  682. ((REG_SR_TIM << EMIF_REG_SR_TIM_SHDW_SHIFT)\
  683. & EMIF_REG_SR_TIM_SHDW_MASK) |\
  684. ((REG_PD_TIM << EMIF_REG_PD_TIM_SHDW_SHIFT)\
  685. & EMIF_REG_PD_TIM_SHDW_MASK) |\
  686. ((REG_PD_TIM << EMIF_REG_PD_TIM_SHDW_SHIFT)\
  687. & EMIF_REG_PD_TIM_SHDW_MASK))
  688. /* EMIF_L3_CONFIG register value */
  689. #define EMIF_L3_CONFIG_VAL_SYS_10_LL_0 0x0A0000FF
  690. #define EMIF_L3_CONFIG_VAL_SYS_10_MPU_3_LL_0 0x0A300000
  691. #define EMIF_L3_CONFIG_VAL_SYS_10_MPU_5_LL_0 0x0A300000
  692. /*
  693. * Value of bits 12:31 of DDR_PHY_CTRL_1 register:
  694. * All these fields have magic values dependent on frequency and
  695. * determined by PHY and DLL integration with EMIF. Setting the magic
  696. * values suggested by hw team.
  697. */
  698. #define EMIF_DDR_PHY_CTRL_1_BASE_VAL 0x049FF
  699. #define EMIF_DLL_SLAVE_DLY_CTRL_400_MHZ 0x41
  700. #define EMIF_DLL_SLAVE_DLY_CTRL_200_MHZ 0x80
  701. #define EMIF_DLL_SLAVE_DLY_CTRL_100_MHZ_AND_LESS 0xFF
  702. /*
  703. * MR1 value:
  704. * Burst length : 8
  705. * Burst type : sequential
  706. * Wrap : enabled
  707. * nWR : 3(default). EMIF does not do pre-charge.
  708. * : So nWR is don't care
  709. */
  710. #define MR1_BL_8_BT_SEQ_WRAP_EN_NWR_3 0x23
  711. /* MR2 */
  712. #define MR2_RL3_WL1 1
  713. #define MR2_RL4_WL2 2
  714. #define MR2_RL5_WL2 3
  715. #define MR2_RL6_WL3 4
  716. /* MR10: ZQ calibration codes */
  717. #define MR10_ZQ_ZQCS 0x56
  718. #define MR10_ZQ_ZQCL 0xAB
  719. #define MR10_ZQ_ZQINIT 0xFF
  720. #define MR10_ZQ_ZQRESET 0xC3
  721. /* TEMP_ALERT_CONFIG */
  722. #define TEMP_ALERT_POLL_INTERVAL_MS 360 /* for temp gradient - 5 C/s */
  723. #define TEMP_ALERT_CONFIG_DEVCT_1 0
  724. #define TEMP_ALERT_CONFIG_DEVWDT_32 2
  725. /* MR16 value: refresh full array(no partial array self refresh) */
  726. #define MR16_REF_FULL_ARRAY 0
  727. /*
  728. * Maximum number of entries we keep in our array of timing tables
  729. * We need not keep all the speed bins supported by the device
  730. * We need to keep timing tables for only the speed bins that we
  731. * are interested in
  732. */
  733. #define MAX_NUM_SPEEDBINS 4
  734. /* LPDDR2 Densities */
  735. #define LPDDR2_DENSITY_64Mb 0
  736. #define LPDDR2_DENSITY_128Mb 1
  737. #define LPDDR2_DENSITY_256Mb 2
  738. #define LPDDR2_DENSITY_512Mb 3
  739. #define LPDDR2_DENSITY_1Gb 4
  740. #define LPDDR2_DENSITY_2Gb 5
  741. #define LPDDR2_DENSITY_4Gb 6
  742. #define LPDDR2_DENSITY_8Gb 7
  743. #define LPDDR2_DENSITY_16Gb 8
  744. #define LPDDR2_DENSITY_32Gb 9
  745. /* LPDDR2 type */
  746. #define LPDDR2_TYPE_S4 0
  747. #define LPDDR2_TYPE_S2 1
  748. #define LPDDR2_TYPE_NVM 2
  749. /* LPDDR2 IO width */
  750. #define LPDDR2_IO_WIDTH_32 0
  751. #define LPDDR2_IO_WIDTH_16 1
  752. #define LPDDR2_IO_WIDTH_8 2
  753. /* Mode register numbers */
  754. #define LPDDR2_MR0 0
  755. #define LPDDR2_MR1 1
  756. #define LPDDR2_MR2 2
  757. #define LPDDR2_MR3 3
  758. #define LPDDR2_MR4 4
  759. #define LPDDR2_MR5 5
  760. #define LPDDR2_MR6 6
  761. #define LPDDR2_MR7 7
  762. #define LPDDR2_MR8 8
  763. #define LPDDR2_MR9 9
  764. #define LPDDR2_MR10 10
  765. #define LPDDR2_MR11 11
  766. #define LPDDR2_MR16 16
  767. #define LPDDR2_MR17 17
  768. #define LPDDR2_MR18 18
  769. /* MR0 */
  770. #define LPDDR2_MR0_DAI_SHIFT 0
  771. #define LPDDR2_MR0_DAI_MASK 1
  772. #define LPDDR2_MR0_DI_SHIFT 1
  773. #define LPDDR2_MR0_DI_MASK (1 << 1)
  774. #define LPDDR2_MR0_DNVI_SHIFT 2
  775. #define LPDDR2_MR0_DNVI_MASK (1 << 2)
  776. /* MR4 */
  777. #define MR4_SDRAM_REF_RATE_SHIFT 0
  778. #define MR4_SDRAM_REF_RATE_MASK 7
  779. #define MR4_TUF_SHIFT 7
  780. #define MR4_TUF_MASK (1 << 7)
  781. /* MR4 SDRAM Refresh Rate field values */
  782. #define SDRAM_TEMP_LESS_LOW_SHUTDOWN 0x0
  783. #define SDRAM_TEMP_LESS_4X_REFRESH_AND_TIMINGS 0x1
  784. #define SDRAM_TEMP_LESS_2X_REFRESH_AND_TIMINGS 0x2
  785. #define SDRAM_TEMP_NOMINAL 0x3
  786. #define SDRAM_TEMP_RESERVED_4 0x4
  787. #define SDRAM_TEMP_HIGH_DERATE_REFRESH 0x5
  788. #define SDRAM_TEMP_HIGH_DERATE_REFRESH_AND_TIMINGS 0x6
  789. #define SDRAM_TEMP_VERY_HIGH_SHUTDOWN 0x7
  790. #define LPDDR2_MANUFACTURER_SAMSUNG 1
  791. #define LPDDR2_MANUFACTURER_QIMONDA 2
  792. #define LPDDR2_MANUFACTURER_ELPIDA 3
  793. #define LPDDR2_MANUFACTURER_ETRON 4
  794. #define LPDDR2_MANUFACTURER_NANYA 5
  795. #define LPDDR2_MANUFACTURER_HYNIX 6
  796. #define LPDDR2_MANUFACTURER_MOSEL 7
  797. #define LPDDR2_MANUFACTURER_WINBOND 8
  798. #define LPDDR2_MANUFACTURER_ESMT 9
  799. #define LPDDR2_MANUFACTURER_SPANSION 11
  800. #define LPDDR2_MANUFACTURER_SST 12
  801. #define LPDDR2_MANUFACTURER_ZMOS 13
  802. #define LPDDR2_MANUFACTURER_INTEL 14
  803. #define LPDDR2_MANUFACTURER_NUMONYX 254
  804. #define LPDDR2_MANUFACTURER_MICRON 255
  805. /* MR8 register fields */
  806. #define MR8_TYPE_SHIFT 0x0
  807. #define MR8_TYPE_MASK 0x3
  808. #define MR8_DENSITY_SHIFT 0x2
  809. #define MR8_DENSITY_MASK (0xF << 0x2)
  810. #define MR8_IO_WIDTH_SHIFT 0x6
  811. #define MR8_IO_WIDTH_MASK (0x3 << 0x6)
  812. struct lpddr2_addressing {
  813. u8 num_banks;
  814. u8 t_REFI_us_x10;
  815. u8 row_sz[2]; /* One entry each for x32 and x16 */
  816. u8 col_sz[2]; /* One entry each for x32 and x16 */
  817. };
  818. /* Structure for timings from the DDR datasheet */
  819. struct lpddr2_ac_timings {
  820. u32 max_freq;
  821. u8 RL;
  822. u8 tRPab;
  823. u8 tRCD;
  824. u8 tWR;
  825. u8 tRASmin;
  826. u8 tRRD;
  827. u8 tWTRx2;
  828. u8 tXSR;
  829. u8 tXPx2;
  830. u8 tRFCab;
  831. u8 tRTPx2;
  832. u8 tCKE;
  833. u8 tCKESR;
  834. u8 tZQCS;
  835. u32 tZQCL;
  836. u32 tZQINIT;
  837. u8 tDQSCKMAXx2;
  838. u8 tRASmax;
  839. u8 tFAW;
  840. };
  841. /*
  842. * Min tCK values for some of the parameters:
  843. * If the calculated clock cycles for the respective parameter is
  844. * less than the corresponding min tCK value, we need to set the min
  845. * tCK value. This may happen at lower frequencies.
  846. */
  847. struct lpddr2_min_tck {
  848. u32 tRL;
  849. u32 tRP_AB;
  850. u32 tRCD;
  851. u32 tWR;
  852. u32 tRAS_MIN;
  853. u32 tRRD;
  854. u32 tWTR;
  855. u32 tXP;
  856. u32 tRTP;
  857. u8 tCKE;
  858. u32 tCKESR;
  859. u32 tFAW;
  860. };
  861. struct lpddr2_device_details {
  862. u8 type;
  863. u8 density;
  864. u8 io_width;
  865. u8 manufacturer;
  866. };
  867. struct lpddr2_device_timings {
  868. const struct lpddr2_ac_timings **ac_timings;
  869. const struct lpddr2_min_tck *min_tck;
  870. };
  871. /* Details of the devices connected to each chip-select of an EMIF instance */
  872. struct emif_device_details {
  873. const struct lpddr2_device_details *cs0_device_details;
  874. const struct lpddr2_device_details *cs1_device_details;
  875. const struct lpddr2_device_timings *cs0_device_timings;
  876. const struct lpddr2_device_timings *cs1_device_timings;
  877. };
  878. /*
  879. * Structure containing shadow of important registers in EMIF
  880. * The calculation function fills in this structure to be later used for
  881. * initialization and DVFS
  882. */
  883. struct emif_regs {
  884. u32 freq;
  885. u32 sdram_config_init;
  886. u32 sdram_config;
  887. u32 ref_ctrl;
  888. u32 sdram_tim1;
  889. u32 sdram_tim2;
  890. u32 sdram_tim3;
  891. u32 read_idle_ctrl;
  892. u32 zq_config;
  893. u32 temp_alert_config;
  894. u32 emif_ddr_phy_ctlr_1_init;
  895. u32 emif_ddr_phy_ctlr_1;
  896. };
  897. /* assert macros */
  898. #if defined(DEBUG)
  899. #define emif_assert(c) ({ if (!(c)) for (;;); })
  900. #else
  901. #define emif_assert(c) ({ if (0) hang(); })
  902. #endif
  903. #ifdef CONFIG_SYS_EMIF_PRECALCULATED_TIMING_REGS
  904. void emif_get_reg_dump(u32 emif_nr, const struct emif_regs **regs);
  905. void emif_get_dmm_regs(const struct dmm_lisa_map_regs **dmm_lisa_regs);
  906. #else
  907. struct lpddr2_device_details *emif_get_device_details(u32 emif_nr, u8 cs,
  908. struct lpddr2_device_details *lpddr2_dev_details);
  909. void emif_get_device_timings(u32 emif_nr,
  910. const struct lpddr2_device_timings **cs0_device_timings,
  911. const struct lpddr2_device_timings **cs1_device_timings);
  912. #endif
  913. #ifndef CONFIG_SYS_EMIF_PRECALCULATED_TIMING_REGS
  914. extern u32 *const T_num;
  915. extern u32 *const T_den;
  916. extern u32 *const emif_sizes;
  917. #endif
  918. #endif