pci.c 3.2 KB

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