altera_edac.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. /*
  2. *
  3. * Copyright (C) 2015 Altera Corporation
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms and conditions of the GNU General Public License,
  7. * version 2, as published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12. * more details.
  13. *
  14. * You should have received a copy of the GNU General Public License along with
  15. * this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. #ifndef _ALTERA_EDAC_H
  18. #define _ALTERA_EDAC_H
  19. #include <linux/edac.h>
  20. #include <linux/types.h>
  21. /* SDRAM Controller CtrlCfg Register */
  22. #define CV_CTLCFG_OFST 0x00
  23. /* SDRAM Controller CtrlCfg Register Bit Masks */
  24. #define CV_CTLCFG_ECC_EN 0x400
  25. #define CV_CTLCFG_ECC_CORR_EN 0x800
  26. #define CV_CTLCFG_GEN_SB_ERR 0x2000
  27. #define CV_CTLCFG_GEN_DB_ERR 0x4000
  28. #define CV_CTLCFG_ECC_AUTO_EN (CV_CTLCFG_ECC_EN)
  29. /* SDRAM Controller Address Width Register */
  30. #define CV_DRAMADDRW_OFST 0x2C
  31. /* SDRAM Controller Address Widths Field Register */
  32. #define DRAMADDRW_COLBIT_MASK 0x001F
  33. #define DRAMADDRW_COLBIT_SHIFT 0
  34. #define DRAMADDRW_ROWBIT_MASK 0x03E0
  35. #define DRAMADDRW_ROWBIT_SHIFT 5
  36. #define CV_DRAMADDRW_BANKBIT_MASK 0x1C00
  37. #define CV_DRAMADDRW_BANKBIT_SHIFT 10
  38. #define CV_DRAMADDRW_CSBIT_MASK 0xE000
  39. #define CV_DRAMADDRW_CSBIT_SHIFT 13
  40. /* SDRAM Controller Interface Data Width Register */
  41. #define CV_DRAMIFWIDTH_OFST 0x30
  42. /* SDRAM Controller Interface Data Width Defines */
  43. #define CV_DRAMIFWIDTH_16B_ECC 24
  44. #define CV_DRAMIFWIDTH_32B_ECC 40
  45. /* SDRAM Controller DRAM Status Register */
  46. #define CV_DRAMSTS_OFST 0x38
  47. /* SDRAM Controller DRAM Status Register Bit Masks */
  48. #define CV_DRAMSTS_SBEERR 0x04
  49. #define CV_DRAMSTS_DBEERR 0x08
  50. #define CV_DRAMSTS_CORR_DROP 0x10
  51. /* SDRAM Controller DRAM IRQ Register */
  52. #define CV_DRAMINTR_OFST 0x3C
  53. /* SDRAM Controller DRAM IRQ Register Bit Masks */
  54. #define CV_DRAMINTR_INTREN 0x01
  55. #define CV_DRAMINTR_SBEMASK 0x02
  56. #define CV_DRAMINTR_DBEMASK 0x04
  57. #define CV_DRAMINTR_CORRDROPMASK 0x08
  58. #define CV_DRAMINTR_INTRCLR 0x10
  59. /* SDRAM Controller Single Bit Error Count Register */
  60. #define CV_SBECOUNT_OFST 0x40
  61. /* SDRAM Controller Double Bit Error Count Register */
  62. #define CV_DBECOUNT_OFST 0x44
  63. /* SDRAM Controller ECC Error Address Register */
  64. #define CV_ERRADDR_OFST 0x48
  65. /*-----------------------------------------*/
  66. /* SDRAM Controller EccCtrl Register */
  67. #define A10_ECCCTRL1_OFST 0x00
  68. /* SDRAM Controller EccCtrl Register Bit Masks */
  69. #define A10_ECCCTRL1_ECC_EN 0x001
  70. #define A10_ECCCTRL1_CNT_RST 0x010
  71. #define A10_ECCCTRL1_AWB_CNT_RST 0x100
  72. #define A10_ECC_CNT_RESET_MASK (A10_ECCCTRL1_CNT_RST | \
  73. A10_ECCCTRL1_AWB_CNT_RST)
  74. /* SDRAM Controller Address Width Register */
  75. #define CV_DRAMADDRW 0xFFC2502C
  76. #define A10_DRAMADDRW 0xFFCFA0A8
  77. /* SDRAM Controller Address Widths Field Register */
  78. #define DRAMADDRW_COLBIT_MASK 0x001F
  79. #define DRAMADDRW_COLBIT_SHIFT 0
  80. #define DRAMADDRW_ROWBIT_MASK 0x03E0
  81. #define DRAMADDRW_ROWBIT_SHIFT 5
  82. #define CV_DRAMADDRW_BANKBIT_MASK 0x1C00
  83. #define CV_DRAMADDRW_BANKBIT_SHIFT 10
  84. #define CV_DRAMADDRW_CSBIT_MASK 0xE000
  85. #define CV_DRAMADDRW_CSBIT_SHIFT 13
  86. #define A10_DRAMADDRW_BANKBIT_MASK 0x3C00
  87. #define A10_DRAMADDRW_BANKBIT_SHIFT 10
  88. #define A10_DRAMADDRW_GRPBIT_MASK 0xC000
  89. #define A10_DRAMADDRW_GRPBIT_SHIFT 14
  90. #define A10_DRAMADDRW_CSBIT_MASK 0x70000
  91. #define A10_DRAMADDRW_CSBIT_SHIFT 16
  92. /* SDRAM Controller Interface Data Width Register */
  93. #define CV_DRAMIFWIDTH 0xFFC25030
  94. #define A10_DRAMIFWIDTH 0xFFCFB008
  95. /* SDRAM Controller Interface Data Width Defines */
  96. #define CV_DRAMIFWIDTH_16B_ECC 24
  97. #define CV_DRAMIFWIDTH_32B_ECC 40
  98. #define A10_DRAMIFWIDTH_16B 0x0
  99. #define A10_DRAMIFWIDTH_32B 0x1
  100. #define A10_DRAMIFWIDTH_64B 0x2
  101. /* SDRAM Controller DRAM IRQ Register */
  102. #define A10_ERRINTEN_OFST 0x10
  103. /* SDRAM Controller DRAM IRQ Register Bit Masks */
  104. #define A10_ERRINTEN_SERRINTEN 0x01
  105. #define A10_ERRINTEN_DERRINTEN 0x02
  106. #define A10_ECC_IRQ_EN_MASK (A10_ERRINTEN_SERRINTEN | \
  107. A10_ERRINTEN_DERRINTEN)
  108. /* SDRAM Interrupt Mode Register */
  109. #define A10_INTMODE_OFST 0x1C
  110. #define A10_INTMODE_SB_INT 1
  111. /* SDRAM Controller Error Status Register */
  112. #define A10_INTSTAT_OFST 0x20
  113. /* SDRAM Controller Error Status Register Bit Masks */
  114. #define A10_INTSTAT_SBEERR 0x01
  115. #define A10_INTSTAT_DBEERR 0x02
  116. /* SDRAM Controller ECC Error Address Register */
  117. #define A10_DERRADDR_OFST 0x2C
  118. #define A10_SERRADDR_OFST 0x30
  119. /* SDRAM Controller ECC Diagnostic Register */
  120. #define A10_DIAGINTTEST_OFST 0x24
  121. #define A10_DIAGINT_TSERRA_MASK 0x0001
  122. #define A10_DIAGINT_TDERRA_MASK 0x0100
  123. #define A10_SBERR_IRQ 34
  124. #define A10_DBERR_IRQ 32
  125. /* SDRAM Single Bit Error Count Compare Set Register */
  126. #define A10_SERRCNTREG_OFST 0x3C
  127. #define A10_SYMAN_INTMASK_CLR 0xFFD06098
  128. #define A10_INTMASK_CLR_OFST 0x10
  129. #define A10_DDR0_IRQ_MASK BIT(17)
  130. struct altr_sdram_prv_data {
  131. int ecc_ctrl_offset;
  132. int ecc_ctl_en_mask;
  133. int ecc_cecnt_offset;
  134. int ecc_uecnt_offset;
  135. int ecc_stat_offset;
  136. int ecc_stat_ce_mask;
  137. int ecc_stat_ue_mask;
  138. int ecc_saddr_offset;
  139. int ecc_daddr_offset;
  140. int ecc_irq_en_offset;
  141. int ecc_irq_en_mask;
  142. int ecc_irq_clr_offset;
  143. int ecc_irq_clr_mask;
  144. int ecc_cnt_rst_offset;
  145. int ecc_cnt_rst_mask;
  146. struct edac_dev_sysfs_attribute *eccmgr_sysfs_attr;
  147. int ecc_enable_mask;
  148. int ce_set_mask;
  149. int ue_set_mask;
  150. int ce_ue_trgr_offset;
  151. };
  152. /* Altera SDRAM Memory Controller data */
  153. struct altr_sdram_mc_data {
  154. struct regmap *mc_vbase;
  155. int sb_irq;
  156. int db_irq;
  157. const struct altr_sdram_prv_data *data;
  158. };
  159. #endif /* #ifndef _ALTERA_EDAC_H */