2 * IBM Summit-Specific Code
4 * Written By: Matthew Dobson, IBM Corporation
6 * Copyright (c) 2003 IBM Corp.
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.
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
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.
25 * Send feedback to <colpatch@us.ibm.com>
30 #include <linux/init.h>
32 #include <asm/bios_ebda.h>
33 #include <asm/mach-summit/mach_mpparse.h>
35 static struct rio_table_hdr *rio_table_hdr __initdata;
36 static struct scal_detail *scal_devs[MAX_NUMNODES] __initdata;
37 static struct rio_detail *rio_devs[MAX_NUMNODES*4] __initdata;
39 static int mp_bus_id_to_node[MAX_MP_BUSSES] __initdata;
41 static int __init setup_pci_node_map_for_wpeg(int wpeg_num, int last_bus)
43 int twister = 0, node = 0;
44 int i, bus, num_buses;
46 for (i = 0; i < rio_table_hdr->num_rio_dev; i++) {
47 if (rio_devs[i]->node_id == rio_devs[wpeg_num]->owner_id) {
48 twister = rio_devs[i]->owner_id;
52 if (i == rio_table_hdr->num_rio_dev) {
53 printk(KERN_ERR "%s: Couldn't find owner Cyclone for Winnipeg!\n", __func__);
57 for (i = 0; i < rio_table_hdr->num_scal_dev; i++) {
58 if (scal_devs[i]->node_id == twister) {
59 node = scal_devs[i]->node_id;
63 if (i == rio_table_hdr->num_scal_dev) {
64 printk(KERN_ERR "%s: Couldn't find owner Twister for Cyclone!\n", __func__);
68 switch (rio_devs[wpeg_num]->type) {
71 * The Compatibility Winnipeg controls the 2 legacy buses,
72 * the 66MHz PCI bus [2 slots] and the 2 "extra" buses in case
73 * a PCI-PCI bridge card is used in either slot: total 5 buses.
79 * The Alternate Winnipeg controls the 2 133MHz buses [1 slot
80 * each], their 2 "extra" buses, the 100MHz bus [2 slots] and
81 * the "extra" buses for each of those slots: total 7 buses.
88 * A Lookout Winnipeg controls 3 100MHz buses [2 slots each]
89 * & the "extra" buses for each of those slots: total 9 buses.
94 printk(KERN_INFO "%s: Unsupported Winnipeg type!\n", __func__);
98 for (bus = last_bus; bus < last_bus + num_buses; bus++)
99 mp_bus_id_to_node[bus] = node;
103 static int __init build_detail_arrays(void)
106 int i, scal_detail_size, rio_detail_size;
108 if (rio_table_hdr->num_scal_dev > MAX_NUMNODES) {
109 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);
113 switch (rio_table_hdr->version) {
115 printk(KERN_WARNING "%s: Invalid Rio Grande Table Version: %d\n", __func__, rio_table_hdr->version);
118 scal_detail_size = 11;
119 rio_detail_size = 13;
122 scal_detail_size = 12;
123 rio_detail_size = 15;
127 ptr = (unsigned long)rio_table_hdr + 3;
128 for (i = 0; i < rio_table_hdr->num_scal_dev; i++, ptr += scal_detail_size)
129 scal_devs[i] = (struct scal_detail *)ptr;
131 for (i = 0; i < rio_table_hdr->num_rio_dev; i++, ptr += rio_detail_size)
132 rio_devs[i] = (struct rio_detail *)ptr;
137 void __init setup_summit(void)
140 unsigned short offset;
141 int i, next_wpeg, next_bus = 0;
143 /* The pointer to the EBDA is stored in the word @ phys 0x40E(40:0E) */
144 ptr = get_bios_ebda();
145 ptr = (unsigned long)phys_to_virt(ptr);
147 rio_table_hdr = NULL;
150 /* The block id is stored in the 2nd word */
151 if (*((unsigned short *)(ptr + offset + 2)) == 0x4752) {
152 /* set the pointer past the offset & block id */
153 rio_table_hdr = (struct rio_table_hdr *)(ptr + offset + 4);
156 /* The next offset is stored in the 1st word. 0 means no more */
157 offset = *((unsigned short *)(ptr + offset));
159 if (!rio_table_hdr) {
160 printk(KERN_ERR "%s: Unable to locate Rio Grande Table in EBDA - bailing!\n", __func__);
164 if (!build_detail_arrays())
167 /* The first Winnipeg we're looking for has an index of 0 */
170 for (i = 0; i < rio_table_hdr->num_rio_dev; i++) {
171 if (is_WPEG(rio_devs[i]) && rio_devs[i]->WP_index == next_wpeg) {
172 /* It's the Winnipeg we're looking for! */
173 next_bus = setup_pci_node_map_for_wpeg(i, next_bus);
179 * If we go through all Rio devices and don't find one with
180 * the next index, it means we've found all the Winnipegs,
181 * and thus all the PCI buses.
183 if (i == rio_table_hdr->num_rio_dev)
185 } while (next_wpeg != 0);