2005-04-16 16:20:36 -06:00
|
|
|
/*
|
2007-10-12 19:10:53 -06:00
|
|
|
* IBM Summit-Specific Code
|
2005-04-16 16:20:36 -06:00
|
|
|
*
|
|
|
|
* Written By: Matthew Dobson, IBM Corporation
|
|
|
|
*
|
|
|
|
* Copyright (c) 2003 IBM Corp.
|
|
|
|
*
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or (at
|
|
|
|
* your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
|
|
|
|
* NON INFRINGEMENT. See the GNU General Public License for more
|
|
|
|
* details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
*
|
|
|
|
* Send feedback to <colpatch@us.ibm.com>
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/mm.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <asm/io.h>
|
2008-04-19 08:55:20 -06:00
|
|
|
#include <asm/bios_ebda.h>
|
2005-04-16 16:20:36 -06:00
|
|
|
#include <asm/mach-summit/mach_mpparse.h>
|
|
|
|
|
|
|
|
static struct rio_table_hdr *rio_table_hdr __initdata;
|
|
|
|
static struct scal_detail *scal_devs[MAX_NUMNODES] __initdata;
|
|
|
|
static struct rio_detail *rio_devs[MAX_NUMNODES*4] __initdata;
|
|
|
|
|
2008-06-08 19:31:54 -06:00
|
|
|
#ifndef CONFIG_X86_NUMAQ
|
2008-03-11 13:55:48 -06:00
|
|
|
static int mp_bus_id_to_node[MAX_MP_BUSSES] __initdata;
|
2008-06-08 19:31:54 -06:00
|
|
|
#endif
|
2008-03-11 13:55:48 -06:00
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
static int __init setup_pci_node_map_for_wpeg(int wpeg_num, int last_bus)
|
|
|
|
{
|
|
|
|
int twister = 0, node = 0;
|
|
|
|
int i, bus, num_buses;
|
|
|
|
|
2008-02-22 15:09:34 -07:00
|
|
|
for (i = 0; i < rio_table_hdr->num_rio_dev; i++) {
|
|
|
|
if (rio_devs[i]->node_id == rio_devs[wpeg_num]->owner_id) {
|
2005-04-16 16:20:36 -06:00
|
|
|
twister = rio_devs[i]->owner_id;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2008-02-22 15:09:34 -07:00
|
|
|
if (i == rio_table_hdr->num_rio_dev) {
|
2008-03-03 12:37:23 -07:00
|
|
|
printk(KERN_ERR "%s: Couldn't find owner Cyclone for Winnipeg!\n", __func__);
|
2005-04-16 16:20:36 -06:00
|
|
|
return last_bus;
|
|
|
|
}
|
|
|
|
|
2008-02-22 15:09:34 -07:00
|
|
|
for (i = 0; i < rio_table_hdr->num_scal_dev; i++) {
|
|
|
|
if (scal_devs[i]->node_id == twister) {
|
2005-04-16 16:20:36 -06:00
|
|
|
node = scal_devs[i]->node_id;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2008-02-22 15:09:34 -07:00
|
|
|
if (i == rio_table_hdr->num_scal_dev) {
|
2008-03-03 12:37:23 -07:00
|
|
|
printk(KERN_ERR "%s: Couldn't find owner Twister for Cyclone!\n", __func__);
|
2005-04-16 16:20:36 -06:00
|
|
|
return last_bus;
|
|
|
|
}
|
|
|
|
|
2008-02-22 15:09:34 -07:00
|
|
|
switch (rio_devs[wpeg_num]->type) {
|
2005-04-16 16:20:36 -06:00
|
|
|
case CompatWPEG:
|
2008-02-22 15:09:34 -07:00
|
|
|
/*
|
|
|
|
* The Compatibility Winnipeg controls the 2 legacy buses,
|
2005-04-16 16:20:36 -06:00
|
|
|
* the 66MHz PCI bus [2 slots] and the 2 "extra" buses in case
|
|
|
|
* a PCI-PCI bridge card is used in either slot: total 5 buses.
|
|
|
|
*/
|
|
|
|
num_buses = 5;
|
|
|
|
break;
|
|
|
|
case AltWPEG:
|
2008-02-22 15:09:34 -07:00
|
|
|
/*
|
|
|
|
* The Alternate Winnipeg controls the 2 133MHz buses [1 slot
|
2005-04-16 16:20:36 -06:00
|
|
|
* each], their 2 "extra" buses, the 100MHz bus [2 slots] and
|
|
|
|
* the "extra" buses for each of those slots: total 7 buses.
|
|
|
|
*/
|
|
|
|
num_buses = 7;
|
|
|
|
break;
|
|
|
|
case LookOutAWPEG:
|
|
|
|
case LookOutBWPEG:
|
2008-02-22 15:09:34 -07:00
|
|
|
/*
|
|
|
|
* A Lookout Winnipeg controls 3 100MHz buses [2 slots each]
|
2005-04-16 16:20:36 -06:00
|
|
|
* & the "extra" buses for each of those slots: total 9 buses.
|
|
|
|
*/
|
|
|
|
num_buses = 9;
|
|
|
|
break;
|
|
|
|
default:
|
2008-03-03 12:37:23 -07:00
|
|
|
printk(KERN_INFO "%s: Unsupported Winnipeg type!\n", __func__);
|
2005-04-16 16:20:36 -06:00
|
|
|
return last_bus;
|
|
|
|
}
|
|
|
|
|
2008-02-22 15:09:34 -07:00
|
|
|
for (bus = last_bus; bus < last_bus + num_buses; bus++)
|
2005-04-16 16:20:36 -06:00
|
|
|
mp_bus_id_to_node[bus] = node;
|
|
|
|
return bus;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int __init build_detail_arrays(void)
|
|
|
|
{
|
|
|
|
unsigned long ptr;
|
|
|
|
int i, scal_detail_size, rio_detail_size;
|
|
|
|
|
2008-02-22 15:09:34 -07:00
|
|
|
if (rio_table_hdr->num_scal_dev > MAX_NUMNODES) {
|
2008-03-03 12:37:23 -07:00
|
|
|
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);
|
2005-04-16 16:20:36 -06:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-02-22 15:09:34 -07:00
|
|
|
switch (rio_table_hdr->version) {
|
2005-04-16 16:20:36 -06:00
|
|
|
default:
|
2008-03-03 12:37:23 -07:00
|
|
|
printk(KERN_WARNING "%s: Invalid Rio Grande Table Version: %d\n", __func__, rio_table_hdr->version);
|
2005-04-16 16:20:36 -06:00
|
|
|
return 0;
|
|
|
|
case 2:
|
|
|
|
scal_detail_size = 11;
|
|
|
|
rio_detail_size = 13;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
scal_detail_size = 12;
|
|
|
|
rio_detail_size = 15;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
ptr = (unsigned long)rio_table_hdr + 3;
|
2008-02-22 15:09:34 -07:00
|
|
|
for (i = 0; i < rio_table_hdr->num_scal_dev; i++, ptr += scal_detail_size)
|
2005-04-16 16:20:36 -06:00
|
|
|
scal_devs[i] = (struct scal_detail *)ptr;
|
|
|
|
|
2008-02-22 15:09:34 -07:00
|
|
|
for (i = 0; i < rio_table_hdr->num_rio_dev; i++, ptr += rio_detail_size)
|
2005-04-16 16:20:36 -06:00
|
|
|
rio_devs[i] = (struct rio_detail *)ptr;
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void __init setup_summit(void)
|
|
|
|
{
|
|
|
|
unsigned long ptr;
|
|
|
|
unsigned short offset;
|
|
|
|
int i, next_wpeg, next_bus = 0;
|
|
|
|
|
|
|
|
/* The pointer to the EBDA is stored in the word @ phys 0x40E(40:0E) */
|
2008-04-19 08:55:20 -06:00
|
|
|
ptr = get_bios_ebda();
|
|
|
|
ptr = (unsigned long)phys_to_virt(ptr);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
rio_table_hdr = NULL;
|
|
|
|
offset = 0x180;
|
2008-02-22 15:09:34 -07:00
|
|
|
while (offset) {
|
2005-04-16 16:20:36 -06:00
|
|
|
/* The block id is stored in the 2nd word */
|
2008-02-22 15:09:34 -07:00
|
|
|
if (*((unsigned short *)(ptr + offset + 2)) == 0x4752) {
|
2005-04-16 16:20:36 -06:00
|
|
|
/* set the pointer past the offset & block id */
|
|
|
|
rio_table_hdr = (struct rio_table_hdr *)(ptr + offset + 4);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
/* The next offset is stored in the 1st word. 0 means no more */
|
|
|
|
offset = *((unsigned short *)(ptr + offset));
|
|
|
|
}
|
2008-02-22 15:09:34 -07:00
|
|
|
if (!rio_table_hdr) {
|
2008-03-03 12:37:23 -07:00
|
|
|
printk(KERN_ERR "%s: Unable to locate Rio Grande Table in EBDA - bailing!\n", __func__);
|
2005-04-16 16:20:36 -06:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!build_detail_arrays())
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* The first Winnipeg we're looking for has an index of 0 */
|
|
|
|
next_wpeg = 0;
|
|
|
|
do {
|
2008-02-22 15:09:34 -07:00
|
|
|
for (i = 0; i < rio_table_hdr->num_rio_dev; i++) {
|
|
|
|
if (is_WPEG(rio_devs[i]) && rio_devs[i]->WP_index == next_wpeg) {
|
2005-04-16 16:20:36 -06:00
|
|
|
/* It's the Winnipeg we're looking for! */
|
|
|
|
next_bus = setup_pci_node_map_for_wpeg(i, next_bus);
|
|
|
|
next_wpeg++;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* If we go through all Rio devices and don't find one with
|
|
|
|
* the next index, it means we've found all the Winnipegs,
|
|
|
|
* and thus all the PCI buses.
|
|
|
|
*/
|
|
|
|
if (i == rio_table_hdr->num_rio_dev)
|
|
|
|
next_wpeg = 0;
|
|
|
|
} while (next_wpeg != 0);
|
|
|
|
}
|