pci.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /*
  2. * (C) Copyright 2005
  3. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  4. * Copyright (C) 2006-2009 Freescale Semiconductor, Inc.
  5. *
  6. * See file CREDITS for list of people who contributed to this
  7. * project.
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License as
  11. * published by the Free Software Foundation; either version 2 of
  12. * the License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  22. * MA 02111-1307 USA
  23. *
  24. */
  25. #include <asm/mmu.h>
  26. #include <asm/io.h>
  27. #include <common.h>
  28. #include <mpc83xx.h>
  29. #include <pci.h>
  30. #include <i2c.h>
  31. #include <asm/fsl_i2c.h>
  32. DECLARE_GLOBAL_DATA_PTR;
  33. static struct pci_region pci1_regions[] = {
  34. {
  35. bus_start: CONFIG_SYS_PCI1_MEM_BASE,
  36. phys_start: CONFIG_SYS_PCI1_MEM_PHYS,
  37. size: CONFIG_SYS_PCI1_MEM_SIZE,
  38. flags: PCI_REGION_MEM | PCI_REGION_PREFETCH
  39. },
  40. {
  41. bus_start: CONFIG_SYS_PCI1_IO_BASE,
  42. phys_start: CONFIG_SYS_PCI1_IO_PHYS,
  43. size: CONFIG_SYS_PCI1_IO_SIZE,
  44. flags: PCI_REGION_IO
  45. },
  46. {
  47. bus_start: CONFIG_SYS_PCI1_MMIO_BASE,
  48. phys_start: CONFIG_SYS_PCI1_MMIO_PHYS,
  49. size: CONFIG_SYS_PCI1_MMIO_SIZE,
  50. flags: PCI_REGION_MEM
  51. },
  52. };
  53. /*
  54. * pci_init_board()
  55. *
  56. * NOTICE: MPC8349 internally has two PCI controllers (PCI1 and PCI2) but since
  57. * per TQM834x design physical connections to external devices (PCI sockets)
  58. * are routed only to the PCI1 we do not account for the second one - this code
  59. * supports PCI1 module only. Should support for the PCI2 be required in the
  60. * future it needs a separate pci_controller structure (above) and handling -
  61. * please refer to other boards' implementation for dual PCI host controllers,
  62. * for example board/Marvell/db64360/pci.c, pci_init_board()
  63. *
  64. */
  65. void
  66. pci_init_board(void)
  67. {
  68. volatile immap_t *immr = (volatile immap_t *)CONFIG_SYS_IMMR;
  69. volatile clk83xx_t *clk = (volatile clk83xx_t *)&immr->clk;
  70. volatile law83xx_t *pci_law = immr->sysconf.pcilaw;
  71. struct pci_region *reg[] = { pci1_regions };
  72. u32 reg32;
  73. /*
  74. * Configure PCI controller and PCI_CLK_OUTPUT
  75. *
  76. * WARNING! only PCI_CLK_OUTPUT1 is enabled here as this is the one
  77. * line actually used for clocking all external PCI devices in TQM83xx.
  78. * Enabling other PCI_CLK_OUTPUT lines may lead to board's hang for
  79. * unknown reasons - particularly PCI_CLK_OUTPUT6 and PCI_CLK_OUTPUT7
  80. * are known to hang the board; this issue is under investigation
  81. * (13 oct 05)
  82. */
  83. reg32 = OCCR_PCICOE1;
  84. #if 0
  85. /* enabling all PCI_CLK_OUTPUT lines HANGS the board... */
  86. reg32 = 0xff000000;
  87. #endif
  88. if (clk->spmr & SPMR_CKID) {
  89. /* PCI Clock is half CONFIG_83XX_CLKIN so need to set up OCCR
  90. * fields accordingly */
  91. reg32 |= (OCCR_PCI1CR | OCCR_PCI2CR);
  92. reg32 |= (OCCR_PCICD0 | OCCR_PCICD1 | OCCR_PCICD2 \
  93. | OCCR_PCICD3 | OCCR_PCICD4 | OCCR_PCICD5 \
  94. | OCCR_PCICD6 | OCCR_PCICD7);
  95. }
  96. clk->occr = reg32;
  97. udelay(2000);
  98. /* Configure PCI Local Access Windows */
  99. pci_law[0].bar = CONFIG_SYS_PCI1_MEM_PHYS & LAWBAR_BAR;
  100. pci_law[0].ar = LAWAR_EN | LAWAR_SIZE_512M;
  101. pci_law[1].bar = CONFIG_SYS_PCI1_IO_PHYS & LAWBAR_BAR;
  102. pci_law[1].ar = LAWAR_EN | LAWAR_SIZE_16M;
  103. udelay(2000);
  104. mpc83xx_pci_init(1, reg);
  105. }