2018-01-26 20:22:04 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* IBM Hot Plug Controller Driver
|
|
|
|
*
|
|
|
|
* Written By: Tong Yu, IBM Corporation
|
|
|
|
*
|
|
|
|
* Copyright (C) 2001,2003 Greg Kroah-Hartman (greg@kroah.com)
|
|
|
|
* Copyright (C) 2001-2003 IBM Corp.
|
|
|
|
*
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Send feedback to <gregkh@us.ibm.com>
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/errno.h>
|
|
|
|
#include <linux/mm.h>
|
|
|
|
#include <linux/slab.h>
|
|
|
|
#include <linux/pci.h>
|
|
|
|
#include <linux/list.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include "ibmphp.h"
|
|
|
|
|
|
|
|
/*
|
|
|
|
* POST builds data blocks(in this data block definition, a char-1
|
|
|
|
* byte, short(or word)-2 byte, long(dword)-4 byte) in the Extended
|
|
|
|
* BIOS Data Area which describe the configuration of the hot-plug
|
|
|
|
* controllers and resources used by the PCI Hot-Plug devices.
|
|
|
|
*
|
|
|
|
* This file walks EBDA, maps data block from physical addr,
|
|
|
|
* reconstruct linked lists about all system resource(MEM, PFM, IO)
|
|
|
|
* already assigned by POST, as well as linked lists about hot plug
|
|
|
|
* controllers (ctlr#, slot#, bus&slot features...)
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Global lists */
|
2015-12-27 21:21:11 +00:00
|
|
|
LIST_HEAD(ibmphp_ebda_pci_rsrc_head);
|
|
|
|
LIST_HEAD(ibmphp_slot_head);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/* Local variables */
|
|
|
|
static struct ebda_hpc_list *hpc_list_ptr;
|
|
|
|
static struct ebda_rsrc_list *rsrc_list_ptr;
|
|
|
|
static struct rio_table_hdr *rio_table_ptr = NULL;
|
2015-12-27 21:21:11 +00:00
|
|
|
static LIST_HEAD(ebda_hpc_head);
|
|
|
|
static LIST_HEAD(bus_info_head);
|
|
|
|
static LIST_HEAD(rio_vg_head);
|
|
|
|
static LIST_HEAD(rio_lo_head);
|
|
|
|
static LIST_HEAD(opt_vg_head);
|
|
|
|
static LIST_HEAD(opt_lo_head);
|
2005-04-16 22:20:36 +00:00
|
|
|
static void __iomem *io_mem;
|
|
|
|
|
|
|
|
/* Local functions */
|
2015-12-27 21:21:11 +00:00
|
|
|
static int ebda_rsrc_controller(void);
|
|
|
|
static int ebda_rsrc_rsrc(void);
|
|
|
|
static int ebda_rio_table(void);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2015-12-27 21:21:11 +00:00
|
|
|
static struct ebda_hpc_list * __init alloc_ebda_hpc_list(void)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2006-02-28 14:34:49 +00:00
|
|
|
return kzalloc(sizeof(struct ebda_hpc_list), GFP_KERNEL);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2015-12-27 21:21:11 +00:00
|
|
|
static struct controller *alloc_ebda_hpc(u32 slot_count, u32 bus_count)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
struct controller *controller;
|
|
|
|
struct ebda_hpc_slot *slots;
|
|
|
|
struct ebda_hpc_bus *buses;
|
|
|
|
|
2006-02-28 14:34:49 +00:00
|
|
|
controller = kzalloc(sizeof(struct controller), GFP_KERNEL);
|
2005-04-16 22:20:36 +00:00
|
|
|
if (!controller)
|
|
|
|
goto error;
|
|
|
|
|
2006-02-28 14:34:49 +00:00
|
|
|
slots = kcalloc(slot_count, sizeof(struct ebda_hpc_slot), GFP_KERNEL);
|
2005-04-16 22:20:36 +00:00
|
|
|
if (!slots)
|
|
|
|
goto error_contr;
|
|
|
|
controller->slots = slots;
|
|
|
|
|
2006-02-28 14:34:49 +00:00
|
|
|
buses = kcalloc(bus_count, sizeof(struct ebda_hpc_bus), GFP_KERNEL);
|
2005-04-16 22:20:36 +00:00
|
|
|
if (!buses)
|
|
|
|
goto error_slots;
|
|
|
|
controller->buses = buses;
|
|
|
|
|
|
|
|
return controller;
|
|
|
|
error_slots:
|
|
|
|
kfree(controller->slots);
|
|
|
|
error_contr:
|
|
|
|
kfree(controller);
|
|
|
|
error:
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2015-12-27 21:21:11 +00:00
|
|
|
static void free_ebda_hpc(struct controller *controller)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2015-12-27 21:21:11 +00:00
|
|
|
kfree(controller->slots);
|
|
|
|
kfree(controller->buses);
|
|
|
|
kfree(controller);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2015-12-27 21:21:11 +00:00
|
|
|
static struct ebda_rsrc_list * __init alloc_ebda_rsrc_list(void)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2006-02-28 14:34:49 +00:00
|
|
|
return kzalloc(sizeof(struct ebda_rsrc_list), GFP_KERNEL);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2015-12-27 21:21:11 +00:00
|
|
|
static struct ebda_pci_rsrc *alloc_ebda_pci_rsrc(void)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2006-02-28 14:34:49 +00:00
|
|
|
return kzalloc(sizeof(struct ebda_pci_rsrc), GFP_KERNEL);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2015-12-27 21:21:11 +00:00
|
|
|
static void __init print_bus_info(void)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
struct bus_info *ptr;
|
2013-11-14 18:28:18 +00:00
|
|
|
|
2008-08-22 20:30:14 +00:00
|
|
|
list_for_each_entry(ptr, &bus_info_head, bus_info_list) {
|
2015-12-27 21:21:11 +00:00
|
|
|
debug("%s - slot_min = %x\n", __func__, ptr->slot_min);
|
|
|
|
debug("%s - slot_max = %x\n", __func__, ptr->slot_max);
|
|
|
|
debug("%s - slot_count = %x\n", __func__, ptr->slot_count);
|
|
|
|
debug("%s - bus# = %x\n", __func__, ptr->busno);
|
|
|
|
debug("%s - current_speed = %x\n", __func__, ptr->current_speed);
|
|
|
|
debug("%s - controller_id = %x\n", __func__, ptr->controller_id);
|
|
|
|
|
|
|
|
debug("%s - slots_at_33_conv = %x\n", __func__, ptr->slots_at_33_conv);
|
|
|
|
debug("%s - slots_at_66_conv = %x\n", __func__, ptr->slots_at_66_conv);
|
|
|
|
debug("%s - slots_at_66_pcix = %x\n", __func__, ptr->slots_at_66_pcix);
|
|
|
|
debug("%s - slots_at_100_pcix = %x\n", __func__, ptr->slots_at_100_pcix);
|
|
|
|
debug("%s - slots_at_133_pcix = %x\n", __func__, ptr->slots_at_133_pcix);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-27 21:21:11 +00:00
|
|
|
static void print_lo_info(void)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
struct rio_detail *ptr;
|
2015-12-27 21:21:11 +00:00
|
|
|
debug("print_lo_info ----\n");
|
2008-08-22 20:30:14 +00:00
|
|
|
list_for_each_entry(ptr, &rio_lo_head, rio_detail_list) {
|
2015-12-27 21:21:11 +00:00
|
|
|
debug("%s - rio_node_id = %x\n", __func__, ptr->rio_node_id);
|
|
|
|
debug("%s - rio_type = %x\n", __func__, ptr->rio_type);
|
|
|
|
debug("%s - owner_id = %x\n", __func__, ptr->owner_id);
|
|
|
|
debug("%s - first_slot_num = %x\n", __func__, ptr->first_slot_num);
|
|
|
|
debug("%s - wpindex = %x\n", __func__, ptr->wpindex);
|
|
|
|
debug("%s - chassis_num = %x\n", __func__, ptr->chassis_num);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-27 21:21:11 +00:00
|
|
|
static void print_vg_info(void)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
struct rio_detail *ptr;
|
2015-12-27 21:21:11 +00:00
|
|
|
debug("%s ---\n", __func__);
|
2008-08-22 20:30:14 +00:00
|
|
|
list_for_each_entry(ptr, &rio_vg_head, rio_detail_list) {
|
2015-12-27 21:21:11 +00:00
|
|
|
debug("%s - rio_node_id = %x\n", __func__, ptr->rio_node_id);
|
|
|
|
debug("%s - rio_type = %x\n", __func__, ptr->rio_type);
|
|
|
|
debug("%s - owner_id = %x\n", __func__, ptr->owner_id);
|
|
|
|
debug("%s - first_slot_num = %x\n", __func__, ptr->first_slot_num);
|
|
|
|
debug("%s - wpindex = %x\n", __func__, ptr->wpindex);
|
|
|
|
debug("%s - chassis_num = %x\n", __func__, ptr->chassis_num);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-27 21:21:11 +00:00
|
|
|
static void __init print_ebda_pci_rsrc(void)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
struct ebda_pci_rsrc *ptr;
|
|
|
|
|
2008-08-22 20:30:14 +00:00
|
|
|
list_for_each_entry(ptr, &ibmphp_ebda_pci_rsrc_head, ebda_pci_rsrc_list) {
|
2015-12-27 21:21:11 +00:00
|
|
|
debug("%s - rsrc type: %x bus#: %x dev_func: %x start addr: %x end addr: %x\n",
|
|
|
|
__func__, ptr->rsrc_type, ptr->bus_num, ptr->dev_fun, ptr->start_addr, ptr->end_addr);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-27 21:21:11 +00:00
|
|
|
static void __init print_ibm_slot(void)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
struct slot *ptr;
|
|
|
|
|
2008-08-22 20:30:14 +00:00
|
|
|
list_for_each_entry(ptr, &ibmphp_slot_head, ibm_slot_list) {
|
2015-12-27 21:21:11 +00:00
|
|
|
debug("%s - slot_number: %x\n", __func__, ptr->number);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-27 21:21:11 +00:00
|
|
|
static void __init print_opt_vg(void)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
struct opt_rio *ptr;
|
2015-12-27 21:21:11 +00:00
|
|
|
debug("%s ---\n", __func__);
|
2008-08-22 20:30:14 +00:00
|
|
|
list_for_each_entry(ptr, &opt_vg_head, opt_rio_list) {
|
2015-12-27 21:21:11 +00:00
|
|
|
debug("%s - rio_type %x\n", __func__, ptr->rio_type);
|
|
|
|
debug("%s - chassis_num: %x\n", __func__, ptr->chassis_num);
|
|
|
|
debug("%s - first_slot_num: %x\n", __func__, ptr->first_slot_num);
|
|
|
|
debug("%s - middle_num: %x\n", __func__, ptr->middle_num);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-27 21:21:11 +00:00
|
|
|
static void __init print_ebda_hpc(void)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
struct controller *hpc_ptr;
|
|
|
|
u16 index;
|
|
|
|
|
2008-08-22 20:30:14 +00:00
|
|
|
list_for_each_entry(hpc_ptr, &ebda_hpc_head, ebda_hpc_list) {
|
2005-04-16 22:20:36 +00:00
|
|
|
for (index = 0; index < hpc_ptr->slot_count; index++) {
|
2015-12-27 21:21:11 +00:00
|
|
|
debug("%s - physical slot#: %x\n", __func__, hpc_ptr->slots[index].slot_num);
|
|
|
|
debug("%s - pci bus# of the slot: %x\n", __func__, hpc_ptr->slots[index].slot_bus_num);
|
|
|
|
debug("%s - index into ctlr addr: %x\n", __func__, hpc_ptr->slots[index].ctl_index);
|
|
|
|
debug("%s - cap of the slot: %x\n", __func__, hpc_ptr->slots[index].slot_cap);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2014-09-07 18:02:47 +00:00
|
|
|
for (index = 0; index < hpc_ptr->bus_count; index++)
|
2015-12-27 21:21:11 +00:00
|
|
|
debug("%s - bus# of each bus controlled by this ctlr: %x\n", __func__, hpc_ptr->buses[index].bus_num);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2015-12-27 21:21:11 +00:00
|
|
|
debug("%s - type of hpc: %x\n", __func__, hpc_ptr->ctlr_type);
|
2005-04-16 22:20:36 +00:00
|
|
|
switch (hpc_ptr->ctlr_type) {
|
|
|
|
case 1:
|
2015-12-27 21:21:11 +00:00
|
|
|
debug("%s - bus: %x\n", __func__, hpc_ptr->u.pci_ctlr.bus);
|
|
|
|
debug("%s - dev_fun: %x\n", __func__, hpc_ptr->u.pci_ctlr.dev_fun);
|
|
|
|
debug("%s - irq: %x\n", __func__, hpc_ptr->irq);
|
2005-04-16 22:20:36 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0:
|
2015-12-27 21:21:11 +00:00
|
|
|
debug("%s - io_start: %x\n", __func__, hpc_ptr->u.isa_ctlr.io_start);
|
|
|
|
debug("%s - io_end: %x\n", __func__, hpc_ptr->u.isa_ctlr.io_end);
|
|
|
|
debug("%s - irq: %x\n", __func__, hpc_ptr->irq);
|
2005-04-16 22:20:36 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
case 4:
|
2015-12-27 21:21:11 +00:00
|
|
|
debug("%s - wpegbbar: %lx\n", __func__, hpc_ptr->u.wpeg_ctlr.wpegbbar);
|
|
|
|
debug("%s - i2c_addr: %x\n", __func__, hpc_ptr->u.wpeg_ctlr.i2c_addr);
|
|
|
|
debug("%s - irq: %x\n", __func__, hpc_ptr->irq);
|
2005-04-16 22:20:36 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-27 21:21:11 +00:00
|
|
|
int __init ibmphp_access_ebda(void)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2010-01-11 06:19:21 +00:00
|
|
|
u8 format, num_ctlrs, rio_complete, hs_complete, ebda_sz;
|
2005-04-16 22:20:36 +00:00
|
|
|
u16 ebda_seg, num_entries, next_offset, offset, blk_id, sub_addr, re, rc_id, re_id, base;
|
|
|
|
int rc = 0;
|
|
|
|
|
|
|
|
|
|
|
|
rio_complete = 0;
|
|
|
|
hs_complete = 0;
|
|
|
|
|
2015-12-27 21:21:11 +00:00
|
|
|
io_mem = ioremap((0x40 << 4) + 0x0e, 2);
|
|
|
|
if (!io_mem)
|
2005-04-16 22:20:36 +00:00
|
|
|
return -ENOMEM;
|
2015-12-27 21:21:11 +00:00
|
|
|
ebda_seg = readw(io_mem);
|
|
|
|
iounmap(io_mem);
|
|
|
|
debug("returned ebda segment: %x\n", ebda_seg);
|
2013-11-14 18:28:18 +00:00
|
|
|
|
2010-01-11 06:19:21 +00:00
|
|
|
io_mem = ioremap(ebda_seg<<4, 1);
|
2010-02-02 22:45:54 +00:00
|
|
|
if (!io_mem)
|
|
|
|
return -ENOMEM;
|
2010-01-11 06:19:21 +00:00
|
|
|
ebda_sz = readb(io_mem);
|
|
|
|
iounmap(io_mem);
|
|
|
|
debug("ebda size: %d(KiB)\n", ebda_sz);
|
|
|
|
if (ebda_sz == 0)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
io_mem = ioremap(ebda_seg<<4, (ebda_sz * 1024));
|
2015-12-27 21:21:11 +00:00
|
|
|
if (!io_mem)
|
2005-04-16 22:20:36 +00:00
|
|
|
return -ENOMEM;
|
|
|
|
next_offset = 0x180;
|
|
|
|
|
|
|
|
for (;;) {
|
|
|
|
offset = next_offset;
|
2010-11-09 04:20:27 +00:00
|
|
|
|
|
|
|
/* Make sure what we read is still in the mapped section */
|
|
|
|
if (WARN(offset > (ebda_sz * 1024 - 4),
|
|
|
|
"ibmphp_ebda: next read is beyond ebda_sz\n"))
|
|
|
|
break;
|
|
|
|
|
2015-12-27 21:21:11 +00:00
|
|
|
next_offset = readw(io_mem + offset); /* offset of next blk */
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
offset += 2;
|
|
|
|
if (next_offset == 0) /* 0 indicate it's last blk */
|
|
|
|
break;
|
2015-12-27 21:21:11 +00:00
|
|
|
blk_id = readw(io_mem + offset); /* this blk id */
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
offset += 2;
|
|
|
|
/* check if it is hot swap block or rio block */
|
|
|
|
if (blk_id != 0x4853 && blk_id != 0x4752)
|
|
|
|
continue;
|
|
|
|
/* found hs table */
|
|
|
|
if (blk_id == 0x4853) {
|
2015-12-27 21:21:11 +00:00
|
|
|
debug("now enter hot swap block---\n");
|
|
|
|
debug("hot blk id: %x\n", blk_id);
|
|
|
|
format = readb(io_mem + offset);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
offset += 1;
|
|
|
|
if (format != 4)
|
|
|
|
goto error_nodev;
|
2015-12-27 21:21:11 +00:00
|
|
|
debug("hot blk format: %x\n", format);
|
2005-04-16 22:20:36 +00:00
|
|
|
/* hot swap sub blk */
|
|
|
|
base = offset;
|
|
|
|
|
|
|
|
sub_addr = base;
|
2015-12-27 21:21:11 +00:00
|
|
|
re = readw(io_mem + sub_addr); /* next sub blk */
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
sub_addr += 2;
|
2015-12-27 21:21:11 +00:00
|
|
|
rc_id = readw(io_mem + sub_addr); /* sub blk id */
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
sub_addr += 2;
|
|
|
|
if (rc_id != 0x5243)
|
|
|
|
goto error_nodev;
|
|
|
|
/* rc sub blk signature */
|
2015-12-27 21:21:11 +00:00
|
|
|
num_ctlrs = readb(io_mem + sub_addr);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
sub_addr += 1;
|
2015-12-27 21:21:11 +00:00
|
|
|
hpc_list_ptr = alloc_ebda_hpc_list();
|
2005-04-16 22:20:36 +00:00
|
|
|
if (!hpc_list_ptr) {
|
|
|
|
rc = -ENOMEM;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
hpc_list_ptr->format = format;
|
|
|
|
hpc_list_ptr->num_ctlrs = num_ctlrs;
|
|
|
|
hpc_list_ptr->phys_addr = sub_addr; /* offset of RSRC_CONTROLLER blk */
|
2015-12-27 21:21:11 +00:00
|
|
|
debug("info about hpc descriptor---\n");
|
|
|
|
debug("hot blk format: %x\n", format);
|
|
|
|
debug("num of controller: %x\n", num_ctlrs);
|
|
|
|
debug("offset of hpc data structure entries: %x\n ", sub_addr);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
sub_addr = base + re; /* re sub blk */
|
|
|
|
/* FIXME: rc is never used/checked */
|
2015-12-27 21:21:11 +00:00
|
|
|
rc = readw(io_mem + sub_addr); /* next sub blk */
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
sub_addr += 2;
|
2015-12-27 21:21:11 +00:00
|
|
|
re_id = readw(io_mem + sub_addr); /* sub blk id */
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
sub_addr += 2;
|
|
|
|
if (re_id != 0x5245)
|
|
|
|
goto error_nodev;
|
|
|
|
|
|
|
|
/* signature of re */
|
2015-12-27 21:21:11 +00:00
|
|
|
num_entries = readw(io_mem + sub_addr);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
sub_addr += 2; /* offset of RSRC_ENTRIES blk */
|
2015-12-27 21:21:11 +00:00
|
|
|
rsrc_list_ptr = alloc_ebda_rsrc_list();
|
|
|
|
if (!rsrc_list_ptr) {
|
2005-04-16 22:20:36 +00:00
|
|
|
rc = -ENOMEM;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
rsrc_list_ptr->format = format;
|
|
|
|
rsrc_list_ptr->num_entries = num_entries;
|
|
|
|
rsrc_list_ptr->phys_addr = sub_addr;
|
|
|
|
|
2015-12-27 21:21:11 +00:00
|
|
|
debug("info about rsrc descriptor---\n");
|
|
|
|
debug("format: %x\n", format);
|
|
|
|
debug("num of rsrc: %x\n", num_entries);
|
|
|
|
debug("offset of rsrc data structure entries: %x\n ", sub_addr);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
hs_complete = 1;
|
|
|
|
} else {
|
|
|
|
/* found rio table, blk_id == 0x4752 */
|
2015-12-27 21:21:11 +00:00
|
|
|
debug("now enter io table ---\n");
|
|
|
|
debug("rio blk id: %x\n", blk_id);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2006-02-28 14:34:49 +00:00
|
|
|
rio_table_ptr = kzalloc(sizeof(struct rio_table_hdr), GFP_KERNEL);
|
2012-01-12 09:55:16 +00:00
|
|
|
if (!rio_table_ptr) {
|
|
|
|
rc = -ENOMEM;
|
|
|
|
goto out;
|
|
|
|
}
|
2015-12-27 21:21:11 +00:00
|
|
|
rio_table_ptr->ver_num = readb(io_mem + offset);
|
|
|
|
rio_table_ptr->scal_count = readb(io_mem + offset + 1);
|
|
|
|
rio_table_ptr->riodev_count = readb(io_mem + offset + 2);
|
|
|
|
rio_table_ptr->offset = offset + 3 ;
|
2013-11-14 18:28:18 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
debug("info about rio table hdr ---\n");
|
|
|
|
debug("ver_num: %x\nscal_count: %x\nriodev_count: %x\noffset of rio table: %x\n ",
|
|
|
|
rio_table_ptr->ver_num, rio_table_ptr->scal_count,
|
|
|
|
rio_table_ptr->riodev_count, rio_table_ptr->offset);
|
|
|
|
|
|
|
|
rio_complete = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!hs_complete && !rio_complete)
|
|
|
|
goto error_nodev;
|
|
|
|
|
|
|
|
if (rio_table_ptr) {
|
|
|
|
if (rio_complete && rio_table_ptr->ver_num == 3) {
|
2015-12-27 21:21:11 +00:00
|
|
|
rc = ebda_rio_table();
|
2005-04-16 22:20:36 +00:00
|
|
|
if (rc)
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
}
|
2015-12-27 21:21:11 +00:00
|
|
|
rc = ebda_rsrc_controller();
|
2005-04-16 22:20:36 +00:00
|
|
|
if (rc)
|
|
|
|
goto out;
|
|
|
|
|
2015-12-27 21:21:11 +00:00
|
|
|
rc = ebda_rsrc_rsrc();
|
2005-04-16 22:20:36 +00:00
|
|
|
goto out;
|
|
|
|
error_nodev:
|
|
|
|
rc = -ENODEV;
|
|
|
|
out:
|
2015-12-27 21:21:11 +00:00
|
|
|
iounmap(io_mem);
|
2005-04-16 22:20:36 +00:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* map info of scalability details and rio details from physical address
|
|
|
|
*/
|
2015-12-27 21:21:11 +00:00
|
|
|
static int __init ebda_rio_table(void)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
u16 offset;
|
|
|
|
u8 i;
|
|
|
|
struct rio_detail *rio_detail_ptr;
|
|
|
|
|
|
|
|
offset = rio_table_ptr->offset;
|
|
|
|
offset += 12 * rio_table_ptr->scal_count;
|
|
|
|
|
|
|
|
// we do concern about rio details
|
|
|
|
for (i = 0; i < rio_table_ptr->riodev_count; i++) {
|
2006-02-28 14:34:49 +00:00
|
|
|
rio_detail_ptr = kzalloc(sizeof(struct rio_detail), GFP_KERNEL);
|
2005-04-16 22:20:36 +00:00
|
|
|
if (!rio_detail_ptr)
|
|
|
|
return -ENOMEM;
|
2015-12-27 21:21:11 +00:00
|
|
|
rio_detail_ptr->rio_node_id = readb(io_mem + offset);
|
|
|
|
rio_detail_ptr->bbar = readl(io_mem + offset + 1);
|
|
|
|
rio_detail_ptr->rio_type = readb(io_mem + offset + 5);
|
|
|
|
rio_detail_ptr->owner_id = readb(io_mem + offset + 6);
|
|
|
|
rio_detail_ptr->port0_node_connect = readb(io_mem + offset + 7);
|
|
|
|
rio_detail_ptr->port0_port_connect = readb(io_mem + offset + 8);
|
|
|
|
rio_detail_ptr->port1_node_connect = readb(io_mem + offset + 9);
|
|
|
|
rio_detail_ptr->port1_port_connect = readb(io_mem + offset + 10);
|
|
|
|
rio_detail_ptr->first_slot_num = readb(io_mem + offset + 11);
|
|
|
|
rio_detail_ptr->status = readb(io_mem + offset + 12);
|
|
|
|
rio_detail_ptr->wpindex = readb(io_mem + offset + 13);
|
|
|
|
rio_detail_ptr->chassis_num = readb(io_mem + offset + 14);
|
|
|
|
// debug("rio_node_id: %x\nbbar: %x\nrio_type: %x\nowner_id: %x\nport0_node: %x\nport0_port: %x\nport1_node: %x\nport1_port: %x\nfirst_slot_num: %x\nstatus: %x\n", rio_detail_ptr->rio_node_id, rio_detail_ptr->bbar, rio_detail_ptr->rio_type, rio_detail_ptr->owner_id, rio_detail_ptr->port0_node_connect, rio_detail_ptr->port0_port_connect, rio_detail_ptr->port1_node_connect, rio_detail_ptr->port1_port_connect, rio_detail_ptr->first_slot_num, rio_detail_ptr->status);
|
2005-04-16 22:20:36 +00:00
|
|
|
//create linked list of chassis
|
2013-11-14 18:28:18 +00:00
|
|
|
if (rio_detail_ptr->rio_type == 4 || rio_detail_ptr->rio_type == 5)
|
2015-12-27 21:21:11 +00:00
|
|
|
list_add(&rio_detail_ptr->rio_detail_list, &rio_vg_head);
|
2013-11-14 18:28:18 +00:00
|
|
|
//create linked list of expansion box
|
|
|
|
else if (rio_detail_ptr->rio_type == 6 || rio_detail_ptr->rio_type == 7)
|
2015-12-27 21:21:11 +00:00
|
|
|
list_add(&rio_detail_ptr->rio_detail_list, &rio_lo_head);
|
2013-11-14 18:28:18 +00:00
|
|
|
else
|
2005-04-16 22:20:36 +00:00
|
|
|
// not in my concern
|
2015-12-27 21:21:11 +00:00
|
|
|
kfree(rio_detail_ptr);
|
2005-04-16 22:20:36 +00:00
|
|
|
offset += 15;
|
|
|
|
}
|
2015-12-27 21:21:11 +00:00
|
|
|
print_lo_info();
|
|
|
|
print_vg_info();
|
2005-04-16 22:20:36 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2013-11-14 18:28:18 +00:00
|
|
|
* reorganizing linked list of chassis
|
2005-04-16 22:20:36 +00:00
|
|
|
*/
|
2015-12-27 21:21:11 +00:00
|
|
|
static struct opt_rio *search_opt_vg(u8 chassis_num)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
struct opt_rio *ptr;
|
2008-08-22 20:30:14 +00:00
|
|
|
list_for_each_entry(ptr, &opt_vg_head, opt_rio_list) {
|
2005-04-16 22:20:36 +00:00
|
|
|
if (ptr->chassis_num == chassis_num)
|
|
|
|
return ptr;
|
2013-11-14 18:28:18 +00:00
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2015-12-27 21:21:11 +00:00
|
|
|
static int __init combine_wpg_for_chassis(void)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
struct opt_rio *opt_rio_ptr = NULL;
|
|
|
|
struct rio_detail *rio_detail_ptr = NULL;
|
2013-11-14 18:28:18 +00:00
|
|
|
|
2008-08-22 20:30:14 +00:00
|
|
|
list_for_each_entry(rio_detail_ptr, &rio_vg_head, rio_detail_list) {
|
2015-12-27 21:21:11 +00:00
|
|
|
opt_rio_ptr = search_opt_vg(rio_detail_ptr->chassis_num);
|
2005-04-16 22:20:36 +00:00
|
|
|
if (!opt_rio_ptr) {
|
2006-02-28 14:34:49 +00:00
|
|
|
opt_rio_ptr = kzalloc(sizeof(struct opt_rio), GFP_KERNEL);
|
2005-04-16 22:20:36 +00:00
|
|
|
if (!opt_rio_ptr)
|
|
|
|
return -ENOMEM;
|
|
|
|
opt_rio_ptr->rio_type = rio_detail_ptr->rio_type;
|
|
|
|
opt_rio_ptr->chassis_num = rio_detail_ptr->chassis_num;
|
|
|
|
opt_rio_ptr->first_slot_num = rio_detail_ptr->first_slot_num;
|
|
|
|
opt_rio_ptr->middle_num = rio_detail_ptr->first_slot_num;
|
2015-12-27 21:21:11 +00:00
|
|
|
list_add(&opt_rio_ptr->opt_rio_list, &opt_vg_head);
|
2013-11-14 18:28:18 +00:00
|
|
|
} else {
|
2015-12-27 21:21:11 +00:00
|
|
|
opt_rio_ptr->first_slot_num = min(opt_rio_ptr->first_slot_num, rio_detail_ptr->first_slot_num);
|
|
|
|
opt_rio_ptr->middle_num = max(opt_rio_ptr->middle_num, rio_detail_ptr->first_slot_num);
|
2013-11-14 18:28:18 +00:00
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
2015-12-27 21:21:11 +00:00
|
|
|
print_opt_vg();
|
2013-11-14 18:28:18 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/*
|
2008-08-22 20:28:17 +00:00
|
|
|
* reorganizing linked list of expansion box
|
2005-04-16 22:20:36 +00:00
|
|
|
*/
|
2015-12-27 21:21:11 +00:00
|
|
|
static struct opt_rio_lo *search_opt_lo(u8 chassis_num)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
struct opt_rio_lo *ptr;
|
2008-08-22 20:30:14 +00:00
|
|
|
list_for_each_entry(ptr, &opt_lo_head, opt_rio_lo_list) {
|
2005-04-16 22:20:36 +00:00
|
|
|
if (ptr->chassis_num == chassis_num)
|
|
|
|
return ptr;
|
2013-11-14 18:28:18 +00:00
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2015-12-27 21:21:11 +00:00
|
|
|
static int combine_wpg_for_expansion(void)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
struct opt_rio_lo *opt_rio_lo_ptr = NULL;
|
|
|
|
struct rio_detail *rio_detail_ptr = NULL;
|
2013-11-14 18:28:18 +00:00
|
|
|
|
2008-08-22 20:30:14 +00:00
|
|
|
list_for_each_entry(rio_detail_ptr, &rio_lo_head, rio_detail_list) {
|
2015-12-27 21:21:11 +00:00
|
|
|
opt_rio_lo_ptr = search_opt_lo(rio_detail_ptr->chassis_num);
|
2005-04-16 22:20:36 +00:00
|
|
|
if (!opt_rio_lo_ptr) {
|
2006-02-28 14:34:49 +00:00
|
|
|
opt_rio_lo_ptr = kzalloc(sizeof(struct opt_rio_lo), GFP_KERNEL);
|
2005-04-16 22:20:36 +00:00
|
|
|
if (!opt_rio_lo_ptr)
|
|
|
|
return -ENOMEM;
|
|
|
|
opt_rio_lo_ptr->rio_type = rio_detail_ptr->rio_type;
|
|
|
|
opt_rio_lo_ptr->chassis_num = rio_detail_ptr->chassis_num;
|
|
|
|
opt_rio_lo_ptr->first_slot_num = rio_detail_ptr->first_slot_num;
|
|
|
|
opt_rio_lo_ptr->middle_num = rio_detail_ptr->first_slot_num;
|
|
|
|
opt_rio_lo_ptr->pack_count = 1;
|
2013-11-14 18:28:18 +00:00
|
|
|
|
2015-12-27 21:21:11 +00:00
|
|
|
list_add(&opt_rio_lo_ptr->opt_rio_lo_list, &opt_lo_head);
|
2013-11-14 18:28:18 +00:00
|
|
|
} else {
|
2015-12-27 21:21:11 +00:00
|
|
|
opt_rio_lo_ptr->first_slot_num = min(opt_rio_lo_ptr->first_slot_num, rio_detail_ptr->first_slot_num);
|
|
|
|
opt_rio_lo_ptr->middle_num = max(opt_rio_lo_ptr->middle_num, rio_detail_ptr->first_slot_num);
|
2005-04-16 22:20:36 +00:00
|
|
|
opt_rio_lo_ptr->pack_count = 2;
|
2013-11-14 18:28:18 +00:00
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
2013-11-14 18:28:18 +00:00
|
|
|
return 0;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
2013-11-14 18:28:18 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/* Since we don't know the max slot number per each chassis, hence go
|
|
|
|
* through the list of all chassis to find out the range
|
2013-11-14 18:28:18 +00:00
|
|
|
* Arguments: slot_num, 1st slot number of the chassis we think we are on,
|
|
|
|
* var (0 = chassis, 1 = expansion box)
|
2005-04-16 22:20:36 +00:00
|
|
|
*/
|
2015-12-27 21:21:11 +00:00
|
|
|
static int first_slot_num(u8 slot_num, u8 first_slot, u8 var)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
struct opt_rio *opt_vg_ptr = NULL;
|
|
|
|
struct opt_rio_lo *opt_lo_ptr = NULL;
|
|
|
|
int rc = 0;
|
|
|
|
|
|
|
|
if (!var) {
|
2008-08-22 20:30:14 +00:00
|
|
|
list_for_each_entry(opt_vg_ptr, &opt_vg_head, opt_rio_list) {
|
2013-11-14 18:28:18 +00:00
|
|
|
if ((first_slot < opt_vg_ptr->first_slot_num) && (slot_num >= opt_vg_ptr->first_slot_num)) {
|
2005-04-16 22:20:36 +00:00
|
|
|
rc = -ENODEV;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
2008-08-22 20:30:14 +00:00
|
|
|
list_for_each_entry(opt_lo_ptr, &opt_lo_head, opt_rio_lo_list) {
|
2005-04-16 22:20:36 +00:00
|
|
|
if ((first_slot < opt_lo_ptr->first_slot_num) && (slot_num >= opt_lo_ptr->first_slot_num)) {
|
|
|
|
rc = -ENODEV;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2015-12-27 21:21:11 +00:00
|
|
|
static struct opt_rio_lo *find_rxe_num(u8 slot_num)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
struct opt_rio_lo *opt_lo_ptr;
|
|
|
|
|
2008-08-22 20:30:14 +00:00
|
|
|
list_for_each_entry(opt_lo_ptr, &opt_lo_head, opt_rio_lo_list) {
|
2005-04-16 22:20:36 +00:00
|
|
|
//check to see if this slot_num belongs to expansion box
|
2015-12-27 21:21:11 +00:00
|
|
|
if ((slot_num >= opt_lo_ptr->first_slot_num) && (!first_slot_num(slot_num, opt_lo_ptr->first_slot_num, 1)))
|
2005-04-16 22:20:36 +00:00
|
|
|
return opt_lo_ptr;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2015-12-27 21:21:11 +00:00
|
|
|
static struct opt_rio *find_chassis_num(u8 slot_num)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
struct opt_rio *opt_vg_ptr;
|
|
|
|
|
2008-08-22 20:30:14 +00:00
|
|
|
list_for_each_entry(opt_vg_ptr, &opt_vg_head, opt_rio_list) {
|
2013-11-14 18:28:18 +00:00
|
|
|
//check to see if this slot_num belongs to chassis
|
2015-12-27 21:21:11 +00:00
|
|
|
if ((slot_num >= opt_vg_ptr->first_slot_num) && (!first_slot_num(slot_num, opt_vg_ptr->first_slot_num, 0)))
|
2005-04-16 22:20:36 +00:00
|
|
|
return opt_vg_ptr;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* This routine will find out how many slots are in the chassis, so that
|
|
|
|
* the slot numbers for rxe100 would start from 1, and not from 7, or 6 etc
|
|
|
|
*/
|
2015-12-27 21:21:11 +00:00
|
|
|
static u8 calculate_first_slot(u8 slot_num)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
u8 first_slot = 1;
|
2014-04-19 00:13:49 +00:00
|
|
|
struct slot *slot_cur;
|
2013-11-14 18:28:18 +00:00
|
|
|
|
2008-08-22 20:30:14 +00:00
|
|
|
list_for_each_entry(slot_cur, &ibmphp_slot_head, ibm_slot_list) {
|
2005-04-16 22:20:36 +00:00
|
|
|
if (slot_cur->ctrl) {
|
2013-11-14 18:28:18 +00:00
|
|
|
if ((slot_cur->ctrl->ctlr_type != 4) && (slot_cur->ctrl->ending_slot_num > first_slot) && (slot_num > slot_cur->ctrl->ending_slot_num))
|
2005-04-16 22:20:36 +00:00
|
|
|
first_slot = slot_cur->ctrl->ending_slot_num;
|
|
|
|
}
|
2013-11-14 18:28:18 +00:00
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
return first_slot + 1;
|
|
|
|
|
|
|
|
}
|
2008-10-20 23:41:33 +00:00
|
|
|
|
|
|
|
#define SLOT_NAME_SIZE 30
|
|
|
|
|
2015-12-27 21:21:11 +00:00
|
|
|
static char *create_file_name(struct slot *slot_cur)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
struct opt_rio *opt_vg_ptr = NULL;
|
|
|
|
struct opt_rio_lo *opt_lo_ptr = NULL;
|
2008-10-20 23:41:33 +00:00
|
|
|
static char str[SLOT_NAME_SIZE];
|
2005-04-16 22:20:36 +00:00
|
|
|
int which = 0; /* rxe = 1, chassis = 0 */
|
|
|
|
u8 number = 1; /* either chassis or rxe # */
|
|
|
|
u8 first_slot = 1;
|
|
|
|
u8 slot_num;
|
|
|
|
u8 flag = 0;
|
|
|
|
|
|
|
|
if (!slot_cur) {
|
2015-12-27 21:21:11 +00:00
|
|
|
err("Structure passed is empty\n");
|
2005-04-16 22:20:36 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
2013-11-14 18:28:18 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
slot_num = slot_cur->number;
|
|
|
|
|
2015-12-27 21:21:11 +00:00
|
|
|
memset(str, 0, sizeof(str));
|
2013-11-14 18:28:18 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
if (rio_table_ptr) {
|
|
|
|
if (rio_table_ptr->ver_num == 3) {
|
2015-12-27 21:21:11 +00:00
|
|
|
opt_vg_ptr = find_chassis_num(slot_num);
|
|
|
|
opt_lo_ptr = find_rxe_num(slot_num);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (opt_vg_ptr) {
|
|
|
|
if (opt_lo_ptr) {
|
|
|
|
if ((slot_num - opt_vg_ptr->first_slot_num) > (slot_num - opt_lo_ptr->first_slot_num)) {
|
|
|
|
number = opt_lo_ptr->chassis_num;
|
|
|
|
first_slot = opt_lo_ptr->first_slot_num;
|
|
|
|
which = 1; /* it is RXE */
|
|
|
|
} else {
|
|
|
|
first_slot = opt_vg_ptr->first_slot_num;
|
|
|
|
number = opt_vg_ptr->chassis_num;
|
|
|
|
which = 0;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
first_slot = opt_vg_ptr->first_slot_num;
|
|
|
|
number = opt_vg_ptr->chassis_num;
|
|
|
|
which = 0;
|
|
|
|
}
|
|
|
|
++flag;
|
|
|
|
} else if (opt_lo_ptr) {
|
|
|
|
number = opt_lo_ptr->chassis_num;
|
|
|
|
first_slot = opt_lo_ptr->first_slot_num;
|
|
|
|
which = 1;
|
|
|
|
++flag;
|
|
|
|
} else if (rio_table_ptr) {
|
|
|
|
if (rio_table_ptr->ver_num == 3) {
|
|
|
|
/* if both NULL and we DO have correct RIO table in BIOS */
|
|
|
|
return NULL;
|
|
|
|
}
|
2013-11-14 18:28:18 +00:00
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
if (!flag) {
|
|
|
|
if (slot_cur->ctrl->ctlr_type == 4) {
|
2015-12-27 21:21:11 +00:00
|
|
|
first_slot = calculate_first_slot(slot_num);
|
2005-04-16 22:20:36 +00:00
|
|
|
which = 1;
|
|
|
|
} else {
|
|
|
|
which = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sprintf(str, "%s%dslot%d",
|
|
|
|
which == 0 ? "chassis" : "rxe",
|
|
|
|
number, slot_num - first_slot + 1);
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int fillslotinfo(struct hotplug_slot *hotplug_slot)
|
|
|
|
{
|
|
|
|
struct slot *slot;
|
|
|
|
int rc = 0;
|
|
|
|
|
2018-09-08 07:59:01 +00:00
|
|
|
slot = to_slot(hotplug_slot);
|
2005-04-16 22:20:36 +00:00
|
|
|
rc = ibmphp_hpc_readslot(slot, READ_ALLSTAT, NULL);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct pci_driver ibmphp_driver;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* map info (ctlr-id, slot count, slot#.. bus count, bus#, ctlr type...) of
|
|
|
|
* each hpc from physical address to a list of hot plug controllers based on
|
|
|
|
* hpc descriptors.
|
|
|
|
*/
|
2015-12-27 21:21:11 +00:00
|
|
|
static int __init ebda_rsrc_controller(void)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
u16 addr, addr_slot, addr_bus;
|
|
|
|
u8 ctlr_id, temp, bus_index;
|
|
|
|
u16 ctlr, slot, bus;
|
|
|
|
u16 slot_num, bus_num, index;
|
|
|
|
struct controller *hpc_ptr;
|
|
|
|
struct ebda_hpc_bus *bus_ptr;
|
|
|
|
struct ebda_hpc_slot *slot_ptr;
|
|
|
|
struct bus_info *bus_info_ptr1, *bus_info_ptr2;
|
|
|
|
int rc;
|
|
|
|
struct slot *tmp_slot;
|
2008-10-20 23:41:33 +00:00
|
|
|
char name[SLOT_NAME_SIZE];
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
addr = hpc_list_ptr->phys_addr;
|
|
|
|
for (ctlr = 0; ctlr < hpc_list_ptr->num_ctlrs; ctlr++) {
|
|
|
|
bus_index = 1;
|
2015-12-27 21:21:11 +00:00
|
|
|
ctlr_id = readb(io_mem + addr);
|
2005-04-16 22:20:36 +00:00
|
|
|
addr += 1;
|
2015-12-27 21:21:11 +00:00
|
|
|
slot_num = readb(io_mem + addr);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
addr += 1;
|
|
|
|
addr_slot = addr; /* offset of slot structure */
|
|
|
|
addr += (slot_num * 4);
|
|
|
|
|
2015-12-27 21:21:11 +00:00
|
|
|
bus_num = readb(io_mem + addr);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
addr += 1;
|
|
|
|
addr_bus = addr; /* offset of bus */
|
|
|
|
addr += (bus_num * 9); /* offset of ctlr_type */
|
2015-12-27 21:21:11 +00:00
|
|
|
temp = readb(io_mem + addr);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
addr += 1;
|
|
|
|
/* init hpc structure */
|
2015-12-27 21:21:11 +00:00
|
|
|
hpc_ptr = alloc_ebda_hpc(slot_num, bus_num);
|
|
|
|
if (!hpc_ptr) {
|
2005-04-16 22:20:36 +00:00
|
|
|
rc = -ENOMEM;
|
|
|
|
goto error_no_hpc;
|
|
|
|
}
|
|
|
|
hpc_ptr->ctlr_id = ctlr_id;
|
|
|
|
hpc_ptr->ctlr_relative_id = ctlr;
|
|
|
|
hpc_ptr->slot_count = slot_num;
|
|
|
|
hpc_ptr->bus_count = bus_num;
|
2015-12-27 21:21:11 +00:00
|
|
|
debug("now enter ctlr data structure ---\n");
|
|
|
|
debug("ctlr id: %x\n", ctlr_id);
|
|
|
|
debug("ctlr_relative_id: %x\n", hpc_ptr->ctlr_relative_id);
|
|
|
|
debug("count of slots controlled by this ctlr: %x\n", slot_num);
|
|
|
|
debug("count of buses controlled by this ctlr: %x\n", bus_num);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/* init slot structure, fetch slot, bus, cap... */
|
|
|
|
slot_ptr = hpc_ptr->slots;
|
|
|
|
for (slot = 0; slot < slot_num; slot++) {
|
2015-12-27 21:21:11 +00:00
|
|
|
slot_ptr->slot_num = readb(io_mem + addr_slot);
|
|
|
|
slot_ptr->slot_bus_num = readb(io_mem + addr_slot + slot_num);
|
|
|
|
slot_ptr->ctl_index = readb(io_mem + addr_slot + 2*slot_num);
|
|
|
|
slot_ptr->slot_cap = readb(io_mem + addr_slot + 3*slot_num);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2013-11-14 18:28:18 +00:00
|
|
|
// create bus_info lined list --- if only one slot per bus: slot_min = slot_max
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2015-12-27 21:21:11 +00:00
|
|
|
bus_info_ptr2 = ibmphp_find_same_bus_num(slot_ptr->slot_bus_num);
|
2005-04-16 22:20:36 +00:00
|
|
|
if (!bus_info_ptr2) {
|
2006-02-28 14:34:49 +00:00
|
|
|
bus_info_ptr1 = kzalloc(sizeof(struct bus_info), GFP_KERNEL);
|
2005-04-16 22:20:36 +00:00
|
|
|
if (!bus_info_ptr1) {
|
|
|
|
rc = -ENOMEM;
|
2018-09-08 07:59:01 +00:00
|
|
|
goto error_no_slot;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
bus_info_ptr1->slot_min = slot_ptr->slot_num;
|
|
|
|
bus_info_ptr1->slot_max = slot_ptr->slot_num;
|
|
|
|
bus_info_ptr1->slot_count += 1;
|
|
|
|
bus_info_ptr1->busno = slot_ptr->slot_bus_num;
|
|
|
|
bus_info_ptr1->index = bus_index++;
|
|
|
|
bus_info_ptr1->current_speed = 0xff;
|
|
|
|
bus_info_ptr1->current_bus_mode = 0xff;
|
2013-11-14 18:28:18 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
bus_info_ptr1->controller_id = hpc_ptr->ctlr_id;
|
2013-11-14 18:28:18 +00:00
|
|
|
|
2015-12-27 21:21:11 +00:00
|
|
|
list_add_tail(&bus_info_ptr1->bus_info_list, &bus_info_head);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
} else {
|
2015-12-27 21:21:11 +00:00
|
|
|
bus_info_ptr2->slot_min = min(bus_info_ptr2->slot_min, slot_ptr->slot_num);
|
|
|
|
bus_info_ptr2->slot_max = max(bus_info_ptr2->slot_max, slot_ptr->slot_num);
|
2005-04-16 22:20:36 +00:00
|
|
|
bus_info_ptr2->slot_count += 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// end of creating the bus_info linked list
|
|
|
|
|
|
|
|
slot_ptr++;
|
|
|
|
addr_slot += 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* init bus structure */
|
|
|
|
bus_ptr = hpc_ptr->buses;
|
|
|
|
for (bus = 0; bus < bus_num; bus++) {
|
2015-12-27 21:21:11 +00:00
|
|
|
bus_ptr->bus_num = readb(io_mem + addr_bus + bus);
|
|
|
|
bus_ptr->slots_at_33_conv = readb(io_mem + addr_bus + bus_num + 8 * bus);
|
|
|
|
bus_ptr->slots_at_66_conv = readb(io_mem + addr_bus + bus_num + 8 * bus + 1);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2015-12-27 21:21:11 +00:00
|
|
|
bus_ptr->slots_at_66_pcix = readb(io_mem + addr_bus + bus_num + 8 * bus + 2);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2015-12-27 21:21:11 +00:00
|
|
|
bus_ptr->slots_at_100_pcix = readb(io_mem + addr_bus + bus_num + 8 * bus + 3);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2015-12-27 21:21:11 +00:00
|
|
|
bus_ptr->slots_at_133_pcix = readb(io_mem + addr_bus + bus_num + 8 * bus + 4);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2015-12-27 21:21:11 +00:00
|
|
|
bus_info_ptr2 = ibmphp_find_same_bus_num(bus_ptr->bus_num);
|
2005-04-16 22:20:36 +00:00
|
|
|
if (bus_info_ptr2) {
|
|
|
|
bus_info_ptr2->slots_at_33_conv = bus_ptr->slots_at_33_conv;
|
|
|
|
bus_info_ptr2->slots_at_66_conv = bus_ptr->slots_at_66_conv;
|
|
|
|
bus_info_ptr2->slots_at_66_pcix = bus_ptr->slots_at_66_pcix;
|
|
|
|
bus_info_ptr2->slots_at_100_pcix = bus_ptr->slots_at_100_pcix;
|
2013-11-14 18:28:18 +00:00
|
|
|
bus_info_ptr2->slots_at_133_pcix = bus_ptr->slots_at_133_pcix;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
bus_ptr++;
|
|
|
|
}
|
|
|
|
|
|
|
|
hpc_ptr->ctlr_type = temp;
|
|
|
|
|
|
|
|
switch (hpc_ptr->ctlr_type) {
|
|
|
|
case 1:
|
2015-12-27 21:21:11 +00:00
|
|
|
hpc_ptr->u.pci_ctlr.bus = readb(io_mem + addr);
|
|
|
|
hpc_ptr->u.pci_ctlr.dev_fun = readb(io_mem + addr + 1);
|
|
|
|
hpc_ptr->irq = readb(io_mem + addr + 2);
|
2005-04-16 22:20:36 +00:00
|
|
|
addr += 3;
|
2015-12-27 21:21:11 +00:00
|
|
|
debug("ctrl bus = %x, ctlr devfun = %x, irq = %x\n",
|
2005-04-16 22:20:36 +00:00
|
|
|
hpc_ptr->u.pci_ctlr.bus,
|
|
|
|
hpc_ptr->u.pci_ctlr.dev_fun, hpc_ptr->irq);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0:
|
2015-12-27 21:21:11 +00:00
|
|
|
hpc_ptr->u.isa_ctlr.io_start = readw(io_mem + addr);
|
|
|
|
hpc_ptr->u.isa_ctlr.io_end = readw(io_mem + addr + 2);
|
|
|
|
if (!request_region(hpc_ptr->u.isa_ctlr.io_start,
|
2005-04-16 22:20:36 +00:00
|
|
|
(hpc_ptr->u.isa_ctlr.io_end - hpc_ptr->u.isa_ctlr.io_start + 1),
|
|
|
|
"ibmphp")) {
|
|
|
|
rc = -ENODEV;
|
2018-09-08 07:59:01 +00:00
|
|
|
goto error_no_slot;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
2015-12-27 21:21:11 +00:00
|
|
|
hpc_ptr->irq = readb(io_mem + addr + 4);
|
2005-04-16 22:20:36 +00:00
|
|
|
addr += 5;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
case 4:
|
2015-12-27 21:21:11 +00:00
|
|
|
hpc_ptr->u.wpeg_ctlr.wpegbbar = readl(io_mem + addr);
|
|
|
|
hpc_ptr->u.wpeg_ctlr.i2c_addr = readb(io_mem + addr + 4);
|
|
|
|
hpc_ptr->irq = readb(io_mem + addr + 5);
|
2005-04-16 22:20:36 +00:00
|
|
|
addr += 6;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
rc = -ENODEV;
|
2018-09-08 07:59:01 +00:00
|
|
|
goto error_no_slot;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//reorganize chassis' linked list
|
2015-12-27 21:21:11 +00:00
|
|
|
combine_wpg_for_chassis();
|
|
|
|
combine_wpg_for_expansion();
|
2005-04-16 22:20:36 +00:00
|
|
|
hpc_ptr->revision = 0xff;
|
|
|
|
hpc_ptr->options = 0xff;
|
|
|
|
hpc_ptr->starting_slot_num = hpc_ptr->slots[0].slot_num;
|
|
|
|
hpc_ptr->ending_slot_num = hpc_ptr->slots[slot_num-1].slot_num;
|
|
|
|
|
|
|
|
// register slots with hpc core as well as create linked list of ibm slot
|
|
|
|
for (index = 0; index < hpc_ptr->slot_count; index++) {
|
2006-02-28 14:34:49 +00:00
|
|
|
tmp_slot = kzalloc(sizeof(*tmp_slot), GFP_KERNEL);
|
2005-04-16 22:20:36 +00:00
|
|
|
if (!tmp_slot) {
|
|
|
|
rc = -ENOMEM;
|
|
|
|
goto error_no_slot;
|
|
|
|
}
|
|
|
|
|
2006-03-15 00:24:47 +00:00
|
|
|
tmp_slot->flag = 1;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
tmp_slot->capabilities = hpc_ptr->slots[index].slot_cap;
|
|
|
|
if ((hpc_ptr->slots[index].slot_cap & EBDA_SLOT_133_MAX) == EBDA_SLOT_133_MAX)
|
|
|
|
tmp_slot->supported_speed = 3;
|
|
|
|
else if ((hpc_ptr->slots[index].slot_cap & EBDA_SLOT_100_MAX) == EBDA_SLOT_100_MAX)
|
|
|
|
tmp_slot->supported_speed = 2;
|
|
|
|
else if ((hpc_ptr->slots[index].slot_cap & EBDA_SLOT_66_MAX) == EBDA_SLOT_66_MAX)
|
|
|
|
tmp_slot->supported_speed = 1;
|
2013-11-14 18:28:18 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
if ((hpc_ptr->slots[index].slot_cap & EBDA_SLOT_PCIX_CAP) == EBDA_SLOT_PCIX_CAP)
|
|
|
|
tmp_slot->supported_bus_mode = 1;
|
|
|
|
else
|
|
|
|
tmp_slot->supported_bus_mode = 0;
|
|
|
|
|
|
|
|
|
|
|
|
tmp_slot->bus = hpc_ptr->slots[index].slot_bus_num;
|
|
|
|
|
2015-12-27 21:21:11 +00:00
|
|
|
bus_info_ptr1 = ibmphp_find_same_bus_num(hpc_ptr->slots[index].slot_bus_num);
|
2005-04-16 22:20:36 +00:00
|
|
|
if (!bus_info_ptr1) {
|
|
|
|
rc = -ENODEV;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
tmp_slot->bus_on = bus_info_ptr1;
|
|
|
|
bus_info_ptr1 = NULL;
|
|
|
|
tmp_slot->ctrl = hpc_ptr;
|
|
|
|
|
|
|
|
tmp_slot->ctlr_index = hpc_ptr->slots[index].ctl_index;
|
|
|
|
tmp_slot->number = hpc_ptr->slots[index].slot_num;
|
|
|
|
|
2018-09-08 07:59:01 +00:00
|
|
|
rc = fillslotinfo(&tmp_slot->hotplug_slot);
|
2005-04-16 22:20:36 +00:00
|
|
|
if (rc)
|
|
|
|
goto error;
|
|
|
|
|
2018-09-08 07:59:01 +00:00
|
|
|
rc = ibmphp_init_devno(&tmp_slot);
|
2005-04-16 22:20:36 +00:00
|
|
|
if (rc)
|
|
|
|
goto error;
|
2018-09-08 07:59:01 +00:00
|
|
|
tmp_slot->hotplug_slot.ops = &ibmphp_hotplug_slot_ops;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
// end of registering ibm slot with hotplug core
|
|
|
|
|
2018-09-08 07:59:01 +00:00
|
|
|
list_add(&tmp_slot->ibm_slot_list, &ibmphp_slot_head);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2015-12-27 21:21:11 +00:00
|
|
|
print_bus_info();
|
|
|
|
list_add(&hpc_ptr->ebda_hpc_list, &ebda_hpc_head);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
} /* each hpc */
|
|
|
|
|
2008-08-22 20:30:14 +00:00
|
|
|
list_for_each_entry(tmp_slot, &ibmphp_slot_head, ibm_slot_list) {
|
2008-10-20 23:41:33 +00:00
|
|
|
snprintf(name, SLOT_NAME_SIZE, "%s", create_file_name(tmp_slot));
|
2018-09-08 07:59:01 +00:00
|
|
|
pci_hp_register(&tmp_slot->hotplug_slot,
|
2008-10-20 23:41:33 +00:00
|
|
|
pci_find_bus(0, tmp_slot->bus), tmp_slot->device, name);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2015-12-27 21:21:11 +00:00
|
|
|
print_ebda_hpc();
|
|
|
|
print_ibm_slot();
|
2005-04-16 22:20:36 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
error:
|
2018-09-08 07:59:01 +00:00
|
|
|
kfree(tmp_slot);
|
2005-04-16 22:20:36 +00:00
|
|
|
error_no_slot:
|
2015-12-27 21:21:11 +00:00
|
|
|
free_ebda_hpc(hpc_ptr);
|
2005-04-16 22:20:36 +00:00
|
|
|
error_no_hpc:
|
2015-12-27 21:21:11 +00:00
|
|
|
iounmap(io_mem);
|
2005-04-16 22:20:36 +00:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2013-11-14 18:28:18 +00:00
|
|
|
/*
|
2005-04-16 22:20:36 +00:00
|
|
|
* map info (bus, devfun, start addr, end addr..) of i/o, memory,
|
|
|
|
* pfm from the physical addr to a list of resource.
|
|
|
|
*/
|
2015-12-27 21:21:11 +00:00
|
|
|
static int __init ebda_rsrc_rsrc(void)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
u16 addr;
|
|
|
|
short rsrc;
|
|
|
|
u8 type, rsrc_type;
|
|
|
|
struct ebda_pci_rsrc *rsrc_ptr;
|
|
|
|
|
|
|
|
addr = rsrc_list_ptr->phys_addr;
|
2015-12-27 21:21:11 +00:00
|
|
|
debug("now entering rsrc land\n");
|
|
|
|
debug("offset of rsrc: %x\n", rsrc_list_ptr->phys_addr);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
for (rsrc = 0; rsrc < rsrc_list_ptr->num_entries; rsrc++) {
|
2015-12-27 21:21:11 +00:00
|
|
|
type = readb(io_mem + addr);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
addr += 1;
|
|
|
|
rsrc_type = type & EBDA_RSRC_TYPE_MASK;
|
|
|
|
|
|
|
|
if (rsrc_type == EBDA_IO_RSRC_TYPE) {
|
2015-12-27 21:21:11 +00:00
|
|
|
rsrc_ptr = alloc_ebda_pci_rsrc();
|
2005-04-16 22:20:36 +00:00
|
|
|
if (!rsrc_ptr) {
|
2015-12-27 21:21:11 +00:00
|
|
|
iounmap(io_mem);
|
2005-04-16 22:20:36 +00:00
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
rsrc_ptr->rsrc_type = type;
|
|
|
|
|
2015-12-27 21:21:11 +00:00
|
|
|
rsrc_ptr->bus_num = readb(io_mem + addr);
|
|
|
|
rsrc_ptr->dev_fun = readb(io_mem + addr + 1);
|
|
|
|
rsrc_ptr->start_addr = readw(io_mem + addr + 2);
|
|
|
|
rsrc_ptr->end_addr = readw(io_mem + addr + 4);
|
2005-04-16 22:20:36 +00:00
|
|
|
addr += 6;
|
|
|
|
|
2015-12-27 21:21:11 +00:00
|
|
|
debug("rsrc from io type ----\n");
|
|
|
|
debug("rsrc type: %x bus#: %x dev_func: %x start addr: %x end addr: %x\n",
|
2005-04-16 22:20:36 +00:00
|
|
|
rsrc_ptr->rsrc_type, rsrc_ptr->bus_num, rsrc_ptr->dev_fun, rsrc_ptr->start_addr, rsrc_ptr->end_addr);
|
|
|
|
|
2015-12-27 21:21:11 +00:00
|
|
|
list_add(&rsrc_ptr->ebda_pci_rsrc_list, &ibmphp_ebda_pci_rsrc_head);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (rsrc_type == EBDA_MEM_RSRC_TYPE || rsrc_type == EBDA_PFM_RSRC_TYPE) {
|
2015-12-27 21:21:11 +00:00
|
|
|
rsrc_ptr = alloc_ebda_pci_rsrc();
|
|
|
|
if (!rsrc_ptr) {
|
|
|
|
iounmap(io_mem);
|
2005-04-16 22:20:36 +00:00
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
rsrc_ptr->rsrc_type = type;
|
|
|
|
|
2015-12-27 21:21:11 +00:00
|
|
|
rsrc_ptr->bus_num = readb(io_mem + addr);
|
|
|
|
rsrc_ptr->dev_fun = readb(io_mem + addr + 1);
|
|
|
|
rsrc_ptr->start_addr = readl(io_mem + addr + 2);
|
|
|
|
rsrc_ptr->end_addr = readl(io_mem + addr + 6);
|
2005-04-16 22:20:36 +00:00
|
|
|
addr += 10;
|
|
|
|
|
2015-12-27 21:21:11 +00:00
|
|
|
debug("rsrc from mem or pfm ---\n");
|
|
|
|
debug("rsrc type: %x bus#: %x dev_func: %x start addr: %x end addr: %x\n",
|
2005-04-16 22:20:36 +00:00
|
|
|
rsrc_ptr->rsrc_type, rsrc_ptr->bus_num, rsrc_ptr->dev_fun, rsrc_ptr->start_addr, rsrc_ptr->end_addr);
|
|
|
|
|
2015-12-27 21:21:11 +00:00
|
|
|
list_add(&rsrc_ptr->ebda_pci_rsrc_list, &ibmphp_ebda_pci_rsrc_head);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
}
|
2015-12-27 21:21:11 +00:00
|
|
|
kfree(rsrc_list_ptr);
|
2005-04-16 22:20:36 +00:00
|
|
|
rsrc_list_ptr = NULL;
|
2015-12-27 21:21:11 +00:00
|
|
|
print_ebda_pci_rsrc();
|
2005-04-16 22:20:36 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-12-27 21:21:11 +00:00
|
|
|
u16 ibmphp_get_total_controllers(void)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
return hpc_list_ptr->num_ctlrs;
|
|
|
|
}
|
|
|
|
|
2015-12-27 21:21:11 +00:00
|
|
|
struct slot *ibmphp_get_slot_from_physical_num(u8 physical_num)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
struct slot *slot;
|
|
|
|
|
2008-08-22 20:30:14 +00:00
|
|
|
list_for_each_entry(slot, &ibmphp_slot_head, ibm_slot_list) {
|
2005-04-16 22:20:36 +00:00
|
|
|
if (slot->number == physical_num)
|
|
|
|
return slot;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* To find:
|
|
|
|
* - the smallest slot number
|
|
|
|
* - the largest slot number
|
|
|
|
* - the total number of the slots based on each bus
|
|
|
|
* (if only one slot per bus slot_min = slot_max )
|
|
|
|
*/
|
2015-12-27 21:21:11 +00:00
|
|
|
struct bus_info *ibmphp_find_same_bus_num(u32 num)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
struct bus_info *ptr;
|
|
|
|
|
2008-08-22 20:30:14 +00:00
|
|
|
list_for_each_entry(ptr, &bus_info_head, bus_info_list) {
|
2013-11-14 18:28:18 +00:00
|
|
|
if (ptr->busno == num)
|
2005-04-16 22:20:36 +00:00
|
|
|
return ptr;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Finding relative bus number, in order to map corresponding
|
|
|
|
* bus register
|
|
|
|
*/
|
2015-12-27 21:21:11 +00:00
|
|
|
int ibmphp_get_bus_index(u8 num)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
struct bus_info *ptr;
|
|
|
|
|
2008-08-22 20:30:14 +00:00
|
|
|
list_for_each_entry(ptr, &bus_info_head, bus_info_list) {
|
2013-11-14 18:28:18 +00:00
|
|
|
if (ptr->busno == num)
|
2005-04-16 22:20:36 +00:00
|
|
|
return ptr->index;
|
|
|
|
}
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
2015-12-27 21:21:11 +00:00
|
|
|
void ibmphp_free_bus_info_queue(void)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2015-12-12 13:36:57 +00:00
|
|
|
struct bus_info *bus_info, *next;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2015-12-12 13:36:57 +00:00
|
|
|
list_for_each_entry_safe(bus_info, next, &bus_info_head,
|
|
|
|
bus_info_list) {
|
2005-04-16 22:20:36 +00:00
|
|
|
kfree (bus_info);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-27 21:21:11 +00:00
|
|
|
void ibmphp_free_ebda_hpc_queue(void)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2015-12-12 13:36:57 +00:00
|
|
|
struct controller *controller = NULL, *next;
|
2005-04-16 22:20:36 +00:00
|
|
|
int pci_flag = 0;
|
|
|
|
|
2015-12-12 13:36:57 +00:00
|
|
|
list_for_each_entry_safe(controller, next, &ebda_hpc_head,
|
|
|
|
ebda_hpc_list) {
|
2005-04-16 22:20:36 +00:00
|
|
|
if (controller->ctlr_type == 0)
|
2015-12-27 21:21:11 +00:00
|
|
|
release_region(controller->u.isa_ctlr.io_start, (controller->u.isa_ctlr.io_end - controller->u.isa_ctlr.io_start + 1));
|
2005-04-16 22:20:36 +00:00
|
|
|
else if ((controller->ctlr_type == 1) && (!pci_flag)) {
|
|
|
|
++pci_flag;
|
2015-12-27 21:21:11 +00:00
|
|
|
pci_unregister_driver(&ibmphp_driver);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
2015-12-27 21:21:11 +00:00
|
|
|
free_ebda_hpc(controller);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-27 21:21:11 +00:00
|
|
|
void ibmphp_free_ebda_pci_rsrc_queue(void)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2015-12-12 13:36:57 +00:00
|
|
|
struct ebda_pci_rsrc *resource, *next;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2015-12-12 13:36:57 +00:00
|
|
|
list_for_each_entry_safe(resource, next, &ibmphp_ebda_pci_rsrc_head,
|
|
|
|
ebda_pci_rsrc_list) {
|
2005-04-16 22:20:36 +00:00
|
|
|
kfree (resource);
|
|
|
|
resource = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-03 23:20:17 +00:00
|
|
|
static const struct pci_device_id id_table[] = {
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
.vendor = PCI_VENDOR_ID_IBM,
|
|
|
|
.device = HPC_DEVICE_ID,
|
|
|
|
.subvendor = PCI_VENDOR_ID_IBM,
|
|
|
|
.subdevice = HPC_SUBSYSTEM_ID,
|
|
|
|
.class = ((PCI_CLASS_SYSTEM_PCI_HOTPLUG << 8) | 0x00),
|
|
|
|
}, {}
|
2013-11-14 18:28:18 +00:00
|
|
|
};
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
MODULE_DEVICE_TABLE(pci, id_table);
|
|
|
|
|
2015-12-27 21:21:11 +00:00
|
|
|
static int ibmphp_probe(struct pci_dev *, const struct pci_device_id *);
|
2005-04-16 22:20:36 +00:00
|
|
|
static struct pci_driver ibmphp_driver = {
|
|
|
|
.name = "ibmphp",
|
|
|
|
.id_table = id_table,
|
|
|
|
.probe = ibmphp_probe,
|
|
|
|
};
|
|
|
|
|
2015-12-27 21:21:11 +00:00
|
|
|
int ibmphp_register_pci(void)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
struct controller *ctrl;
|
|
|
|
int rc = 0;
|
|
|
|
|
2008-08-22 20:30:14 +00:00
|
|
|
list_for_each_entry(ctrl, &ebda_hpc_head, ebda_hpc_list) {
|
2005-04-16 22:20:36 +00:00
|
|
|
if (ctrl->ctlr_type == 1) {
|
|
|
|
rc = pci_register_driver(&ibmphp_driver);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return rc;
|
|
|
|
}
|
2015-12-27 21:21:11 +00:00
|
|
|
static int ibmphp_probe(struct pci_dev *dev, const struct pci_device_id *ids)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
struct controller *ctrl;
|
|
|
|
|
2015-12-27 21:21:11 +00:00
|
|
|
debug("inside ibmphp_probe\n");
|
2013-11-14 18:28:18 +00:00
|
|
|
|
2008-08-22 20:30:14 +00:00
|
|
|
list_for_each_entry(ctrl, &ebda_hpc_head, ebda_hpc_list) {
|
2005-04-16 22:20:36 +00:00
|
|
|
if (ctrl->ctlr_type == 1) {
|
|
|
|
if ((dev->devfn == ctrl->u.pci_ctlr.dev_fun) && (dev->bus->number == ctrl->u.pci_ctlr.bus)) {
|
|
|
|
ctrl->ctrl_dev = dev;
|
2015-12-27 21:21:11 +00:00
|
|
|
debug("found device!!!\n");
|
|
|
|
debug("dev->device = %x, dev->subsystem_device = %x\n", dev->device, dev->subsystem_device);
|
2005-04-16 22:20:36 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return -ENODEV;
|
|
|
|
}
|