ppc4xx.h 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. /*----------------------------------------------------------------------------+
  2. | This source code is dual-licensed. You may use it under the terms of
  3. | the GNU General Public License version 2, or under the license below.
  4. |
  5. | This source code has been made available to you by IBM on an AS-IS
  6. | basis. Anyone receiving this source is licensed under IBM
  7. | copyrights to use it in any way he or she deems fit, including
  8. | copying it, modifying it, compiling it, and redistributing it either
  9. | with or without modifications. No license under IBM patents or
  10. | patent applications is to be implied by the copyright license.
  11. |
  12. | Any user of this software should understand that IBM cannot provide
  13. | technical support for this software and will not be responsible for
  14. | any consequences resulting from the use of this software.
  15. |
  16. | Any person who transfers this source code or any derivative work
  17. | must include the IBM copyright notice, this paragraph, and the
  18. | preceding two paragraphs in the transferred software.
  19. |
  20. | COPYRIGHT I B M CORPORATION 1999
  21. | LICENSED MATERIAL - PROGRAM PROPERTY OF I B M
  22. +----------------------------------------------------------------------------*/
  23. #ifndef __PPC4XX_H__
  24. #define __PPC4XX_H__
  25. /*
  26. * Include SoC specific headers
  27. */
  28. #if defined(CONFIG_405CR)
  29. #include <asm/ppc405cr.h>
  30. #endif
  31. #if defined(CONFIG_405EP)
  32. #include <asm/ppc405ep.h>
  33. #endif
  34. #if defined(CONFIG_405EX)
  35. #include <asm/ppc405ex.h>
  36. #endif
  37. #if defined(CONFIG_405EZ)
  38. #include <asm/ppc405ez.h>
  39. #endif
  40. #if defined(CONFIG_405GP)
  41. #include <asm/ppc405gp.h>
  42. #endif
  43. #if defined(CONFIG_440EP) || defined(CONFIG_440GR)
  44. #include <asm/ppc440ep_gr.h>
  45. #endif
  46. #if defined(CONFIG_440EPX) || defined(CONFIG_440GRX)
  47. #include <asm/ppc440epx_grx.h>
  48. #endif
  49. #if defined(CONFIG_440GP)
  50. #include <asm/ppc440gp.h>
  51. #endif
  52. #if defined(CONFIG_440GX)
  53. #include <asm/ppc440gx.h>
  54. #endif
  55. #if defined(CONFIG_440SP)
  56. #include <asm/ppc440sp.h>
  57. #endif
  58. #if defined(CONFIG_440SPE)
  59. #include <asm/ppc440spe.h>
  60. #endif
  61. #if defined(CONFIG_460EX) || defined(CONFIG_460GT)
  62. #include <asm/ppc460ex_gt.h>
  63. #endif
  64. #if defined(CONFIG_460SX)
  65. #include <asm/ppc460sx.h>
  66. #endif
  67. /*
  68. * Configure which SDRAM/DDR/DDR2 controller is equipped
  69. */
  70. // test-only: what to do with these???
  71. #if defined(CONFIG_AP1000) || defined(CONFIG_ML2)
  72. #define CONFIG_SDRAM_PPC4xx_IBM_SDRAM /* IBM SDRAM controller */
  73. #endif
  74. /*
  75. * Common registers for all SoC's
  76. */
  77. /* DCR registers */
  78. #define PLB3A0_ACR 0x0077
  79. #define PLB4A0_ACR 0x0081
  80. #define PLB4A1_ACR 0x0089
  81. #define PLB4Ax_ACR_PPM_MASK 0xf0000000
  82. #define PLB4Ax_ACR_PPM_FIXED 0x00000000
  83. #define PLB4Ax_ACR_PPM_FAIR 0xd0000000
  84. #define PLB4Ax_ACR_HBU_MASK 0x08000000
  85. #define PLB4Ax_ACR_HBU_DISABLED 0x00000000
  86. #define PLB4Ax_ACR_HBU_ENABLED 0x08000000
  87. #define PLB4Ax_ACR_RDP_MASK 0x06000000
  88. #define PLB4Ax_ACR_RDP_DISABLED 0x00000000
  89. #define PLB4Ax_ACR_RDP_2DEEP 0x02000000
  90. #define PLB4Ax_ACR_RDP_3DEEP 0x04000000
  91. #define PLB4Ax_ACR_RDP_4DEEP 0x06000000
  92. #define PLB4Ax_ACR_WRP_MASK 0x01000000
  93. #define PLB4Ax_ACR_WRP_DISABLED 0x00000000
  94. #define PLB4Ax_ACR_WRP_2DEEP 0x01000000
  95. /* General Purpose Timer (GPT) Register Offsets */
  96. #define GPT0_TBC 0x00000000
  97. #define GPT0_IM 0x00000018
  98. #define GPT0_ISS 0x0000001C
  99. #define GPT0_ISC 0x00000020
  100. #define GPT0_IE 0x00000024
  101. #define GPT0_COMP0 0x00000080
  102. #define GPT0_COMP1 0x00000084
  103. #define GPT0_COMP2 0x00000088
  104. #define GPT0_COMP3 0x0000008C
  105. #define GPT0_COMP4 0x00000090
  106. #define GPT0_COMP5 0x00000094
  107. #define GPT0_COMP6 0x00000098
  108. #define GPT0_MASK0 0x000000C0
  109. #define GPT0_MASK1 0x000000C4
  110. #define GPT0_MASK2 0x000000C8
  111. #define GPT0_MASK3 0x000000CC
  112. #define GPT0_MASK4 0x000000D0
  113. #define GPT0_MASK5 0x000000D4
  114. #define GPT0_MASK6 0x000000D8
  115. #define GPT0_DCT0 0x00000110
  116. #define GPT0_DCIS 0x0000011C
  117. #if defined(CONFIG_440)
  118. #include <asm/ppc440.h>
  119. #else
  120. #include <asm/ppc405.h>
  121. #endif
  122. #include <asm/ppc4xx-sdram.h>
  123. #include <asm/ppc4xx-ebc.h>
  124. #if !defined(CONFIG_XILINX_440)
  125. #include <asm/ppc4xx-uic.h>
  126. #endif
  127. /*
  128. * Macro for generating register field mnemonics
  129. */
  130. #define PPC_REG_BITS 32
  131. #define PPC_REG_VAL(bit, value) ((value) << ((PPC_REG_BITS - 1) - (bit)))
  132. /*
  133. * Elide casts when assembling register mnemonics
  134. */
  135. #ifndef __ASSEMBLY__
  136. #define static_cast(type, val) (type)(val)
  137. #else
  138. #define static_cast(type, val) (val)
  139. #endif
  140. /*
  141. * Common stuff for 4xx (405 and 440)
  142. */
  143. #define EXC_OFF_SYS_RESET 0x0100 /* System reset */
  144. #define _START_OFFSET (EXC_OFF_SYS_RESET + 0x2000)
  145. #define RESET_VECTOR 0xfffffffc
  146. #define CACHELINE_MASK (CONFIG_SYS_CACHELINE_SIZE - 1) /* Address mask for
  147. cache line aligned data. */
  148. #define CPR0_DCR_BASE 0x0C
  149. #define CPR0_CFGADDR (CPR0_DCR_BASE + 0x0)
  150. #define CPR0_CFGDATA (CPR0_DCR_BASE + 0x1)
  151. #define SDR_DCR_BASE 0x0E
  152. #define SDR0_CFGADDR (SDR_DCR_BASE + 0x0)
  153. #define SDR0_CFGDATA (SDR_DCR_BASE + 0x1)
  154. #define SDRAM_DCR_BASE 0x10
  155. #define SDRAM0_CFGADDR (SDRAM_DCR_BASE + 0x0)
  156. #define SDRAM0_CFGDATA (SDRAM_DCR_BASE + 0x1)
  157. #define EBC_DCR_BASE 0x12
  158. #define EBC0_CFGADDR (EBC_DCR_BASE + 0x0)
  159. #define EBC0_CFGDATA (EBC_DCR_BASE + 0x1)
  160. /*
  161. * Macros for indirect DCR access
  162. */
  163. #define mtcpr(reg, d) \
  164. do { mtdcr(CPR0_CFGADDR, reg); mtdcr(CPR0_CFGDATA, d); } while (0)
  165. #define mfcpr(reg, d) \
  166. do { mtdcr(CPR0_CFGADDR, reg); d = mfdcr(CPR0_CFGDATA); } while (0)
  167. #define mtebc(reg, d) \
  168. do { mtdcr(EBC0_CFGADDR, reg); mtdcr(EBC0_CFGDATA, d); } while (0)
  169. #define mfebc(reg, d) \
  170. do { mtdcr(EBC0_CFGADDR, reg); d = mfdcr(EBC0_CFGDATA); } while (0)
  171. #define mtsdram(reg, d) \
  172. do { mtdcr(SDRAM0_CFGADDR, reg); mtdcr(SDRAM0_CFGDATA, d); } while (0)
  173. #define mfsdram(reg, d) \
  174. do { mtdcr(SDRAM0_CFGADDR, reg); d = mfdcr(SDRAM0_CFGDATA); } while (0)
  175. #define mtsdr(reg, d) \
  176. do { mtdcr(SDR0_CFGADDR, reg); mtdcr(SDR0_CFGDATA, d); } while (0)
  177. #define mfsdr(reg, d) \
  178. do { mtdcr(SDR0_CFGADDR, reg); d = mfdcr(SDR0_CFGDATA); } while (0)
  179. #ifndef __ASSEMBLY__
  180. typedef struct
  181. {
  182. unsigned long freqDDR;
  183. unsigned long freqEBC;
  184. unsigned long freqOPB;
  185. unsigned long freqPCI;
  186. unsigned long freqPLB;
  187. unsigned long freqTmrClk;
  188. unsigned long freqUART;
  189. unsigned long freqProcessor;
  190. unsigned long freqVCOHz;
  191. unsigned long freqVCOMhz; /* in MHz */
  192. unsigned long pciClkSync; /* PCI clock is synchronous */
  193. unsigned long pciIntArbEn; /* Internal PCI arbiter is enabled */
  194. unsigned long pllExtBusDiv;
  195. unsigned long pllFbkDiv;
  196. unsigned long pllFwdDiv;
  197. unsigned long pllFwdDivA;
  198. unsigned long pllFwdDivB;
  199. unsigned long pllOpbDiv;
  200. unsigned long pllPciDiv;
  201. unsigned long pllPlbDiv;
  202. } PPC4xx_SYS_INFO;
  203. static inline u32 get_mcsr(void)
  204. {
  205. u32 val;
  206. asm volatile("mfspr %0, 0x23c" : "=r" (val) :);
  207. return val;
  208. }
  209. static inline void set_mcsr(u32 val)
  210. {
  211. asm volatile("mtspr 0x23c, %0" : "=r" (val) :);
  212. }
  213. int ppc4xx_pci_sync_clock_config(u32 async);
  214. #endif /* __ASSEMBLY__ */
  215. /* for multi-cpu support */
  216. #define NA_OR_UNKNOWN_CPU -1
  217. #endif /* __PPC4XX_H__ */