agilex5_memory_controller.h 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. /*
  2. * Copyright (c) 2019-2022, Intel Corporation. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #ifndef AGX_MEMORYCONTROLLER_H
  7. #define AGX_MEMORYCONTROLLER_H
  8. #include "socfpga_plat_def.h"
  9. #define AGX_MPFE_IOHMC_REG_DRAMADDRW 0xf80100a8
  10. #define AGX_MPFE_IOHMC_CTRLCFG0 0xf8010028
  11. #define AGX_MPFE_IOHMC_CTRLCFG1 0xf801002c
  12. #define AGX_MPFE_IOHMC_CTRLCFG2 0xf8010030
  13. #define AGX_MPFE_IOHMC_CTRLCFG3 0xf8010034
  14. #define AGX_MPFE_IOHMC_DRAMADDRW 0xf80100a8
  15. #define AGX_MPFE_IOHMC_DRAMTIMING0 0xf8010050
  16. #define AGX_MPFE_IOHMC_CALTIMING0 0xf801007c
  17. #define AGX_MPFE_IOHMC_CALTIMING1 0xf8010080
  18. #define AGX_MPFE_IOHMC_CALTIMING2 0xf8010084
  19. #define AGX_MPFE_IOHMC_CALTIMING3 0xf8010088
  20. #define AGX_MPFE_IOHMC_CALTIMING4 0xf801008c
  21. #define AGX_MPFE_IOHMC_CALTIMING9 0xf80100a0
  22. #define AGX_MPFE_IOHMC_CALTIMING9_ACT_TO_ACT(x) (((x) & 0x000000ff) >> 0)
  23. #define AGX_MPFE_IOHMC_CTRLCFG1_CFG_ADDR_ORDER(value) (((value) & 0x00000060) >> 5)
  24. #define AGX_MPFE_HMC_ADP_ECCCTRL1 0xf8011100
  25. #define AGX_MPFE_HMC_ADP_ECCCTRL2 0xf8011104
  26. #define AGX_MPFE_HMC_ADP_RSTHANDSHAKESTAT 0xf8011218
  27. #define AGX_MPFE_HMC_ADP_RSTHANDSHAKESTAT_SEQ2CORE 0x000000ff
  28. #define AGX_MPFE_HMC_ADP_RSTHANDSHAKECTRL 0xf8011214
  29. #define AGX_MPFE_IOHMC_REG_CTRLCFG1 0xf801002c
  30. #define AGX_MPFE_IOHMC_REG_NIOSRESERVE0_OFST 0xf8010110
  31. #define IOHMC_DRAMADDRW_COL_ADDR_WIDTH(x) (((x) & 0x0000001f) >> 0)
  32. #define IOHMC_DRAMADDRW_ROW_ADDR_WIDTH(x) (((x) & 0x000003e0) >> 5)
  33. #define IOHMC_DRAMADDRW_CS_ADDR_WIDTH(x) (((x) & 0x00070000) >> 16)
  34. #define IOHMC_DRAMADDRW_BANK_GRP_ADDR_WIDTH(x) (((x) & 0x0000c000) >> 14)
  35. #define IOHMC_DRAMADDRW_BANK_ADDR_WIDTH(x) (((x) & 0x00003c00) >> 10)
  36. #define AGX_MPFE_DDR(x) (0xf8000000 + x)
  37. #define AGX_MPFE_HMC_ADP_DDRCALSTAT 0xf801100c
  38. #define AGX_MPFE_DDR_MAIN_SCHED 0xf8000400
  39. #define AGX_MPFE_DDR_MAIN_SCHED_DDRCONF 0xf8000408
  40. #define AGX_MPFE_DDR_MAIN_SCHED_DDRTIMING 0xf800040c
  41. #define AGX_MPFE_DDR_MAIN_SCHED_DDRCONF_SET_MSK 0x0000001f
  42. #define AGX_MPFE_DDR_MAIN_SCHED_DDRMODE 0xf8000410
  43. #define AGX_MPFE_DDR_MAIN_SCHED_DEVTODEV 0xf800043c
  44. #define AGX_MPFE_DDR_MAIN_SCHED_READLATENCY 0xf8000414
  45. #define AGX_MPFE_DDR_MAIN_SCHED_ACTIVATE 0xf8000438
  46. #define AGX_MPFE_DDR_MAIN_SCHED_ACTIVATE_FAWBANK_OFST 10
  47. #define AGX_MPFE_DDR_MAIN_SCHED_ACTIVATE_FAW_OFST 4
  48. #define AGX_MPFE_DDR_MAIN_SCHED_ACTIVATE_RRD_OFST 0
  49. #define AGX_MPFE_DDR_MAIN_SCHED_DDRCONF_SET(x) (((x) << 0) & 0x0000001f)
  50. #define AGX_MPFE_DDR_MAIN_SCHED_DEVTODEV_BUSRDTORD_OFST 0
  51. #define AGX_MPFE_DDR_MAIN_SCHED_DEVTODEV_BUSRDTORD_MSK (BIT(0) | BIT(1))
  52. #define AGX_MPFE_DDR_MAIN_SCHED_DEVTODEV_BUSRDTOWR_OFST 2
  53. #define AGX_MPFE_DDR_MAIN_SCHED_DEVTODEV_BUSRDTOWR_MSK (BIT(2) | BIT(3))
  54. #define AGX_MPFE_DDR_MAIN_SCHED_DEVTODEV_BUSWRTORD_OFST 4
  55. #define AGX_MPFE_DDR_MAIN_SCHED_DEVTODEV_BUSWRTORD_MSK (BIT(4) | BIT(5))
  56. #define AGX_MPFE_HMC_ADP(x) (0xf8011000 + (x))
  57. #define AGX_MPFE_HMC_ADP_HPSINTFCSEL 0xf8011210
  58. #define AGX_MPFE_HMC_ADP_DDRIOCTRL 0xf8011008
  59. #define HMC_ADP_DDRIOCTRL 0x8
  60. #define HMC_ADP_DDRIOCTRL_IO_SIZE(x) (((x) & 0x00000003) >> 0)
  61. #define HMC_ADP_DDRIOCTRL_CTRL_BURST_LENGTH(x) (((x) & 0x00003e00) >> 9)
  62. #define ADP_DRAMADDRWIDTH 0xe0
  63. #define ACT_TO_ACT_DIFF_BANK(value) (((value) & 0x00fc0000) >> 18)
  64. #define ACT_TO_ACT(value) (((value) & 0x0003f000) >> 12)
  65. #define ACT_TO_RDWR(value) (((value) & 0x0000003f) >> 0)
  66. #define ACT_TO_ACT(value) (((value) & 0x0003f000) >> 12)
  67. /* timing 2 */
  68. #define RD_TO_RD_DIFF_CHIP(value) (((value) & 0x00000fc0) >> 6)
  69. #define RD_TO_WR_DIFF_CHIP(value) (((value) & 0x3f000000) >> 24)
  70. #define RD_TO_WR(value) (((value) & 0x00fc0000) >> 18)
  71. #define RD_TO_PCH(value) (((value) & 0x00000fc0) >> 6)
  72. /* timing 3 */
  73. #define CALTIMING3_WR_TO_RD_DIFF_CHIP(value) (((value) & 0x0003f000) >> 12)
  74. #define CALTIMING3_WR_TO_RD(value) (((value) & 0x00000fc0) >> 6)
  75. /* timing 4 */
  76. #define PCH_TO_VALID(value) (((value) & 0x00000fc0) >> 6)
  77. #define DDRTIMING_BWRATIO_OFST 31
  78. #define DDRTIMING_WRTORD_OFST 26
  79. #define DDRTIMING_RDTOWR_OFST 21
  80. #define DDRTIMING_BURSTLEN_OFST 18
  81. #define DDRTIMING_WRTOMISS_OFST 12
  82. #define DDRTIMING_RDTOMISS_OFST 6
  83. #define DDRTIMING_ACTTOACT_OFST 0
  84. #define ADP_DDRIOCTRL_IO_SIZE(x) (((x) & 0x3) >> 0)
  85. #define DDRMODE_AUTOPRECHARGE_OFST 1
  86. #define DDRMODE_BWRATIOEXTENDED_OFST 0
  87. #define AGX_MPFE_IOHMC_REG_DRAMTIMING0_CFG_TCL(x) (((x) & 0x7f) >> 0)
  88. #define AGX_MPFE_IOHMC_REG_CTRLCFG0_CFG_MEM_TYPE(x) (((x) & 0x0f) >> 0)
  89. #define AGX_CCU_CPU0_MPRT_DDR 0xf7004400
  90. #define AGX_CCU_CPU0_MPRT_MEM0 0xf70045c0
  91. #define AGX_CCU_CPU0_MPRT_MEM1A 0xf70045e0
  92. #define AGX_CCU_CPU0_MPRT_MEM1B 0xf7004600
  93. #define AGX_CCU_CPU0_MPRT_MEM1C 0xf7004620
  94. #define AGX_CCU_CPU0_MPRT_MEM1D 0xf7004640
  95. #define AGX_CCU_CPU0_MPRT_MEM1E 0xf7004660
  96. #define AGX_CCU_IOM_MPRT_MEM0 0xf7018560
  97. #define AGX_CCU_IOM_MPRT_MEM1A 0xf7018580
  98. #define AGX_CCU_IOM_MPRT_MEM1B 0xf70185a0
  99. #define AGX_CCU_IOM_MPRT_MEM1C 0xf70185c0
  100. #define AGX_CCU_IOM_MPRT_MEM1D 0xf70185e0
  101. #define AGX_CCU_IOM_MPRT_MEM1E 0xf7018600
  102. #define AGX_NOC_FW_DDR_SCR 0xf8020200
  103. #define AGX_NOC_FW_DDR_SCR_MPUREGION0ADDR_LIMITEXT 0xf802021c
  104. #define AGX_NOC_FW_DDR_SCR_MPUREGION0ADDR_LIMIT 0xf8020218
  105. #define AGX_NOC_FW_DDR_SCR_NONMPUREGION0ADDR_LIMITEXT 0xf802029c
  106. #define AGX_NOC_FW_DDR_SCR_NONMPUREGION0ADDR_LIMIT 0xf8020298
  107. #define AGX_SOC_NOC_FW_DDR_SCR_ENABLE 0xf8020200
  108. #define AGX_SOC_NOC_FW_DDR_SCR_ENABLESET 0xf8020204
  109. #define AGX_CCU_NOC_DI_SET_MSK 0x10
  110. #define AGX_SYSMGR_CORE_HMC_CLK 0xffd120b4
  111. #define AGX_SYSMGR_CORE_HMC_CLK_STATUS 0x00000001
  112. #define AGX_MPFE_IOHMC_NIOSRESERVE0_NIOS_RESERVE0(x) (((x) & 0xffff) >> 0)
  113. #define AGX_MPFE_HMC_ADP_DDRIOCTRL_IO_SIZE_MSK 0x00000003
  114. #define AGX_MPFE_HMC_ADP_DDRIOCTRL_IO_SIZE_OFST 0
  115. #define AGX_MPFE_HMC_ADP_HPSINTFCSEL_ENABLE 0x001f1f1f
  116. #define AGX_IOHMC_CTRLCFG1_ENABLE_ECC_OFST 7
  117. #define AGX_MPFE_HMC_ADP_ECCCTRL1_AUTOWB_CNT_RST_SET_MSK 0x00010000
  118. #define AGX_MPFE_HMC_ADP_ECCCTRL1_CNT_RST_SET_MSK 0x00000100
  119. #define AGX_MPFE_HMC_ADP_ECCCTRL1_ECC_EN_SET_MSK 0x00000001
  120. #define AGX_MPFE_HMC_ADP_ECCCTRL2_AUTOWB_EN_SET_MSK 0x00000001
  121. #define AGX_MPFE_HMC_ADP_ECCCTRL2_OVRW_RB_ECC_EN_SET_MSK 0x00010000
  122. #define AGX_MPFE_HMC_ADP_ECCCTRL2_RMW_EN_SET_MSK 0x00000100
  123. #define AGX_MPFE_HMC_ADP_DDRCALSTAT_CAL(value) (((value) & 0x1) >> 0)
  124. #define AGX_MPFE_HMC_ADP_DDRIOCTRL_IO_SIZE(x) (((x) & 0x00003) >> 0)
  125. #define IOHMC_DRAMADDRW_CFG_BANK_ADDR_WIDTH(x) (((x) & 0x03c00) >> 10)
  126. #define IOHMC_DRAMADDRW_CFG_BANK_GROUP_ADDR_WIDTH(x) (((x) & 0x0c000) >> 14)
  127. #define IOHMC_DRAMADDRW_CFG_COL_ADDR_WIDTH(x) (((x) & 0x0001f) >> 0)
  128. #define IOHMC_DRAMADDRW_CFG_CS_ADDR_WIDTH(x) (((x) & 0x70000) >> 16)
  129. #define IOHMC_DRAMADDRW_CFG_ROW_ADDR_WIDTH(x) (((x) & 0x003e0) >> 5)
  130. #define AGX_SDRAM_0_LB_ADDR 0x0
  131. #define AGX_DDR_SIZE 0x40000000
  132. /* Macros */
  133. #define SOCFPGA_MEMCTRL_ECCCTRL1 0x008
  134. #define SOCFPGA_MEMCTRL_ERRINTEN 0x010
  135. #define SOCFPGA_MEMCTRL_ERRINTENS 0x014
  136. #define SOCFPGA_MEMCTRL_ERRINTENR 0x018
  137. #define SOCFPGA_MEMCTRL_INTMODE 0x01C
  138. #define SOCFPGA_MEMCTRL_INTSTAT 0x020
  139. #define SOCFPGA_MEMCTRL_DIAGINTTEST 0x024
  140. #define SOCFPGA_MEMCTRL_DERRADDRA 0x02C
  141. #define SOCFPGA_MEMCTRL(_reg) (SOCFPGA_MEMCTRL_REG_BASE \
  142. + (SOCFPGA_MEMCTRL_##_reg))
  143. #endif