pci.c 3.1 KB

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