pci.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  20. * MA 02111-1307 USA
  21. */
  22. #include <common.h>
  23. #include <asm/mmu.h>
  24. #include <asm/io.h>
  25. #include <mpc83xx.h>
  26. #include <pci.h>
  27. #include <i2c.h>
  28. #include <asm/fsl_i2c.h>
  29. DECLARE_GLOBAL_DATA_PTR;
  30. static struct pci_region pci1_regions[] = {
  31. {
  32. bus_start: CONFIG_SYS_PCI1_MEM_BASE,
  33. phys_start: CONFIG_SYS_PCI1_MEM_PHYS,
  34. size: CONFIG_SYS_PCI1_MEM_SIZE,
  35. flags: PCI_REGION_MEM | PCI_REGION_PREFETCH
  36. },
  37. {
  38. bus_start: CONFIG_SYS_PCI1_IO_BASE,
  39. phys_start: CONFIG_SYS_PCI1_IO_PHYS,
  40. size: CONFIG_SYS_PCI1_IO_SIZE,
  41. flags: PCI_REGION_IO
  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. #ifdef CONFIG_MPC83XX_PCI2
  51. static struct pci_region pci2_regions[] = {
  52. {
  53. bus_start: CONFIG_SYS_PCI2_MEM_BASE,
  54. phys_start: CONFIG_SYS_PCI2_MEM_PHYS,
  55. size: CONFIG_SYS_PCI2_MEM_SIZE,
  56. flags: PCI_REGION_MEM | PCI_REGION_PREFETCH
  57. },
  58. {
  59. bus_start: CONFIG_SYS_PCI2_IO_BASE,
  60. phys_start: CONFIG_SYS_PCI2_IO_PHYS,
  61. size: CONFIG_SYS_PCI2_IO_SIZE,
  62. flags: PCI_REGION_IO
  63. },
  64. {
  65. bus_start: CONFIG_SYS_PCI2_MMIO_BASE,
  66. phys_start: CONFIG_SYS_PCI2_MMIO_PHYS,
  67. size: CONFIG_SYS_PCI2_MMIO_SIZE,
  68. flags: PCI_REGION_MEM
  69. },
  70. };
  71. #endif
  72. void pci_init_board(void)
  73. {
  74. volatile immap_t *immr = (volatile immap_t *)CONFIG_SYS_IMMR;
  75. volatile clk83xx_t *clk = (volatile clk83xx_t *)&immr->clk;
  76. volatile law83xx_t *pci_law = immr->sysconf.pcilaw;
  77. #ifndef CONFIG_MPC83XX_PCI2
  78. struct pci_region *reg[] = { pci1_regions };
  79. #else
  80. struct pci_region *reg[] = { pci1_regions, pci2_regions };
  81. #endif
  82. u8 reg8;
  83. #ifdef CONFIG_HARD_I2C
  84. i2c_set_bus_num(1);
  85. /* Read the PCI_M66EN jumper setting */
  86. if ((i2c_read(CONFIG_SYS_I2C_8574_ADDR2, 0, 0, &reg8, sizeof(reg8)) == 0) ||
  87. (i2c_read(CONFIG_SYS_I2C_8574A_ADDR2, 0, 0, &reg8, sizeof(reg8)) == 0)) {
  88. if (reg8 & I2C_8574_PCI66)
  89. clk->occr = 0xff000000; /* 66 MHz PCI */
  90. else
  91. clk->occr = 0xff600001; /* 33 MHz PCI */
  92. } else {
  93. clk->occr = 0xff600001; /* 33 MHz PCI */
  94. }
  95. #else
  96. clk->occr = 0xff000000; /* 66 MHz PCI */
  97. #endif
  98. udelay(2000);
  99. /* Configure PCI Local Access Windows */
  100. pci_law[0].bar = CONFIG_SYS_PCI1_MEM_PHYS & LAWBAR_BAR;
  101. pci_law[0].ar = LAWAR_EN | LAWAR_SIZE_1G;
  102. pci_law[1].bar = CONFIG_SYS_PCI1_IO_PHYS & LAWBAR_BAR;
  103. pci_law[1].ar = LAWAR_EN | LAWAR_SIZE_32M;
  104. udelay(2000);
  105. #ifndef CONFIG_MPC83XX_PCI2
  106. mpc83xx_pci_init(1, reg);
  107. #else
  108. mpc83xx_pci_init(2, reg);
  109. #endif
  110. }