pci.c 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. /*
  2. * Copyright 2007-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 <command.h>
  24. #include <pci.h>
  25. #include <asm/fsl_pci.h>
  26. #include <libfdt.h>
  27. #include <fdt_support.h>
  28. #include <asm/fsl_serdes.h>
  29. #ifdef CONFIG_PCIE1
  30. static struct pci_controller pcie1_hose;
  31. #endif
  32. #ifdef CONFIG_PCIE2
  33. static struct pci_controller pcie2_hose;
  34. #endif
  35. #ifdef CONFIG_PCIE3
  36. static struct pci_controller pcie3_hose;
  37. #endif
  38. #ifdef CONFIG_PCIE4
  39. static struct pci_controller pcie4_hose;
  40. #endif
  41. void pci_init_board(void)
  42. {
  43. volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
  44. struct fsl_pci_info pci_info[4];
  45. u32 devdisr;
  46. int first_free_busno = 0;
  47. int num = 0;
  48. int pcie_ep, pcie_configured;
  49. devdisr = in_be32(&gur->devdisr);
  50. debug (" pci_init_board: devdisr=%x\n", devdisr);
  51. #ifdef CONFIG_PCIE1
  52. pcie_configured = is_serdes_configured(PCIE1);
  53. if (pcie_configured && !(devdisr & FSL_CORENET_DEVDISR_PCIE1)) {
  54. set_next_law(CONFIG_SYS_PCIE1_MEM_PHYS, LAW_SIZE_512M,
  55. LAW_TRGT_IF_PCIE_1);
  56. set_next_law(CONFIG_SYS_PCIE1_IO_PHYS, LAW_SIZE_64K,
  57. LAW_TRGT_IF_PCIE_1);
  58. SET_STD_PCIE_INFO(pci_info[num], 1);
  59. pcie_ep = fsl_setup_hose(&pcie1_hose, pci_info[num].regs);
  60. printf(" PCIE1 connected to Slot 1 as %s (base addr %lx)\n",
  61. pcie_ep ? "End Point" : "Root Complex",
  62. pci_info[num].regs);
  63. first_free_busno = fsl_pci_init_port(&pci_info[num++],
  64. &pcie1_hose, first_free_busno);
  65. } else {
  66. printf (" PCIE1: disabled\n");
  67. }
  68. #else
  69. setbits_be32(&gur->devdisr, FSL_CORENET_DEVDISR_PCIE1); /* disable */
  70. #endif
  71. #ifdef CONFIG_PCIE2
  72. pcie_configured = is_serdes_configured(PCIE2);
  73. if (pcie_configured && !(devdisr & FSL_CORENET_DEVDISR_PCIE2)) {
  74. set_next_law(CONFIG_SYS_PCIE2_MEM_PHYS, LAW_SIZE_512M,
  75. LAW_TRGT_IF_PCIE_2);
  76. set_next_law(CONFIG_SYS_PCIE2_IO_PHYS, LAW_SIZE_64K,
  77. LAW_TRGT_IF_PCIE_2);
  78. SET_STD_PCIE_INFO(pci_info[num], 2);
  79. pcie_ep = fsl_setup_hose(&pcie2_hose, pci_info[num].regs);
  80. printf(" PCIE2 connected to Slot 3 as %s (base addr %lx)\n",
  81. pcie_ep ? "End Point" : "Root Complex",
  82. pci_info[num].regs);
  83. first_free_busno = fsl_pci_init_port(&pci_info[num++],
  84. &pcie2_hose, first_free_busno);
  85. } else {
  86. printf (" PCIE2: disabled\n");
  87. }
  88. #else
  89. setbits_be32(&gur->devdisr, FSL_CORENET_DEVDISR_PCIE2); /* disable */
  90. #endif
  91. #ifdef CONFIG_PCIE3
  92. pcie_configured = is_serdes_configured(PCIE3);
  93. if (pcie_configured && !(devdisr & FSL_CORENET_DEVDISR_PCIE3)) {
  94. set_next_law(CONFIG_SYS_PCIE3_MEM_PHYS, LAW_SIZE_512M,
  95. LAW_TRGT_IF_PCIE_3);
  96. set_next_law(CONFIG_SYS_PCIE3_IO_PHYS, LAW_SIZE_64K,
  97. LAW_TRGT_IF_PCIE_3);
  98. SET_STD_PCIE_INFO(pci_info[num], 3);
  99. pcie_ep = fsl_setup_hose(&pcie3_hose, pci_info[num].regs);
  100. printf(" PCIE3 connected to Slot 2 as %s (base addr %lx)\n",
  101. pcie_ep ? "End Point" : "Root Complex",
  102. pci_info[num].regs);
  103. first_free_busno = fsl_pci_init_port(&pci_info[num++],
  104. &pcie3_hose, first_free_busno);
  105. } else {
  106. printf (" PCIE3: disabled\n");
  107. }
  108. #else
  109. setbits_be32(&gur->devdisr, FSL_CORENET_DEVDISR_PCIE3); /* disable */
  110. #endif
  111. #ifdef CONFIG_PCIE4
  112. pcie_configured = is_serdes_configured(PCIE4);
  113. if (pcie_configured && !(devdisr & FSL_CORENET_DEVDISR_PCIE4)) {
  114. set_next_law(CONFIG_SYS_PCIE4_MEM_PHYS, LAW_SIZE_512M,
  115. LAW_TRGT_IF_PCIE_4);
  116. set_next_law(CONFIG_SYS_PCIE4_IO_PHYS, LAW_SIZE_64K,
  117. LAW_TRGT_IF_PCIE_4);
  118. SET_STD_PCIE_INFO(pci_info[num], 4);
  119. pcie_ep = fsl_setup_hose(&pcie4_hose, pci_info[num].regs);
  120. printf(" PCIE4 connected to as %s (base addr %lx)\n",
  121. pcie_ep ? "End Point" : "Root Complex",
  122. pci_info[num].regs);
  123. first_free_busno = fsl_pci_init_port(&pci_info[num++],
  124. &pcie4_hose, first_free_busno);
  125. } else {
  126. printf (" PCIE4: disabled\n");
  127. }
  128. #else
  129. setbits_be32(&gur->devdisr, FSL_CORENET_DEVDISR_PCIE4); /* disable */
  130. #endif
  131. }
  132. void pci_of_setup(void *blob, bd_t *bd)
  133. {
  134. FT_FSL_PCI_SETUP;
  135. }