ppc4xx_edac.h 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. /*
  2. * Copyright (c) 2008 Nuovation System Designs, LLC
  3. * Grant Erickson <gerickson@nuovations.com>
  4. *
  5. * This file defines processor mnemonics for accessing and managing
  6. * the IBM DDR1/DDR2 ECC controller found in the 405EX[r], 440SP,
  7. * 440SPe, 460EX, 460GT and 460SX.
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License as
  11. * published by the Free Software Foundation; version 2 of the
  12. * License.
  13. *
  14. */
  15. #ifndef __PPC4XX_EDAC_H
  16. #define __PPC4XX_EDAC_H
  17. #include <linux/types.h>
  18. /*
  19. * Macro for generating register field mnemonics
  20. */
  21. #define PPC_REG_BITS 32
  22. #define PPC_REG_VAL(bit, val) ((val) << ((PPC_REG_BITS - 1) - (bit)))
  23. #define PPC_REG_DECODE(bit, val) ((val) >> ((PPC_REG_BITS - 1) - (bit)))
  24. /*
  25. * IBM 4xx DDR1/DDR2 SDRAM memory controller registers (at least those
  26. * relevant to ECC)
  27. */
  28. #define SDRAM_BESR 0x00 /* Error status (read/clear) */
  29. #define SDRAM_BESRT 0x01 /* Error statuss (test/set) */
  30. #define SDRAM_BEARL 0x02 /* Error address low */
  31. #define SDRAM_BEARH 0x03 /* Error address high */
  32. #define SDRAM_WMIRQ 0x06 /* Write master (read/clear) */
  33. #define SDRAM_WMIRQT 0x07 /* Write master (test/set) */
  34. #define SDRAM_MCOPT1 0x20 /* Controller options 1 */
  35. #define SDRAM_MBXCF_BASE 0x40 /* Bank n configuration base */
  36. #define SDRAM_MBXCF(n) (SDRAM_MBXCF_BASE + (4 * (n)))
  37. #define SDRAM_MB0CF SDRAM_MBXCF(0)
  38. #define SDRAM_MB1CF SDRAM_MBXCF(1)
  39. #define SDRAM_MB2CF SDRAM_MBXCF(2)
  40. #define SDRAM_MB3CF SDRAM_MBXCF(3)
  41. #define SDRAM_ECCCR 0x98 /* ECC error status */
  42. #define SDRAM_ECCES SDRAM_ECCCR
  43. /*
  44. * PLB Master IDs
  45. */
  46. #define SDRAM_PLB_M0ID_FIRST 0
  47. #define SDRAM_PLB_M0ID_ICU SDRAM_PLB_M0ID_FIRST
  48. #define SDRAM_PLB_M0ID_PCIE0 1
  49. #define SDRAM_PLB_M0ID_PCIE1 2
  50. #define SDRAM_PLB_M0ID_DMA 3
  51. #define SDRAM_PLB_M0ID_DCU 4
  52. #define SDRAM_PLB_M0ID_OPB 5
  53. #define SDRAM_PLB_M0ID_MAL 6
  54. #define SDRAM_PLB_M0ID_SEC 7
  55. #define SDRAM_PLB_M0ID_AHB 8
  56. #define SDRAM_PLB_M0ID_LAST SDRAM_PLB_M0ID_AHB
  57. #define SDRAM_PLB_M0ID_COUNT (SDRAM_PLB_M0ID_LAST - \
  58. SDRAM_PLB_M0ID_FIRST + 1)
  59. /*
  60. * Memory Controller Bus Error Status Register
  61. */
  62. #define SDRAM_BESR_MASK PPC_REG_VAL(7, 0xFF)
  63. #define SDRAM_BESR_M0ID_MASK PPC_REG_VAL(3, 0xF)
  64. #define SDRAM_BESR_M0ID_DECODE(n) PPC_REG_DECODE(3, n)
  65. #define SDRAM_BESR_M0ID_ICU PPC_REG_VAL(3, SDRAM_PLB_M0ID_ICU)
  66. #define SDRAM_BESR_M0ID_PCIE0 PPC_REG_VAL(3, SDRAM_PLB_M0ID_PCIE0)
  67. #define SDRAM_BESR_M0ID_PCIE1 PPC_REG_VAL(3, SDRAM_PLB_M0ID_PCIE1)
  68. #define SDRAM_BESR_M0ID_DMA PPC_REG_VAL(3, SDRAM_PLB_M0ID_DMA)
  69. #define SDRAM_BESR_M0ID_DCU PPC_REG_VAL(3, SDRAM_PLB_M0ID_DCU)
  70. #define SDRAM_BESR_M0ID_OPB PPC_REG_VAL(3, SDRAM_PLB_M0ID_OPB)
  71. #define SDRAM_BESR_M0ID_MAL PPC_REG_VAL(3, SDRAM_PLB_M0ID_MAL)
  72. #define SDRAM_BESR_M0ID_SEC PPC_REG_VAL(3, SDRAM_PLB_M0ID_SEC)
  73. #define SDRAM_BESR_M0ID_AHB PPC_REG_VAL(3, SDRAM_PLB_M0ID_AHB)
  74. #define SDRAM_BESR_M0ET_MASK PPC_REG_VAL(6, 0x7)
  75. #define SDRAM_BESR_M0ET_NONE PPC_REG_VAL(6, 0)
  76. #define SDRAM_BESR_M0ET_ECC PPC_REG_VAL(6, 1)
  77. #define SDRAM_BESR_M0RW_MASK PPC_REG_VAL(7, 1)
  78. #define SDRAM_BESR_M0RW_WRITE PPC_REG_VAL(7, 0)
  79. #define SDRAM_BESR_M0RW_READ PPC_REG_VAL(7, 1)
  80. /*
  81. * Memory Controller PLB Write Master Interrupt Register
  82. */
  83. #define SDRAM_WMIRQ_MASK PPC_REG_VAL(8, 0x1FF)
  84. #define SDRAM_WMIRQ_ENCODE(id) PPC_REG_VAL((id % \
  85. SDRAM_PLB_M0ID_COUNT), 1)
  86. #define SDRAM_WMIRQ_ICU PPC_REG_VAL(SDRAM_PLB_M0ID_ICU, 1)
  87. #define SDRAM_WMIRQ_PCIE0 PPC_REG_VAL(SDRAM_PLB_M0ID_PCIE0, 1)
  88. #define SDRAM_WMIRQ_PCIE1 PPC_REG_VAL(SDRAM_PLB_M0ID_PCIE1, 1)
  89. #define SDRAM_WMIRQ_DMA PPC_REG_VAL(SDRAM_PLB_M0ID_DMA, 1)
  90. #define SDRAM_WMIRQ_DCU PPC_REG_VAL(SDRAM_PLB_M0ID_DCU, 1)
  91. #define SDRAM_WMIRQ_OPB PPC_REG_VAL(SDRAM_PLB_M0ID_OPB, 1)
  92. #define SDRAM_WMIRQ_MAL PPC_REG_VAL(SDRAM_PLB_M0ID_MAL, 1)
  93. #define SDRAM_WMIRQ_SEC PPC_REG_VAL(SDRAM_PLB_M0ID_SEC, 1)
  94. #define SDRAM_WMIRQ_AHB PPC_REG_VAL(SDRAM_PLB_M0ID_AHB, 1)
  95. /*
  96. * Memory Controller Options 1 Register
  97. */
  98. #define SDRAM_MCOPT1_MCHK_MASK PPC_REG_VAL(3, 0x3) /* ECC mask */
  99. #define SDRAM_MCOPT1_MCHK_NON PPC_REG_VAL(3, 0x0) /* No ECC gen */
  100. #define SDRAM_MCOPT1_MCHK_GEN PPC_REG_VAL(3, 0x2) /* ECC gen */
  101. #define SDRAM_MCOPT1_MCHK_CHK PPC_REG_VAL(3, 0x1) /* ECC gen and chk */
  102. #define SDRAM_MCOPT1_MCHK_CHK_REP PPC_REG_VAL(3, 0x3) /* ECC gen/chk/rpt */
  103. #define SDRAM_MCOPT1_MCHK_DECODE(n) ((((u32)(n)) >> 28) & 0x3)
  104. #define SDRAM_MCOPT1_RDEN_MASK PPC_REG_VAL(4, 0x1) /* Rgstrd DIMM mask */
  105. #define SDRAM_MCOPT1_RDEN PPC_REG_VAL(4, 0x1) /* Rgstrd DIMM enbl */
  106. #define SDRAM_MCOPT1_WDTH_MASK PPC_REG_VAL(7, 0x1) /* Width mask */
  107. #define SDRAM_MCOPT1_WDTH_32 PPC_REG_VAL(7, 0x0) /* 32 bits */
  108. #define SDRAM_MCOPT1_WDTH_16 PPC_REG_VAL(7, 0x1) /* 16 bits */
  109. #define SDRAM_MCOPT1_DDR_TYPE_MASK PPC_REG_VAL(11, 0x1) /* DDR type mask */
  110. #define SDRAM_MCOPT1_DDR1_TYPE PPC_REG_VAL(11, 0x0) /* DDR1 type */
  111. #define SDRAM_MCOPT1_DDR2_TYPE PPC_REG_VAL(11, 0x1) /* DDR2 type */
  112. /*
  113. * Memory Bank 0 - n Configuration Register
  114. */
  115. #define SDRAM_MBCF_BA_MASK PPC_REG_VAL(12, 0x1FFF)
  116. #define SDRAM_MBCF_SZ_MASK PPC_REG_VAL(19, 0xF)
  117. #define SDRAM_MBCF_SZ_DECODE(mbxcf) PPC_REG_DECODE(19, mbxcf)
  118. #define SDRAM_MBCF_SZ_4MB PPC_REG_VAL(19, 0x0)
  119. #define SDRAM_MBCF_SZ_8MB PPC_REG_VAL(19, 0x1)
  120. #define SDRAM_MBCF_SZ_16MB PPC_REG_VAL(19, 0x2)
  121. #define SDRAM_MBCF_SZ_32MB PPC_REG_VAL(19, 0x3)
  122. #define SDRAM_MBCF_SZ_64MB PPC_REG_VAL(19, 0x4)
  123. #define SDRAM_MBCF_SZ_128MB PPC_REG_VAL(19, 0x5)
  124. #define SDRAM_MBCF_SZ_256MB PPC_REG_VAL(19, 0x6)
  125. #define SDRAM_MBCF_SZ_512MB PPC_REG_VAL(19, 0x7)
  126. #define SDRAM_MBCF_SZ_1GB PPC_REG_VAL(19, 0x8)
  127. #define SDRAM_MBCF_SZ_2GB PPC_REG_VAL(19, 0x9)
  128. #define SDRAM_MBCF_SZ_4GB PPC_REG_VAL(19, 0xA)
  129. #define SDRAM_MBCF_SZ_8GB PPC_REG_VAL(19, 0xB)
  130. #define SDRAM_MBCF_AM_MASK PPC_REG_VAL(23, 0xF)
  131. #define SDRAM_MBCF_AM_MODE0 PPC_REG_VAL(23, 0x0)
  132. #define SDRAM_MBCF_AM_MODE1 PPC_REG_VAL(23, 0x1)
  133. #define SDRAM_MBCF_AM_MODE2 PPC_REG_VAL(23, 0x2)
  134. #define SDRAM_MBCF_AM_MODE3 PPC_REG_VAL(23, 0x3)
  135. #define SDRAM_MBCF_AM_MODE4 PPC_REG_VAL(23, 0x4)
  136. #define SDRAM_MBCF_AM_MODE5 PPC_REG_VAL(23, 0x5)
  137. #define SDRAM_MBCF_AM_MODE6 PPC_REG_VAL(23, 0x6)
  138. #define SDRAM_MBCF_AM_MODE7 PPC_REG_VAL(23, 0x7)
  139. #define SDRAM_MBCF_AM_MODE8 PPC_REG_VAL(23, 0x8)
  140. #define SDRAM_MBCF_AM_MODE9 PPC_REG_VAL(23, 0x9)
  141. #define SDRAM_MBCF_BE_MASK PPC_REG_VAL(31, 0x1)
  142. #define SDRAM_MBCF_BE_DISABLE PPC_REG_VAL(31, 0x0)
  143. #define SDRAM_MBCF_BE_ENABLE PPC_REG_VAL(31, 0x1)
  144. /*
  145. * ECC Error Status
  146. */
  147. #define SDRAM_ECCES_MASK PPC_REG_VAL(21, 0x3FFFFF)
  148. #define SDRAM_ECCES_BNCE_MASK PPC_REG_VAL(15, 0xFFFF)
  149. #define SDRAM_ECCES_BNCE_ENCODE(lane) PPC_REG_VAL(((lane) & 0xF), 1)
  150. #define SDRAM_ECCES_CKBER_MASK PPC_REG_VAL(17, 0x3)
  151. #define SDRAM_ECCES_CKBER_NONE PPC_REG_VAL(17, 0)
  152. #define SDRAM_ECCES_CKBER_16_ECC_0_3 PPC_REG_VAL(17, 2)
  153. #define SDRAM_ECCES_CKBER_32_ECC_0_3 PPC_REG_VAL(17, 1)
  154. #define SDRAM_ECCES_CKBER_32_ECC_4_8 PPC_REG_VAL(17, 2)
  155. #define SDRAM_ECCES_CKBER_32_ECC_0_8 PPC_REG_VAL(17, 3)
  156. #define SDRAM_ECCES_CE PPC_REG_VAL(18, 1)
  157. #define SDRAM_ECCES_UE PPC_REG_VAL(19, 1)
  158. #define SDRAM_ECCES_BKNER_MASK PPC_REG_VAL(21, 0x3)
  159. #define SDRAM_ECCES_BK0ER PPC_REG_VAL(20, 1)
  160. #define SDRAM_ECCES_BK1ER PPC_REG_VAL(21, 1)
  161. #endif /* __PPC4XX_EDAC_H */