pci.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /*
  2. * Copyright (C) 2007 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. #include <common.h>
  13. #include <mpc83xx.h>
  14. #include <pci.h>
  15. #include <asm/io.h>
  16. #if defined(CONFIG_PCI)
  17. static struct pci_region pci_regions[] = {
  18. {
  19. bus_start: CONFIG_SYS_PCI_MEM_BASE,
  20. phys_start: CONFIG_SYS_PCI_MEM_PHYS,
  21. size: CONFIG_SYS_PCI_MEM_SIZE,
  22. flags: PCI_REGION_MEM | PCI_REGION_PREFETCH
  23. },
  24. {
  25. bus_start: CONFIG_SYS_PCI_MMIO_BASE,
  26. phys_start: CONFIG_SYS_PCI_MMIO_PHYS,
  27. size: CONFIG_SYS_PCI_MMIO_SIZE,
  28. flags: PCI_REGION_MEM
  29. },
  30. {
  31. bus_start: CONFIG_SYS_PCI_IO_BASE,
  32. phys_start: CONFIG_SYS_PCI_IO_PHYS,
  33. size: CONFIG_SYS_PCI_IO_SIZE,
  34. flags: PCI_REGION_IO
  35. }
  36. };
  37. static struct pci_region pcie_regions_0[] = {
  38. {
  39. .bus_start = CONFIG_SYS_PCIE1_MEM_BASE,
  40. .phys_start = CONFIG_SYS_PCIE1_MEM_PHYS,
  41. .size = CONFIG_SYS_PCIE1_MEM_SIZE,
  42. .flags = PCI_REGION_MEM,
  43. },
  44. {
  45. .bus_start = CONFIG_SYS_PCIE1_IO_BASE,
  46. .phys_start = CONFIG_SYS_PCIE1_IO_PHYS,
  47. .size = CONFIG_SYS_PCIE1_IO_SIZE,
  48. .flags = PCI_REGION_IO,
  49. },
  50. };
  51. static struct pci_region pcie_regions_1[] = {
  52. {
  53. .bus_start = CONFIG_SYS_PCIE2_MEM_BASE,
  54. .phys_start = CONFIG_SYS_PCIE2_MEM_PHYS,
  55. .size = CONFIG_SYS_PCIE2_MEM_SIZE,
  56. .flags = PCI_REGION_MEM,
  57. },
  58. {
  59. .bus_start = CONFIG_SYS_PCIE2_IO_BASE,
  60. .phys_start = CONFIG_SYS_PCIE2_IO_PHYS,
  61. .size = CONFIG_SYS_PCIE2_IO_SIZE,
  62. .flags = PCI_REGION_IO,
  63. },
  64. };
  65. void pci_init_board(void)
  66. {
  67. volatile immap_t *immr = (volatile immap_t *)CONFIG_SYS_IMMR;
  68. volatile sysconf83xx_t *sysconf = &immr->sysconf;
  69. volatile clk83xx_t *clk = (volatile clk83xx_t *)&immr->clk;
  70. volatile law83xx_t *pci_law = immr->sysconf.pcilaw;
  71. volatile law83xx_t *pcie_law = sysconf->pcielaw;
  72. struct pci_region *reg[] = { pci_regions };
  73. struct pci_region *pcie_reg[] = { pcie_regions_0, pcie_regions_1, };
  74. u32 spridr = in_be32(&immr->sysconf.spridr);
  75. /* Enable all 5 PCI_CLK_OUTPUTS */
  76. clk->occr |= 0xf8000000;
  77. udelay(2000);
  78. /* Configure PCI Local Access Windows */
  79. pci_law[0].bar = CONFIG_SYS_PCI_MEM_PHYS & LAWBAR_BAR;
  80. pci_law[0].ar = LBLAWAR_EN | LBLAWAR_512MB;
  81. pci_law[1].bar = CONFIG_SYS_PCI_IO_PHYS & LAWBAR_BAR;
  82. pci_law[1].ar = LBLAWAR_EN | LBLAWAR_1MB;
  83. mpc83xx_pci_init(1, reg, 0);
  84. /* There is no PEX in MPC8379 parts. */
  85. if (PARTID_NO_E(spridr) == SPR_8379)
  86. return;
  87. /* Configure the clock for PCIE controller */
  88. clrsetbits_be32(&clk->sccr, SCCR_PCIEXP1CM | SCCR_PCIEXP2CM,
  89. SCCR_PCIEXP1CM_1 | SCCR_PCIEXP2CM_1);
  90. /* Deassert the resets in the control register */
  91. out_be32(&sysconf->pecr1, 0xE0008000);
  92. out_be32(&sysconf->pecr2, 0xE0008000);
  93. udelay(2000);
  94. /* Configure PCI Express Local Access Windows */
  95. out_be32(&pcie_law[0].bar, CONFIG_SYS_PCIE1_BASE & LAWBAR_BAR);
  96. out_be32(&pcie_law[0].ar, LBLAWAR_EN | LBLAWAR_512MB);
  97. out_be32(&pcie_law[1].bar, CONFIG_SYS_PCIE2_BASE & LAWBAR_BAR);
  98. out_be32(&pcie_law[1].ar, LBLAWAR_EN | LBLAWAR_512MB);
  99. mpc83xx_pcie_init(2, pcie_reg, 0);
  100. }
  101. #endif /* CONFIG_PCI */