dram_regs.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*
  2. * Copyright (c) 2016, ARM Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #ifndef DRAM_REGS_H
  7. #define DRAM_REGS_H
  8. #define CTL_REG_NUM 332
  9. #define PHY_REG_NUM 959
  10. #define PI_REG_NUM 200
  11. #define MSCH_ID_COREID 0x0
  12. #define MSCH_ID_REVISIONID 0x4
  13. #define MSCH_DEVICECONF 0x8
  14. #define MSCH_DEVICESIZE 0xc
  15. #define MSCH_DDRTIMINGA0 0x10
  16. #define MSCH_DDRTIMINGB0 0x14
  17. #define MSCH_DDRTIMINGC0 0x18
  18. #define MSCH_DEVTODEV0 0x1c
  19. #define MSCH_DDRMODE 0x110
  20. #define MSCH_AGINGX0 0x1000
  21. #define CIC_CTRL0 0x0
  22. #define CIC_CTRL1 0x4
  23. #define CIC_IDLE_TH 0x8
  24. #define CIC_CG_WAIT_TH 0xc
  25. #define CIC_STATUS0 0x10
  26. #define CIC_STATUS1 0x14
  27. #define CIC_CTRL2 0x18
  28. #define CIC_CTRL3 0x1c
  29. #define CIC_CTRL4 0x20
  30. /* DENALI_CTL_00 */
  31. #define START 1
  32. /* DENALI_CTL_68 */
  33. #define PWRUP_SREFRESH_EXIT (1 << 16)
  34. /* DENALI_CTL_274 */
  35. #define MEM_RST_VALID 1
  36. #define PHY_DRV_ODT_Hi_Z 0x0
  37. #define PHY_DRV_ODT_240 0x1
  38. #define PHY_DRV_ODT_120 0x8
  39. #define PHY_DRV_ODT_80 0x9
  40. #define PHY_DRV_ODT_60 0xc
  41. #define PHY_DRV_ODT_48 0xd
  42. #define PHY_DRV_ODT_40 0xe
  43. #define PHY_DRV_ODT_34_3 0xf
  44. /*
  45. * sys_reg bitfield struct
  46. * [31] row_3_4_ch1
  47. * [30] row_3_4_ch0
  48. * [29:28] chinfo
  49. * [27] rank_ch1
  50. * [26:25] col_ch1
  51. * [24] bk_ch1
  52. * [23:22] cs0_row_ch1
  53. * [21:20] cs1_row_ch1
  54. * [19:18] bw_ch1
  55. * [17:16] dbw_ch1;
  56. * [15:13] ddrtype
  57. * [12] channelnum
  58. * [11] rank_ch0
  59. * [10:9] col_ch0
  60. * [8] bk_ch0
  61. * [7:6] cs0_row_ch0
  62. * [5:4] cs1_row_ch0
  63. * [3:2] bw_ch0
  64. * [1:0] dbw_ch0
  65. */
  66. #define SYS_REG_ENC_ROW_3_4(n, ch) ((n) << (30 + (ch)))
  67. #define SYS_REG_DEC_ROW_3_4(n, ch) (((n) >> (30 + (ch))) & 0x1)
  68. #define SYS_REG_ENC_CHINFO(ch) (1 << (28 + (ch)))
  69. #define SYS_REG_DEC_CHINFO(n, ch) (((n) >> (28 + (ch))) & 0x1)
  70. #define SYS_REG_ENC_DDRTYPE(n) ((n) << 13)
  71. #define SYS_REG_DEC_DDRTYPE(n) (((n) >> 13) & 0x7)
  72. #define SYS_REG_ENC_NUM_CH(n) (((n) - 1) << 12)
  73. #define SYS_REG_DEC_NUM_CH(n) (1 + (((n) >> 12) & 0x1))
  74. #define SYS_REG_ENC_RANK(n, ch) (((n) - 1) << (11 + (ch) * 16))
  75. #define SYS_REG_DEC_RANK(n, ch) (1 + (((n) >> (11 + (ch) * 16)) & 0x1))
  76. #define SYS_REG_ENC_COL(n, ch) (((n) - 9) << (9 + (ch) * 16))
  77. #define SYS_REG_DEC_COL(n, ch) (9 + (((n) >> (9 + (ch) * 16)) & 0x3))
  78. #define SYS_REG_ENC_BK(n, ch) (((n) == 3 ? 0 : 1) << (8 + (ch) * 16))
  79. #define SYS_REG_DEC_BK(n, ch) (3 - (((n) >> (8 + (ch) * 16)) & 0x1))
  80. #define SYS_REG_ENC_CS0_ROW(n, ch) (((n) - 13) << (6 + (ch) * 16))
  81. #define SYS_REG_DEC_CS0_ROW(n, ch) (13 + (((n) >> (6 + (ch) * 16)) & 0x3))
  82. #define SYS_REG_ENC_CS1_ROW(n, ch) (((n) - 13) << (4 + (ch) * 16))
  83. #define SYS_REG_DEC_CS1_ROW(n, ch) (13 + (((n) >> (4 + (ch) * 16)) & 0x3))
  84. #define SYS_REG_ENC_BW(n, ch) ((2 >> (n)) << (2 + (ch) * 16))
  85. #define SYS_REG_DEC_BW(n, ch) (2 >> (((n) >> (2 + (ch) * 16)) & 0x3))
  86. #define SYS_REG_ENC_DBW(n, ch) ((2 >> (n)) << (0 + (ch) * 16))
  87. #define SYS_REG_DEC_DBW(n, ch) (2 >> (((n) >> (0 + (ch) * 16)) & 0x3))
  88. #define DDR_STRIDE(n) mmio_write_32(SGRF_BASE + SGRF_SOC_CON3_7(4), \
  89. (0x1f<<(10+16))|((n)<<10))
  90. #endif /* DRAM_REGS_H */