pci.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /*
  2. * Copyright 2004 Freescale Semiconductor.
  3. * Copyright (C) 2003 Motorola Inc.
  4. * Xianghua Xiao (x.xiao@motorola.com)
  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. * PCI Configuration space access support for MPC85xx PCI Bridge
  26. */
  27. #include <common.h>
  28. #include <asm/cpm_85xx.h>
  29. #include <pci.h>
  30. #if defined(CONFIG_PCI)
  31. void
  32. pci_mpc85xx_init(struct pci_controller *hose)
  33. {
  34. volatile immap_t *immap = (immap_t *)CFG_CCSRBAR;
  35. volatile ccsr_pcix_t *pcix = &immap->im_pcix;
  36. u16 reg16;
  37. hose->first_busno = 0;
  38. hose->last_busno = 0xff;
  39. pci_set_region(hose->regions + 0,
  40. CFG_PCI1_MEM_BASE,
  41. CFG_PCI1_MEM_PHYS,
  42. CFG_PCI1_MEM_SIZE,
  43. PCI_REGION_MEM);
  44. pci_set_region(hose->regions + 1,
  45. CFG_PCI1_IO_BASE,
  46. CFG_PCI1_IO_PHYS,
  47. CFG_PCI1_IO_SIZE,
  48. PCI_REGION_IO);
  49. hose->region_count = 2;
  50. pci_setup_indirect(hose,
  51. (CFG_IMMR+0x8000),
  52. (CFG_IMMR+0x8004));
  53. pci_read_config_word (PCI_BDF(0,0,0), PCI_COMMAND, &reg16);
  54. reg16 |= PCI_COMMAND_SERR | PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY;
  55. pci_write_config_word(PCI_BDF(0,0,0), PCI_COMMAND, reg16);
  56. /*
  57. * Clear non-reserved bits in status register.
  58. */
  59. pci_write_config_word(PCI_BDF(0,0,0), PCI_STATUS, 0xffff);
  60. pci_write_config_byte(PCI_BDF(0,0,0), PCI_LATENCY_TIMER,0x80);
  61. pcix->potar1 = (CFG_PCI1_MEM_BASE >> 12) & 0x000fffff;
  62. pcix->potear1 = 0x00000000;
  63. pcix->powbar1 = (CFG_PCI1_MEM_BASE >> 12) & 0x000fffff;
  64. pcix->powbear1 = 0x00000000;
  65. pcix->powar1 = 0x8004401c; /* 512M MEM space */
  66. pcix->potar2 = 0x00000000;
  67. pcix->potear2 = 0x00000000;
  68. pcix->powbar2 = (CFG_PCI1_IO_BASE >> 12) & 0x000fffff;
  69. pcix->powbear2 = 0x00000000;
  70. pcix->powar2 = 0x80088017; /* 16M IO space */
  71. pcix->pitar1 = 0x00000000;
  72. pcix->piwbar1 = 0x00000000;
  73. pcix->piwar1 = 0xa0f5501e; /* Enable, Prefetch, Local Mem,
  74. * Snoop R/W, 2G */
  75. /*
  76. * Hose scan.
  77. */
  78. pci_register_hose(hose);
  79. #if defined(CONFIG_MPC8555CDS) || defined(CONFIG_MPC8541CDS)
  80. /*
  81. * This is a SW workaround for an apparent HW problem
  82. * in the PCI controller on the MPC85555/41 CDS boards.
  83. * The first config cycle must be to a valid, known
  84. * device on the PCI bus in order to trick the PCI
  85. * controller state machine into a known valid state.
  86. * Without this, the first config cycle has the chance
  87. * of hanging the controller permanently, just leaving
  88. * it in a semi-working state, or leaving it working.
  89. *
  90. * Pick on the Tundra, Device 17, to get it right.
  91. */
  92. {
  93. u8 header_type;
  94. pci_hose_read_config_byte(hose,
  95. PCI_BDF(0,17,0),
  96. PCI_HEADER_TYPE,
  97. &header_type);
  98. }
  99. #endif
  100. hose->last_busno = pci_hose_scan(hose);
  101. }
  102. #endif /* CONFIG_PCI */