pci.c 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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. void pci_init_board(void)
  67. #ifdef CONFIG_PCISLAVE
  68. {
  69. volatile immap_t *immr = (volatile immap_t *)CONFIG_SYS_IMMR;
  70. volatile law83xx_t *pci_law = immr->sysconf.pcilaw;
  71. volatile pcictrl83xx_t *pci_ctrl = &immr->pci_ctrl[0];
  72. struct pci_region *reg[] = { pci1_regions };
  73. /* Configure PCI Local Access Windows */
  74. pci_law[0].bar = CONFIG_SYS_PCI1_MEM_PHYS & LAWBAR_BAR;
  75. pci_law[0].ar = LAWAR_EN | LAWAR_SIZE_512M;
  76. pci_law[1].bar = CONFIG_SYS_PCI1_IO_PHYS & LAWBAR_BAR;
  77. pci_law[1].ar = LAWAR_EN | LAWAR_SIZE_1M;
  78. mpc83xx_pci_init(1, reg);
  79. /*
  80. * Configure PCI Inbound Translation Windows
  81. */
  82. pci_ctrl[0].pitar0 = 0x0;
  83. pci_ctrl[0].pibar0 = 0x0;
  84. pci_ctrl[0].piwar0 = PIWAR_EN | PIWAR_RTT_SNOOP |
  85. PIWAR_WTT_SNOOP | PIWAR_IWS_4K;
  86. pci_ctrl[0].pitar1 = 0x0;
  87. pci_ctrl[0].pibar1 = 0x0;
  88. pci_ctrl[0].piebar1 = 0x0;
  89. pci_ctrl[0].piwar1 &= ~PIWAR_EN;
  90. pci_ctrl[0].pitar2 = 0x0;
  91. pci_ctrl[0].pibar2 = 0x0;
  92. pci_ctrl[0].piebar2 = 0x0;
  93. pci_ctrl[0].piwar2 &= ~PIWAR_EN;
  94. /* Unlock the configuration bit */
  95. mpc83xx_pcislave_unlock(0);
  96. printf("PCI: Agent mode enabled\n");
  97. }
  98. #else
  99. {
  100. volatile immap_t *immr = (volatile immap_t *)CONFIG_SYS_IMMR;
  101. volatile clk83xx_t *clk = (volatile clk83xx_t *)&immr->clk;
  102. volatile law83xx_t *pci_law = immr->sysconf.pcilaw;
  103. #ifndef CONFIG_MPC83XX_PCI2
  104. struct pci_region *reg[] = { pci1_regions };
  105. #else
  106. struct pci_region *reg[] = { pci1_regions, pci2_regions };
  107. #endif
  108. /* initialize the PCA9555PW IO expander on the PIB board */
  109. pib_init();
  110. #if defined(CONFIG_PCI_66M)
  111. clk->occr = OCCR_PCICOE0 | OCCR_PCICOE1 | OCCR_PCICOE2;
  112. printf("PCI clock is 66MHz\n");
  113. #elif defined(CONFIG_PCI_33M)
  114. clk->occr = OCCR_PCICOE0 | OCCR_PCICOE1 | OCCR_PCICOE2 |
  115. OCCR_PCICD0 | OCCR_PCICD1 | OCCR_PCICD2 | OCCR_PCICR;
  116. printf("PCI clock is 33MHz\n");
  117. #else
  118. clk->occr = OCCR_PCICOE0 | OCCR_PCICOE1 | OCCR_PCICOE2;
  119. printf("PCI clock is 66MHz\n");
  120. #endif
  121. udelay(2000);
  122. /* Configure PCI Local Access Windows */
  123. pci_law[0].bar = CONFIG_SYS_PCI1_MEM_PHYS & LAWBAR_BAR;
  124. pci_law[0].ar = LAWAR_EN | LAWAR_SIZE_512M;
  125. pci_law[1].bar = CONFIG_SYS_PCI1_IO_PHYS & LAWBAR_BAR;
  126. pci_law[1].ar = LAWAR_EN | LAWAR_SIZE_1M;
  127. udelay(2000);
  128. #ifndef CONFIG_MPC83XX_PCI2
  129. mpc83xx_pci_init(1, reg);
  130. #else
  131. mpc83xx_pci_init(2, reg);
  132. #endif
  133. }
  134. #endif /* CONFIG_PCISLAVE */