fsl_8xxx_pci.c 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*
  2. * Copyright 2008 Extreme Engineering Solutions, Inc.
  3. * Copyright 2007-2008 Freescale Semiconductor, Inc.
  4. *
  5. * See file CREDITS for list of people who contributed to this
  6. * project.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  21. * MA 02111-1307 USA
  22. */
  23. #include <common.h>
  24. #include <pci.h>
  25. #include <asm/fsl_pci.h>
  26. #include <asm/fsl_serdes.h>
  27. #include <asm/io.h>
  28. #include <linux/compiler.h>
  29. #include <libfdt.h>
  30. #include <fdt_support.h>
  31. #ifdef CONFIG_PCI1
  32. static struct pci_controller pci1_hose;
  33. #endif
  34. void pci_init_board(void)
  35. {
  36. int first_free_busno = 0;
  37. #ifdef CONFIG_PCI1
  38. int pcie_ep;
  39. struct fsl_pci_info pci_info;
  40. volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
  41. u32 devdisr = in_be32(&gur->devdisr);
  42. uint pci_spd_norm = in_be32(&gur->pordevsr) & MPC85xx_PORDEVSR_PCI1_SPD;
  43. uint pci_32 = in_be32(&gur->pordevsr) & MPC85xx_PORDEVSR_PCI1_PCI32;
  44. uint pci_arb = in_be32(&gur->pordevsr) & MPC85xx_PORDEVSR_PCI1_ARB;
  45. uint pcix = in_be32(&gur->pordevsr) & MPC85xx_PORDEVSR_PCI1;
  46. uint freq = CONFIG_SYS_CLK_FREQ / 1000 / 1000;
  47. if (!(devdisr & MPC85xx_DEVDISR_PCI1)) {
  48. SET_STD_PCI_INFO(pci_info, 1);
  49. set_next_law(pci_info.mem_phys,
  50. law_size_bits(pci_info.mem_size), pci_info.law);
  51. set_next_law(pci_info.io_phys,
  52. law_size_bits(pci_info.io_size), pci_info.law);
  53. pcie_ep = fsl_setup_hose(&pci1_hose, pci_info.regs);
  54. printf("PCI1: %d bit %s, %s %d MHz, %s, %s\n",
  55. pci_32 ? 32 : 64,
  56. pcix ? "PCIX" : "PCI",
  57. pci_spd_norm ? ">=" : "<=",
  58. pcix ? freq * 2 : freq,
  59. pcie_ep ? "agent" : "host",
  60. pci_arb ? "arbiter" : "external-arbiter");
  61. first_free_busno = fsl_pci_init_port(&pci_info,
  62. &pci1_hose, first_free_busno);
  63. } else {
  64. printf("PCI1: disabled\n");
  65. }
  66. #elif defined CONFIG_MPC8548
  67. volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
  68. /* PCI1 not present on MPC8572 */
  69. setbits_be32(&gur->devdisr, MPC85xx_DEVDISR_PCI1);
  70. #endif
  71. fsl_pcie_init_board(first_free_busno);
  72. }
  73. #if defined(CONFIG_OF_BOARD_SETUP)
  74. void ft_board_pci_setup(void *blob, bd_t *bd)
  75. {
  76. FT_FSL_PCI_SETUP;
  77. }
  78. #endif /* CONFIG_OF_BOARD_SETUP */