pci.c 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. /*
  2. * Carsten Langgaard, carstenl@mips.com
  3. * Copyright (C) 1999, 2000 MIPS Technologies, Inc. All rights reserved.
  4. *
  5. * Copyright (C) 2004 by Ralf Baechle (ralf@linux-mips.org)
  6. *
  7. * This program is free software; you can distribute it and/or modify it
  8. * under the terms of the GNU General Public License (Version 2) as
  9. * published by the Free Software Foundation.
  10. *
  11. * This program is distributed in the hope it will be useful, but WITHOUT
  12. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  14. * for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along
  17. * with this program; if not, write to the Free Software Foundation, Inc.,
  18. * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
  19. *
  20. * MIPS boards specific PCI support.
  21. */
  22. #include <linux/config.h>
  23. #include <linux/types.h>
  24. #include <linux/pci.h>
  25. #include <linux/kernel.h>
  26. #include <linux/init.h>
  27. #include <asm/mips-boards/generic.h>
  28. #include <asm/gt64120.h>
  29. #include <asm/mips-boards/bonito64.h>
  30. #include <asm/mips-boards/msc01_pci.h>
  31. #ifdef CONFIG_MIPS_MALTA
  32. #include <asm/mips-boards/malta.h>
  33. #endif
  34. static struct resource bonito64_mem_resource = {
  35. .name = "Bonito PCI MEM",
  36. .start = 0x10000000UL,
  37. .end = 0x1bffffffUL,
  38. .flags = IORESOURCE_MEM,
  39. };
  40. static struct resource bonito64_io_resource = {
  41. .name = "Bonito IO MEM",
  42. .start = 0x00002000UL, /* avoid conflicts with YAMON allocated I/O addresses */
  43. .end = 0x000fffffUL,
  44. .flags = IORESOURCE_IO,
  45. };
  46. static struct resource gt64120_mem_resource = {
  47. .name = "GT64120 PCI MEM",
  48. .start = 0x10000000UL,
  49. .end = 0x1bdfffffUL,
  50. .flags = IORESOURCE_MEM,
  51. };
  52. static struct resource gt64120_io_resource = {
  53. .name = "GT64120 IO MEM",
  54. #ifdef CONFIG_MIPS_ATLAS
  55. .start = 0x18000000UL,
  56. .end = 0x181fffffUL,
  57. #endif
  58. #ifdef CONFIG_MIPS_MALTA
  59. .start = 0x00002000UL,
  60. .end = 0x001fffffUL,
  61. #endif
  62. .flags = IORESOURCE_IO,
  63. };
  64. static struct resource msc_mem_resource = {
  65. .name = "MSC PCI MEM",
  66. .start = 0x10000000UL,
  67. .end = 0x1fffffffUL,
  68. .flags = IORESOURCE_MEM,
  69. };
  70. static struct resource msc_io_resource = {
  71. .name = "MSC IO MEM",
  72. .start = 0x00002000UL,
  73. .end = 0x007fffffUL,
  74. .flags = IORESOURCE_IO,
  75. };
  76. extern struct pci_ops bonito64_pci_ops;
  77. extern struct pci_ops gt64120_pci_ops;
  78. extern struct pci_ops msc_pci_ops;
  79. static struct pci_controller bonito64_controller = {
  80. .pci_ops = &bonito64_pci_ops,
  81. .io_resource = &bonito64_io_resource,
  82. .mem_resource = &bonito64_mem_resource,
  83. .mem_offset = 0x10000000UL,
  84. .io_offset = 0x00000000UL,
  85. };
  86. static struct pci_controller gt64120_controller = {
  87. .pci_ops = &gt64120_pci_ops,
  88. .io_resource = &gt64120_io_resource,
  89. .mem_resource = &gt64120_mem_resource,
  90. .mem_offset = 0x00000000UL,
  91. .io_offset = 0x00000000UL,
  92. };
  93. static struct pci_controller msc_controller = {
  94. .pci_ops = &msc_pci_ops,
  95. .io_resource = &msc_io_resource,
  96. .mem_resource = &msc_mem_resource,
  97. .mem_offset = 0x10000000UL,
  98. .io_offset = 0x00000000UL,
  99. };
  100. static int __init pcibios_init(void)
  101. {
  102. struct pci_controller *controller;
  103. switch (mips_revision_corid) {
  104. case MIPS_REVISION_CORID_QED_RM5261:
  105. case MIPS_REVISION_CORID_CORE_LV:
  106. case MIPS_REVISION_CORID_CORE_FPGA:
  107. case MIPS_REVISION_CORID_CORE_FPGAR2:
  108. /*
  109. * Due to a bug in the Galileo system controller, we need
  110. * to setup the PCI BAR for the Galileo internal registers.
  111. * This should be done in the bios/bootprom and will be
  112. * fixed in a later revision of YAMON (the MIPS boards
  113. * boot prom).
  114. */
  115. GT_WRITE(GT_PCI0_CFGADDR_OFS,
  116. (0 << GT_PCI0_CFGADDR_BUSNUM_SHF) | /* Local bus */
  117. (0 << GT_PCI0_CFGADDR_DEVNUM_SHF) | /* GT64120 dev */
  118. (0 << GT_PCI0_CFGADDR_FUNCTNUM_SHF) | /* Function 0*/
  119. ((0x20/4) << GT_PCI0_CFGADDR_REGNUM_SHF) | /* BAR 4*/
  120. GT_PCI0_CFGADDR_CONFIGEN_BIT );
  121. /* Perform the write */
  122. GT_WRITE(GT_PCI0_CFGDATA_OFS, CPHYSADDR(MIPS_GT_BASE));
  123. controller = &gt64120_controller;
  124. break;
  125. case MIPS_REVISION_CORID_BONITO64:
  126. case MIPS_REVISION_CORID_CORE_20K:
  127. case MIPS_REVISION_CORID_CORE_EMUL_BON:
  128. controller = &bonito64_controller;
  129. break;
  130. case MIPS_REVISION_CORID_CORE_MSC:
  131. case MIPS_REVISION_CORID_CORE_FPGA2:
  132. case MIPS_REVISION_CORID_CORE_EMUL_MSC:
  133. controller = &msc_controller;
  134. break;
  135. default:
  136. return 1;
  137. }
  138. ioport_resource.end = controller->io_resource->end;
  139. register_pci_controller (controller);
  140. return 0;
  141. }
  142. early_initcall(pcibios_init);