pci_cfg.c 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  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. };
  56. #elif defined(CONFIG_MPC8544)
  57. static struct pci_info pci_config_info[] =
  58. {
  59. [LAW_TRGT_IF_PCI] = {
  60. .cfg = 0,
  61. },
  62. [LAW_TRGT_IF_PCIE_1] = {
  63. .cfg = (1 << 2) | (1 << 3) | (1 << 4) | (1 << 5) |
  64. (1 << 6) | (1 << 7),
  65. },
  66. [LAW_TRGT_IF_PCIE_2] = {
  67. .cfg = (1 << 4) | (1 << 5) | (1 << 6) | (1 << 7),
  68. },
  69. [LAW_TRGT_IF_PCIE_3] = {
  70. .cfg = (1 << 6) | (1 << 7),
  71. },
  72. };
  73. #elif defined(CONFIG_MPC8548)
  74. static struct pci_info pci_config_info[] =
  75. {
  76. [LAW_TRGT_IF_PCI_1] = {
  77. .cfg = 0,
  78. },
  79. [LAW_TRGT_IF_PCI_2] = {
  80. .cfg = 0,
  81. },
  82. /* PCI_2 is always host and we dont use iosel to determine enable/disable */
  83. [LAW_TRGT_IF_PCIE_1] = {
  84. .cfg = (1 << 3) | (1 << 4) | (1 << 7),
  85. },
  86. };
  87. #elif defined(CONFIG_MPC8568)
  88. static struct pci_info pci_config_info[] =
  89. {
  90. [LAW_TRGT_IF_PCI] = {
  91. .cfg = 0,
  92. },
  93. [LAW_TRGT_IF_PCIE_1] = {
  94. .cfg = (1 << 3) | (1 << 4) | (1 << 7),
  95. },
  96. };
  97. #elif defined(CONFIG_MPC8569)
  98. static struct pci_info pci_config_info[] =
  99. {
  100. [LAW_TRGT_IF_PCIE_1] = {
  101. .cfg = (1 << 0) | (1 << 4) | (1 << 5) | (1 << 6) | (1 << 7) |
  102. (1 << 8) | (1 << 0xc) | (1 << 0xf),
  103. },
  104. };
  105. #elif defined(CONFIG_MPC8572)
  106. static struct pci_info pci_config_info[] =
  107. {
  108. [LAW_TRGT_IF_PCIE_1] = {
  109. .cfg = (1 << 2) | (1 << 3) | (1 << 7) |
  110. (1 << 0xb) | (1 << 0xc) | (1 << 0xf),
  111. },
  112. [LAW_TRGT_IF_PCIE_2] = {
  113. .cfg = (1 << 3) | (1 << 7),
  114. },
  115. [LAW_TRGT_IF_PCIE_3] = {
  116. .cfg = (1 << 7),
  117. },
  118. };
  119. #elif defined(CONFIG_MPC8610)
  120. static struct pci_info pci_config_info[] =
  121. {
  122. [LAW_TRGT_IF_PCI_1] = {
  123. .cfg = 0,
  124. },
  125. [LAW_TRGT_IF_PCIE_1] = {
  126. .cfg = (1 << 1) | (1 << 4),
  127. },
  128. [LAW_TRGT_IF_PCIE_2] = {
  129. .cfg = (1 << 0) | (1 << 4),
  130. },
  131. };
  132. #elif defined(CONFIG_MPC8641)
  133. static struct pci_info pci_config_info[] =
  134. {
  135. [LAW_TRGT_IF_PCIE_1] = {
  136. .cfg = (1 << 2) | (1 << 3) | (1 << 5) | (1 << 6) |
  137. (1 << 7) | (1 << 0xe) | (1 << 0xf),
  138. },
  139. };
  140. #elif defined(CONFIG_P1011) || defined(CONFIG_P1020) || \
  141. defined(CONFIG_P1012) || defined(CONFIG_P1021)
  142. static struct pci_info pci_config_info[] =
  143. {
  144. [LAW_TRGT_IF_PCIE_1] = {
  145. .cfg = (1 << 0) | (1 << 6) | (1 << 0xe) | (1 << 0xf),
  146. },
  147. [LAW_TRGT_IF_PCIE_2] = {
  148. .cfg = (1 << 0xe),
  149. },
  150. };
  151. #elif defined(CONFIG_P1013) || defined(CONFIG_P1022)
  152. static struct pci_info pci_config_info[] =
  153. {
  154. [LAW_TRGT_IF_PCIE_1] = {
  155. .cfg = (1 << 6) | (1 << 7) | (1 << 9) | (1 << 0xa) |
  156. (1 << 0xb) | (1 << 0xd) | (1 << 0xe) |
  157. (1 << 0xf) | (1 << 0x15) | (1 << 0x16) |
  158. (1 << 0x17) | (1 << 0x18) | (1 << 0x19) |
  159. (1 << 0x1a) | (1 << 0x1b) | (1 << 0x1c) |
  160. (1 << 0x1d) | (1 << 0x1e) | (1 << 0x1f),
  161. },
  162. [LAW_TRGT_IF_PCIE_2] = {
  163. .cfg = (1 << 1) | (1 << 6) | (1 << 7) | (1 << 9) |
  164. (1 << 0xd) | (1 << 0x15) | (1 << 0x16) | (1 << 0x17) |
  165. (1 << 0x18) | (1 << 0x19) | (1 << 0x1a) | (1 << 0x1b),
  166. },
  167. [LAW_TRGT_IF_PCIE_3] = {
  168. .cfg = (1 << 0) | (1 << 1) | (1 << 6) | (1 << 7) | (1 << 9) |
  169. (1 << 0xa) | (1 << 0xb) | (1 << 0xd) | (1 << 0x15) |
  170. (1 << 0x16) | (1 << 0x17) | (1 << 0x18) | (1 << 0x1c),
  171. },
  172. };
  173. #elif defined(CONFIG_P2010) || defined(CONFIG_P2020)
  174. static struct pci_info pci_config_info[] =
  175. {
  176. [LAW_TRGT_IF_PCIE_1] = {
  177. .cfg = (1 << 0) | (1 << 2) | (1 << 4) | (1 << 6) |
  178. (1 << 0xd) | (1 << 0xe) | (1 << 0xf),
  179. },
  180. [LAW_TRGT_IF_PCIE_2] = {
  181. .cfg = (1 << 2) | (1 << 0xe),
  182. },
  183. [LAW_TRGT_IF_PCIE_3] = {
  184. .cfg = (1 << 2) | (1 << 4),
  185. },
  186. };
  187. #elif defined(CONFIG_FSL_CORENET)
  188. #else
  189. #error Need to define pci_config_info for processor
  190. #endif
  191. #ifndef CONFIG_FSL_CORENET
  192. int is_fsl_pci_cfg(enum law_trgt_if trgt, u32 io_sel)
  193. {
  194. return ((1 << io_sel) & pci_config_info[trgt].cfg);
  195. }
  196. #endif