ppc4xx.h 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  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. #if defined(CONFIG_440EP) || defined(CONFIG_440GR) || \
  44. defined(CONFIG_440EPX) || defined(CONFIG_440GRX) || \
  45. defined(CONFIG_405EZ) || defined(CONFIG_405EX) || \
  46. defined(CONFIG_460EX) || defined(CONFIG_460GT)
  47. #define CONFIG_NAND_NDFC
  48. #endif
  49. /* PLB4 CrossBar Arbiter Core supported across PPC4xx families */
  50. #if defined(CONFIG_405EX) || \
  51. defined(CONFIG_440EP) || defined(CONFIG_440EPX) || \
  52. defined(CONFIG_440GR) || defined(CONFIG_440GRX) || \
  53. defined(CONFIG_440SP) || defined(CONFIG_440SPE) || \
  54. defined(CONFIG_460EX) || defined(CONFIG_460GT) || \
  55. defined(CONFIG_460SX)
  56. #define PLB_ARBITER_BASE 0x80
  57. #define plb0_revid (PLB_ARBITER_BASE + 0x00)
  58. #define plb0_acr (PLB_ARBITER_BASE + 0x01)
  59. #define plb0_acr_ppm_mask 0xF0000000
  60. #define plb0_acr_ppm_fixed 0x00000000
  61. #define plb0_acr_ppm_fair 0xD0000000
  62. #define plb0_acr_hbu_mask 0x08000000
  63. #define plb0_acr_hbu_disabled 0x00000000
  64. #define plb0_acr_hbu_enabled 0x08000000
  65. #define plb0_acr_rdp_mask 0x06000000
  66. #define plb0_acr_rdp_disabled 0x00000000
  67. #define plb0_acr_rdp_2deep 0x02000000
  68. #define plb0_acr_rdp_3deep 0x04000000
  69. #define plb0_acr_rdp_4deep 0x06000000
  70. #define plb0_acr_wrp_mask 0x01000000
  71. #define plb0_acr_wrp_disabled 0x00000000
  72. #define plb0_acr_wrp_2deep 0x01000000
  73. #define plb0_besrl (PLB_ARBITER_BASE + 0x02)
  74. #define plb0_besrh (PLB_ARBITER_BASE + 0x03)
  75. #define plb0_bearl (PLB_ARBITER_BASE + 0x04)
  76. #define plb0_bearh (PLB_ARBITER_BASE + 0x05)
  77. #define plb0_ccr (PLB_ARBITER_BASE + 0x08)
  78. #define plb1_acr (PLB_ARBITER_BASE + 0x09)
  79. #define plb1_acr_ppm_mask 0xF0000000
  80. #define plb1_acr_ppm_fixed 0x00000000
  81. #define plb1_acr_ppm_fair 0xD0000000
  82. #define plb1_acr_hbu_mask 0x08000000
  83. #define plb1_acr_hbu_disabled 0x00000000
  84. #define plb1_acr_hbu_enabled 0x08000000
  85. #define plb1_acr_rdp_mask 0x06000000
  86. #define plb1_acr_rdp_disabled 0x00000000
  87. #define plb1_acr_rdp_2deep 0x02000000
  88. #define plb1_acr_rdp_3deep 0x04000000
  89. #define plb1_acr_rdp_4deep 0x06000000
  90. #define plb1_acr_wrp_mask 0x01000000
  91. #define plb1_acr_wrp_disabled 0x00000000
  92. #define plb1_acr_wrp_2deep 0x01000000
  93. #define plb1_besrl (PLB_ARBITER_BASE + 0x0A)
  94. #define plb1_besrh (PLB_ARBITER_BASE + 0x0B)
  95. #define plb1_bearl (PLB_ARBITER_BASE + 0x0C)
  96. #define plb1_bearh (PLB_ARBITER_BASE + 0x0D)
  97. #endif /* 440EP/EPX 440GR/GRX 440SP/SPE 460EX/GT/SX 405EX*/
  98. #if defined(CONFIG_440)
  99. /*
  100. * Enable long long (%ll ...) printf format on 440 PPC's since most of
  101. * them support 36bit physical addressing
  102. */
  103. #define CONFIG_SYS_64BIT_VSPRINTF
  104. #define CONFIG_SYS_64BIT_STRTOUL
  105. #include <ppc440.h>
  106. #else
  107. #include <ppc405.h>
  108. #endif
  109. #include <asm/ppc4xx-sdram.h>
  110. #include <asm/ppc4xx-ebc.h>
  111. #if !defined(CONFIG_XILINX_440)
  112. #include <asm/ppc4xx-uic.h>
  113. #endif
  114. /*
  115. * Macro for generating register field mnemonics
  116. */
  117. #define PPC_REG_BITS 32
  118. #define PPC_REG_VAL(bit, value) ((value) << ((PPC_REG_BITS - 1) - (bit)))
  119. /*
  120. * Elide casts when assembling register mnemonics
  121. */
  122. #ifndef __ASSEMBLY__
  123. #define static_cast(type, val) (type)(val)
  124. #else
  125. #define static_cast(type, val) (val)
  126. #endif
  127. /*
  128. * Common stuff for 4xx (405 and 440)
  129. */
  130. #define EXC_OFF_SYS_RESET 0x0100 /* System reset */
  131. #define _START_OFFSET (EXC_OFF_SYS_RESET + 0x2000)
  132. #define RESET_VECTOR 0xfffffffc
  133. #define CACHELINE_MASK (CONFIG_SYS_CACHELINE_SIZE - 1) /* Address mask for cache
  134. line aligned data. */
  135. #define CPR0_DCR_BASE 0x0C
  136. #define cprcfga (CPR0_DCR_BASE+0x0)
  137. #define cprcfgd (CPR0_DCR_BASE+0x1)
  138. #define SDR_DCR_BASE 0x0E
  139. #define sdrcfga (SDR_DCR_BASE+0x0)
  140. #define sdrcfgd (SDR_DCR_BASE+0x1)
  141. #define SDRAM_DCR_BASE 0x10
  142. #define memcfga (SDRAM_DCR_BASE+0x0)
  143. #define memcfgd (SDRAM_DCR_BASE+0x1)
  144. #define EBC_DCR_BASE 0x12
  145. #define ebccfga (EBC_DCR_BASE+0x0)
  146. #define ebccfgd (EBC_DCR_BASE+0x1)
  147. /*
  148. * Macros for indirect DCR access
  149. */
  150. #define mtcpr(reg, d) do { mtdcr(cprcfga,reg);mtdcr(cprcfgd,d); } while (0)
  151. #define mfcpr(reg, d) do { mtdcr(cprcfga,reg);d = mfdcr(cprcfgd); } while (0)
  152. #define mtebc(reg, d) do { mtdcr(ebccfga,reg);mtdcr(ebccfgd,d); } while (0)
  153. #define mfebc(reg, d) do { mtdcr(ebccfga,reg);d = mfdcr(ebccfgd); } while (0)
  154. #define mtsdram(reg, d) do { mtdcr(memcfga,reg);mtdcr(memcfgd,d); } while (0)
  155. #define mfsdram(reg, d) do { mtdcr(memcfga,reg);d = mfdcr(memcfgd); } while (0)
  156. #define mtsdr(reg, d) do { mtdcr(sdrcfga,reg);mtdcr(sdrcfgd,d); } while (0)
  157. #define mfsdr(reg, d) do { mtdcr(sdrcfga,reg);d = mfdcr(sdrcfgd); } while (0)
  158. #ifndef __ASSEMBLY__
  159. typedef struct
  160. {
  161. unsigned long freqDDR;
  162. unsigned long freqEBC;
  163. unsigned long freqOPB;
  164. unsigned long freqPCI;
  165. unsigned long freqPLB;
  166. unsigned long freqTmrClk;
  167. unsigned long freqUART;
  168. unsigned long freqProcessor;
  169. unsigned long freqVCOHz;
  170. unsigned long freqVCOMhz; /* in MHz */
  171. unsigned long pciClkSync; /* PCI clock is synchronous */
  172. unsigned long pciIntArbEn; /* Internal PCI arbiter is enabled */
  173. unsigned long pllExtBusDiv;
  174. unsigned long pllFbkDiv;
  175. unsigned long pllFwdDiv;
  176. unsigned long pllFwdDivA;
  177. unsigned long pllFwdDivB;
  178. unsigned long pllOpbDiv;
  179. unsigned long pllPciDiv;
  180. unsigned long pllPlbDiv;
  181. } PPC4xx_SYS_INFO;
  182. static inline u32 get_mcsr(void)
  183. {
  184. u32 val;
  185. asm volatile("mfspr %0, 0x23c" : "=r" (val) :);
  186. return val;
  187. }
  188. static inline void set_mcsr(u32 val)
  189. {
  190. asm volatile("mtspr 0x23c, %0" : "=r" (val) :);
  191. }
  192. #endif /* __ASSEMBLY__ */
  193. /* for multi-cpu support */
  194. #define NA_OR_UNKNOWN_CPU -1
  195. #endif /* __PPC4XX_H__ */