ppc4xx.h 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. /*----------------------------------------------------------------------------+
  2. |
  3. | This source code has been made available to you by IBM on an AS-IS
  4. | basis. Anyone receiving this source is licensed under IBM
  5. | copyrights to use it in any way he or she deems fit, including
  6. | copying it, modifying it, compiling it, and redistributing it either
  7. | with or without modifications. No license under IBM patents or
  8. | patent applications is to be implied by the copyright license.
  9. |
  10. | Any user of this software should understand that IBM cannot provide
  11. | technical support for this software and will not be responsible for
  12. | any consequences resulting from the use of this software.
  13. |
  14. | Any person who transfers this source code or any derivative work
  15. | must include the IBM copyright notice, this paragraph, and the
  16. | preceding two paragraphs in the transferred software.
  17. |
  18. | COPYRIGHT I B M CORPORATION 1999
  19. | LICENSED MATERIAL - PROGRAM PROPERTY OF I B M
  20. +----------------------------------------------------------------------------*/
  21. #ifndef __PPC4XX_H__
  22. #define __PPC4XX_H__
  23. /*
  24. * Configure which SDRAM/DDR/DDR2 controller is equipped
  25. */
  26. #if defined(CONFIG_405GP) || defined(CONFIG_405CR) || defined(CONFIG_405EP) || \
  27. defined(CONFIG_AP1000) || defined(CONFIG_ML2)
  28. #define CONFIG_SDRAM_PPC4xx_IBM_SDRAM /* IBM SDRAM controller */
  29. #endif
  30. #if defined(CONFIG_440GP) || defined(CONFIG_440GX) || \
  31. defined(CONFIG_440EP) || defined(CONFIG_440GR)
  32. #define CONFIG_SDRAM_PPC4xx_IBM_DDR /* IBM DDR controller */
  33. #endif
  34. #if defined(CONFIG_440EPX) || defined(CONFIG_440GRX)
  35. #define CONFIG_SDRAM_PPC4xx_DENALI_DDR2 /* Denali DDR(2) controller */
  36. #endif
  37. #if defined(CONFIG_405EX) || \
  38. defined(CONFIG_440SP) || defined(CONFIG_440SPE) || \
  39. defined(CONFIG_460EX) || defined(CONFIG_460GT) || \
  40. defined(CONFIG_460SX)
  41. #define CONFIG_SDRAM_PPC4xx_IBM_DDR2 /* IBM DDR(2) controller */
  42. #endif
  43. /* PLB4 CrossBar Arbiter Core supported across PPC4xx families */
  44. #if defined(CONFIG_405EX) || \
  45. defined(CONFIG_440EP) || defined(CONFIG_440EPX) || \
  46. defined(CONFIG_440GR) || defined(CONFIG_440GRX) || \
  47. defined(CONFIG_440SP) || defined(CONFIG_440SPE) || \
  48. defined(CONFIG_460EX) || defined(CONFIG_460GT) || \
  49. defined(CONFIG_460SX)
  50. #define PLB_ARBITER_BASE 0x80
  51. #define plb0_revid (PLB_ARBITER_BASE + 0x00)
  52. #define plb0_acr (PLB_ARBITER_BASE + 0x01)
  53. #define plb0_acr_ppm_mask 0xF0000000
  54. #define plb0_acr_ppm_fixed 0x00000000
  55. #define plb0_acr_ppm_fair 0xD0000000
  56. #define plb0_acr_hbu_mask 0x08000000
  57. #define plb0_acr_hbu_disabled 0x00000000
  58. #define plb0_acr_hbu_enabled 0x08000000
  59. #define plb0_acr_rdp_mask 0x06000000
  60. #define plb0_acr_rdp_disabled 0x00000000
  61. #define plb0_acr_rdp_2deep 0x02000000
  62. #define plb0_acr_rdp_3deep 0x04000000
  63. #define plb0_acr_rdp_4deep 0x06000000
  64. #define plb0_acr_wrp_mask 0x01000000
  65. #define plb0_acr_wrp_disabled 0x00000000
  66. #define plb0_acr_wrp_2deep 0x01000000
  67. #define plb0_besrl (PLB_ARBITER_BASE + 0x02)
  68. #define plb0_besrh (PLB_ARBITER_BASE + 0x03)
  69. #define plb0_bearl (PLB_ARBITER_BASE + 0x04)
  70. #define plb0_bearh (PLB_ARBITER_BASE + 0x05)
  71. #define plb0_ccr (PLB_ARBITER_BASE + 0x08)
  72. #define plb1_acr (PLB_ARBITER_BASE + 0x09)
  73. #define plb1_acr_ppm_mask 0xF0000000
  74. #define plb1_acr_ppm_fixed 0x00000000
  75. #define plb1_acr_ppm_fair 0xD0000000
  76. #define plb1_acr_hbu_mask 0x08000000
  77. #define plb1_acr_hbu_disabled 0x00000000
  78. #define plb1_acr_hbu_enabled 0x08000000
  79. #define plb1_acr_rdp_mask 0x06000000
  80. #define plb1_acr_rdp_disabled 0x00000000
  81. #define plb1_acr_rdp_2deep 0x02000000
  82. #define plb1_acr_rdp_3deep 0x04000000
  83. #define plb1_acr_rdp_4deep 0x06000000
  84. #define plb1_acr_wrp_mask 0x01000000
  85. #define plb1_acr_wrp_disabled 0x00000000
  86. #define plb1_acr_wrp_2deep 0x01000000
  87. #define plb1_besrl (PLB_ARBITER_BASE + 0x0A)
  88. #define plb1_besrh (PLB_ARBITER_BASE + 0x0B)
  89. #define plb1_bearl (PLB_ARBITER_BASE + 0x0C)
  90. #define plb1_bearh (PLB_ARBITER_BASE + 0x0D)
  91. #endif /* 440EP/EPX 440GR/GRX 440SP/SPE 460EX/GT/SX 405EX*/
  92. #if defined(CONFIG_440)
  93. /*
  94. * Enable long long (%ll ...) printf format on 440 PPC's since most of
  95. * them support 36bit physical addressing
  96. */
  97. #define CONFIG_SYS_64BIT_VSPRINTF
  98. #define CONFIG_SYS_64BIT_STRTOUL
  99. #include <ppc440.h>
  100. #else
  101. #include <ppc405.h>
  102. #endif
  103. #include <asm/ppc4xx-sdram.h>
  104. #include <asm/ppc4xx-ebc.h>
  105. #if !defined(CONFIG_XILINX_440)
  106. #include <asm/ppc4xx-uic.h>
  107. #endif
  108. /*
  109. * Macro for generating register field mnemonics
  110. */
  111. #define PPC_REG_BITS 32
  112. #define PPC_REG_VAL(bit, value) ((value) << ((PPC_REG_BITS - 1) - (bit)))
  113. /*
  114. * Elide casts when assembling register mnemonics
  115. */
  116. #ifndef __ASSEMBLY__
  117. #define static_cast(type, val) (type)(val)
  118. #else
  119. #define static_cast(type, val) (val)
  120. #endif
  121. /*
  122. * Common stuff for 4xx (405 and 440)
  123. */
  124. #define EXC_OFF_SYS_RESET 0x0100 /* System reset */
  125. #define _START_OFFSET (EXC_OFF_SYS_RESET + 0x2000)
  126. #define RESET_VECTOR 0xfffffffc
  127. #define CACHELINE_MASK (CONFIG_SYS_CACHELINE_SIZE - 1) /* Address mask for cache
  128. line aligned data. */
  129. #define CPR0_DCR_BASE 0x0C
  130. #define cprcfga (CPR0_DCR_BASE+0x0)
  131. #define cprcfgd (CPR0_DCR_BASE+0x1)
  132. #define SDR_DCR_BASE 0x0E
  133. #define sdrcfga (SDR_DCR_BASE+0x0)
  134. #define sdrcfgd (SDR_DCR_BASE+0x1)
  135. #define SDRAM_DCR_BASE 0x10
  136. #define memcfga (SDRAM_DCR_BASE+0x0)
  137. #define memcfgd (SDRAM_DCR_BASE+0x1)
  138. #define EBC_DCR_BASE 0x12
  139. #define ebccfga (EBC_DCR_BASE+0x0)
  140. #define ebccfgd (EBC_DCR_BASE+0x1)
  141. /*
  142. * Macros for indirect DCR access
  143. */
  144. #define mtcpr(reg, d) do { mtdcr(cprcfga,reg);mtdcr(cprcfgd,d); } while (0)
  145. #define mfcpr(reg, d) do { mtdcr(cprcfga,reg);d = mfdcr(cprcfgd); } while (0)
  146. #define mtebc(reg, d) do { mtdcr(ebccfga,reg);mtdcr(ebccfgd,d); } while (0)
  147. #define mfebc(reg, d) do { mtdcr(ebccfga,reg);d = mfdcr(ebccfgd); } while (0)
  148. #define mtsdram(reg, d) do { mtdcr(memcfga,reg);mtdcr(memcfgd,d); } while (0)
  149. #define mfsdram(reg, d) do { mtdcr(memcfga,reg);d = mfdcr(memcfgd); } while (0)
  150. #define mtsdr(reg, d) do { mtdcr(sdrcfga,reg);mtdcr(sdrcfgd,d); } while (0)
  151. #define mfsdr(reg, d) do { mtdcr(sdrcfga,reg);d = mfdcr(sdrcfgd); } while (0)
  152. #ifndef __ASSEMBLY__
  153. typedef struct
  154. {
  155. unsigned long freqDDR;
  156. unsigned long freqEBC;
  157. unsigned long freqOPB;
  158. unsigned long freqPCI;
  159. unsigned long freqPLB;
  160. unsigned long freqTmrClk;
  161. unsigned long freqUART;
  162. unsigned long freqProcessor;
  163. unsigned long freqVCOHz;
  164. unsigned long freqVCOMhz; /* in MHz */
  165. unsigned long pciClkSync; /* PCI clock is synchronous */
  166. unsigned long pciIntArbEn; /* Internal PCI arbiter is enabled */
  167. unsigned long pllExtBusDiv;
  168. unsigned long pllFbkDiv;
  169. unsigned long pllFwdDiv;
  170. unsigned long pllFwdDivA;
  171. unsigned long pllFwdDivB;
  172. unsigned long pllOpbDiv;
  173. unsigned long pllPciDiv;
  174. unsigned long pllPlbDiv;
  175. } PPC4xx_SYS_INFO;
  176. static inline u32 get_mcsr(void)
  177. {
  178. u32 val;
  179. asm volatile("mfspr %0, 0x23c" : "=r" (val) :);
  180. return val;
  181. }
  182. static inline void set_mcsr(u32 val)
  183. {
  184. asm volatile("mtspr 0x23c, %0" : "=r" (val) :);
  185. }
  186. #endif /* __ASSEMBLY__ */
  187. /* for multi-cpu support */
  188. #define NA_OR_UNKNOWN_CPU -1
  189. #endif /* __PPC4XX_H__ */