ppc4xx.h 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. /*
  2. * SPDX-License-Identifier: GPL-2.0 IBM-pibs
  3. */
  4. #ifndef __PPC4XX_H__
  5. #define __PPC4XX_H__
  6. /*
  7. * Include SoC specific headers
  8. */
  9. #if defined(CONFIG_405EP)
  10. #include <asm/ppc405ep.h>
  11. #endif
  12. #if defined(CONFIG_405EX)
  13. #include <asm/ppc405ex.h>
  14. #endif
  15. #if defined(CONFIG_405EZ)
  16. #include <asm/ppc405ez.h>
  17. #endif
  18. #if defined(CONFIG_405GP)
  19. #include <asm/ppc405gp.h>
  20. #endif
  21. #if defined(CONFIG_440EP) || defined(CONFIG_440GR)
  22. #include <asm/ppc440ep_gr.h>
  23. #endif
  24. #if defined(CONFIG_440EPX) || defined(CONFIG_440GRX)
  25. #include <asm/ppc440epx_grx.h>
  26. #endif
  27. #if defined(CONFIG_440GP)
  28. #include <asm/ppc440gp.h>
  29. #endif
  30. #if defined(CONFIG_440GX)
  31. #include <asm/ppc440gx.h>
  32. #endif
  33. #if defined(CONFIG_440SP)
  34. #include <asm/ppc440sp.h>
  35. #endif
  36. #if defined(CONFIG_440SPE)
  37. #include <asm/ppc440spe.h>
  38. #endif
  39. #if defined(CONFIG_460EX) || defined(CONFIG_460GT)
  40. #include <asm/ppc460ex_gt.h>
  41. #endif
  42. #if defined(CONFIG_460SX)
  43. #include <asm/ppc460sx.h>
  44. #endif
  45. /*
  46. * Common registers for all SoC's
  47. */
  48. /* DCR registers */
  49. #define PLB3A0_ACR 0x0077
  50. #define PLB4A0_ACR 0x0081
  51. #define PLB4A1_ACR 0x0089
  52. /* CPR register declarations */
  53. #define PLB4Ax_ACR_PPM_MASK 0xf0000000
  54. #define PLB4Ax_ACR_PPM_FIXED 0x00000000
  55. #define PLB4Ax_ACR_PPM_FAIR 0xd0000000
  56. #define PLB4Ax_ACR_HBU_MASK 0x08000000
  57. #define PLB4Ax_ACR_HBU_DISABLED 0x00000000
  58. #define PLB4Ax_ACR_HBU_ENABLED 0x08000000
  59. #define PLB4Ax_ACR_RDP_MASK 0x06000000
  60. #define PLB4Ax_ACR_RDP_DISABLED 0x00000000
  61. #define PLB4Ax_ACR_RDP_2DEEP 0x02000000
  62. #define PLB4Ax_ACR_RDP_3DEEP 0x04000000
  63. #define PLB4Ax_ACR_RDP_4DEEP 0x06000000
  64. #define PLB4Ax_ACR_WRP_MASK 0x01000000
  65. #define PLB4Ax_ACR_WRP_DISABLED 0x00000000
  66. #define PLB4Ax_ACR_WRP_2DEEP 0x01000000
  67. /*
  68. * External Bus Controller
  69. */
  70. /* Values for EBC0_CFGADDR register - indirect addressing of these regs */
  71. #define PB0CR 0x00 /* periph bank 0 config reg */
  72. #define PB1CR 0x01 /* periph bank 1 config reg */
  73. #define PB2CR 0x02 /* periph bank 2 config reg */
  74. #define PB3CR 0x03 /* periph bank 3 config reg */
  75. #define PB4CR 0x04 /* periph bank 4 config reg */
  76. #define PB5CR 0x05 /* periph bank 5 config reg */
  77. #define PB6CR 0x06 /* periph bank 6 config reg */
  78. #define PB7CR 0x07 /* periph bank 7 config reg */
  79. #define PB0AP 0x10 /* periph bank 0 access parameters */
  80. #define PB1AP 0x11 /* periph bank 1 access parameters */
  81. #define PB2AP 0x12 /* periph bank 2 access parameters */
  82. #define PB3AP 0x13 /* periph bank 3 access parameters */
  83. #define PB4AP 0x14 /* periph bank 4 access parameters */
  84. #define PB5AP 0x15 /* periph bank 5 access parameters */
  85. #define PB6AP 0x16 /* periph bank 6 access parameters */
  86. #define PB7AP 0x17 /* periph bank 7 access parameters */
  87. #define PBEAR 0x20 /* periph bus error addr reg */
  88. #define PBESR0 0x21 /* periph bus error status reg 0 */
  89. #define PBESR1 0x22 /* periph bus error status reg 1 */
  90. #define EBC0_CFG 0x23 /* external bus configuration reg */
  91. /*
  92. * GPIO macro register defines
  93. */
  94. /* todo: merge with gpio.h header */
  95. #define GPIO_BASE GPIO0_BASE
  96. #define GPIO0_OR (GPIO0_BASE + 0x0)
  97. #define GPIO0_TCR (GPIO0_BASE + 0x4)
  98. #define GPIO0_OSRL (GPIO0_BASE + 0x8)
  99. #define GPIO0_OSRH (GPIO0_BASE + 0xC)
  100. #define GPIO0_TSRL (GPIO0_BASE + 0x10)
  101. #define GPIO0_TSRH (GPIO0_BASE + 0x14)
  102. #define GPIO0_ODR (GPIO0_BASE + 0x18)
  103. #define GPIO0_IR (GPIO0_BASE + 0x1C)
  104. #define GPIO0_RR1 (GPIO0_BASE + 0x20)
  105. #define GPIO0_RR2 (GPIO0_BASE + 0x24)
  106. #define GPIO0_RR3 (GPIO0_BASE + 0x28)
  107. #define GPIO0_ISR1L (GPIO0_BASE + 0x30)
  108. #define GPIO0_ISR1H (GPIO0_BASE + 0x34)
  109. #define GPIO0_ISR2L (GPIO0_BASE + 0x38)
  110. #define GPIO0_ISR2H (GPIO0_BASE + 0x3C)
  111. #define GPIO0_ISR3L (GPIO0_BASE + 0x40)
  112. #define GPIO0_ISR3H (GPIO0_BASE + 0x44)
  113. #define GPIO1_OR (GPIO1_BASE + 0x0)
  114. #define GPIO1_TCR (GPIO1_BASE + 0x4)
  115. #define GPIO1_OSRL (GPIO1_BASE + 0x8)
  116. #define GPIO1_OSRH (GPIO1_BASE + 0xC)
  117. #define GPIO1_TSRL (GPIO1_BASE + 0x10)
  118. #define GPIO1_TSRH (GPIO1_BASE + 0x14)
  119. #define GPIO1_ODR (GPIO1_BASE + 0x18)
  120. #define GPIO1_IR (GPIO1_BASE + 0x1C)
  121. #define GPIO1_RR1 (GPIO1_BASE + 0x20)
  122. #define GPIO1_RR2 (GPIO1_BASE + 0x24)
  123. #define GPIO1_RR3 (GPIO1_BASE + 0x28)
  124. #define GPIO1_ISR1L (GPIO1_BASE + 0x30)
  125. #define GPIO1_ISR1H (GPIO1_BASE + 0x34)
  126. #define GPIO1_ISR2L (GPIO1_BASE + 0x38)
  127. #define GPIO1_ISR2H (GPIO1_BASE + 0x3C)
  128. #define GPIO1_ISR3L (GPIO1_BASE + 0x40)
  129. #define GPIO1_ISR3H (GPIO1_BASE + 0x44)
  130. /* General Purpose Timer (GPT) Register Offsets */
  131. #define GPT0_TBC 0x00000000
  132. #define GPT0_IM 0x00000018
  133. #define GPT0_ISS 0x0000001C
  134. #define GPT0_ISC 0x00000020
  135. #define GPT0_IE 0x00000024
  136. #define GPT0_COMP0 0x00000080
  137. #define GPT0_COMP1 0x00000084
  138. #define GPT0_COMP2 0x00000088
  139. #define GPT0_COMP3 0x0000008C
  140. #define GPT0_COMP4 0x00000090
  141. #define GPT0_COMP5 0x00000094
  142. #define GPT0_COMP6 0x00000098
  143. #define GPT0_MASK0 0x000000C0
  144. #define GPT0_MASK1 0x000000C4
  145. #define GPT0_MASK2 0x000000C8
  146. #define GPT0_MASK3 0x000000CC
  147. #define GPT0_MASK4 0x000000D0
  148. #define GPT0_MASK5 0x000000D4
  149. #define GPT0_MASK6 0x000000D8
  150. #define GPT0_DCT0 0x00000110
  151. #define GPT0_DCIS 0x0000011C
  152. #if defined(CONFIG_440)
  153. #include <asm/ppc440.h>
  154. #else
  155. #include <asm/ppc405.h>
  156. #endif
  157. #include <asm/ppc4xx-sdram.h>
  158. #include <asm/ppc4xx-ebc.h>
  159. #if !defined(CONFIG_XILINX_440)
  160. #include <asm/ppc4xx-uic.h>
  161. #endif
  162. /*
  163. * Macro for generating register field mnemonics
  164. */
  165. #define PPC_REG_BITS 32
  166. #define PPC_REG_VAL(bit, value) ((value) << ((PPC_REG_BITS - 1) - (bit)))
  167. /*
  168. * Elide casts when assembling register mnemonics
  169. */
  170. #ifndef __ASSEMBLY__
  171. #define static_cast(type, val) (type)(val)
  172. #else
  173. #define static_cast(type, val) (val)
  174. #endif
  175. /*
  176. * Common stuff for 4xx (405 and 440)
  177. */
  178. #define EXC_OFF_SYS_RESET 0x0100 /* System reset */
  179. #define _START_OFFSET (EXC_OFF_SYS_RESET + 0x2000)
  180. #define RESET_VECTOR 0xfffffffc
  181. #define CACHELINE_MASK (CONFIG_SYS_CACHELINE_SIZE - 1) /* Address mask for
  182. cache line aligned data. */
  183. #define CPR0_DCR_BASE 0x0C
  184. #define CPR0_CFGADDR (CPR0_DCR_BASE + 0x0)
  185. #define CPR0_CFGDATA (CPR0_DCR_BASE + 0x1)
  186. #define SDR_DCR_BASE 0x0E
  187. #define SDR0_CFGADDR (SDR_DCR_BASE + 0x0)
  188. #define SDR0_CFGDATA (SDR_DCR_BASE + 0x1)
  189. #define SDRAM_DCR_BASE 0x10
  190. #define SDRAM0_CFGADDR (SDRAM_DCR_BASE + 0x0)
  191. #define SDRAM0_CFGDATA (SDRAM_DCR_BASE + 0x1)
  192. #define EBC_DCR_BASE 0x12
  193. #define EBC0_CFGADDR (EBC_DCR_BASE + 0x0)
  194. #define EBC0_CFGDATA (EBC_DCR_BASE + 0x1)
  195. /*
  196. * Macros for indirect DCR access
  197. */
  198. #define mtcpr(reg, d) \
  199. do { mtdcr(CPR0_CFGADDR, reg); mtdcr(CPR0_CFGDATA, d); } while (0)
  200. #define mfcpr(reg, d) \
  201. do { mtdcr(CPR0_CFGADDR, reg); d = mfdcr(CPR0_CFGDATA); } while (0)
  202. #define mtebc(reg, d) \
  203. do { mtdcr(EBC0_CFGADDR, reg); mtdcr(EBC0_CFGDATA, d); } while (0)
  204. #define mfebc(reg, d) \
  205. do { mtdcr(EBC0_CFGADDR, reg); d = mfdcr(EBC0_CFGDATA); } while (0)
  206. #define mtsdram(reg, d) \
  207. do { mtdcr(SDRAM0_CFGADDR, reg); mtdcr(SDRAM0_CFGDATA, d); } while (0)
  208. #define mfsdram(reg, d) \
  209. do { mtdcr(SDRAM0_CFGADDR, reg); d = mfdcr(SDRAM0_CFGDATA); } while (0)
  210. #define mtsdr(reg, d) \
  211. do { mtdcr(SDR0_CFGADDR, reg); mtdcr(SDR0_CFGDATA, d); } while (0)
  212. #define mfsdr(reg, d) \
  213. do { mtdcr(SDR0_CFGADDR, reg); d = mfdcr(SDR0_CFGDATA); } while (0)
  214. #ifndef __ASSEMBLY__
  215. typedef struct
  216. {
  217. unsigned long freqDDR;
  218. unsigned long freqEBC;
  219. unsigned long freqOPB;
  220. unsigned long freqPCI;
  221. unsigned long freqPLB;
  222. unsigned long freqTmrClk;
  223. unsigned long freqUART;
  224. unsigned long freqProcessor;
  225. unsigned long freqVCOHz;
  226. unsigned long freqVCOMhz; /* in MHz */
  227. unsigned long pciClkSync; /* PCI clock is synchronous */
  228. unsigned long pciIntArbEn; /* Internal PCI arbiter is enabled */
  229. unsigned long pllExtBusDiv;
  230. unsigned long pllFbkDiv;
  231. unsigned long pllFwdDiv;
  232. unsigned long pllFwdDivA;
  233. unsigned long pllFwdDivB;
  234. unsigned long pllOpbDiv;
  235. unsigned long pllPciDiv;
  236. unsigned long pllPlbDiv;
  237. } PPC4xx_SYS_INFO;
  238. static inline u32 get_mcsr(void)
  239. {
  240. u32 val;
  241. asm volatile("mfspr %0, 0x23c" : "=r" (val) :);
  242. return val;
  243. }
  244. static inline void set_mcsr(u32 val)
  245. {
  246. asm volatile("mtspr 0x23c, %0" : "=r" (val) :);
  247. }
  248. int ppc4xx_pci_sync_clock_config(u32 async);
  249. #endif /* __ASSEMBLY__ */
  250. /* for multi-cpu support */
  251. #define NA_OR_UNKNOWN_CPU -1
  252. #endif /* __PPC4XX_H__ */