pci_cfg.c 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. /*
  2. * Copyright 2009-2010 Freescale Semiconductor, Inc.
  3. *
  4. * See file CREDITS for list of people who contributed to this
  5. * project.
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License as
  9. * published by the Free Software Foundation; either version 2 of
  10. * the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  20. * MA 02111-1307 USA
  21. */
  22. #include <common.h>
  23. #include <asm/fsl_law.h>
  24. #include <pci.h>
  25. struct pci_info {
  26. u32 cfg;
  27. };
  28. /* The cfg field is a bit mask in which each bit represents the value of
  29. * cfg_IO_ports[] signal and the bit is set if the interface would be
  30. * enabled based on the value of cfg_IO_ports[] signal
  31. *
  32. * On MPC86xx/PQ3 based systems:
  33. * we extract cfg_IO_ports from GUTS register PORDEVSR
  34. *
  35. * cfg_IO_ports only exist on systems w/PCIe (we set cfg 0 for systems
  36. * without PCIe)
  37. */
  38. #if defined(CONFIG_MPC8540) || defined(CONFIG_MPC8560)
  39. static struct pci_info pci_config_info[] =
  40. {
  41. [LAW_TRGT_IF_PCI] = {
  42. .cfg = 0,
  43. },
  44. };
  45. #elif defined(CONFIG_MPC8541) || defined(CONFIG_MPC8555)
  46. static struct pci_info pci_config_info[] =
  47. {
  48. [LAW_TRGT_IF_PCI] = {
  49. .cfg = 0,
  50. },
  51. };
  52. #elif defined(CONFIG_MPC8536)
  53. static struct pci_info pci_config_info[] =
  54. {
  55. [LAW_TRGT_IF_PCI] = {
  56. .cfg = 0,
  57. },
  58. [LAW_TRGT_IF_PCIE_1] = {
  59. .cfg = (1 << 2) | (1 << 3) | (1 << 5) | (1 << 7),
  60. },
  61. [LAW_TRGT_IF_PCIE_2] = {
  62. .cfg = (1 << 5) | (1 << 7),
  63. },
  64. [LAW_TRGT_IF_PCIE_3] = {
  65. .cfg = (1 << 7),
  66. },
  67. };
  68. #elif defined(CONFIG_MPC8544)
  69. static struct pci_info pci_config_info[] =
  70. {
  71. [LAW_TRGT_IF_PCI] = {
  72. .cfg = 0,
  73. },
  74. [LAW_TRGT_IF_PCIE_1] = {
  75. .cfg = (1 << 2) | (1 << 3) | (1 << 4) | (1 << 5) |
  76. (1 << 6) | (1 << 7),
  77. },
  78. [LAW_TRGT_IF_PCIE_2] = {
  79. .cfg = (1 << 4) | (1 << 5) | (1 << 6) | (1 << 7),
  80. },
  81. [LAW_TRGT_IF_PCIE_3] = {
  82. .cfg = (1 << 6) | (1 << 7),
  83. },
  84. };
  85. #elif defined(CONFIG_MPC8548)
  86. static struct pci_info pci_config_info[] =
  87. {
  88. [LAW_TRGT_IF_PCI_1] = {
  89. .cfg = 0,
  90. },
  91. [LAW_TRGT_IF_PCI_2] = {
  92. .cfg = 0,
  93. },
  94. /* PCI_2 is always host and we dont use iosel to determine enable/disable */
  95. [LAW_TRGT_IF_PCIE_1] = {
  96. .cfg = (1 << 3) | (1 << 4) | (1 << 7),
  97. },
  98. };
  99. #elif defined(CONFIG_MPC8568)
  100. static struct pci_info pci_config_info[] =
  101. {
  102. [LAW_TRGT_IF_PCI] = {
  103. .cfg = 0,
  104. },
  105. [LAW_TRGT_IF_PCIE_1] = {
  106. .cfg = (1 << 3) | (1 << 4) | (1 << 7),
  107. },
  108. };
  109. #elif defined(CONFIG_MPC8569)
  110. static struct pci_info pci_config_info[] =
  111. {
  112. [LAW_TRGT_IF_PCIE_1] = {
  113. .cfg = (1 << 0) | (1 << 4) | (1 << 5) | (1 << 6) | (1 << 7) |
  114. (1 << 8) | (1 << 0xc) | (1 << 0xf),
  115. },
  116. };
  117. #elif defined(CONFIG_MPC8572)
  118. static struct pci_info pci_config_info[] =
  119. {
  120. [LAW_TRGT_IF_PCIE_1] = {
  121. .cfg = (1 << 2) | (1 << 3) | (1 << 7) |
  122. (1 << 0xb) | (1 << 0xc) | (1 << 0xf),
  123. },
  124. [LAW_TRGT_IF_PCIE_2] = {
  125. .cfg = (1 << 3) | (1 << 7),
  126. },
  127. [LAW_TRGT_IF_PCIE_3] = {
  128. .cfg = (1 << 7),
  129. },
  130. };
  131. #elif defined(CONFIG_MPC8610)
  132. static struct pci_info pci_config_info[] =
  133. {
  134. [LAW_TRGT_IF_PCI_1] = {
  135. .cfg = 0,
  136. },
  137. [LAW_TRGT_IF_PCIE_1] = {
  138. .cfg = (1 << 1) | (1 << 4),
  139. },
  140. [LAW_TRGT_IF_PCIE_2] = {
  141. .cfg = (1 << 0) | (1 << 4),
  142. },
  143. };
  144. #elif defined(CONFIG_MPC8641)
  145. static struct pci_info pci_config_info[] =
  146. {
  147. [LAW_TRGT_IF_PCIE_1] = {
  148. .cfg = (1 << 2) | (1 << 3) | (1 << 5) | (1 << 6) |
  149. (1 << 7) | (1 << 0xe) | (1 << 0xf),
  150. },
  151. };
  152. #elif defined(CONFIG_P1011) || defined(CONFIG_P1020) || \
  153. defined(CONFIG_P1012) || defined(CONFIG_P1021)
  154. static struct pci_info pci_config_info[] =
  155. {
  156. [LAW_TRGT_IF_PCIE_1] = {
  157. .cfg = (1 << 0) | (1 << 6) | (1 << 0xe) | (1 << 0xf),
  158. },
  159. [LAW_TRGT_IF_PCIE_2] = {
  160. .cfg = (1 << 0xe),
  161. },
  162. };
  163. #elif defined(CONFIG_P1013) || defined(CONFIG_P1022)
  164. static struct pci_info pci_config_info[] =
  165. {
  166. [LAW_TRGT_IF_PCIE_1] = {
  167. .cfg = (1 << 6) | (1 << 7) | (1 << 9) | (1 << 0xa) |
  168. (1 << 0xb) | (1 << 0xd) | (1 << 0xe) |
  169. (1 << 0xf) | (1 << 0x15) | (1 << 0x16) |
  170. (1 << 0x17) | (1 << 0x18) | (1 << 0x19) |
  171. (1 << 0x1a) | (1 << 0x1b) | (1 << 0x1c) |
  172. (1 << 0x1d) | (1 << 0x1e) | (1 << 0x1f),
  173. },
  174. [LAW_TRGT_IF_PCIE_2] = {
  175. .cfg = (1 << 0) | (1 << 1) | (1 << 6) | (1 << 7) |
  176. (1 << 9) | (1 << 0xa) | (1 << 0xb) | (1 << 0xd) |
  177. (1 << 0x15) | (1 << 0x16) | (1 << 0x17) |
  178. (1 << 0x18) | (1 << 0x1c),
  179. },
  180. [LAW_TRGT_IF_PCIE_3] = {
  181. .cfg = (1 << 6) | (1 << 7) | (1 << 9) | (1 << 0xd) |
  182. (1 << 0x15) | (1 << 0x16) | (1 << 0x17) | (1 << 0x18) |
  183. (1 << 0x19) | (1 << 0x1a) | (1 << 0x1b),
  184. },
  185. };
  186. #elif defined(CONFIG_P2010) || defined(CONFIG_P2020)
  187. static struct pci_info pci_config_info[] =
  188. {
  189. [LAW_TRGT_IF_PCIE_1] = {
  190. .cfg = (1 << 0) | (1 << 2) | (1 << 4) | (1 << 6) |
  191. (1 << 0xd) | (1 << 0xe) | (1 << 0xf),
  192. },
  193. [LAW_TRGT_IF_PCIE_2] = {
  194. .cfg = (1 << 2) | (1 << 0xe),
  195. },
  196. [LAW_TRGT_IF_PCIE_3] = {
  197. .cfg = (1 << 2) | (1 << 4),
  198. },
  199. };
  200. #elif defined(CONFIG_FSL_CORENET)
  201. #else
  202. #error Need to define pci_config_info for processor
  203. #endif
  204. #ifndef CONFIG_FSL_CORENET
  205. int is_fsl_pci_cfg(enum law_trgt_if trgt, u32 io_sel)
  206. {
  207. return ((1 << io_sel) & pci_config_info[trgt].cfg);
  208. }
  209. #endif