pci.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. /*
  2. * Copyright (C) 2006-2009 Freescale Semiconductor, Inc.
  3. *
  4. * Copyright (C) 2011 Matrix Vision GmbH
  5. * Andre Schwarz <andre.schwarz@matrix-vision.de>
  6. *
  7. * See file CREDITS for list of people who contributed to this
  8. * project.
  9. *
  10. * This program is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU General Public License as
  12. * published by the Free Software Foundation; either version 2 of
  13. * the License, or (at your option) any later version.
  14. */
  15. #include <common.h>
  16. #include <mpc83xx.h>
  17. #include <pci.h>
  18. #include <asm/io.h>
  19. #include <asm/fsl_mpc83xx_serdes.h>
  20. #include "mergerbox.h"
  21. #include "fpga.h"
  22. #include "../common/mv_common.h"
  23. static struct pci_region pci_regions[] = {
  24. {
  25. .bus_start = CONFIG_SYS_PCI_MEM_BASE,
  26. .phys_start = CONFIG_SYS_PCI_MEM_PHYS,
  27. .size = CONFIG_SYS_PCI_MEM_SIZE,
  28. .flags = PCI_REGION_MEM | PCI_REGION_PREFETCH
  29. },
  30. {
  31. .bus_start = CONFIG_SYS_PCI_MMIO_BASE,
  32. .phys_start = CONFIG_SYS_PCI_MMIO_PHYS,
  33. .size = CONFIG_SYS_PCI_MMIO_SIZE,
  34. .flags = PCI_REGION_MEM
  35. },
  36. {
  37. .bus_start = CONFIG_SYS_PCI_IO_BASE,
  38. .phys_start = CONFIG_SYS_PCI_IO_PHYS,
  39. .size = CONFIG_SYS_PCI_IO_SIZE,
  40. .flags = PCI_REGION_IO
  41. }
  42. };
  43. static struct pci_region pcie_regions_0[] = {
  44. {
  45. .bus_start = CONFIG_SYS_PCIE1_MEM_BASE,
  46. .phys_start = CONFIG_SYS_PCIE1_MEM_PHYS,
  47. .size = CONFIG_SYS_PCIE1_MEM_SIZE,
  48. .flags = PCI_REGION_MEM,
  49. },
  50. {
  51. .bus_start = CONFIG_SYS_PCIE1_IO_BASE,
  52. .phys_start = CONFIG_SYS_PCIE1_IO_PHYS,
  53. .size = CONFIG_SYS_PCIE1_IO_SIZE,
  54. .flags = PCI_REGION_IO,
  55. },
  56. };
  57. static struct pci_region pcie_regions_1[] = {
  58. {
  59. .bus_start = CONFIG_SYS_PCIE2_MEM_BASE,
  60. .phys_start = CONFIG_SYS_PCIE2_MEM_PHYS,
  61. .size = CONFIG_SYS_PCIE2_MEM_SIZE,
  62. .flags = PCI_REGION_MEM,
  63. },
  64. {
  65. .bus_start = CONFIG_SYS_PCIE2_IO_BASE,
  66. .phys_start = CONFIG_SYS_PCIE2_IO_PHYS,
  67. .size = CONFIG_SYS_PCIE2_IO_SIZE,
  68. .flags = PCI_REGION_IO,
  69. },
  70. };
  71. void pci_init_board(void)
  72. {
  73. volatile immap_t *immr = (immap_t *)CONFIG_SYS_IMMR;
  74. volatile sysconf83xx_t *sysconf = &immr->sysconf;
  75. volatile clk83xx_t *clk = (clk83xx_t *)&immr->clk;
  76. volatile law83xx_t *pci_law = immr->sysconf.pcilaw;
  77. volatile law83xx_t *pcie_law = sysconf->pcielaw;
  78. struct pci_region *reg[] = { pci_regions };
  79. struct pci_region *pcie_reg[] = { pcie_regions_0, pcie_regions_1, };
  80. volatile gpio83xx_t *gpio;
  81. gpio = (gpio83xx_t *)&immr->gpio[0];
  82. gpio->dat = MV_GPIO1_DAT;
  83. gpio->odr = MV_GPIO1_ODE;
  84. gpio->dir = MV_GPIO1_OUT;
  85. gpio = (gpio83xx_t *)&immr->gpio[1];
  86. gpio->dat = MV_GPIO2_DAT;
  87. gpio->odr = MV_GPIO2_ODE;
  88. gpio->dir = MV_GPIO2_OUT;
  89. printf("SICRH / SICRL : 0x%08x / 0x%08x\n", immr->sysconf.sicrh,
  90. immr->sysconf.sicrl);
  91. /* Enable PCI_CLK[0:1] */
  92. clk->occr |= 0xc0000000;
  93. udelay(2000);
  94. mergerbox_init_fpga();
  95. mv_load_fpga();
  96. mergerbox_tft_dim(0);
  97. /* Configure PCI Local Access Windows */
  98. pci_law[0].bar = CONFIG_SYS_PCI_MEM_PHYS & LAWBAR_BAR;
  99. pci_law[0].ar = LBLAWAR_EN | LBLAWAR_512MB;
  100. pci_law[1].bar = CONFIG_SYS_PCI_IO_PHYS & LAWBAR_BAR;
  101. pci_law[1].ar = LBLAWAR_EN | LBLAWAR_1MB;
  102. udelay(2000);
  103. mpc83xx_pci_init(1, reg);
  104. /* Deassert the resets in the control register */
  105. out_be32(&sysconf->pecr1, 0xE0008000);
  106. out_be32(&sysconf->pecr2, 0xE0008000);
  107. udelay(2000);
  108. out_be32(&pcie_law[0].bar, CONFIG_SYS_PCIE1_BASE & LAWBAR_BAR);
  109. out_be32(&pcie_law[0].ar, LBLAWAR_EN | LBLAWAR_512MB);
  110. out_be32(&pcie_law[1].bar, CONFIG_SYS_PCIE2_BASE & LAWBAR_BAR);
  111. out_be32(&pcie_law[1].ar, LBLAWAR_EN | LBLAWAR_512MB);
  112. mpc83xx_pcie_init(2, pcie_reg);
  113. }