pci.c 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. * SPDX-License-Identifier: GPL-2.0+
  8. */
  9. #include <common.h>
  10. #if defined(CONFIG_OF_LIBFDT)
  11. #include <libfdt.h>
  12. #endif
  13. #include <pci.h>
  14. #include <mpc83xx.h>
  15. #include <fpga.h>
  16. #include "mvblm7.h"
  17. #include "fpga.h"
  18. #include "../common/mv_common.h"
  19. DECLARE_GLOBAL_DATA_PTR;
  20. static struct pci_region pci_regions[] = {
  21. {
  22. bus_start: CONFIG_SYS_PCI1_MEM_BASE,
  23. phys_start: CONFIG_SYS_PCI1_MEM_PHYS,
  24. size: CONFIG_SYS_PCI1_MEM_SIZE,
  25. flags: PCI_REGION_MEM | PCI_REGION_PREFETCH
  26. },
  27. {
  28. bus_start: CONFIG_SYS_PCI1_MMIO_BASE,
  29. phys_start: CONFIG_SYS_PCI1_MMIO_PHYS,
  30. size: CONFIG_SYS_PCI1_MMIO_SIZE,
  31. flags: PCI_REGION_MEM
  32. },
  33. {
  34. bus_start: CONFIG_SYS_PCI1_IO_BASE,
  35. phys_start: CONFIG_SYS_PCI1_IO_PHYS,
  36. size: CONFIG_SYS_PCI1_IO_SIZE,
  37. flags: PCI_REGION_IO
  38. }
  39. };
  40. void pci_init_board(void)
  41. {
  42. int i;
  43. volatile immap_t *immr;
  44. volatile pcictrl83xx_t *pci_ctrl;
  45. volatile gpio83xx_t *gpio;
  46. volatile clk83xx_t *clk;
  47. volatile law83xx_t *pci_law;
  48. struct pci_region *reg[] = { pci_regions };
  49. immr = (immap_t *) CONFIG_SYS_IMMR;
  50. clk = (clk83xx_t *) &immr->clk;
  51. pci_ctrl = immr->pci_ctrl;
  52. pci_law = immr->sysconf.pcilaw;
  53. gpio = (volatile gpio83xx_t *)&immr->gpio[0];
  54. gpio->dat = MV_GPIO_DAT;
  55. gpio->odr = MV_GPIO_ODE;
  56. gpio->dir = MV_GPIO_OUT;
  57. printf("SICRH / SICRL : 0x%08x / 0x%08x\n", immr->sysconf.sicrh,
  58. immr->sysconf.sicrl);
  59. mvblm7_init_fpga();
  60. mv_load_fpga();
  61. gpio->dir = MV_GPIO_OUT & ~(FPGA_DIN|FPGA_CCLK);
  62. /* Enable PCI_CLK_OUTPUTs 0 and 1 with 1:1 clocking */
  63. clk->occr = 0xc0000000;
  64. pci_ctrl[0].gcr = 0;
  65. udelay(2000);
  66. pci_ctrl[0].gcr = 1;
  67. for (i = 0; i < 1000; ++i)
  68. udelay(1000);
  69. pci_law[0].bar = CONFIG_SYS_PCI1_MEM_PHYS & LAWBAR_BAR;
  70. pci_law[0].ar = LBLAWAR_EN | LBLAWAR_1GB;
  71. pci_law[1].bar = CONFIG_SYS_PCI1_IO_PHYS & LAWBAR_BAR;
  72. pci_law[1].ar = LBLAWAR_EN | LBLAWAR_1MB;
  73. mpc83xx_pci_init(1, reg);
  74. }