pci.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /*
  2. * Copyright (C) Freescale Semiconductor, Inc. 2006. All rights reserved.
  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. DECLARE_GLOBAL_DATA_PTR;
  35. int mvblm7_load_fpga(void)
  36. {
  37. size_t data_size = 0;
  38. void *fpga_data = NULL;
  39. char *datastr = getenv("fpgadata");
  40. char *sizestr = getenv("fpgadatasize");
  41. if (datastr)
  42. fpga_data = (void *)simple_strtoul(datastr, NULL, 16);
  43. if (sizestr)
  44. data_size = (size_t)simple_strtoul(sizestr, NULL, 16);
  45. return fpga_load(0, fpga_data, data_size);
  46. }
  47. static struct pci_region pci_regions[] = {
  48. {
  49. bus_start: CONFIG_SYS_PCI1_MEM_BASE,
  50. phys_start: CONFIG_SYS_PCI1_MEM_PHYS,
  51. size: CONFIG_SYS_PCI1_MEM_SIZE,
  52. flags: PCI_REGION_MEM | PCI_REGION_PREFETCH
  53. },
  54. {
  55. bus_start: CONFIG_SYS_PCI1_MMIO_BASE,
  56. phys_start: CONFIG_SYS_PCI1_MMIO_PHYS,
  57. size: CONFIG_SYS_PCI1_MMIO_SIZE,
  58. flags: PCI_REGION_MEM
  59. },
  60. {
  61. bus_start: CONFIG_SYS_PCI1_IO_BASE,
  62. phys_start: CONFIG_SYS_PCI1_IO_PHYS,
  63. size: CONFIG_SYS_PCI1_IO_SIZE,
  64. flags: PCI_REGION_IO
  65. }
  66. };
  67. void pci_init_board(void)
  68. {
  69. char *s;
  70. int i;
  71. int warmboot;
  72. int load_fpga;
  73. volatile immap_t *immr;
  74. volatile pcictrl83xx_t *pci_ctrl;
  75. volatile gpio83xx_t *gpio;
  76. volatile clk83xx_t *clk;
  77. volatile law83xx_t *pci_law;
  78. struct pci_region *reg[] = { pci_regions };
  79. load_fpga = 1;
  80. immr = (immap_t *) CONFIG_SYS_IMMR;
  81. clk = (clk83xx_t *) &immr->clk;
  82. pci_ctrl = immr->pci_ctrl;
  83. pci_law = immr->sysconf.pcilaw;
  84. gpio = (volatile gpio83xx_t *)&immr->gpio[0];
  85. s = getenv("skip_fpga");
  86. if (s) {
  87. printf("found 'skip_fpga' -> FPGA _not_ loaded !\n");
  88. load_fpga = 0;
  89. }
  90. gpio->dat = MV_GPIO_DAT;
  91. gpio->odr = MV_GPIO_ODE;
  92. if (load_fpga)
  93. gpio->dir = MV_GPIO_OUT;
  94. else
  95. gpio->dir = MV_GPIO_OUT & ~(FPGA_DIN|FPGA_CCLK);
  96. printf("SICRH / SICRL : 0x%08x / 0x%08x\n", immr->sysconf.sicrh,
  97. immr->sysconf.sicrl);
  98. mvblm7_init_fpga();
  99. if (load_fpga)
  100. mvblm7_load_fpga();
  101. /* Enable PCI_CLK_OUTPUTs 0 and 1 with 1:1 clocking */
  102. clk->occr = 0xc0000000;
  103. pci_ctrl[0].gcr = 0;
  104. udelay(2000);
  105. pci_ctrl[0].gcr = 1;
  106. for (i = 0; i < 1000; ++i)
  107. udelay(1000);
  108. pci_law[0].bar = CONFIG_SYS_PCI1_MEM_PHYS & LAWBAR_BAR;
  109. pci_law[0].ar = LBLAWAR_EN | LBLAWAR_1GB;
  110. pci_law[1].bar = CONFIG_SYS_PCI1_IO_PHYS & LAWBAR_BAR;
  111. pci_law[1].ar = LBLAWAR_EN | LBLAWAR_1MB;
  112. warmboot = gd->bd->bi_bootflags & BOOTFLAG_WARM;
  113. mpc83xx_pci_init(1, reg, warmboot);
  114. }