emif.h 38 KB

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