m8260_pci.c 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. /*
  2. * (C) Copyright 2003
  3. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  4. *
  5. * (C) Copyright 2004 Red Hat, Inc.
  6. *
  7. * See file CREDITS for list of people who contributed to this
  8. * project.
  9. *
  10. * This program is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU General Public License as
  12. * published by the Free Software Foundation; either version 2 of
  13. * the License, or (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, write to the Free Software
  22. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  23. * MA 02111-1307 USA
  24. */
  25. #include <linux/kernel.h>
  26. #include <linux/init.h>
  27. #include <linux/pci.h>
  28. #include <linux/slab.h>
  29. #include <linux/delay.h>
  30. #include <asm/byteorder.h>
  31. #include <asm/io.h>
  32. #include <asm/irq.h>
  33. #include <asm/uaccess.h>
  34. #include <asm/machdep.h>
  35. #include <asm/pci-bridge.h>
  36. #include <asm/immap_cpm2.h>
  37. #include <asm/mpc8260.h>
  38. #include "m8260_pci.h"
  39. /* PCI bus configuration registers.
  40. */
  41. static void __init m8260_setup_pci(struct pci_controller *hose)
  42. {
  43. volatile cpm2_map_t *immap = cpm2_immr;
  44. unsigned long pocmr;
  45. u16 tempShort;
  46. #ifndef CONFIG_ATC /* already done in U-Boot */
  47. /*
  48. * Setting required to enable IRQ1-IRQ7 (SIUMCR [DPPC]),
  49. * and local bus for PCI (SIUMCR [LBPC]).
  50. */
  51. immap->im_siu_conf.siu_82xx.sc_siumcr = 0x00640000;
  52. #endif
  53. /* Make PCI lowest priority */
  54. /* Each 4 bits is a device bus request and the MS 4bits
  55. is highest priority */
  56. /* Bus 4bit value
  57. --- ----------
  58. CPM high 0b0000
  59. CPM middle 0b0001
  60. CPM low 0b0010
  61. PCI reguest 0b0011
  62. Reserved 0b0100
  63. Reserved 0b0101
  64. Internal Core 0b0110
  65. External Master 1 0b0111
  66. External Master 2 0b1000
  67. External Master 3 0b1001
  68. The rest are reserved */
  69. immap->im_siu_conf.siu_82xx.sc_ppc_alrh = 0x61207893;
  70. /* Park bus on core while modifying PCI Bus accesses */
  71. immap->im_siu_conf.siu_82xx.sc_ppc_acr = 0x6;
  72. /*
  73. * Set up master window that allows the CPU to access PCI space. This
  74. * window is set up using the first SIU PCIBR registers.
  75. */
  76. immap->im_memctl.memc_pcimsk0 = MPC826x_PCI_MASK;
  77. immap->im_memctl.memc_pcibr0 = MPC826x_PCI_BASE | PCIBR_ENABLE;
  78. /* Disable machine check on no response or target abort */
  79. immap->im_pci.pci_emr = cpu_to_le32(0x1fe7);
  80. /* Release PCI RST (by default the PCI RST signal is held low) */
  81. immap->im_pci.pci_gcr = cpu_to_le32(PCIGCR_PCI_BUS_EN);
  82. /* give it some time */
  83. mdelay(1);
  84. /*
  85. * Set up master window that allows the CPU to access PCI Memory (prefetch)
  86. * space. This window is set up using the first set of Outbound ATU registers.
  87. */
  88. immap->im_pci.pci_potar0 = cpu_to_le32(MPC826x_PCI_LOWER_MEM >> 12);
  89. immap->im_pci.pci_pobar0 = cpu_to_le32((MPC826x_PCI_LOWER_MEM - MPC826x_PCI_MEM_OFFSET) >> 12);
  90. pocmr = ((MPC826x_PCI_UPPER_MEM - MPC826x_PCI_LOWER_MEM) >> 12) ^ 0xfffff;
  91. immap->im_pci.pci_pocmr0 = cpu_to_le32(pocmr | POCMR_ENABLE | POCMR_PREFETCH_EN);
  92. /*
  93. * Set up master window that allows the CPU to access PCI Memory (non-prefetch)
  94. * space. This window is set up using the second set of Outbound ATU registers.
  95. */
  96. immap->im_pci.pci_potar1 = cpu_to_le32(MPC826x_PCI_LOWER_MMIO >> 12);
  97. immap->im_pci.pci_pobar1 = cpu_to_le32((MPC826x_PCI_LOWER_MMIO - MPC826x_PCI_MMIO_OFFSET) >> 12);
  98. pocmr = ((MPC826x_PCI_UPPER_MMIO - MPC826x_PCI_LOWER_MMIO) >> 12) ^ 0xfffff;
  99. immap->im_pci.pci_pocmr1 = cpu_to_le32(pocmr | POCMR_ENABLE);
  100. /*
  101. * Set up master window that allows the CPU to access PCI IO space. This window
  102. * is set up using the third set of Outbound ATU registers.
  103. */
  104. immap->im_pci.pci_potar2 = cpu_to_le32(MPC826x_PCI_IO_BASE >> 12);
  105. immap->im_pci.pci_pobar2 = cpu_to_le32(MPC826x_PCI_LOWER_IO >> 12);
  106. pocmr = ((MPC826x_PCI_UPPER_IO - MPC826x_PCI_LOWER_IO) >> 12) ^ 0xfffff;
  107. immap->im_pci.pci_pocmr2 = cpu_to_le32(pocmr | POCMR_ENABLE | POCMR_PCI_IO);
  108. /*
  109. * Set up slave window that allows PCI masters to access MPC826x local memory.
  110. * This window is set up using the first set of Inbound ATU registers
  111. */
  112. immap->im_pci.pci_pitar0 = cpu_to_le32(MPC826x_PCI_SLAVE_MEM_LOCAL >> 12);
  113. immap->im_pci.pci_pibar0 = cpu_to_le32(MPC826x_PCI_SLAVE_MEM_BUS >> 12);
  114. pocmr = ((MPC826x_PCI_SLAVE_MEM_SIZE-1) >> 12) ^ 0xfffff;
  115. immap->im_pci.pci_picmr0 = cpu_to_le32(pocmr | PICMR_ENABLE | PICMR_PREFETCH_EN);
  116. /* See above for description - puts PCI request as highest priority */
  117. immap->im_siu_conf.siu_82xx.sc_ppc_alrh = 0x03124567;
  118. /* Park the bus on the PCI */
  119. immap->im_siu_conf.siu_82xx.sc_ppc_acr = PPC_ACR_BUS_PARK_PCI;
  120. /* Host mode - specify the bridge as a host-PCI bridge */
  121. early_write_config_word(hose, 0, 0, PCI_CLASS_DEVICE, PCI_CLASS_BRIDGE_HOST);
  122. /* Enable the host bridge to be a master on the PCI bus, and to act as a PCI memory target */
  123. early_read_config_word(hose, 0, 0, PCI_COMMAND, &tempShort);
  124. early_write_config_word(hose, 0, 0, PCI_COMMAND,
  125. tempShort | PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY);
  126. }
  127. void __init m8260_find_bridges(void)
  128. {
  129. extern int pci_assign_all_busses;
  130. struct pci_controller * hose;
  131. pci_assign_all_busses = 1;
  132. hose = pcibios_alloc_controller();
  133. if (!hose)
  134. return;
  135. ppc_md.pci_swizzle = common_swizzle;
  136. hose->first_busno = 0;
  137. hose->bus_offset = 0;
  138. hose->last_busno = 0xff;
  139. setup_m8260_indirect_pci(hose,
  140. (unsigned long)&cpm2_immr->im_pci.pci_cfg_addr,
  141. (unsigned long)&cpm2_immr->im_pci.pci_cfg_data);
  142. m8260_setup_pci(hose);
  143. hose->pci_mem_offset = MPC826x_PCI_MEM_OFFSET;
  144. hose->io_base_virt = ioremap(MPC826x_PCI_IO_BASE,
  145. MPC826x_PCI_IO_SIZE);
  146. isa_io_base = (unsigned long) hose->io_base_virt;
  147. /* setup resources */
  148. pci_init_resource(&hose->mem_resources[0],
  149. MPC826x_PCI_LOWER_MEM,
  150. MPC826x_PCI_UPPER_MEM,
  151. IORESOURCE_MEM|IORESOURCE_PREFETCH, "PCI prefetchable memory");
  152. pci_init_resource(&hose->mem_resources[1],
  153. MPC826x_PCI_LOWER_MMIO,
  154. MPC826x_PCI_UPPER_MMIO,
  155. IORESOURCE_MEM, "PCI memory");
  156. pci_init_resource(&hose->io_resource,
  157. MPC826x_PCI_LOWER_IO,
  158. MPC826x_PCI_UPPER_IO,
  159. IORESOURCE_IO, "PCI I/O");
  160. }