fsl_pci.h 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. /*
  2. * Copyright 2007,2009-2012 Freescale Semiconductor, Inc.
  3. *
  4. * SPDX-License-Identifier: GPL-2.0+
  5. */
  6. #ifndef __FSL_PCI_H_
  7. #define __FSL_PCI_H_
  8. #include <asm/fsl_law.h>
  9. #include <asm/fsl_serdes.h>
  10. #include <pci.h>
  11. #define PEX_IP_BLK_REV_2_2 0x02080202
  12. #define PEX_IP_BLK_REV_2_3 0x02080203
  13. #define PEX_IP_BLK_REV_3_0 0x02080300
  14. /* Freescale-specific PCI config registers */
  15. #define FSL_PCI_PBFR 0x44
  16. #define FSL_PCIE_CFG_RDY 0x4b0
  17. #define FSL_PCIE_V3_CFG_RDY 0x1
  18. #define FSL_PROG_IF_AGENT 0x1
  19. #define PCI_LTSSM 0x404 /* PCIe Link Training, Status State Machine */
  20. #define PCI_LTSSM_L0 0x16 /* L0 state */
  21. int fsl_setup_hose(struct pci_controller *hose, unsigned long addr);
  22. int fsl_is_pci_agent(struct pci_controller *hose);
  23. void fsl_pci_config_unlock(struct pci_controller *hose);
  24. void ft_fsl_pci_setup(void *blob, const char *compat, unsigned long ctrl_addr);
  25. /*
  26. * Common PCI/PCIE Register structure for mpc85xx and mpc86xx
  27. */
  28. /*
  29. * PCI Translation Registers
  30. */
  31. typedef struct pci_outbound_window {
  32. u32 potar; /* 0x00 - Address */
  33. u32 potear; /* 0x04 - Address Extended */
  34. u32 powbar; /* 0x08 - Window Base Address */
  35. u32 res1;
  36. u32 powar; /* 0x10 - Window Attributes */
  37. #define POWAR_EN 0x80000000
  38. #define POWAR_IO_READ 0x00080000
  39. #define POWAR_MEM_READ 0x00040000
  40. #define POWAR_IO_WRITE 0x00008000
  41. #define POWAR_MEM_WRITE 0x00004000
  42. u32 res2[3];
  43. } pot_t;
  44. typedef struct pci_inbound_window {
  45. u32 pitar; /* 0x00 - Address */
  46. u32 res1;
  47. u32 piwbar; /* 0x08 - Window Base Address */
  48. u32 piwbear; /* 0x0c - Window Base Address Extended */
  49. u32 piwar; /* 0x10 - Window Attributes */
  50. #define PIWAR_EN 0x80000000
  51. #define PIWAR_PF 0x20000000
  52. #define PIWAR_LOCAL 0x00f00000
  53. #define PIWAR_READ_SNOOP 0x00050000
  54. #define PIWAR_WRITE_SNOOP 0x00005000
  55. u32 res2[3];
  56. } pit_t;
  57. /* PCI/PCI Express Registers */
  58. typedef struct ccsr_pci {
  59. u32 cfg_addr; /* 0x000 - PCI Configuration Address Register */
  60. u32 cfg_data; /* 0x004 - PCI Configuration Data Register */
  61. u32 int_ack; /* 0x008 - PCI Interrupt Acknowledge Register */
  62. u32 out_comp_to; /* 0x00C - PCI Outbound Completion Timeout Register */
  63. u32 out_conf_to; /* 0x010 - PCI Configuration Timeout Register */
  64. u32 config; /* 0x014 - PCIE CONFIG Register */
  65. u32 int_status; /* 0x018 - PCIE interrupt status register */
  66. char res2[4];
  67. u32 pme_msg_det; /* 0x020 - PCIE PME & message detect register */
  68. u32 pme_msg_dis; /* 0x024 - PCIE PME & message disable register */
  69. u32 pme_msg_int_en; /* 0x028 - PCIE PME & message interrupt enable register */
  70. u32 pm_command; /* 0x02c - PCIE PM Command register */
  71. char res3[2188]; /* (0x8bc - 0x30 = 2188) */
  72. u32 dbi_ro_wr_en; /* 0x8bc - DBI read only write enable reg */
  73. char res4[824]; /* (0xbf8 - 0x8c0 = 824) */
  74. u32 block_rev1; /* 0xbf8 - PCIE Block Revision register 1 */
  75. u32 block_rev2; /* 0xbfc - PCIE Block Revision register 2 */
  76. pot_t pot[5]; /* 0xc00 - 0xc9f Outbound ATMU's 0, 1, 2, 3, and 4 */
  77. u32 res5[24];
  78. pit_t pmit; /* 0xd00 - 0xd9c Inbound ATMU's MSI */
  79. u32 res6[24];
  80. pit_t pit[4]; /* 0xd80 - 0xdff Inbound ATMU's 3, 2, 1 and 0 */
  81. #define PIT3 0
  82. #define PIT2 1
  83. #define PIT1 2
  84. #if 0
  85. u32 potar0; /* 0xc00 - PCI Outbound Transaction Address Register 0 */
  86. u32 potear0; /* 0xc04 - PCI Outbound Translation Extended Address Register 0 */
  87. char res5[8];
  88. u32 powar0; /* 0xc10 - PCI Outbound Window Attributes Register 0 */
  89. char res6[12];
  90. u32 potar1; /* 0xc20 - PCI Outbound Transaction Address Register 1 */
  91. u32 potear1; /* 0xc24 - PCI Outbound Translation Extended Address Register 1 */
  92. u32 powbar1; /* 0xc28 - PCI Outbound Window Base Address Register 1 */
  93. char res7[4];
  94. u32 powar1; /* 0xc30 - PCI Outbound Window Attributes Register 1 */
  95. char res8[12];
  96. u32 potar2; /* 0xc40 - PCI Outbound Transaction Address Register 2 */
  97. u32 potear2; /* 0xc44 - PCI Outbound Translation Extended Address Register 2 */
  98. u32 powbar2; /* 0xc48 - PCI Outbound Window Base Address Register 2 */
  99. char res9[4];
  100. u32 powar2; /* 0xc50 - PCI Outbound Window Attributes Register 2 */
  101. char res10[12];
  102. u32 potar3; /* 0xc60 - PCI Outbound Transaction Address Register 3 */
  103. u32 potear3; /* 0xc64 - PCI Outbound Translation Extended Address Register 3 */
  104. u32 powbar3; /* 0xc68 - PCI Outbound Window Base Address Register 3 */
  105. char res11[4];
  106. u32 powar3; /* 0xc70 - PCI Outbound Window Attributes Register 3 */
  107. char res12[12];
  108. u32 potar4; /* 0xc80 - PCI Outbound Transaction Address Register 4 */
  109. u32 potear4; /* 0xc84 - PCI Outbound Translation Extended Address Register 4 */
  110. u32 powbar4; /* 0xc88 - PCI Outbound Window Base Address Register 4 */
  111. char res13[4];
  112. u32 powar4; /* 0xc90 - PCI Outbound Window Attributes Register 4 */
  113. char res14[268];
  114. u32 pitar3; /* 0xda0 - PCI Inbound Translation Address Register 3 */
  115. char res15[4];
  116. u32 piwbar3; /* 0xda8 - PCI Inbound Window Base Address Register 3 */
  117. u32 piwbear3; /* 0xdac - PCI Inbound Window Base Extended Address Register 3 */
  118. u32 piwar3; /* 0xdb0 - PCI Inbound Window Attributes Register 3 */
  119. char res16[12];
  120. u32 pitar2; /* 0xdc0 - PCI Inbound Translation Address Register 2 */
  121. char res17[4];
  122. u32 piwbar2; /* 0xdc8 - PCI Inbound Window Base Address Register 2 */
  123. u32 piwbear2; /* 0xdcc - PCI Inbound Window Base Extended Address Register 2 */
  124. u32 piwar2; /* 0xdd0 - PCI Inbound Window Attributes Register 2 */
  125. char res18[12];
  126. u32 pitar1; /* 0xde0 - PCI Inbound Translation Address Register 1 */
  127. char res19[4];
  128. u32 piwbar1; /* 0xde8 - PCI Inbound Window Base Address Register 1 */
  129. char res20[4];
  130. u32 piwar1; /* 0xdf0 - PCI Inbound Window Attributes Register 1 */
  131. char res21[12];
  132. #endif
  133. u32 pedr; /* 0xe00 - PCI Error Detect Register */
  134. u32 pecdr; /* 0xe04 - PCI Error Capture Disable Register */
  135. u32 peer; /* 0xe08 - PCI Error Interrupt Enable Register */
  136. u32 peattrcr; /* 0xe0c - PCI Error Attributes Capture Register */
  137. u32 peaddrcr; /* 0xe10 - PCI Error Address Capture Register */
  138. /* u32 perr_disr * 0xe10 - PCIE Erorr Disable Register */
  139. u32 peextaddrcr; /* 0xe14 - PCI Error Extended Address Capture Register */
  140. u32 pedlcr; /* 0xe18 - PCI Error Data Low Capture Register */
  141. u32 pedhcr; /* 0xe1c - PCI Error Error Data High Capture Register */
  142. u32 gas_timr; /* 0xe20 - PCI Gasket Timer Register */
  143. /* u32 perr_cap_stat; * 0xe20 - PCIE Error Capture Status Register */
  144. char res22[4];
  145. u32 perr_cap0; /* 0xe28 - PCIE Error Capture Register 0 */
  146. u32 perr_cap1; /* 0xe2c - PCIE Error Capture Register 1 */
  147. u32 perr_cap2; /* 0xe30 - PCIE Error Capture Register 2 */
  148. u32 perr_cap3; /* 0xe34 - PCIE Error Capture Register 3 */
  149. char res23[200];
  150. u32 pdb_stat; /* 0xf00 - PCIE Debug Status */
  151. char res24[16];
  152. u32 pex_csr0; /* 0xf14 - PEX Control/Status register 0*/
  153. u32 pex_csr1; /* 0xf18 - PEX Control/Status register 1*/
  154. char res25[228];
  155. } ccsr_fsl_pci_t;
  156. #define PCIE_CONFIG_PC 0x00020000
  157. #define PCIE_CONFIG_OB_CK 0x00002000
  158. #define PCIE_CONFIG_SAC 0x00000010
  159. #define PCIE_CONFIG_SP 0x80000002
  160. #define PCIE_CONFIG_SCC 0x80000001
  161. struct fsl_pci_info {
  162. unsigned long regs;
  163. pci_addr_t mem_bus;
  164. phys_size_t mem_phys;
  165. pci_size_t mem_size;
  166. pci_addr_t io_bus;
  167. phys_size_t io_phys;
  168. pci_size_t io_size;
  169. enum law_trgt_if law;
  170. int pci_num;
  171. };
  172. void fsl_pci_init(struct pci_controller *hose, struct fsl_pci_info *pci_info);
  173. int fsl_pci_init_port(struct fsl_pci_info *pci_info,
  174. struct pci_controller *hose, int busno);
  175. int fsl_pcie_init_ctrl(int busno, u32 devdisr, enum srds_prtcl dev,
  176. struct fsl_pci_info *pci_info);
  177. int fsl_pcie_init_board(int busno);
  178. #define SET_STD_PCI_INFO(x, num) \
  179. { \
  180. x.regs = CONFIG_SYS_PCI##num##_ADDR; \
  181. x.mem_bus = CONFIG_SYS_PCI##num##_MEM_BUS; \
  182. x.mem_phys = CONFIG_SYS_PCI##num##_MEM_PHYS; \
  183. x.mem_size = CONFIG_SYS_PCI##num##_MEM_SIZE; \
  184. x.io_bus = CONFIG_SYS_PCI##num##_IO_BUS; \
  185. x.io_phys = CONFIG_SYS_PCI##num##_IO_PHYS; \
  186. x.io_size = CONFIG_SYS_PCI##num##_IO_SIZE; \
  187. x.law = LAW_TRGT_IF_PCI_##num; \
  188. x.pci_num = num; \
  189. }
  190. #define SET_STD_PCIE_INFO(x, num) \
  191. { \
  192. x.regs = CONFIG_SYS_PCIE##num##_ADDR; \
  193. x.mem_bus = CONFIG_SYS_PCIE##num##_MEM_BUS; \
  194. x.mem_phys = CONFIG_SYS_PCIE##num##_MEM_PHYS; \
  195. x.mem_size = CONFIG_SYS_PCIE##num##_MEM_SIZE; \
  196. x.io_bus = CONFIG_SYS_PCIE##num##_IO_BUS; \
  197. x.io_phys = CONFIG_SYS_PCIE##num##_IO_PHYS; \
  198. x.io_size = CONFIG_SYS_PCIE##num##_IO_SIZE; \
  199. x.law = LAW_TRGT_IF_PCIE_##num; \
  200. x.pci_num = num; \
  201. }
  202. #define __FT_FSL_PCI_SETUP(blob, compat, num) \
  203. ft_fsl_pci_setup(blob, compat, CONFIG_SYS_PCI##num##_ADDR)
  204. #define __FT_FSL_PCIE_SETUP(blob, compat, num) \
  205. ft_fsl_pci_setup(blob, compat, CONFIG_SYS_PCIE##num##_ADDR)
  206. #define FT_FSL_PCI1_SETUP __FT_FSL_PCI_SETUP(blob, FSL_PCI_COMPAT, 1)
  207. #define FT_FSL_PCI2_SETUP __FT_FSL_PCI_SETUP(blob, FSL_PCI_COMPAT, 2)
  208. #define FT_FSL_PCIE1_SETUP __FT_FSL_PCIE_SETUP(blob, FSL_PCIE_COMPAT, 1)
  209. #define FT_FSL_PCIE2_SETUP __FT_FSL_PCIE_SETUP(blob, FSL_PCIE_COMPAT, 2)
  210. #define FT_FSL_PCIE3_SETUP __FT_FSL_PCIE_SETUP(blob, FSL_PCIE_COMPAT, 3)
  211. #define FT_FSL_PCIE4_SETUP __FT_FSL_PCIE_SETUP(blob, FSL_PCIE_COMPAT, 4)
  212. #if !defined(CONFIG_PCI)
  213. #define FT_FSL_PCI_SETUP
  214. #elif defined(CONFIG_FSL_CORENET)
  215. #define FSL_PCIE_COMPAT CONFIG_SYS_FSL_PCIE_COMPAT
  216. #define FT_FSL_PCI_SETUP \
  217. FT_FSL_PCIE1_SETUP; \
  218. FT_FSL_PCIE2_SETUP; \
  219. FT_FSL_PCIE3_SETUP; \
  220. FT_FSL_PCIE4_SETUP;
  221. #define FT_FSL_PCIE_SETUP FT_FSL_PCI_SETUP
  222. #elif defined(CONFIG_MPC85xx)
  223. #define FSL_PCI_COMPAT "fsl,mpc8540-pci"
  224. #ifdef CONFIG_SYS_FSL_PCIE_COMPAT
  225. #define FSL_PCIE_COMPAT CONFIG_SYS_FSL_PCIE_COMPAT
  226. #else
  227. #define FSL_PCIE_COMPAT "fsl,mpc8548-pcie"
  228. #endif
  229. #define FT_FSL_PCI_SETUP \
  230. FT_FSL_PCI1_SETUP; \
  231. FT_FSL_PCI2_SETUP; \
  232. FT_FSL_PCIE1_SETUP; \
  233. FT_FSL_PCIE2_SETUP; \
  234. FT_FSL_PCIE3_SETUP;
  235. #define FT_FSL_PCIE_SETUP \
  236. FT_FSL_PCIE1_SETUP; \
  237. FT_FSL_PCIE2_SETUP; \
  238. FT_FSL_PCIE3_SETUP;
  239. #elif defined(CONFIG_MPC86xx)
  240. #define FSL_PCI_COMPAT "fsl,mpc8610-pci"
  241. #define FSL_PCIE_COMPAT "fsl,mpc8641-pcie"
  242. #define FT_FSL_PCI_SETUP \
  243. FT_FSL_PCI1_SETUP; \
  244. FT_FSL_PCIE1_SETUP; \
  245. FT_FSL_PCIE2_SETUP;
  246. #else
  247. #error FT_FSL_PCI_SETUP not defined
  248. #endif
  249. #endif