pci.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*
  2. * Copyright (C) Freescale Semiconductor, Inc. 2006.
  3. *
  4. * (C) Copyright 2008
  5. * Andre Schwarz, Matrix Vision GmbH, 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. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, write to the Free Software
  22. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  23. * MA 02111-1307 USA
  24. */
  25. #include <common.h>
  26. #if defined(CONFIG_OF_LIBFDT)
  27. #include <libfdt.h>
  28. #endif
  29. #include <pci.h>
  30. #include <mpc83xx.h>
  31. #include <fpga.h>
  32. #include "mvblm7.h"
  33. #include "fpga.h"
  34. #include "../common/mv_common.h"
  35. DECLARE_GLOBAL_DATA_PTR;
  36. static struct pci_region pci_regions[] = {
  37. {
  38. bus_start: CONFIG_SYS_PCI1_MEM_BASE,
  39. phys_start: CONFIG_SYS_PCI1_MEM_PHYS,
  40. size: CONFIG_SYS_PCI1_MEM_SIZE,
  41. flags: PCI_REGION_MEM | PCI_REGION_PREFETCH
  42. },
  43. {
  44. bus_start: CONFIG_SYS_PCI1_MMIO_BASE,
  45. phys_start: CONFIG_SYS_PCI1_MMIO_PHYS,
  46. size: CONFIG_SYS_PCI1_MMIO_SIZE,
  47. flags: PCI_REGION_MEM
  48. },
  49. {
  50. bus_start: CONFIG_SYS_PCI1_IO_BASE,
  51. phys_start: CONFIG_SYS_PCI1_IO_PHYS,
  52. size: CONFIG_SYS_PCI1_IO_SIZE,
  53. flags: PCI_REGION_IO
  54. }
  55. };
  56. void pci_init_board(void)
  57. {
  58. int i;
  59. volatile immap_t *immr;
  60. volatile pcictrl83xx_t *pci_ctrl;
  61. volatile gpio83xx_t *gpio;
  62. volatile clk83xx_t *clk;
  63. volatile law83xx_t *pci_law;
  64. struct pci_region *reg[] = { pci_regions };
  65. immr = (immap_t *) CONFIG_SYS_IMMR;
  66. clk = (clk83xx_t *) &immr->clk;
  67. pci_ctrl = immr->pci_ctrl;
  68. pci_law = immr->sysconf.pcilaw;
  69. gpio = (volatile gpio83xx_t *)&immr->gpio[0];
  70. gpio->dat = MV_GPIO_DAT;
  71. gpio->odr = MV_GPIO_ODE;
  72. gpio->dir = MV_GPIO_OUT;
  73. printf("SICRH / SICRL : 0x%08x / 0x%08x\n", immr->sysconf.sicrh,
  74. immr->sysconf.sicrl);
  75. mvblm7_init_fpga();
  76. mv_load_fpga();
  77. gpio->dir = MV_GPIO_OUT & ~(FPGA_DIN|FPGA_CCLK);
  78. /* Enable PCI_CLK_OUTPUTs 0 and 1 with 1:1 clocking */
  79. clk->occr = 0xc0000000;
  80. pci_ctrl[0].gcr = 0;
  81. udelay(2000);
  82. pci_ctrl[0].gcr = 1;
  83. for (i = 0; i < 1000; ++i)
  84. udelay(1000);
  85. pci_law[0].bar = CONFIG_SYS_PCI1_MEM_PHYS & LAWBAR_BAR;
  86. pci_law[0].ar = LBLAWAR_EN | LBLAWAR_1GB;
  87. pci_law[1].bar = CONFIG_SYS_PCI1_IO_PHYS & LAWBAR_BAR;
  88. pci_law[1].ar = LBLAWAR_EN | LBLAWAR_1MB;
  89. mpc83xx_pci_init(1, reg);
  90. }