ppc4xx.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  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. #if defined(CONFIG_APM821XX)
  68. #include <asm/apm821xx.h>
  69. #endif
  70. /*
  71. * Configure which SDRAM/DDR/DDR2 controller is equipped
  72. */
  73. // test-only: what to do with these???
  74. #if defined(CONFIG_AP1000) || defined(CONFIG_ML2)
  75. #define CONFIG_SDRAM_PPC4xx_IBM_SDRAM /* IBM SDRAM controller */
  76. #endif
  77. /*
  78. * Common registers for all SoC's
  79. */
  80. /* DCR registers */
  81. #define PLB3A0_ACR 0x0077
  82. #define PLB4A0_ACR 0x0081
  83. #define PLB4A1_ACR 0x0089
  84. /* CPR register declarations */
  85. #define PLB4Ax_ACR_PPM_MASK 0xf0000000
  86. #define PLB4Ax_ACR_PPM_FIXED 0x00000000
  87. #define PLB4Ax_ACR_PPM_FAIR 0xd0000000
  88. #define PLB4Ax_ACR_HBU_MASK 0x08000000
  89. #define PLB4Ax_ACR_HBU_DISABLED 0x00000000
  90. #define PLB4Ax_ACR_HBU_ENABLED 0x08000000
  91. #define PLB4Ax_ACR_RDP_MASK 0x06000000
  92. #define PLB4Ax_ACR_RDP_DISABLED 0x00000000
  93. #define PLB4Ax_ACR_RDP_2DEEP 0x02000000
  94. #define PLB4Ax_ACR_RDP_3DEEP 0x04000000
  95. #define PLB4Ax_ACR_RDP_4DEEP 0x06000000
  96. #define PLB4Ax_ACR_WRP_MASK 0x01000000
  97. #define PLB4Ax_ACR_WRP_DISABLED 0x00000000
  98. #define PLB4Ax_ACR_WRP_2DEEP 0x01000000
  99. /*
  100. * External Bus Controller
  101. */
  102. /* Values for EBC0_CFGADDR register - indirect addressing of these regs */
  103. #define PB0CR 0x00 /* periph bank 0 config reg */
  104. #define PB1CR 0x01 /* periph bank 1 config reg */
  105. #define PB2CR 0x02 /* periph bank 2 config reg */
  106. #define PB3CR 0x03 /* periph bank 3 config reg */
  107. #define PB4CR 0x04 /* periph bank 4 config reg */
  108. #define PB5CR 0x05 /* periph bank 5 config reg */
  109. #define PB6CR 0x06 /* periph bank 6 config reg */
  110. #define PB7CR 0x07 /* periph bank 7 config reg */
  111. #define PB0AP 0x10 /* periph bank 0 access parameters */
  112. #define PB1AP 0x11 /* periph bank 1 access parameters */
  113. #define PB2AP 0x12 /* periph bank 2 access parameters */
  114. #define PB3AP 0x13 /* periph bank 3 access parameters */
  115. #define PB4AP 0x14 /* periph bank 4 access parameters */
  116. #define PB5AP 0x15 /* periph bank 5 access parameters */
  117. #define PB6AP 0x16 /* periph bank 6 access parameters */
  118. #define PB7AP 0x17 /* periph bank 7 access parameters */
  119. #define PBEAR 0x20 /* periph bus error addr reg */
  120. #define PBESR0 0x21 /* periph bus error status reg 0 */
  121. #define PBESR1 0x22 /* periph bus error status reg 1 */
  122. #define EBC0_CFG 0x23 /* external bus configuration reg */
  123. /*
  124. * GPIO macro register defines
  125. */
  126. /* todo: merge with gpio.h header */
  127. #define GPIO_BASE GPIO0_BASE
  128. #define GPIO0_OR (GPIO0_BASE + 0x0)
  129. #define GPIO0_TCR (GPIO0_BASE + 0x4)
  130. #define GPIO0_OSRL (GPIO0_BASE + 0x8)
  131. #define GPIO0_OSRH (GPIO0_BASE + 0xC)
  132. #define GPIO0_TSRL (GPIO0_BASE + 0x10)
  133. #define GPIO0_TSRH (GPIO0_BASE + 0x14)
  134. #define GPIO0_ODR (GPIO0_BASE + 0x18)
  135. #define GPIO0_IR (GPIO0_BASE + 0x1C)
  136. #define GPIO0_RR1 (GPIO0_BASE + 0x20)
  137. #define GPIO0_RR2 (GPIO0_BASE + 0x24)
  138. #define GPIO0_RR3 (GPIO0_BASE + 0x28)
  139. #define GPIO0_ISR1L (GPIO0_BASE + 0x30)
  140. #define GPIO0_ISR1H (GPIO0_BASE + 0x34)
  141. #define GPIO0_ISR2L (GPIO0_BASE + 0x38)
  142. #define GPIO0_ISR2H (GPIO0_BASE + 0x3C)
  143. #define GPIO0_ISR3L (GPIO0_BASE + 0x40)
  144. #define GPIO0_ISR3H (GPIO0_BASE + 0x44)
  145. #define GPIO1_OR (GPIO1_BASE + 0x0)
  146. #define GPIO1_TCR (GPIO1_BASE + 0x4)
  147. #define GPIO1_OSRL (GPIO1_BASE + 0x8)
  148. #define GPIO1_OSRH (GPIO1_BASE + 0xC)
  149. #define GPIO1_TSRL (GPIO1_BASE + 0x10)
  150. #define GPIO1_TSRH (GPIO1_BASE + 0x14)
  151. #define GPIO1_ODR (GPIO1_BASE + 0x18)
  152. #define GPIO1_IR (GPIO1_BASE + 0x1C)
  153. #define GPIO1_RR1 (GPIO1_BASE + 0x20)
  154. #define GPIO1_RR2 (GPIO1_BASE + 0x24)
  155. #define GPIO1_RR3 (GPIO1_BASE + 0x28)
  156. #define GPIO1_ISR1L (GPIO1_BASE + 0x30)
  157. #define GPIO1_ISR1H (GPIO1_BASE + 0x34)
  158. #define GPIO1_ISR2L (GPIO1_BASE + 0x38)
  159. #define GPIO1_ISR2H (GPIO1_BASE + 0x3C)
  160. #define GPIO1_ISR3L (GPIO1_BASE + 0x40)
  161. #define GPIO1_ISR3H (GPIO1_BASE + 0x44)
  162. /* General Purpose Timer (GPT) Register Offsets */
  163. #define GPT0_TBC 0x00000000
  164. #define GPT0_IM 0x00000018
  165. #define GPT0_ISS 0x0000001C
  166. #define GPT0_ISC 0x00000020
  167. #define GPT0_IE 0x00000024
  168. #define GPT0_COMP0 0x00000080
  169. #define GPT0_COMP1 0x00000084
  170. #define GPT0_COMP2 0x00000088
  171. #define GPT0_COMP3 0x0000008C
  172. #define GPT0_COMP4 0x00000090
  173. #define GPT0_COMP5 0x00000094
  174. #define GPT0_COMP6 0x00000098
  175. #define GPT0_MASK0 0x000000C0
  176. #define GPT0_MASK1 0x000000C4
  177. #define GPT0_MASK2 0x000000C8
  178. #define GPT0_MASK3 0x000000CC
  179. #define GPT0_MASK4 0x000000D0
  180. #define GPT0_MASK5 0x000000D4
  181. #define GPT0_MASK6 0x000000D8
  182. #define GPT0_DCT0 0x00000110
  183. #define GPT0_DCIS 0x0000011C
  184. #if 0 // test-only
  185. /*
  186. * All PPC4xx share the same NS16550 UART(s). Only base addresses
  187. * may differ. We define here the integration of the common NS16550
  188. * driver for all PPC4xx SoC's. The board config header must specify
  189. * on which UART the console should be located via CONFIG_CONS_INDEX.
  190. */
  191. #if 0 /* test-only */
  192. #define CONFIG_SERIAL_MULTI
  193. #endif
  194. #define CONFIG_SYS_NS16550
  195. #define CONFIG_SYS_NS16550_SERIAL
  196. #define CONFIG_SYS_NS16550_REG_SIZE 1
  197. #define CONFIG_SYS_NS16550_CLK get_serial_clock()
  198. #endif
  199. #if defined(CONFIG_440)
  200. #include <asm/ppc440.h>
  201. #else
  202. #include <asm/ppc405.h>
  203. #endif
  204. #include <asm/ppc4xx-sdram.h>
  205. #include <asm/ppc4xx-ebc.h>
  206. #if !defined(CONFIG_XILINX_440)
  207. #include <asm/ppc4xx-uic.h>
  208. #endif
  209. /*
  210. * Macro for generating register field mnemonics
  211. */
  212. #define PPC_REG_BITS 32
  213. #define PPC_REG_VAL(bit, value) ((value) << ((PPC_REG_BITS - 1) - (bit)))
  214. /*
  215. * Elide casts when assembling register mnemonics
  216. */
  217. #ifndef __ASSEMBLY__
  218. #define static_cast(type, val) (type)(val)
  219. #else
  220. #define static_cast(type, val) (val)
  221. #endif
  222. /*
  223. * Common stuff for 4xx (405 and 440)
  224. */
  225. #define EXC_OFF_SYS_RESET 0x0100 /* System reset */
  226. #define _START_OFFSET (EXC_OFF_SYS_RESET + 0x2000)
  227. #define RESET_VECTOR 0xfffffffc
  228. #define CACHELINE_MASK (CONFIG_SYS_CACHELINE_SIZE - 1) /* Address mask for
  229. cache line aligned data. */
  230. #define CPR0_DCR_BASE 0x0C
  231. #define CPR0_CFGADDR (CPR0_DCR_BASE + 0x0)
  232. #define CPR0_CFGDATA (CPR0_DCR_BASE + 0x1)
  233. #define SDR_DCR_BASE 0x0E
  234. #define SDR0_CFGADDR (SDR_DCR_BASE + 0x0)
  235. #define SDR0_CFGDATA (SDR_DCR_BASE + 0x1)
  236. #define SDRAM_DCR_BASE 0x10
  237. #define SDRAM0_CFGADDR (SDRAM_DCR_BASE + 0x0)
  238. #define SDRAM0_CFGDATA (SDRAM_DCR_BASE + 0x1)
  239. #define EBC_DCR_BASE 0x12
  240. #define EBC0_CFGADDR (EBC_DCR_BASE + 0x0)
  241. #define EBC0_CFGDATA (EBC_DCR_BASE + 0x1)
  242. /*
  243. * Macros for indirect DCR access
  244. */
  245. #define mtcpr(reg, d) \
  246. do { mtdcr(CPR0_CFGADDR, reg); mtdcr(CPR0_CFGDATA, d); } while (0)
  247. #define mfcpr(reg, d) \
  248. do { mtdcr(CPR0_CFGADDR, reg); d = mfdcr(CPR0_CFGDATA); } while (0)
  249. #define mtebc(reg, d) \
  250. do { mtdcr(EBC0_CFGADDR, reg); mtdcr(EBC0_CFGDATA, d); } while (0)
  251. #define mfebc(reg, d) \
  252. do { mtdcr(EBC0_CFGADDR, reg); d = mfdcr(EBC0_CFGDATA); } while (0)
  253. #define mtsdram(reg, d) \
  254. do { mtdcr(SDRAM0_CFGADDR, reg); mtdcr(SDRAM0_CFGDATA, d); } while (0)
  255. #define mfsdram(reg, d) \
  256. do { mtdcr(SDRAM0_CFGADDR, reg); d = mfdcr(SDRAM0_CFGDATA); } while (0)
  257. #define mtsdr(reg, d) \
  258. do { mtdcr(SDR0_CFGADDR, reg); mtdcr(SDR0_CFGDATA, d); } while (0)
  259. #define mfsdr(reg, d) \
  260. do { mtdcr(SDR0_CFGADDR, reg); d = mfdcr(SDR0_CFGDATA); } while (0)
  261. #ifndef __ASSEMBLY__
  262. typedef struct
  263. {
  264. unsigned long freqDDR;
  265. unsigned long freqEBC;
  266. unsigned long freqOPB;
  267. unsigned long freqPCI;
  268. unsigned long freqPLB;
  269. unsigned long freqTmrClk;
  270. unsigned long freqUART;
  271. unsigned long freqProcessor;
  272. unsigned long freqVCOHz;
  273. unsigned long freqVCOMhz; /* in MHz */
  274. unsigned long pciClkSync; /* PCI clock is synchronous */
  275. unsigned long pciIntArbEn; /* Internal PCI arbiter is enabled */
  276. unsigned long pllExtBusDiv;
  277. unsigned long pllFbkDiv;
  278. unsigned long pllFwdDiv;
  279. unsigned long pllFwdDivA;
  280. unsigned long pllFwdDivB;
  281. unsigned long pllOpbDiv;
  282. unsigned long pllPciDiv;
  283. unsigned long pllPlbDiv;
  284. } PPC4xx_SYS_INFO;
  285. static inline u32 get_mcsr(void)
  286. {
  287. u32 val;
  288. asm volatile("mfspr %0, 0x23c" : "=r" (val) :);
  289. return val;
  290. }
  291. static inline void set_mcsr(u32 val)
  292. {
  293. asm volatile("mtspr 0x23c, %0" : "=r" (val) :);
  294. }
  295. int ppc4xx_pci_sync_clock_config(u32 async);
  296. #endif /* __ASSEMBLY__ */
  297. /* for multi-cpu support */
  298. #define NA_OR_UNKNOWN_CPU -1
  299. #endif /* __PPC4XX_H__ */