pci.c 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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. /*
  13. * PCI Configuration space access support for MPC83xx PCI Bridge
  14. */
  15. #include <asm/mmu.h>
  16. #include <asm/io.h>
  17. #include <common.h>
  18. #include <mpc83xx.h>
  19. #include <pci.h>
  20. #include <i2c.h>
  21. #include <asm/fsl_i2c.h>
  22. #include "../common/pq-mds-pib.h"
  23. DECLARE_GLOBAL_DATA_PTR;
  24. static struct pci_region pci1_regions[] = {
  25. {
  26. bus_start: CONFIG_SYS_PCI1_MEM_BASE,
  27. phys_start: CONFIG_SYS_PCI1_MEM_PHYS,
  28. size: CONFIG_SYS_PCI1_MEM_SIZE,
  29. flags: PCI_REGION_MEM | PCI_REGION_PREFETCH
  30. },
  31. {
  32. bus_start: CONFIG_SYS_PCI1_IO_BASE,
  33. phys_start: CONFIG_SYS_PCI1_IO_PHYS,
  34. size: CONFIG_SYS_PCI1_IO_SIZE,
  35. flags: PCI_REGION_IO
  36. },
  37. {
  38. bus_start: CONFIG_SYS_PCI1_MMIO_BASE,
  39. phys_start: CONFIG_SYS_PCI1_MMIO_PHYS,
  40. size: CONFIG_SYS_PCI1_MMIO_SIZE,
  41. flags: PCI_REGION_MEM
  42. },
  43. };
  44. #ifdef CONFIG_MPC83XX_PCI2
  45. static struct pci_region pci2_regions[] = {
  46. {
  47. bus_start: CONFIG_SYS_PCI2_MEM_BASE,
  48. phys_start: CONFIG_SYS_PCI2_MEM_PHYS,
  49. size: CONFIG_SYS_PCI2_MEM_SIZE,
  50. flags: PCI_REGION_MEM | PCI_REGION_PREFETCH
  51. },
  52. {
  53. bus_start: CONFIG_SYS_PCI2_IO_BASE,
  54. phys_start: CONFIG_SYS_PCI2_IO_PHYS,
  55. size: CONFIG_SYS_PCI2_IO_SIZE,
  56. flags: PCI_REGION_IO
  57. },
  58. {
  59. bus_start: CONFIG_SYS_PCI2_MMIO_BASE,
  60. phys_start: CONFIG_SYS_PCI2_MMIO_PHYS,
  61. size: CONFIG_SYS_PCI2_MMIO_SIZE,
  62. flags: PCI_REGION_MEM
  63. },
  64. };
  65. #endif
  66. DECLARE_GLOBAL_DATA_PTR;
  67. void pci_init_board(void)
  68. #ifdef CONFIG_PCISLAVE
  69. {
  70. volatile immap_t *immr = (volatile immap_t *)CONFIG_SYS_IMMR;
  71. volatile law83xx_t *pci_law = immr->sysconf.pcilaw;
  72. volatile pcictrl83xx_t *pci_ctrl = &immr->pci_ctrl[0];
  73. struct pci_region *reg[] = { pci1_regions };
  74. /* Configure PCI Local Access Windows */
  75. pci_law[0].bar = CONFIG_SYS_PCI1_MEM_PHYS & LAWBAR_BAR;
  76. pci_law[0].ar = LAWAR_EN | LAWAR_SIZE_1G;
  77. pci_law[1].bar = CONFIG_SYS_PCI1_IO_PHYS & LAWBAR_BAR;
  78. pci_law[1].ar = LAWAR_EN | LAWAR_SIZE_4M;
  79. mpc83xx_pci_init(1, reg);
  80. /*
  81. * Configure PCI Inbound Translation Windows
  82. */
  83. pci_ctrl[0].pitar0 = 0x0;
  84. pci_ctrl[0].pibar0 = 0x0;
  85. pci_ctrl[0].piwar0 = PIWAR_EN | PIWAR_RTT_SNOOP |
  86. PIWAR_WTT_SNOOP | PIWAR_IWS_4K;
  87. pci_ctrl[0].pitar1 = 0x0;
  88. pci_ctrl[0].pibar1 = 0x0;
  89. pci_ctrl[0].piebar1 = 0x0;
  90. pci_ctrl[0].piwar1 &= ~PIWAR_EN;
  91. pci_ctrl[0].pitar2 = 0x0;
  92. pci_ctrl[0].pibar2 = 0x0;
  93. pci_ctrl[0].piebar2 = 0x0;
  94. pci_ctrl[0].piwar2 &= ~PIWAR_EN;
  95. /* Unlock the configuration bit */
  96. mpc83xx_pcislave_unlock(0);
  97. printf("PCI: Agent mode enabled\n");
  98. }
  99. #else
  100. {
  101. volatile immap_t *immr = (volatile immap_t *)CONFIG_SYS_IMMR;
  102. volatile clk83xx_t *clk = (volatile clk83xx_t *)&immr->clk;
  103. volatile law83xx_t *pci_law = immr->sysconf.pcilaw;
  104. #ifndef CONFIG_MPC83XX_PCI2
  105. struct pci_region *reg[] = { pci1_regions };
  106. #else
  107. struct pci_region *reg[] = { pci1_regions, pci2_regions };
  108. #endif
  109. /* initialize the PCA9555PW IO expander on the PIB board */
  110. pib_init();
  111. #if defined(PCI_66M)
  112. clk->occr = OCCR_PCICOE0 | OCCR_PCICOE1 | OCCR_PCICOE2;
  113. printf("PCI clock is 66MHz\n");
  114. #elif defined(PCI_33M)
  115. clk->occr = OCCR_PCICOE0 | OCCR_PCICOE1 | OCCR_PCICOE2 |
  116. OCCR_PCICD0 | OCCR_PCICD1 | OCCR_PCICD2 | OCCR_PCICR;
  117. printf("PCI clock is 33MHz\n");
  118. #else
  119. clk->occr = OCCR_PCICOE0 | OCCR_PCICOE1 | OCCR_PCICOE2;
  120. printf("PCI clock is 66MHz\n");
  121. #endif
  122. udelay(2000);
  123. /* Configure PCI Local Access Windows */
  124. pci_law[0].bar = CONFIG_SYS_PCI1_MEM_PHYS & LAWBAR_BAR;
  125. pci_law[0].ar = LAWAR_EN | LAWAR_SIZE_512M;
  126. pci_law[1].bar = CONFIG_SYS_PCI1_IO_PHYS & LAWBAR_BAR;
  127. pci_law[1].ar = LAWAR_EN | LAWAR_SIZE_1M;
  128. udelay(2000);
  129. #ifndef CONFIG_MPC83XX_PCI2
  130. mpc83xx_pci_init(1, reg);
  131. #else
  132. mpc83xx_pci_init(2, reg);
  133. #endif
  134. }
  135. #endif /* CONFIG_PCISLAVE */