sdram_rk3399.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * Copyright (C) 2016-2017 Rockchip Electronics Co., Ltd
  4. */
  5. #ifndef _ASM_ARCH_SDRAM_RK3399_H
  6. #define _ASM_ARCH_SDRAM_RK3399_H
  7. enum {
  8. DDR3 = 0x3,
  9. LPDDR2 = 0x5,
  10. LPDDR3 = 0x6,
  11. LPDDR4 = 0x7,
  12. UNUSED = 0xFF
  13. };
  14. struct rk3399_ddr_pctl_regs {
  15. u32 denali_ctl[332];
  16. };
  17. struct rk3399_ddr_publ_regs {
  18. u32 denali_phy[959];
  19. };
  20. struct rk3399_ddr_pi_regs {
  21. u32 denali_pi[200];
  22. };
  23. struct rk3399_msch_regs {
  24. u32 coreid;
  25. u32 revisionid;
  26. u32 ddrconf;
  27. u32 ddrsize;
  28. u32 ddrtiminga0;
  29. u32 ddrtimingb0;
  30. u32 ddrtimingc0;
  31. u32 devtodev0;
  32. u32 reserved0[(0x110 - 0x20) / 4];
  33. u32 ddrmode;
  34. u32 reserved1[(0x1000 - 0x114) / 4];
  35. u32 agingx0;
  36. };
  37. struct rk3399_msch_timings {
  38. u32 ddrtiminga0;
  39. u32 ddrtimingb0;
  40. u32 ddrtimingc0;
  41. u32 devtodev0;
  42. u32 ddrmode;
  43. u32 agingx0;
  44. };
  45. struct rk3399_ddr_cic_regs {
  46. u32 cic_ctrl0;
  47. u32 cic_ctrl1;
  48. u32 cic_idle_th;
  49. u32 cic_cg_wait_th;
  50. u32 cic_status0;
  51. u32 cic_status1;
  52. u32 cic_ctrl2;
  53. u32 cic_ctrl3;
  54. u32 cic_ctrl4;
  55. };
  56. /* DENALI_CTL_00 */
  57. #define START 1
  58. /* DENALI_CTL_68 */
  59. #define PWRUP_SREFRESH_EXIT (1 << 16)
  60. /* DENALI_CTL_274 */
  61. #define MEM_RST_VALID 1
  62. struct rk3399_sdram_channel {
  63. unsigned int rank;
  64. /* dram column number, 0 means this channel is invalid */
  65. unsigned int col;
  66. /* dram bank number, 3:8bank, 2:4bank */
  67. unsigned int bk;
  68. /* channel buswidth, 2:32bit, 1:16bit, 0:8bit */
  69. unsigned int bw;
  70. /* die buswidth, 2:32bit, 1:16bit, 0:8bit */
  71. unsigned int dbw;
  72. /*
  73. * row_3_4 = 1: 6Gb or 12Gb die
  74. * row_3_4 = 0: normal die, power of 2
  75. */
  76. unsigned int row_3_4;
  77. unsigned int cs0_row;
  78. unsigned int cs1_row;
  79. unsigned int ddrconfig;
  80. struct rk3399_msch_timings noc_timings;
  81. };
  82. struct rk3399_base_params {
  83. unsigned int ddr_freq;
  84. unsigned int dramtype;
  85. unsigned int num_channels;
  86. unsigned int stride;
  87. unsigned int odt;
  88. };
  89. struct rk3399_sdram_params {
  90. struct rk3399_sdram_channel ch[2];
  91. struct rk3399_base_params base;
  92. struct rk3399_ddr_pctl_regs pctl_regs;
  93. struct rk3399_ddr_pi_regs pi_regs;
  94. struct rk3399_ddr_publ_regs phy_regs;
  95. };
  96. #define PI_CA_TRAINING (1 << 0)
  97. #define PI_WRITE_LEVELING (1 << 1)
  98. #define PI_READ_GATE_TRAINING (1 << 2)
  99. #define PI_READ_LEVELING (1 << 3)
  100. #define PI_WDQ_LEVELING (1 << 4)
  101. #define PI_FULL_TRAINING 0xff
  102. #endif