pci.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /*
  2. * pci.c -- esd VME8349 PCI board support.
  3. * Copyright (c) 2006 Wind River Systems, Inc.
  4. * Copyright (C) 2006-2009 Freescale Semiconductor, Inc.
  5. * Copyright (c) 2009 esd gmbh.
  6. *
  7. * Reinhard Arlt <reinhard.arlt@esd-electronics.com>
  8. *
  9. * Based on MPC8349 PCI support but w/o PIB related code.
  10. *
  11. * See file CREDITS for list of people who contributed to this
  12. * project.
  13. *
  14. * This program is free software; you can redistribute it and/or
  15. * modify it under the terms of the GNU General Public License as
  16. * published by the Free Software Foundation; either version 2 of
  17. * the License, or (at your option) any later version.
  18. *
  19. * This program is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. * GNU General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU General Public License
  25. * along with this program; if not, write to the Free Software
  26. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  27. * MA 02111-1307 USA
  28. *
  29. */
  30. #include <asm/mmu.h>
  31. #include <asm/io.h>
  32. #include <common.h>
  33. #include <mpc83xx.h>
  34. #include <pci.h>
  35. #include <i2c.h>
  36. #include <asm/fsl_i2c.h>
  37. #include "vme8349pin.h"
  38. DECLARE_GLOBAL_DATA_PTR;
  39. static struct pci_region pci1_regions[] = {
  40. {
  41. bus_start: CONFIG_SYS_PCI1_MEM_BASE,
  42. phys_start: CONFIG_SYS_PCI1_MEM_PHYS,
  43. size: CONFIG_SYS_PCI1_MEM_SIZE,
  44. flags: PCI_REGION_MEM | PCI_REGION_PREFETCH
  45. },
  46. {
  47. bus_start: CONFIG_SYS_PCI1_IO_BASE,
  48. phys_start: CONFIG_SYS_PCI1_IO_PHYS,
  49. size: CONFIG_SYS_PCI1_IO_SIZE,
  50. flags: PCI_REGION_IO
  51. },
  52. {
  53. bus_start: CONFIG_SYS_PCI1_MMIO_BASE,
  54. phys_start: CONFIG_SYS_PCI1_MMIO_PHYS,
  55. size: CONFIG_SYS_PCI1_MMIO_SIZE,
  56. flags: PCI_REGION_MEM
  57. },
  58. };
  59. /*
  60. * pci_init_board()
  61. *
  62. * NOTICE: PCI2 is not supported. There is only one
  63. * physical PCI slot on the board.
  64. *
  65. */
  66. void
  67. pci_init_board(void)
  68. {
  69. volatile immap_t *immr = (volatile immap_t *)CONFIG_SYS_IMMR;
  70. volatile clk83xx_t *clk = (volatile clk83xx_t *)&immr->clk;
  71. volatile law83xx_t *pci_law = immr->sysconf.pcilaw;
  72. struct pci_region *reg[] = { pci1_regions };
  73. u8 reg8;
  74. int monarch = 0;
  75. i2c_set_bus_num(1);
  76. /* Read the PCI_M66EN jumper setting */
  77. if ((i2c_read(CONFIG_SYS_I2C_8574_ADDR2, 0, 0, &reg8, 1) == 0) ||
  78. (i2c_read(0x38 , 0, 0, &reg8, 1) == 0)) {
  79. if (reg8 & 0x40) {
  80. clk->occr = 0xff000000; /* 66 MHz PCI */
  81. printf("PCI: 66MHz\n");
  82. } else {
  83. clk->occr = 0xffff0003; /* 33 MHz PCI */
  84. printf("PCI: 33MHz\n");
  85. }
  86. if (((reg8 & 0x01) == 0) || ((reg8 & 0x02) == 0))
  87. monarch = 1;
  88. } else {
  89. clk->occr = 0xffff0003; /* 33 MHz PCI */
  90. printf("PCI: 33MHz (I2C read failed)\n");
  91. }
  92. udelay(2000);
  93. /*
  94. * Assert/deassert VME reset
  95. */
  96. clrsetbits_be32(&immr->gpio[1].dat,
  97. GPIO2_TSI_POWERUP_RESET_N | GPIO2_TSI_PLL_RESET_N,
  98. GPIO2_VME_RESET_N | GPIO2_L_RESET_EN_N);
  99. setbits_be32(&immr->gpio[1].dir, GPIO2_TSI_PLL_RESET_N |
  100. GPIO2_TSI_POWERUP_RESET_N |
  101. GPIO2_VME_RESET_N |
  102. GPIO2_L_RESET_EN_N);
  103. clrbits_be32(&immr->gpio[1].dir, GPIO2_V_SCON);
  104. udelay(200);
  105. setbits_be32(&immr->gpio[1].dat, GPIO2_TSI_PLL_RESET_N);
  106. udelay(200);
  107. setbits_be32(&immr->gpio[1].dat, GPIO2_TSI_POWERUP_RESET_N);
  108. udelay(600000);
  109. clrbits_be32(&immr->gpio[1].dat, GPIO2_L_RESET_EN_N);
  110. /* Configure PCI Local Access Windows */
  111. pci_law[0].bar = CONFIG_SYS_PCI1_MEM_PHYS & LAWBAR_BAR;
  112. pci_law[0].ar = LAWAR_EN | LAWAR_SIZE_1G;
  113. pci_law[1].bar = CONFIG_SYS_PCI1_IO_PHYS & LAWBAR_BAR;
  114. pci_law[1].ar = LAWAR_EN | LAWAR_SIZE_4M;
  115. udelay(2000);
  116. if (monarch == 0) {
  117. mpc83xx_pci_init(1, reg);
  118. } else {
  119. /*
  120. * Release PCI RST Output signal
  121. */
  122. out_be32(&immr->pci_ctrl[0].gcr, 0);
  123. udelay(2000);
  124. out_be32(&immr->pci_ctrl[0].gcr, 1);
  125. }
  126. }