s10_memory_controller.h 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. /*
  2. * Copyright (c) 2019, Intel Corporation. All rights reserved.
  3. * Copyright (c) 2024, Altera Corporation. All rights reserved.
  4. *
  5. * SPDX-License-Identifier: BSD-3-Clause
  6. */
  7. #ifndef __S10_MEMORYCONTROLLER_H__
  8. #define __S10_MEMORYCONTROLLER_H__
  9. #define S10_MPFE_IOHMC_REG_DRAMADDRW 0xf80100a8
  10. #define S10_MPFE_IOHMC_CTRLCFG0 0xf8010028
  11. #define S10_MPFE_IOHMC_CTRLCFG1 0xf801002c
  12. #define S10_MPFE_IOHMC_DRAMADDRW 0xf80100a8
  13. #define S10_MPFE_IOHMC_DRAMTIMING0 0xf8010050
  14. #define S10_MPFE_IOHMC_CALTIMING0 0xf801007c
  15. #define S10_MPFE_IOHMC_CALTIMING1 0xf8010080
  16. #define S10_MPFE_IOHMC_CALTIMING2 0xf8010084
  17. #define S10_MPFE_IOHMC_CALTIMING3 0xf8010088
  18. #define S10_MPFE_IOHMC_CALTIMING4 0xf801008c
  19. #define S10_MPFE_IOHMC_CALTIMING9 0xf80100a0
  20. #define S10_MPFE_IOHMC_CALTIMING9_ACT_TO_ACT(x) (((x) & 0x000000ff) >> 0)
  21. #define S10_MPFE_IOHMC_CTRLCFG1_CFG_ADDR_ORDER(value) \
  22. (((value) & 0x00000060) >> 5)
  23. #define S10_MPFE_HMC_ADP_ECCCTRL1 0xf8011100
  24. #define S10_MPFE_HMC_ADP_ECCCTRL2 0xf8011104
  25. #define S10_MPFE_HMC_ADP_RSTHANDSHAKESTAT 0xf8011218
  26. #define S10_MPFE_HMC_ADP_RSTHANDSHAKESTAT_SEQ2CORE 0x0000000f
  27. #define S10_MPFE_HMC_ADP_RSTHANDSHAKECTRL 0xf8011214
  28. #define S10_MPFE_IOHMC_REG_CTRLCFG1 0xf801002c
  29. #define S10_MPFE_IOHMC_REG_NIOSRESERVE0_OFST 0xf8010110
  30. #define IOHMC_DRAMADDRW_COL_ADDR_WIDTH(x) (((x) & 0x0000001f) >> 0)
  31. #define IOHMC_DRAMADDRW_ROW_ADDR_WIDTH(x) (((x) & 0x000003e0) >> 5)
  32. #define IOHMC_DRAMADDRW_CS_ADDR_WIDTH(x) (((x) & 0x00070000) >> 16)
  33. #define IOHMC_DRAMADDRW_BANK_GRP_ADDR_WIDTH(x) (((x) & 0x0000c000) >> 14)
  34. #define IOHMC_DRAMADDRW_BANK_ADDR_WIDTH(x) (((x) & 0x00003c00) >> 10)
  35. #define S10_MPFE_DDR(x) (0xf8000000 + x)
  36. #define S10_MPFE_HMC_ADP_DDRCALSTAT 0xf801100c
  37. #define S10_MPFE_DDR_MAIN_SCHED 0xf8000400
  38. #define S10_MPFE_DDR_MAIN_SCHED_DDRCONF 0xf8000408
  39. #define S10_MPFE_DDR_MAIN_SCHED_DDRTIMING 0xf800040c
  40. #define S10_MPFE_DDR_MAIN_SCHED_DDRCONF_SET_MSK 0x0000001f
  41. #define S10_MPFE_DDR_MAIN_SCHED_DDRMODE 0xf8000410
  42. #define S10_MPFE_DDR_MAIN_SCHED_DEVTODEV 0xf800043c
  43. #define S10_MPFE_DDR_MAIN_SCHED_READLATENCY 0xf8000414
  44. #define S10_MPFE_DDR_MAIN_SCHED_ACTIVATE 0xf8000438
  45. #define S10_MPFE_DDR_MAIN_SCHED_ACTIVATE_FAWBANK_OFST 10
  46. #define S10_MPFE_DDR_MAIN_SCHED_ACTIVATE_FAW_OFST 4
  47. #define S10_MPFE_DDR_MAIN_SCHED_ACTIVATE_RRD_OFST 0
  48. #define S10_MPFE_DDR_MAIN_SCHED_DDRCONF_SET(x) (((x) << 0) & 0x0000001f)
  49. #define S10_MPFE_DDR_MAIN_SCHED_DEVTODEV_BUSRDTORD_OFST 0
  50. #define S10_MPFE_DDR_MAIN_SCHED_DEVTODEV_BUSRDTORD_MSK (BIT(0) | BIT(1))
  51. #define S10_MPFE_DDR_MAIN_SCHED_DEVTODEV_BUSRDTOWR_OFST 2
  52. #define S10_MPFE_DDR_MAIN_SCHED_DEVTODEV_BUSRDTOWR_MSK (BIT(2) | BIT(3))
  53. #define S10_MPFE_DDR_MAIN_SCHED_DEVTODEV_BUSWRTORD_OFST 4
  54. #define S10_MPFE_DDR_MAIN_SCHED_DEVTODEV_BUSWRTORD_MSK (BIT(4) | BIT(5))
  55. #define S10_MPFE_HMC_ADP(x) (0xf8011000 + (x))
  56. #define S10_MPFE_HMC_ADP_HPSINTFCSEL 0xf8011210
  57. #define S10_MPFE_HMC_ADP_DDRIOCTRL 0xf8011008
  58. #define HMC_ADP_DDRIOCTRL 0x8
  59. #define HMC_ADP_DDRIOCTRL_IO_SIZE(x) (((x) & 0x00000003) >> 0)
  60. #define HMC_ADP_DDRIOCTRL_CTRL_BURST_LENGTH(x) (((x) & 0x00003e00) >> 9)
  61. #define ADP_DRAMADDRWIDTH 0xe0
  62. #define ACT_TO_ACT_DIFF_BANK(value) (((value) & 0x00fc0000) >> 18)
  63. #define ACT_TO_ACT(value) (((value) & 0x0003f000) >> 12)
  64. #define ACT_TO_RDWR(value) (((value) & 0x0000003f) >> 0)
  65. #define ACT_TO_ACT(value) (((value) & 0x0003f000) >> 12)
  66. /* timing 2 */
  67. #define RD_TO_RD_DIFF_CHIP(value) (((value) & 0x00000fc0) >> 6)
  68. #define RD_TO_WR_DIFF_CHIP(value) (((value) & 0x3f000000) >> 24)
  69. #define RD_TO_WR(value) (((value) & 0x00fc0000) >> 18)
  70. #define RD_TO_PCH(value) (((value) & 0x00000fc0) >> 6)
  71. /* timing 3 */
  72. #define CALTIMING3_WR_TO_RD_DIFF_CHIP(value) (((value) & 0x0003f000) >> 12)
  73. #define CALTIMING3_WR_TO_RD(value) (((value) & 0x00000fc0) >> 6)
  74. /* timing 4 */
  75. #define PCH_TO_VALID(value) (((value) & 0x00000fc0) >> 6)
  76. #define DDRTIMING_BWRATIO_OFST 31
  77. #define DDRTIMING_WRTORD_OFST 26
  78. #define DDRTIMING_RDTOWR_OFST 21
  79. #define DDRTIMING_BURSTLEN_OFST 18
  80. #define DDRTIMING_WRTOMISS_OFST 12
  81. #define DDRTIMING_RDTOMISS_OFST 6
  82. #define DDRTIMING_ACTTOACT_OFST 0
  83. #define ADP_DDRIOCTRL_IO_SIZE(x) (((x) & 0x00000003) >> 0)
  84. #define DDRMODE_AUTOPRECHARGE_OFST 1
  85. #define DDRMODE_BWRATIOEXTENDED_OFST 0
  86. #define S10_MPFE_IOHMC_REG_DRAMTIMING0_CFG_TCL(x) (((x) & 0x0000007f) >> 0)
  87. #define S10_MPFE_IOHMC_REG_CTRLCFG0_CFG_MEM_TYPE(x) (((x) & 0x0000000f) >> 0)
  88. #define S10_CCU_CPU0_MPRT_DDR 0xf7004400
  89. #define S10_CCU_CPU0_MPRT_MEM0 0xf70045c0
  90. #define S10_CCU_CPU0_MPRT_MEM1A 0xf70045e0
  91. #define S10_CCU_CPU0_MPRT_MEM1B 0xf7004600
  92. #define S10_CCU_CPU0_MPRT_MEM1C 0xf7004620
  93. #define S10_CCU_CPU0_MPRT_MEM1D 0xf7004640
  94. #define S10_CCU_CPU0_MPRT_MEM1E 0xf7004660
  95. #define S10_CCU_IOM_MPRT_MEM0 0xf7018560
  96. #define S10_CCU_IOM_MPRT_MEM1A 0xf7018580
  97. #define S10_CCU_IOM_MPRT_MEM1B 0xf70185a0
  98. #define S10_CCU_IOM_MPRT_MEM1C 0xf70185c0
  99. #define S10_CCU_IOM_MPRT_MEM1D 0xf70185e0
  100. #define S10_CCU_IOM_MPRT_MEM1E 0xf7018600
  101. #define S10_NOC_FW_DDR_SCR 0xf8020100
  102. #define S10_NOC_FW_DDR_SCR_MPUREGION0ADDR_LIMITEXT 0xf802011c
  103. #define S10_NOC_FW_DDR_SCR_MPUREGION0ADDR_LIMIT 0xf8020118
  104. #define S10_NOC_FW_DDR_SCR_NONMPUREGION0ADDR_LIMITEXT 0xf802019c
  105. #define S10_NOC_FW_DDR_SCR_NONMPUREGION0ADDR_LIMIT 0xf8020198
  106. #define S10_SOC_NOC_FW_DDR_SCR_ENABLE 0xf8020100
  107. #define S10_CCU_NOC_DI_SET_MSK 0x10
  108. #define S10_SYSMGR_CORE_HMC_CLK 0xffd120b4
  109. #define S10_SYSMGR_CORE_HMC_CLK_STATUS 0x00000001
  110. #define S10_MPFE_IOHMC_NIOSRESERVE0_NIOS_RESERVE0(x) (((x) & 0x0000ffff) >> 0)
  111. #define S10_MPFE_HMC_ADP_DDRIOCTRL_IO_SIZE_MSK 0x00000003
  112. #define S10_MPFE_HMC_ADP_DDRIOCTRL_IO_SIZE_OFST 0
  113. #define S10_MPFE_HMC_ADP_HPSINTFCSEL_ENABLE 0x001f1f1f
  114. #define S10_IOHMC_CTRLCFG1_ENABLE_ECC_OFST 7
  115. #define S10_MPFE_HMC_ADP_ECCCTRL1_AUTOWB_CNT_RST_SET_MSK 0x00010000
  116. #define S10_MPFE_HMC_ADP_ECCCTRL1_CNT_RST_SET_MSK 0x00000100
  117. #define S10_MPFE_HMC_ADP_ECCCTRL1_ECC_EN_SET_MSK 0x00000001
  118. #define S10_MPFE_HMC_ADP_ECCCTRL2_AUTOWB_EN_SET_MSK 0x00000001
  119. #define S10_MPFE_HMC_ADP_ECCCTRL2_OVRW_RB_ECC_EN_SET_MSK 0x00010000
  120. #define S10_MPFE_HMC_ADP_ECCCTRL2_RMW_EN_SET_MSK 0x00000100
  121. #define S10_MPFE_HMC_ADP_DDRCALSTAT_CAL(value) (((value) & 0x00000001) >> 0)
  122. #define S10_MPFE_HMC_ADP_DDRIOCTRL_IO_SIZE(x) (((x) & 0x00000003) >> 0)
  123. #define IOHMC_DRAMADDRW_CFG_BANK_ADDR_WIDTH(x) (((x) & 0x00003c00) >> 10)
  124. #define IOHMC_DRAMADDRW_CFG_BANK_GROUP_ADDR_WIDTH(x) (((x) & 0x0000c000) >> 14)
  125. #define IOHMC_DRAMADDRW_CFG_COL_ADDR_WIDTH(x) (((x) & 0x0000001f) >> 0)
  126. #define IOHMC_DRAMADDRW_CFG_CS_ADDR_WIDTH(x) (((x) & 0x00070000) >> 16)
  127. #define IOHMC_DRAMADDRW_CFG_ROW_ADDR_WIDTH(x) (((x) & 0x000003e0) >> 5)
  128. #define S10_SDRAM_0_LB_ADDR 0x0
  129. int init_hard_memory_controller(void);
  130. #endif