summit_32.c 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. /*
  2. * IBM Summit-Specific Code
  3. *
  4. * Written By: Matthew Dobson, IBM Corporation
  5. *
  6. * Copyright (c) 2003 IBM Corp.
  7. *
  8. * All rights reserved.
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation; either version 2 of the License, or (at
  13. * your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful, but
  16. * WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
  18. * NON INFRINGEMENT. See the GNU General Public License for more
  19. * 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., 675 Mass Ave, Cambridge, MA 02139, USA.
  24. *
  25. * Send feedback to <colpatch@us.ibm.com>
  26. *
  27. */
  28. #include <linux/mm.h>
  29. #include <linux/init.h>
  30. #include <asm/io.h>
  31. #include <asm/mach-summit/mach_mpparse.h>
  32. static struct rio_table_hdr *rio_table_hdr __initdata;
  33. static struct scal_detail *scal_devs[MAX_NUMNODES] __initdata;
  34. static struct rio_detail *rio_devs[MAX_NUMNODES*4] __initdata;
  35. static int mp_bus_id_to_node[MAX_MP_BUSSES] __initdata;
  36. static int __init setup_pci_node_map_for_wpeg(int wpeg_num, int last_bus)
  37. {
  38. int twister = 0, node = 0;
  39. int i, bus, num_buses;
  40. for (i = 0; i < rio_table_hdr->num_rio_dev; i++) {
  41. if (rio_devs[i]->node_id == rio_devs[wpeg_num]->owner_id) {
  42. twister = rio_devs[i]->owner_id;
  43. break;
  44. }
  45. }
  46. if (i == rio_table_hdr->num_rio_dev) {
  47. printk(KERN_ERR "%s: Couldn't find owner Cyclone for Winnipeg!\n", __func__);
  48. return last_bus;
  49. }
  50. for (i = 0; i < rio_table_hdr->num_scal_dev; i++) {
  51. if (scal_devs[i]->node_id == twister) {
  52. node = scal_devs[i]->node_id;
  53. break;
  54. }
  55. }
  56. if (i == rio_table_hdr->num_scal_dev) {
  57. printk(KERN_ERR "%s: Couldn't find owner Twister for Cyclone!\n", __func__);
  58. return last_bus;
  59. }
  60. switch (rio_devs[wpeg_num]->type) {
  61. case CompatWPEG:
  62. /*
  63. * The Compatibility Winnipeg controls the 2 legacy buses,
  64. * the 66MHz PCI bus [2 slots] and the 2 "extra" buses in case
  65. * a PCI-PCI bridge card is used in either slot: total 5 buses.
  66. */
  67. num_buses = 5;
  68. break;
  69. case AltWPEG:
  70. /*
  71. * The Alternate Winnipeg controls the 2 133MHz buses [1 slot
  72. * each], their 2 "extra" buses, the 100MHz bus [2 slots] and
  73. * the "extra" buses for each of those slots: total 7 buses.
  74. */
  75. num_buses = 7;
  76. break;
  77. case LookOutAWPEG:
  78. case LookOutBWPEG:
  79. /*
  80. * A Lookout Winnipeg controls 3 100MHz buses [2 slots each]
  81. * & the "extra" buses for each of those slots: total 9 buses.
  82. */
  83. num_buses = 9;
  84. break;
  85. default:
  86. printk(KERN_INFO "%s: Unsupported Winnipeg type!\n", __func__);
  87. return last_bus;
  88. }
  89. for (bus = last_bus; bus < last_bus + num_buses; bus++)
  90. mp_bus_id_to_node[bus] = node;
  91. return bus;
  92. }
  93. static int __init build_detail_arrays(void)
  94. {
  95. unsigned long ptr;
  96. int i, scal_detail_size, rio_detail_size;
  97. if (rio_table_hdr->num_scal_dev > MAX_NUMNODES) {
  98. printk(KERN_WARNING "%s: MAX_NUMNODES too low! Defined as %d, but system has %d nodes.\n", __func__, MAX_NUMNODES, rio_table_hdr->num_scal_dev);
  99. return 0;
  100. }
  101. switch (rio_table_hdr->version) {
  102. default:
  103. printk(KERN_WARNING "%s: Invalid Rio Grande Table Version: %d\n", __func__, rio_table_hdr->version);
  104. return 0;
  105. case 2:
  106. scal_detail_size = 11;
  107. rio_detail_size = 13;
  108. break;
  109. case 3:
  110. scal_detail_size = 12;
  111. rio_detail_size = 15;
  112. break;
  113. }
  114. ptr = (unsigned long)rio_table_hdr + 3;
  115. for (i = 0; i < rio_table_hdr->num_scal_dev; i++, ptr += scal_detail_size)
  116. scal_devs[i] = (struct scal_detail *)ptr;
  117. for (i = 0; i < rio_table_hdr->num_rio_dev; i++, ptr += rio_detail_size)
  118. rio_devs[i] = (struct rio_detail *)ptr;
  119. return 1;
  120. }
  121. void __init setup_summit(void)
  122. {
  123. unsigned long ptr;
  124. unsigned short offset;
  125. int i, next_wpeg, next_bus = 0;
  126. /* The pointer to the EBDA is stored in the word @ phys 0x40E(40:0E) */
  127. ptr = *(unsigned short *)phys_to_virt(0x40Eul);
  128. ptr = (unsigned long)phys_to_virt(ptr << 4);
  129. rio_table_hdr = NULL;
  130. offset = 0x180;
  131. while (offset) {
  132. /* The block id is stored in the 2nd word */
  133. if (*((unsigned short *)(ptr + offset + 2)) == 0x4752) {
  134. /* set the pointer past the offset & block id */
  135. rio_table_hdr = (struct rio_table_hdr *)(ptr + offset + 4);
  136. break;
  137. }
  138. /* The next offset is stored in the 1st word. 0 means no more */
  139. offset = *((unsigned short *)(ptr + offset));
  140. }
  141. if (!rio_table_hdr) {
  142. printk(KERN_ERR "%s: Unable to locate Rio Grande Table in EBDA - bailing!\n", __func__);
  143. return;
  144. }
  145. if (!build_detail_arrays())
  146. return;
  147. /* The first Winnipeg we're looking for has an index of 0 */
  148. next_wpeg = 0;
  149. do {
  150. for (i = 0; i < rio_table_hdr->num_rio_dev; i++) {
  151. if (is_WPEG(rio_devs[i]) && rio_devs[i]->WP_index == next_wpeg) {
  152. /* It's the Winnipeg we're looking for! */
  153. next_bus = setup_pci_node_map_for_wpeg(i, next_bus);
  154. next_wpeg++;
  155. break;
  156. }
  157. }
  158. /*
  159. * If we go through all Rio devices and don't find one with
  160. * the next index, it means we've found all the Winnipegs,
  161. * and thus all the PCI buses.
  162. */
  163. if (i == rio_table_hdr->num_rio_dev)
  164. next_wpeg = 0;
  165. } while (next_wpeg != 0);
  166. }