ppc4xx-ebc.h 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. /*
  2. * (C) Copyright 2008
  3. * Stefan Roese, DENX Software Engineering, sr@denx.de.
  4. *
  5. * SPDX-License-Identifier: GPL-2.0+
  6. */
  7. #ifndef _PPC4xx_EBC_H_
  8. #define _PPC4xx_EBC_H_
  9. /*
  10. * Currently there are two register layout versions for the IBM EBC core
  11. * used on 4xx PPC's. The following grouping lists the first layout.
  12. * Within this group there is a slight variation concerning the bit field
  13. * position of the EMPL and EMPH fields:
  14. */
  15. #if defined(CONFIG_405GP) || \
  16. defined(CONFIG_405EP) || \
  17. defined(CONFIG_440EP) || defined(CONFIG_440GR) || \
  18. defined(CONFIG_440EPX) || defined(CONFIG_440GRX)
  19. #define CONFIG_EBC_PPC4xx_IBM_VER1
  20. #if defined(CONFIG_405GP) || \
  21. defined(CONFIG_405EP)
  22. #define EBC_CFG_EMPH_POS 8
  23. #define EBC_CFG_EMPL_POS 6
  24. #else
  25. #define EBC_CFG_EMPH_POS 6
  26. #define EBC_CFG_EMPL_POS 8
  27. #endif
  28. #endif
  29. /*
  30. * Define the max number of EBC banks (chip selects)
  31. */
  32. #if defined(CONFIG_405GP) || \
  33. defined(CONFIG_405EZ) || \
  34. defined(CONFIG_440GP) || defined(CONFIG_440GX)
  35. #define EBC_NUM_BANKS 8
  36. #endif
  37. #if defined(CONFIG_405EP)
  38. #define EBC_NUM_BANKS 5
  39. #endif
  40. #if defined(CONFIG_405EX) || \
  41. defined(CONFIG_460SX)
  42. #define EBC_NUM_BANKS 4
  43. #endif
  44. #if defined(CONFIG_440EP) || defined(CONFIG_440GR) || \
  45. defined(CONFIG_440EPX) || defined(CONFIG_440GRX) || \
  46. defined(CONFIG_460EX) || defined(CONFIG_460GT)
  47. #define EBC_NUM_BANKS 6
  48. #endif
  49. #if defined(CONFIG_440SP) || defined(CONFIG_440SPE)
  50. #define EBC_NUM_BANKS 3
  51. #endif
  52. /* Bank Configuration Register */
  53. #define EBC_BXCR(n) (n)
  54. #define EBC_BXCR_BANK_SIZE(n) (0x100000 << (((n) & EBC_BXCR_BS_MASK) >> 17))
  55. #define EBC_BXCR_BAS_MASK PPC_REG_VAL(11, 0xFFF)
  56. #define EBC_BXCR_BAS_ENCODE(n) (((static_cast(u32, n)) & EBC_BXCR_BAS_MASK))
  57. #define EBC_BXCR_BS_MASK PPC_REG_VAL(14, 0x7)
  58. #define EBC_BXCR_BS_1MB PPC_REG_VAL(14, 0x0)
  59. #define EBC_BXCR_BS_2MB PPC_REG_VAL(14, 0x1)
  60. #define EBC_BXCR_BS_4MB PPC_REG_VAL(14, 0x2)
  61. #define EBC_BXCR_BS_8MB PPC_REG_VAL(14, 0x3)
  62. #define EBC_BXCR_BS_16MB PPC_REG_VAL(14, 0x4)
  63. #define EBC_BXCR_BS_32MB PPC_REG_VAL(14, 0x5)
  64. #define EBC_BXCR_BS_64MB PPC_REG_VAL(14, 0x6)
  65. #define EBC_BXCR_BS_128MB PPC_REG_VAL(14, 0x7)
  66. #define EBC_BXCR_BU_MASK PPC_REG_VAL(16, 0x3)
  67. #define EBC_BXCR_BU_NONE PPC_REG_VAL(16, 0x0)
  68. #define EBC_BXCR_BU_R PPC_REG_VAL(16, 0x1)
  69. #define EBC_BXCR_BU_W PPC_REG_VAL(16, 0x2)
  70. #define EBC_BXCR_BU_RW PPC_REG_VAL(16, 0x3)
  71. #define EBC_BXCR_BW_MASK PPC_REG_VAL(18, 0x3)
  72. #define EBC_BXCR_BW_8BIT PPC_REG_VAL(18, 0x0)
  73. #define EBC_BXCR_BW_16BIT PPC_REG_VAL(18, 0x1)
  74. #if defined(CONFIG_EBC_PPC4xx_IBM_VER1)
  75. #define EBC_BXCR_BW_32BIT PPC_REG_VAL(18, 0x2)
  76. #else
  77. #define EBC_BXCR_BW_32BIT PPC_REG_VAL(18, 0x3)
  78. #endif
  79. /* Bank Access Parameter Register */
  80. #define EBC_BXAP_BME_ENABLED PPC_REG_VAL(0, 0x1)
  81. #define EBC_BXAP_BME_DISABLED PPC_REG_VAL(0, 0x0)
  82. #define EBC_BXAP_TWT_ENCODE(n) PPC_REG_VAL(8, (static_cast(u32, n)) & 0xFF)
  83. #define EBC_BXAP_FWT_ENCODE(n) PPC_REG_VAL(5, (static_cast(u32, n)) & 0x1F)
  84. #define EBC_BXAP_BWT_ENCODE(n) PPC_REG_VAL(8, (static_cast(u32, n)) & 0x7)
  85. #define EBC_BXAP_BCE_DISABLE PPC_REG_VAL(9, 0x0)
  86. #define EBC_BXAP_BCE_ENABLE PPC_REG_VAL(9, 0x1)
  87. #define EBC_BXAP_BCT_MASK PPC_REG_VAL(11, 0x3)
  88. #define EBC_BXAP_BCT_2TRANS PPC_REG_VAL(11, 0x0)
  89. #define EBC_BXAP_BCT_4TRANS PPC_REG_VAL(11, 0x1)
  90. #define EBC_BXAP_BCT_8TRANS PPC_REG_VAL(11, 0x2)
  91. #define EBC_BXAP_BCT_16TRANS PPC_REG_VAL(11, 0x3)
  92. #define EBC_BXAP_CSN_ENCODE(n) PPC_REG_VAL(13, (static_cast(u32, n)) & 0x3)
  93. #define EBC_BXAP_OEN_ENCODE(n) PPC_REG_VAL(15, (static_cast(u32, n)) & 0x3)
  94. #define EBC_BXAP_WBN_ENCODE(n) PPC_REG_VAL(17, (static_cast(u32, n)) & 0x3)
  95. #define EBC_BXAP_WBF_ENCODE(n) PPC_REG_VAL(19, (static_cast(u32, n)) & 0x3)
  96. #define EBC_BXAP_TH_ENCODE(n) PPC_REG_VAL(22, (static_cast(u32, n)) & 0x7)
  97. #define EBC_BXAP_RE_ENABLED PPC_REG_VAL(23, 0x1)
  98. #define EBC_BXAP_RE_DISABLED PPC_REG_VAL(23, 0x0)
  99. #define EBC_BXAP_SOR_DELAYED PPC_REG_VAL(24, 0x0)
  100. #define EBC_BXAP_SOR_NONDELAYED PPC_REG_VAL(24, 0x1)
  101. #define EBC_BXAP_BEM_WRITEONLY PPC_REG_VAL(25, 0x0)
  102. #define EBC_BXAP_BEM_RW PPC_REG_VAL(25, 0x1)
  103. #define EBC_BXAP_PEN_DISABLED PPC_REG_VAL(26, 0x0)
  104. #define EBC_BXAP_PEN_ENABLED PPC_REG_VAL(26, 0x1)
  105. /* Common fields in EBC0_CFG register */
  106. #define EBC_CFG_PTD_MASK PPC_REG_VAL(1, 0x1)
  107. #define EBC_CFG_PTD_ENABLE PPC_REG_VAL(1, 0x0)
  108. #define EBC_CFG_PTD_DISABLE PPC_REG_VAL(1, 0x1)
  109. #define EBC_CFG_RTC_MASK PPC_REG_VAL(4, 0x7)
  110. #define EBC_CFG_RTC_16PERCLK PPC_REG_VAL(4, 0x0)
  111. #define EBC_CFG_RTC_32PERCLK PPC_REG_VAL(4, 0x1)
  112. #define EBC_CFG_RTC_64PERCLK PPC_REG_VAL(4, 0x2)
  113. #define EBC_CFG_RTC_128PERCLK PPC_REG_VAL(4, 0x3)
  114. #define EBC_CFG_RTC_256PERCLK PPC_REG_VAL(4, 0x4)
  115. #define EBC_CFG_RTC_512PERCLK PPC_REG_VAL(4, 0x5)
  116. #define EBC_CFG_RTC_1024PERCLK PPC_REG_VAL(4, 0x6)
  117. #define EBC_CFG_RTC_2048PERCLK PPC_REG_VAL(4, 0x7)
  118. #define EBC_CFG_PME_MASK PPC_REG_VAL(14, 0x1)
  119. #define EBC_CFG_PME_DISABLE PPC_REG_VAL(14, 0x0)
  120. #define EBC_CFG_PME_ENABLE PPC_REG_VAL(14, 0x1)
  121. #define EBC_CFG_PMT_MASK PPC_REG_VAL(19, 0x1F)
  122. #define EBC_CFG_PMT_ENCODE(n) PPC_REG_VAL(19, (static_cast(u32, n)) & 0x1F)
  123. /* Now the two versions of the other bits */
  124. #if defined(CONFIG_EBC_PPC4xx_IBM_VER1)
  125. #define EBC_CFG_EBTC_MASK PPC_REG_VAL(0, 0x1)
  126. #define EBC_CFG_EBTC_HI PPC_REG_VAL(0, 0x0)
  127. #define EBC_CFG_EBTC_DRIVEN PPC_REG_VAL(0, 0x1)
  128. #define EBC_CFG_EMPH_MASK PPC_REG_VAL(EBC_CFG_EMPH_POS, 0x3)
  129. #define EBC_CFG_EMPH_ENCODE(n) PPC_REG_VAL(EBC_CFG_EMPH_POS, \
  130. (static_cast(u32, n)) & 0x3)
  131. #define EBC_CFG_EMPL_MASK PPC_REG_VAL(EBC_CFG_EMPL_POS, 0x3)
  132. #define EBC_CFG_EMPL_ENCODE(n) PPC_REG_VAL(EBC_CFG_EMPH_POS, \
  133. (static_cast(u32, n)) & 0x3)
  134. #define EBC_CFG_CSTC_MASK PPC_REG_VAL(9, 0x1)
  135. #define EBC_CFG_CSTC_HI PPC_REG_VAL(9, 0x0)
  136. #define EBC_CFG_CSTC_DRIVEN PPC_REG_VAL(9, 0x1)
  137. #define EBC_CFG_BPR_MASK PPC_REG_VAL(11, 0x3)
  138. #define EBC_CFG_BPR_1DW PPC_REG_VAL(11, 0x0)
  139. #define EBC_CFG_BPR_2DW PPC_REG_VAL(11, 0x1)
  140. #define EBC_CFG_BPR_4DW PPC_REG_VAL(11, 0x2)
  141. #define EBC_CFG_EMS_MASK PPC_REG_VAL(13, 0x3)
  142. #define EBC_CFG_EMS_8BIT PPC_REG_VAL(13, 0x0)
  143. #define EBC_CFG_EMS_16BIT PPC_REG_VAL(13, 0x1)
  144. #define EBC_CFG_EMS_32BIT PPC_REG_VAL(13, 0x2)
  145. #else
  146. #define EBC_CFG_LE_MASK PPC_REG_VAL(0, 0x1)
  147. #define EBC_CFG_LE_UNLOCK PPC_REG_VAL(0, 0x0)
  148. #define EBC_CFG_LE_LOCK PPC_REG_VAL(0, 0x1)
  149. #define EBC_CFG_ATC_MASK PPC_REG_VAL(5, 0x1)
  150. #define EBC_CFG_ATC_HI PPC_REG_VAL(5, 0x0)
  151. #define EBC_CFG_ATC_PREVIOUS PPC_REG_VAL(5, 0x1)
  152. #define EBC_CFG_DTC_MASK PPC_REG_VAL(6, 0x1)
  153. #define EBC_CFG_DTC_HI PPC_REG_VAL(6, 0x0)
  154. #define EBC_CFG_DTC_PREVIOUS PPC_REG_VAL(6, 0x1)
  155. #define EBC_CFG_CTC_MASK PPC_REG_VAL(7, 0x1)
  156. #define EBC_CFG_CTC_HI PPC_REG_VAL(7, 0x0)
  157. #define EBC_CFG_CTC_PREVIOUS PPC_REG_VAL(7, 0x1)
  158. #define EBC_CFG_OEO_MASK PPC_REG_VAL(8, 0x1)
  159. #define EBC_CFG_OEO_HI PPC_REG_VAL(8, 0x0)
  160. #define EBC_CFG_OEO_PREVIOUS PPC_REG_VAL(8, 0x1)
  161. #define EBC_CFG_EMC_MASK PPC_REG_VAL(9, 0x1)
  162. #define EBC_CFG_EMC_NONDEFAULT PPC_REG_VAL(9, 0x0)
  163. #define EBC_CFG_EMC_DEFAULT PPC_REG_VAL(9, 0x1)
  164. #define EBC_CFG_PR_MASK PPC_REG_VAL(21, 0x3)
  165. #define EBC_CFG_PR_16 PPC_REG_VAL(21, 0x0)
  166. #define EBC_CFG_PR_32 PPC_REG_VAL(21, 0x1)
  167. #define EBC_CFG_PR_64 PPC_REG_VAL(21, 0x2)
  168. #define EBC_CFG_PR_128 PPC_REG_VAL(21, 0x3)
  169. #endif
  170. #endif /* _PPC4xx_EBC_H_ */