Commit 36e4a848 authored by Rolf Eike Beer's avatar Rolf Eike Beer Committed by Deepak Saxena

[PATCH] Compaq PCI Hotplug: fix C++ style comments

This is not C++! Fix comments from C++ style to C style, removing some useless
ones (e.g. no need to tell up and down protect a critical section).
parent c131843c
...@@ -78,7 +78,7 @@ static void long_delay(int delay) ...@@ -78,7 +78,7 @@ static void long_delay(int delay)
} }
//FIXME: The following line needs to be somewhere else... /* FIXME: The following line needs to be somewhere else... */
#define WRONG_BUS_FREQUENCY 0x07 #define WRONG_BUS_FREQUENCY 0x07
static u8 handle_switch_change(u8 change, struct controller * ctrl) static u8 handle_switch_change(u8 change, struct controller * ctrl)
{ {
...@@ -91,19 +91,19 @@ static u8 handle_switch_change(u8 change, struct controller * ctrl) ...@@ -91,19 +91,19 @@ static u8 handle_switch_change(u8 change, struct controller * ctrl)
if (!change) if (!change)
return 0; return 0;
// Switch Change /* Switch Change */
dbg("cpqsbd: Switch interrupt received.\n"); dbg("cpqsbd: Switch interrupt received.\n");
for (hp_slot = 0; hp_slot < 6; hp_slot++) { for (hp_slot = 0; hp_slot < 6; hp_slot++) {
if (change & (0x1L << hp_slot)) { if (change & (0x1L << hp_slot)) {
//********************************* /**********************************
// this one changed. * this one changed.
//********************************* **********************************/
func = cpqhp_slot_find(ctrl->bus, func = cpqhp_slot_find(ctrl->bus,
(hp_slot + ctrl->slot_device_offset), 0); (hp_slot + ctrl->slot_device_offset), 0);
//this is the structure that tells the worker thread /* this is the structure that tells the worker thread
//what to do *what to do */
taskInfo = &(ctrl->event_queue[ctrl->next_event]); taskInfo = &(ctrl->event_queue[ctrl->next_event]);
ctrl->next_event = (ctrl->next_event + 1) % 10; ctrl->next_event = (ctrl->next_event + 1) % 10;
taskInfo->hp_slot = hp_slot; taskInfo->hp_slot = hp_slot;
...@@ -115,17 +115,17 @@ static u8 handle_switch_change(u8 change, struct controller * ctrl) ...@@ -115,17 +115,17 @@ static u8 handle_switch_change(u8 change, struct controller * ctrl)
func->presence_save |= (temp_word >> (hp_slot + 7)) & 0x02; func->presence_save |= (temp_word >> (hp_slot + 7)) & 0x02;
if (ctrl->ctrl_int_comp & (0x1L << hp_slot)) { if (ctrl->ctrl_int_comp & (0x1L << hp_slot)) {
//********************************* /**********************************
// Switch opened * Switch opened
//********************************* **********************************/
func->switch_save = 0; func->switch_save = 0;
taskInfo->event_type = INT_SWITCH_OPEN; taskInfo->event_type = INT_SWITCH_OPEN;
} else { } else {
//********************************* /**********************************
// Switch closed * Switch closed
//********************************* **********************************/
func->switch_save = 0x10; func->switch_save = 0x10;
...@@ -137,9 +137,10 @@ static u8 handle_switch_change(u8 change, struct controller * ctrl) ...@@ -137,9 +137,10 @@ static u8 handle_switch_change(u8 change, struct controller * ctrl)
return rc; return rc;
} }
/**
/* * cpqhp_find_slot: find the struct slot of given device
* cpqhp_find_slot * @ctrl: scan lots of this controller
* @device: the device id to find
*/ */
struct slot *cpqhp_find_slot(struct controller *ctrl, u8 device) struct slot *cpqhp_find_slot(struct controller *ctrl, u8 device)
{ {
...@@ -166,17 +167,17 @@ static u8 handle_presence_change(u16 change, struct controller * ctrl) ...@@ -166,17 +167,17 @@ static u8 handle_presence_change(u16 change, struct controller * ctrl)
if (!change) if (!change)
return 0; return 0;
//********************************* /**********************************
// Presence Change * Presence Change
//********************************* **********************************/
dbg("cpqsbd: Presence/Notify input change.\n"); dbg("cpqsbd: Presence/Notify input change.\n");
dbg(" Changed bits are 0x%4.4x\n", change ); dbg(" Changed bits are 0x%4.4x\n", change );
for (hp_slot = 0; hp_slot < 6; hp_slot++) { for (hp_slot = 0; hp_slot < 6; hp_slot++) {
if (change & (0x0101 << hp_slot)) { if (change & (0x0101 << hp_slot)) {
//********************************* /**********************************
// this one changed. * this one changed.
//********************************* **********************************/
func = cpqhp_slot_find(ctrl->bus, func = cpqhp_slot_find(ctrl->bus,
(hp_slot + ctrl->slot_device_offset), 0); (hp_slot + ctrl->slot_device_offset), 0);
...@@ -190,55 +191,51 @@ static u8 handle_presence_change(u16 change, struct controller * ctrl) ...@@ -190,55 +191,51 @@ static u8 handle_presence_change(u16 change, struct controller * ctrl)
if (!p_slot) if (!p_slot)
return 0; return 0;
// If the switch closed, must be a button /* If the switch closed, must be a button
// If not in button mode, nevermind * If not in button mode, nevermind */
if (func->switch_save && (ctrl->push_button == 1)) { if (func->switch_save && (ctrl->push_button == 1)) {
temp_word = ctrl->ctrl_int_comp >> 16; temp_word = ctrl->ctrl_int_comp >> 16;
temp_byte = (temp_word >> hp_slot) & 0x01; temp_byte = (temp_word >> hp_slot) & 0x01;
temp_byte |= (temp_word >> (hp_slot + 7)) & 0x02; temp_byte |= (temp_word >> (hp_slot + 7)) & 0x02;
if (temp_byte != func->presence_save) { if (temp_byte != func->presence_save) {
//********************************* /**************************************
// button Pressed (doesn't do anything) * button Pressed (doesn't do anything)
//********************************* **************************************/
dbg("hp_slot %d button pressed\n", hp_slot); dbg("hp_slot %d button pressed\n", hp_slot);
taskInfo->event_type = INT_BUTTON_PRESS; taskInfo->event_type = INT_BUTTON_PRESS;
} else { } else {
//********************************* /**********************************
// button Released - TAKE ACTION!!!! * button Released - TAKE ACTION!!!!
//********************************* **********************************/
dbg("hp_slot %d button released\n", hp_slot); dbg("hp_slot %d button released\n", hp_slot);
taskInfo->event_type = INT_BUTTON_RELEASE; taskInfo->event_type = INT_BUTTON_RELEASE;
// Cancel if we are still blinking /* Cancel if we are still blinking */
if ((p_slot->state == BLINKINGON_STATE) if ((p_slot->state == BLINKINGON_STATE)
|| (p_slot->state == BLINKINGOFF_STATE)) { || (p_slot->state == BLINKINGOFF_STATE)) {
taskInfo->event_type = INT_BUTTON_CANCEL; taskInfo->event_type = INT_BUTTON_CANCEL;
dbg("hp_slot %d button cancel\n", hp_slot); dbg("hp_slot %d button cancel\n", hp_slot);
} else if ((p_slot->state == POWERON_STATE) } else if ((p_slot->state == POWERON_STATE)
|| (p_slot->state == POWEROFF_STATE)) { || (p_slot->state == POWEROFF_STATE)) {
//info(msg_button_ignore, p_slot->number); /* info(msg_button_ignore, p_slot->number); */
taskInfo->event_type = INT_BUTTON_IGNORE; taskInfo->event_type = INT_BUTTON_IGNORE;
dbg("hp_slot %d button ignore\n", hp_slot); dbg("hp_slot %d button ignore\n", hp_slot);
} }
} }
} else { } else {
// Switch is open, assume a presence change /* Switch is open, assume a presence change
// Save the presence state * Save the presence state */
temp_word = ctrl->ctrl_int_comp >> 16; temp_word = ctrl->ctrl_int_comp >> 16;
func->presence_save = (temp_word >> hp_slot) & 0x01; func->presence_save = (temp_word >> hp_slot) & 0x01;
func->presence_save |= (temp_word >> (hp_slot + 7)) & 0x02; func->presence_save |= (temp_word >> (hp_slot + 7)) & 0x02;
if ((!(ctrl->ctrl_int_comp & (0x010000 << hp_slot))) || if ((!(ctrl->ctrl_int_comp & (0x010000 << hp_slot))) ||
(!(ctrl->ctrl_int_comp & (0x01000000 << hp_slot)))) { (!(ctrl->ctrl_int_comp & (0x01000000 << hp_slot)))) {
//********************************* /* Present */
// Present
//*********************************
taskInfo->event_type = INT_PRESENCE_ON; taskInfo->event_type = INT_PRESENCE_ON;
} else { } else {
//********************************* /* Not Present */
// Not Present
//*********************************
taskInfo->event_type = INT_PRESENCE_OFF; taskInfo->event_type = INT_PRESENCE_OFF;
} }
} }
...@@ -259,17 +256,17 @@ static u8 handle_power_fault(u8 change, struct controller * ctrl) ...@@ -259,17 +256,17 @@ static u8 handle_power_fault(u8 change, struct controller * ctrl)
if (!change) if (!change)
return 0; return 0;
//********************************* /**********************************
// power fault * power fault
//********************************* **********************************/
info("power fault interrupt\n"); info("power fault interrupt\n");
for (hp_slot = 0; hp_slot < 6; hp_slot++) { for (hp_slot = 0; hp_slot < 6; hp_slot++) {
if (change & (0x01 << hp_slot)) { if (change & (0x01 << hp_slot)) {
//********************************* /**********************************
// this one changed. * this one changed.
//********************************* **********************************/
func = cpqhp_slot_find(ctrl->bus, func = cpqhp_slot_find(ctrl->bus,
(hp_slot + ctrl->slot_device_offset), 0); (hp_slot + ctrl->slot_device_offset), 0);
...@@ -280,16 +277,16 @@ static u8 handle_power_fault(u8 change, struct controller * ctrl) ...@@ -280,16 +277,16 @@ static u8 handle_power_fault(u8 change, struct controller * ctrl)
rc++; rc++;
if (ctrl->ctrl_int_comp & (0x00000100 << hp_slot)) { if (ctrl->ctrl_int_comp & (0x00000100 << hp_slot)) {
//********************************* /**********************************
// power fault Cleared * power fault Cleared
//********************************* **********************************/
func->status = 0x00; func->status = 0x00;
taskInfo->event_type = INT_POWER_FAULT_CLEAR; taskInfo->event_type = INT_POWER_FAULT_CLEAR;
} else { } else {
//********************************* /**********************************
// power fault * power fault
//********************************* **********************************/
taskInfo->event_type = INT_POWER_FAULT; taskInfo->event_type = INT_POWER_FAULT;
if (ctrl->rev < 4) { if (ctrl->rev < 4) {
...@@ -297,18 +294,20 @@ static u8 handle_power_fault(u8 change, struct controller * ctrl) ...@@ -297,18 +294,20 @@ static u8 handle_power_fault(u8 change, struct controller * ctrl)
green_LED_off (ctrl, hp_slot); green_LED_off (ctrl, hp_slot);
set_SOGO (ctrl); set_SOGO (ctrl);
// this is a fatal condition, we want to crash the /* this is a fatal condition, we want
// machine to protect from data corruption * to crash the machine to protect from
// simulated_NMI shouldn't ever return * data corruption. simulated_NMI
//FIXME * shouldn't ever return */
//simulated_NMI(hp_slot, ctrl); /* FIXME
simulated_NMI(hp_slot, ctrl); */
//The following code causes a software crash just in
//case simulated_NMI did return /* The following code causes a software
//FIXME * crash just in case simulated_NMI did
//panic(msg_power_fault); * return */
/*FIXME
panic(msg_power_fault); */
} else { } else {
// set power fault status for this board /* set power fault status for this board */
func->status = 0xFF; func->status = 0xFF;
info("power fault bit %x set\n", hp_slot); info("power fault bit %x set\n", hp_slot);
} }
...@@ -340,7 +339,7 @@ static int sort_by_size(struct pci_resource **head) ...@@ -340,7 +339,7 @@ static int sort_by_size(struct pci_resource **head)
while (out_of_order) { while (out_of_order) {
out_of_order = 0; out_of_order = 0;
// Special case for swapping list head /* Special case for swapping list head */
if (((*head)->next) && if (((*head)->next) &&
((*head)->length > (*head)->next->length)) { ((*head)->length > (*head)->next->length)) {
out_of_order++; out_of_order++;
...@@ -363,7 +362,7 @@ static int sort_by_size(struct pci_resource **head) ...@@ -363,7 +362,7 @@ static int sort_by_size(struct pci_resource **head)
} else } else
current_res = current_res->next; current_res = current_res->next;
} }
} // End of out_of_order loop } /* End of out_of_order loop */
return 0; return 0;
} }
...@@ -389,7 +388,7 @@ static int sort_by_max_size(struct pci_resource **head) ...@@ -389,7 +388,7 @@ static int sort_by_max_size(struct pci_resource **head)
while (out_of_order) { while (out_of_order) {
out_of_order = 0; out_of_order = 0;
// Special case for swapping list head /* Special case for swapping list head */
if (((*head)->next) && if (((*head)->next) &&
((*head)->length < (*head)->next->length)) { ((*head)->length < (*head)->next->length)) {
out_of_order++; out_of_order++;
...@@ -412,7 +411,7 @@ static int sort_by_max_size(struct pci_resource **head) ...@@ -412,7 +411,7 @@ static int sort_by_max_size(struct pci_resource **head)
} else } else
current_res = current_res->next; current_res = current_res->next;
} }
} // End of out_of_order loop } /* End of out_of_order loop */
return 0; return 0;
} }
...@@ -447,15 +446,15 @@ static struct pci_resource *do_pre_bridge_resource_split(struct pci_resource **h ...@@ -447,15 +446,15 @@ static struct pci_resource *do_pre_bridge_resource_split(struct pci_resource **h
return NULL; return NULL;
// If we got here, there the bridge requires some of the resource, but /* If we got here, there the bridge requires some of the resource, but
// we may be able to split some off of the front * we may be able to split some off of the front */
node = *head; node = *head;
if (node->length & (alignment -1)) { if (node->length & (alignment -1)) {
// this one isn't an aligned length, so we'll make a new entry /* this one isn't an aligned length, so we'll make a new entry
// and split it up. * and split it up. */
split_node = (struct pci_resource*) kmalloc(sizeof(struct pci_resource), GFP_KERNEL); split_node = kmalloc(sizeof(struct pci_resource), GFP_KERNEL);
if (!split_node) if (!split_node)
return NULL; return NULL;
...@@ -468,16 +467,15 @@ static struct pci_resource *do_pre_bridge_resource_split(struct pci_resource **h ...@@ -468,16 +467,15 @@ static struct pci_resource *do_pre_bridge_resource_split(struct pci_resource **h
node->length -= temp_dword; node->length -= temp_dword;
node->base += split_node->length; node->base += split_node->length;
// Put it in the list /* Put it in the list */
*head = split_node; *head = split_node;
split_node->next = node; split_node->next = node;
} }
if (node->length < alignment) { if (node->length < alignment)
return NULL; return NULL;
}
// Now unlink it /* Now unlink it */
if (*head == node) { if (*head == node) {
*head = node->next; *head = node->next;
node->next = NULL; node->next = NULL;
...@@ -527,7 +525,7 @@ static struct pci_resource *do_bridge_resource_split(struct pci_resource **head, ...@@ -527,7 +525,7 @@ static struct pci_resource *do_bridge_resource_split(struct pci_resource **head,
} }
if (node->base & (alignment - 1)) { if (node->base & (alignment - 1)) {
// Short circuit if adjusted size is too small /* Short circuit if adjusted size is too small */
temp_dword = (node->base | (alignment-1)) + 1; temp_dword = (node->base | (alignment-1)) + 1;
if ((node->length - (temp_dword - node->base)) < alignment) { if ((node->length - (temp_dword - node->base)) < alignment) {
kfree(node); kfree(node);
...@@ -539,7 +537,7 @@ static struct pci_resource *do_bridge_resource_split(struct pci_resource **head, ...@@ -539,7 +537,7 @@ static struct pci_resource *do_bridge_resource_split(struct pci_resource **head,
} }
if (node->length & (alignment - 1)) { if (node->length & (alignment - 1)) {
// There's stuff in use after this node /* There's stuff in use after this node */
kfree(node); kfree(node);
return NULL; return NULL;
} }
...@@ -579,11 +577,11 @@ static struct pci_resource *get_io_resource(struct pci_resource **head, u32 size ...@@ -579,11 +577,11 @@ static struct pci_resource *get_io_resource(struct pci_resource **head, u32 size
continue; continue;
if (node->base & (size - 1)) { if (node->base & (size - 1)) {
// this one isn't base aligned properly /* this one isn't base aligned properly
// so we'll make a new entry and split it up * so we'll make a new entry and split it up */
temp_dword = (node->base | (size-1)) + 1; temp_dword = (node->base | (size-1)) + 1;
// Short circuit if adjusted size is too small /* Short circuit if adjusted size is too small */
if ((node->length - (temp_dword - node->base)) < size) if ((node->length - (temp_dword - node->base)) < size)
continue; continue;
...@@ -597,15 +595,15 @@ static struct pci_resource *get_io_resource(struct pci_resource **head, u32 size ...@@ -597,15 +595,15 @@ static struct pci_resource *get_io_resource(struct pci_resource **head, u32 size
node->base = temp_dword; node->base = temp_dword;
node->length -= split_node->length; node->length -= split_node->length;
// Put it in the list /* Put it in the list */
split_node->next = node->next; split_node->next = node->next;
node->next = split_node; node->next = split_node;
} // End of non-aligned base } /* End of non-aligned base */
// Don't need to check if too small since we already did /* Don't need to check if too small since we already did */
if (node->length > size) { if (node->length > size) {
// this one is longer than we need /* this one is longer than we need
// so we'll make a new entry and split it up * so we'll make a new entry and split it up */
split_node = (struct pci_resource*) kmalloc(sizeof(struct pci_resource), GFP_KERNEL); split_node = (struct pci_resource*) kmalloc(sizeof(struct pci_resource), GFP_KERNEL);
if (!split_node) if (!split_node)
...@@ -615,17 +613,17 @@ static struct pci_resource *get_io_resource(struct pci_resource **head, u32 size ...@@ -615,17 +613,17 @@ static struct pci_resource *get_io_resource(struct pci_resource **head, u32 size
split_node->length = node->length - size; split_node->length = node->length - size;
node->length = size; node->length = size;
// Put it in the list /* Put it in the list */
split_node->next = node->next; split_node->next = node->next;
node->next = split_node; node->next = split_node;
} // End of too big on top end } /* End of too big on top end */
// For IO make sure it's not in the ISA aliasing space /* For IO make sure it's not in the ISA aliasing space */
if (node->base & 0x300L) if (node->base & 0x300L)
continue; continue;
// If we got here, then it is the right size /* If we got here, then it is the right size
// Now take it out of the list * Now take it out of the list and break */
if (*head == node) { if (*head == node) {
*head = node->next; *head = node->next;
} else { } else {
...@@ -636,7 +634,6 @@ static struct pci_resource *get_io_resource(struct pci_resource **head, u32 size ...@@ -636,7 +634,6 @@ static struct pci_resource *get_io_resource(struct pci_resource **head, u32 size
prevnode->next = node->next; prevnode->next = node->next;
} }
node->next = NULL; node->next = NULL;
// Stop looping
break; break;
} }
...@@ -670,18 +667,17 @@ static struct pci_resource *get_max_resource(struct pci_resource **head, u32 siz ...@@ -670,18 +667,17 @@ static struct pci_resource *get_max_resource(struct pci_resource **head, u32 siz
return NULL; return NULL;
for (max = *head; max; max = max->next) { for (max = *head; max; max = max->next) {
/* If not big enough we could probably just bail,
// If not big enough we could probably just bail, * instead we'll continue to the next. */
// instead we'll continue to the next.
if (max->length < size) if (max->length < size)
continue; continue;
if (max->base & (size - 1)) { if (max->base & (size - 1)) {
// this one isn't base aligned properly /* this one isn't base aligned properly
// so we'll make a new entry and split it up * so we'll make a new entry and split it up */
temp_dword = (max->base | (size-1)) + 1; temp_dword = (max->base | (size-1)) + 1;
// Short circuit if adjusted size is too small /* Short circuit if adjusted size is too small */
if ((max->length - (temp_dword - max->base)) < size) if ((max->length - (temp_dword - max->base)) < size)
continue; continue;
...@@ -695,15 +691,14 @@ static struct pci_resource *get_max_resource(struct pci_resource **head, u32 siz ...@@ -695,15 +691,14 @@ static struct pci_resource *get_max_resource(struct pci_resource **head, u32 siz
max->base = temp_dword; max->base = temp_dword;
max->length -= split_node->length; max->length -= split_node->length;
// Put it next in the list
split_node->next = max->next; split_node->next = max->next;
max->next = split_node; max->next = split_node;
} }
if ((max->base + max->length) & (size - 1)) { if ((max->base + max->length) & (size - 1)) {
// this one isn't end aligned properly at the top /* this one isn't end aligned properly at the top
// so we'll make a new entry and split it up * so we'll make a new entry and split it up */
split_node = (struct pci_resource*) kmalloc(sizeof(struct pci_resource), GFP_KERNEL); split_node = kmalloc(sizeof(struct pci_resource), GFP_KERNEL);
if (!split_node) if (!split_node)
return NULL; return NULL;
...@@ -713,16 +708,15 @@ static struct pci_resource *get_max_resource(struct pci_resource **head, u32 siz ...@@ -713,16 +708,15 @@ static struct pci_resource *get_max_resource(struct pci_resource **head, u32 siz
- split_node->base; - split_node->base;
max->length -= split_node->length; max->length -= split_node->length;
// Put it in the list
split_node->next = max->next; split_node->next = max->next;
max->next = split_node; max->next = split_node;
} }
// Make sure it didn't shrink too much when we aligned it /* Make sure it didn't shrink too much when we aligned it */
if (max->length < size) if (max->length < size)
continue; continue;
// Now take it out of the list /* Now take it out of the list */
temp = (struct pci_resource*) *head; temp = (struct pci_resource*) *head;
if (temp == max) { if (temp == max) {
*head = max->next; *head = max->next;
...@@ -738,7 +732,7 @@ static struct pci_resource *get_max_resource(struct pci_resource **head, u32 siz ...@@ -738,7 +732,7 @@ static struct pci_resource *get_max_resource(struct pci_resource **head, u32 siz
return max; return max;
} }
// If we get here, we couldn't find one /* If we get here, we couldn't find one */
return NULL; return NULL;
} }
...@@ -778,11 +772,11 @@ static struct pci_resource *get_resource(struct pci_resource **head, u32 size) ...@@ -778,11 +772,11 @@ static struct pci_resource *get_resource(struct pci_resource **head, u32 size)
if (node->base & (size - 1)) { if (node->base & (size - 1)) {
dbg("%s: not aligned\n", __FUNCTION__); dbg("%s: not aligned\n", __FUNCTION__);
// this one isn't base aligned properly /* this one isn't base aligned properly
// so we'll make a new entry and split it up * so we'll make a new entry and split it up */
temp_dword = (node->base | (size-1)) + 1; temp_dword = (node->base | (size-1)) + 1;
// Short circuit if adjusted size is too small /* Short circuit if adjusted size is too small */
if ((node->length - (temp_dword - node->base)) < size) if ((node->length - (temp_dword - node->base)) < size)
continue; continue;
...@@ -796,16 +790,15 @@ static struct pci_resource *get_resource(struct pci_resource **head, u32 size) ...@@ -796,16 +790,15 @@ static struct pci_resource *get_resource(struct pci_resource **head, u32 size)
node->base = temp_dword; node->base = temp_dword;
node->length -= split_node->length; node->length -= split_node->length;
// Put it in the list
split_node->next = node->next; split_node->next = node->next;
node->next = split_node; node->next = split_node;
} // End of non-aligned base } /* End of non-aligned base */
// Don't need to check if too small since we already did /* Don't need to check if too small since we already did */
if (node->length > size) { if (node->length > size) {
dbg("%s: too big\n", __FUNCTION__); dbg("%s: too big\n", __FUNCTION__);
// this one is longer than we need /* this one is longer than we need
// so we'll make a new entry and split it up * so we'll make a new entry and split it up */
split_node = (struct pci_resource*) kmalloc(sizeof(struct pci_resource), GFP_KERNEL); split_node = (struct pci_resource*) kmalloc(sizeof(struct pci_resource), GFP_KERNEL);
if (!split_node) if (!split_node)
...@@ -815,14 +808,14 @@ static struct pci_resource *get_resource(struct pci_resource **head, u32 size) ...@@ -815,14 +808,14 @@ static struct pci_resource *get_resource(struct pci_resource **head, u32 size)
split_node->length = node->length - size; split_node->length = node->length - size;
node->length = size; node->length = size;
// Put it in the list /* Put it in the list */
split_node->next = node->next; split_node->next = node->next;
node->next = split_node; node->next = split_node;
} // End of too big on top end } /* End of too big on top end */
dbg("%s: got one!!!\n", __FUNCTION__); dbg("%s: got one!!!\n", __FUNCTION__);
// If we got here, then it is the right size /* If we got here, then it is the right size
// Now take it out of the list * Now take it out of the list */
if (*head == node) { if (*head == node) {
*head = node->next; *head = node->next;
} else { } else {
...@@ -833,7 +826,6 @@ static struct pci_resource *get_resource(struct pci_resource **head, u32 size) ...@@ -833,7 +826,6 @@ static struct pci_resource *get_resource(struct pci_resource **head, u32 size)
prevnode->next = node->next; prevnode->next = node->next;
} }
node->next = NULL; node->next = NULL;
// Stop looping
break; break;
} }
return node; return node;
...@@ -871,7 +863,7 @@ int cpqhp_resource_sort_and_combine(struct pci_resource **head) ...@@ -871,7 +863,7 @@ int cpqhp_resource_sort_and_combine(struct pci_resource **head)
while (out_of_order) { while (out_of_order) {
out_of_order = 0; out_of_order = 0;
// Special case for swapping list head /* Special case for swapping list head */
if (((*head)->next) && if (((*head)->next) &&
((*head)->base > (*head)->next->base)) { ((*head)->base > (*head)->next->base)) {
node1 = *head; node1 = *head;
...@@ -894,13 +886,13 @@ int cpqhp_resource_sort_and_combine(struct pci_resource **head) ...@@ -894,13 +886,13 @@ int cpqhp_resource_sort_and_combine(struct pci_resource **head)
} else } else
node1 = node1->next; node1 = node1->next;
} }
} // End of out_of_order loop } /* End of out_of_order loop */
node1 = *head; node1 = *head;
while (node1 && node1->next) { while (node1 && node1->next) {
if ((node1->base + node1->length) == node1->next->base) { if ((node1->base + node1->length) == node1->next->base) {
// Combine /* Combine */
dbg("8..\n"); dbg("8..\n");
node1->length += node1->next->length; node1->length += node1->next->length;
node2 = node1->next; node2 = node1->next;
...@@ -925,23 +917,23 @@ irqreturn_t cpqhp_ctrl_intr(int IRQ, void *data, struct pt_regs *regs) ...@@ -925,23 +917,23 @@ irqreturn_t cpqhp_ctrl_intr(int IRQ, void *data, struct pt_regs *regs)
misc = readw(ctrl->hpc_reg + MISC); misc = readw(ctrl->hpc_reg + MISC);
//********************************* /***************************************
// Check to see if it was our interrupt * Check to see if it was our interrupt
//********************************* ***************************************/
if (!(misc & 0x000C)) { if (!(misc & 0x000C)) {
return IRQ_NONE; return IRQ_NONE;
} }
if (misc & 0x0004) { if (misc & 0x0004) {
//********************************* /**********************************
// Serial Output interrupt Pending * Serial Output interrupt Pending
//********************************* **********************************/
// Clear the interrupt /* Clear the interrupt */
misc |= 0x0004; misc |= 0x0004;
writew(misc, ctrl->hpc_reg + MISC); writew(misc, ctrl->hpc_reg + MISC);
// Read to clear posted writes /* Read to clear posted writes */
misc = readw(ctrl->hpc_reg + MISC); misc = readw(ctrl->hpc_reg + MISC);
dbg ("%s - waking up\n", __FUNCTION__); dbg ("%s - waking up\n", __FUNCTION__);
...@@ -949,21 +941,20 @@ irqreturn_t cpqhp_ctrl_intr(int IRQ, void *data, struct pt_regs *regs) ...@@ -949,21 +941,20 @@ irqreturn_t cpqhp_ctrl_intr(int IRQ, void *data, struct pt_regs *regs)
} }
if (misc & 0x0008) { if (misc & 0x0008) {
// General-interrupt-input interrupt Pending /* General-interrupt-input interrupt Pending */
Diff = readl(ctrl->hpc_reg + INT_INPUT_CLEAR) ^ ctrl->ctrl_int_comp; Diff = readl(ctrl->hpc_reg + INT_INPUT_CLEAR) ^ ctrl->ctrl_int_comp;
ctrl->ctrl_int_comp = readl(ctrl->hpc_reg + INT_INPUT_CLEAR); ctrl->ctrl_int_comp = readl(ctrl->hpc_reg + INT_INPUT_CLEAR);
// Clear the interrupt /* Clear the interrupt */
writel(Diff, ctrl->hpc_reg + INT_INPUT_CLEAR); writel(Diff, ctrl->hpc_reg + INT_INPUT_CLEAR);
// Read it back to clear any posted writes /* Read it back to clear any posted writes */
temp_dword = readl(ctrl->hpc_reg + INT_INPUT_CLEAR); temp_dword = readl(ctrl->hpc_reg + INT_INPUT_CLEAR);
if (!Diff) { if (!Diff)
// Clear all interrupts /* Clear all interrupts */
writel(0xFFFFFFFF, ctrl->hpc_reg + INT_INPUT_CLEAR); writel(0xFFFFFFFF, ctrl->hpc_reg + INT_INPUT_CLEAR);
}
schedule_flag += handle_switch_change((u8)(Diff & 0xFFL), ctrl); schedule_flag += handle_switch_change((u8)(Diff & 0xFFL), ctrl);
schedule_flag += handle_presence_change((u16)((Diff & 0xFFFF0000L) >> 16), ctrl); schedule_flag += handle_presence_change((u16)((Diff & 0xFFFF0000L) >> 16), ctrl);
...@@ -1001,8 +992,8 @@ struct pci_func *cpqhp_slot_create(u8 busnumber) ...@@ -1001,8 +992,8 @@ struct pci_func *cpqhp_slot_create(u8 busnumber)
new_slot = (struct pci_func *) kmalloc(sizeof(struct pci_func), GFP_KERNEL); new_slot = (struct pci_func *) kmalloc(sizeof(struct pci_func), GFP_KERNEL);
if (new_slot == NULL) { if (new_slot == NULL) {
// I'm not dead yet! /* I'm not dead yet!
// You will be. * You will be. */
return new_slot; return new_slot;
} }
...@@ -1149,11 +1140,11 @@ struct pci_func *cpqhp_slot_find(u8 bus, u8 device, u8 index) ...@@ -1149,11 +1140,11 @@ struct pci_func *cpqhp_slot_find(u8 bus, u8 device, u8 index)
} }
// DJZ: I don't think is_bridge will work as is. /* DJZ: I don't think is_bridge will work as is.
//FIXME * FIXME */
static int is_bridge(struct pci_func * func) static int is_bridge(struct pci_func * func)
{ {
// Check the header type /* Check the header type */
if (((func->config_space[0x03] >> 16) & 0xFF) == 0x01) if (((func->config_space[0x03] >> 16) & 0xFF) == 0x01)
return 1; return 1;
else else
...@@ -1320,36 +1311,35 @@ static u32 board_replaced(struct pci_func * func, struct controller * ctrl) ...@@ -1320,36 +1311,35 @@ static u32 board_replaced(struct pci_func * func, struct controller * ctrl)
hp_slot = func->device - ctrl->slot_device_offset; hp_slot = func->device - ctrl->slot_device_offset;
if (readl(ctrl->hpc_reg + INT_INPUT_CLEAR) & (0x01L << hp_slot)) { if (readl(ctrl->hpc_reg + INT_INPUT_CLEAR) & (0x01L << hp_slot)) {
//********************************* /**********************************
// The switch is open. * The switch is open.
//********************************* **********************************/
rc = INTERLOCK_OPEN; rc = INTERLOCK_OPEN;
} else if (is_slot_enabled (ctrl, hp_slot)) { } else if (is_slot_enabled (ctrl, hp_slot)) {
//********************************* /**********************************
// The board is already on * The board is already on
//********************************* **********************************/
rc = CARD_FUNCTIONING; rc = CARD_FUNCTIONING;
} else { } else {
// Wait for exclusive access to hardware
down(&ctrl->crit_sect); down(&ctrl->crit_sect);
// turn on board without attaching to the bus /* turn on board without attaching to the bus */
enable_slot_power (ctrl, hp_slot); enable_slot_power (ctrl, hp_slot);
set_SOGO(ctrl); set_SOGO(ctrl);
// Wait for SOBS to be unset /* Wait for SOBS to be unset */
wait_for_ctrl_irq (ctrl); wait_for_ctrl_irq (ctrl);
// Change bits in slot power register to force another shift out /* Change bits in slot power register to force another shift out
// NOTE: this is to work around the timer bug * NOTE: this is to work around the timer bug */
temp_byte = readb(ctrl->hpc_reg + SLOT_POWER); temp_byte = readb(ctrl->hpc_reg + SLOT_POWER);
writeb(0x00, ctrl->hpc_reg + SLOT_POWER); writeb(0x00, ctrl->hpc_reg + SLOT_POWER);
writeb(temp_byte, ctrl->hpc_reg + SLOT_POWER); writeb(temp_byte, ctrl->hpc_reg + SLOT_POWER);
set_SOGO(ctrl); set_SOGO(ctrl);
// Wait for SOBS to be unset /* Wait for SOBS to be unset */
wait_for_ctrl_irq (ctrl); wait_for_ctrl_irq (ctrl);
adapter_speed = get_adapter_speed(ctrl, hp_slot); adapter_speed = get_adapter_speed(ctrl, hp_slot);
...@@ -1357,21 +1347,19 @@ static u32 board_replaced(struct pci_func * func, struct controller * ctrl) ...@@ -1357,21 +1347,19 @@ static u32 board_replaced(struct pci_func * func, struct controller * ctrl)
if (set_controller_speed(ctrl, adapter_speed, hp_slot)) if (set_controller_speed(ctrl, adapter_speed, hp_slot))
rc = WRONG_BUS_FREQUENCY; rc = WRONG_BUS_FREQUENCY;
// turn off board without attaching to the bus /* turn off board without attaching to the bus */
disable_slot_power (ctrl, hp_slot); disable_slot_power (ctrl, hp_slot);
set_SOGO(ctrl); set_SOGO(ctrl);
// Wait for SOBS to be unset /* Wait for SOBS to be unset */
wait_for_ctrl_irq (ctrl); wait_for_ctrl_irq (ctrl);
// Done with exclusive hardware access
up(&ctrl->crit_sect); up(&ctrl->crit_sect);
if (rc) if (rc)
return rc; return rc;
// Wait for exclusive access to hardware
down(&ctrl->crit_sect); down(&ctrl->crit_sect);
slot_enable (ctrl, hp_slot); slot_enable (ctrl, hp_slot);
...@@ -1381,35 +1369,34 @@ static u32 board_replaced(struct pci_func * func, struct controller * ctrl) ...@@ -1381,35 +1369,34 @@ static u32 board_replaced(struct pci_func * func, struct controller * ctrl)
set_SOGO(ctrl); set_SOGO(ctrl);
// Wait for SOBS to be unset /* Wait for SOBS to be unset */
wait_for_ctrl_irq (ctrl); wait_for_ctrl_irq (ctrl);
// Done with exclusive hardware access
up(&ctrl->crit_sect); up(&ctrl->crit_sect);
// Wait for ~1 second because of hot plug spec /* Wait for ~1 second because of hot plug spec */
long_delay(1*HZ); long_delay(1*HZ);
// Check for a power fault /* Check for a power fault */
if (func->status == 0xFF) { if (func->status == 0xFF) {
// power fault occurred, but it was benign /* power fault occurred, but it was benign */
rc = POWER_FAILURE; rc = POWER_FAILURE;
func->status = 0; func->status = 0;
} else } else
rc = cpqhp_valid_replace(ctrl, func); rc = cpqhp_valid_replace(ctrl, func);
if (!rc) { if (!rc) {
// It must be the same board /* It must be the same board */
rc = cpqhp_configure_board(ctrl, func); rc = cpqhp_configure_board(ctrl, func);
if (rc || src) { if (rc || src) {
// If configuration fails, turn it off /* If configuration fails, turn it off
// Get slot won't work for devices behind bridges, but * Get slot won't work for devices behind
// in this case it will always be called for the "base" * bridges, but in this case it will always be
// bus/dev/func of an adapter. * called for the "base" bus/dev/func of an
* adapter. */
// Wait for exclusive access to hardware
down(&ctrl->crit_sect); down(&ctrl->crit_sect);
amber_LED_on (ctrl, hp_slot); amber_LED_on (ctrl, hp_slot);
...@@ -1418,10 +1405,9 @@ static u32 board_replaced(struct pci_func * func, struct controller * ctrl) ...@@ -1418,10 +1405,9 @@ static u32 board_replaced(struct pci_func * func, struct controller * ctrl)
set_SOGO(ctrl); set_SOGO(ctrl);
// Wait for SOBS to be unset /* Wait for SOBS to be unset */
wait_for_ctrl_irq (ctrl); wait_for_ctrl_irq (ctrl);
// Done with exclusive hardware access
up(&ctrl->crit_sect); up(&ctrl->crit_sect);
if (rc) if (rc)
...@@ -1440,12 +1426,12 @@ static u32 board_replaced(struct pci_func * func, struct controller * ctrl) ...@@ -1440,12 +1426,12 @@ static u32 board_replaced(struct pci_func * func, struct controller * ctrl)
} }
if (rc) { if (rc) {
// If configuration fails, turn it off /* If configuration fails, turn it off
// Get slot won't work for devices behind bridges, but * Get slot won't work for devices behind
// in this case it will always be called for the "base" * bridges, but in this case it will always be
// bus/dev/func of an adapter. * called for the "base" bus/dev/func of an
* adapter. */
// Wait for exclusive access to hardware
down(&ctrl->crit_sect); down(&ctrl->crit_sect);
amber_LED_on (ctrl, hp_slot); amber_LED_on (ctrl, hp_slot);
...@@ -1454,37 +1440,33 @@ static u32 board_replaced(struct pci_func * func, struct controller * ctrl) ...@@ -1454,37 +1440,33 @@ static u32 board_replaced(struct pci_func * func, struct controller * ctrl)
set_SOGO(ctrl); set_SOGO(ctrl);
// Wait for SOBS to be unset /* Wait for SOBS to be unset */
wait_for_ctrl_irq (ctrl); wait_for_ctrl_irq (ctrl);
// Done with exclusive hardware access
up(&ctrl->crit_sect); up(&ctrl->crit_sect);
return rc; return rc;
} }
// Done configuring so turn LED on full time /* Done configuring so turn LED on full time */
// Wait for exclusive access to hardware
down(&ctrl->crit_sect); down(&ctrl->crit_sect);
green_LED_on (ctrl, hp_slot); green_LED_on (ctrl, hp_slot);
set_SOGO(ctrl); set_SOGO(ctrl);
// Wait for SOBS to be unset /* Wait for SOBS to be unset */
wait_for_ctrl_irq (ctrl); wait_for_ctrl_irq (ctrl);
// Done with exclusive hardware access
up(&ctrl->crit_sect); up(&ctrl->crit_sect);
rc = 0; rc = 0;
} else { } else {
// Something is wrong /* Something is wrong
// Get slot won't work for devices behind bridges, but * Get slot won't work for devices behind bridges, but
// in this case it will always be called for the "base" * in this case it will always be called for the "base"
// bus/dev/func of an adapter. * bus/dev/func of an adapter. */
// Wait for exclusive access to hardware
down(&ctrl->crit_sect); down(&ctrl->crit_sect);
amber_LED_on (ctrl, hp_slot); amber_LED_on (ctrl, hp_slot);
...@@ -1493,10 +1475,9 @@ static u32 board_replaced(struct pci_func * func, struct controller * ctrl) ...@@ -1493,10 +1475,9 @@ static u32 board_replaced(struct pci_func * func, struct controller * ctrl)
set_SOGO(ctrl); set_SOGO(ctrl);
// Wait for SOBS to be unset /* Wait for SOBS to be unset */
wait_for_ctrl_irq (ctrl); wait_for_ctrl_irq (ctrl);
// Done with exclusive hardware access
up(&ctrl->crit_sect); up(&ctrl->crit_sect);
} }
...@@ -1529,26 +1510,25 @@ static u32 board_added(struct pci_func * func, struct controller * ctrl) ...@@ -1529,26 +1510,25 @@ static u32 board_added(struct pci_func * func, struct controller * ctrl)
dbg("%s: func->device, slot_offset, hp_slot = %d, %d ,%d\n", dbg("%s: func->device, slot_offset, hp_slot = %d, %d ,%d\n",
__FUNCTION__, func->device, ctrl->slot_device_offset, hp_slot); __FUNCTION__, func->device, ctrl->slot_device_offset, hp_slot);
// Wait for exclusive access to hardware
down(&ctrl->crit_sect); down(&ctrl->crit_sect);
// turn on board without attaching to the bus /* turn on board without attaching to the bus */
enable_slot_power(ctrl, hp_slot); enable_slot_power(ctrl, hp_slot);
set_SOGO(ctrl); set_SOGO(ctrl);
// Wait for SOBS to be unset /* Wait for SOBS to be unset */
wait_for_ctrl_irq (ctrl); wait_for_ctrl_irq (ctrl);
// Change bits in slot power register to force another shift out /* Change bits in slot power register to force another shift out
// NOTE: this is to work around the timer bug * NOTE: this is to work around the timer bug */
temp_byte = readb(ctrl->hpc_reg + SLOT_POWER); temp_byte = readb(ctrl->hpc_reg + SLOT_POWER);
writeb(0x00, ctrl->hpc_reg + SLOT_POWER); writeb(0x00, ctrl->hpc_reg + SLOT_POWER);
writeb(temp_byte, ctrl->hpc_reg + SLOT_POWER); writeb(temp_byte, ctrl->hpc_reg + SLOT_POWER);
set_SOGO(ctrl); set_SOGO(ctrl);
// Wait for SOBS to be unset /* Wait for SOBS to be unset */
wait_for_ctrl_irq (ctrl); wait_for_ctrl_irq (ctrl);
adapter_speed = get_adapter_speed(ctrl, hp_slot); adapter_speed = get_adapter_speed(ctrl, hp_slot);
...@@ -1556,15 +1536,14 @@ static u32 board_added(struct pci_func * func, struct controller * ctrl) ...@@ -1556,15 +1536,14 @@ static u32 board_added(struct pci_func * func, struct controller * ctrl)
if (set_controller_speed(ctrl, adapter_speed, hp_slot)) if (set_controller_speed(ctrl, adapter_speed, hp_slot))
rc = WRONG_BUS_FREQUENCY; rc = WRONG_BUS_FREQUENCY;
// turn off board without attaching to the bus /* turn off board without attaching to the bus */
disable_slot_power (ctrl, hp_slot); disable_slot_power (ctrl, hp_slot);
set_SOGO(ctrl); set_SOGO(ctrl);
// Wait for SOBS to be unset /* Wait for SOBS to be unset */
wait_for_ctrl_irq(ctrl); wait_for_ctrl_irq(ctrl);
// Done with exclusive hardware access
up(&ctrl->crit_sect); up(&ctrl->crit_sect);
if (rc) if (rc)
...@@ -1572,9 +1551,8 @@ static u32 board_added(struct pci_func * func, struct controller * ctrl) ...@@ -1572,9 +1551,8 @@ static u32 board_added(struct pci_func * func, struct controller * ctrl)
p_slot = cpqhp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset); p_slot = cpqhp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset);
// turn on board and blink green LED /* turn on board and blink green LED */
// Wait for exclusive access to hardware
dbg("%s: before down\n", __FUNCTION__); dbg("%s: before down\n", __FUNCTION__);
down(&ctrl->crit_sect); down(&ctrl->crit_sect);
dbg("%s: after down\n", __FUNCTION__); dbg("%s: after down\n", __FUNCTION__);
...@@ -1591,47 +1569,46 @@ static u32 board_added(struct pci_func * func, struct controller * ctrl) ...@@ -1591,47 +1569,46 @@ static u32 board_added(struct pci_func * func, struct controller * ctrl)
dbg("%s: before set_SOGO\n", __FUNCTION__); dbg("%s: before set_SOGO\n", __FUNCTION__);
set_SOGO(ctrl); set_SOGO(ctrl);
// Wait for SOBS to be unset /* Wait for SOBS to be unset */
dbg("%s: before wait_for_ctrl_irq\n", __FUNCTION__); dbg("%s: before wait_for_ctrl_irq\n", __FUNCTION__);
wait_for_ctrl_irq (ctrl); wait_for_ctrl_irq (ctrl);
dbg("%s: after wait_for_ctrl_irq\n", __FUNCTION__); dbg("%s: after wait_for_ctrl_irq\n", __FUNCTION__);
// Done with exclusive hardware access
dbg("%s: before up\n", __FUNCTION__); dbg("%s: before up\n", __FUNCTION__);
up(&ctrl->crit_sect); up(&ctrl->crit_sect);
dbg("%s: after up\n", __FUNCTION__); dbg("%s: after up\n", __FUNCTION__);
// Wait for ~1 second because of hot plug spec /* Wait for ~1 second because of hot plug spec */
dbg("%s: before long_delay\n", __FUNCTION__); dbg("%s: before long_delay\n", __FUNCTION__);
long_delay(1*HZ); long_delay(1*HZ);
dbg("%s: after long_delay\n", __FUNCTION__); dbg("%s: after long_delay\n", __FUNCTION__);
dbg("%s: func status = %x\n", __FUNCTION__, func->status); dbg("%s: func status = %x\n", __FUNCTION__, func->status);
// Check for a power fault /* Check for a power fault */
if (func->status == 0xFF) { if (func->status == 0xFF) {
// power fault occurred, but it was benign /* power fault occurred, but it was benign */
temp_register = 0xFFFFFFFF; temp_register = 0xFFFFFFFF;
dbg("%s: temp register set to %x by power fault\n", __FUNCTION__, temp_register); dbg("%s: temp register set to %x by power fault\n", __FUNCTION__, temp_register);
rc = POWER_FAILURE; rc = POWER_FAILURE;
func->status = 0; func->status = 0;
} else { } else {
// Get vendor/device ID u32 /* Get vendor/device ID u32 */
ctrl->pci_bus->number = func->bus; ctrl->pci_bus->number = func->bus;
rc = pci_bus_read_config_dword (ctrl->pci_bus, PCI_DEVFN(func->device, func->function), PCI_VENDOR_ID, &temp_register); rc = pci_bus_read_config_dword (ctrl->pci_bus, PCI_DEVFN(func->device, func->function), PCI_VENDOR_ID, &temp_register);
dbg("%s: pci_read_config_dword returns %d\n", __FUNCTION__, rc); dbg("%s: pci_read_config_dword returns %d\n", __FUNCTION__, rc);
dbg("%s: temp_register is %x\n", __FUNCTION__, temp_register); dbg("%s: temp_register is %x\n", __FUNCTION__, temp_register);
if (rc != 0) { if (rc != 0) {
// Something's wrong here /* Something's wrong here */
temp_register = 0xFFFFFFFF; temp_register = 0xFFFFFFFF;
dbg("%s: temp register set to %x by error\n", __FUNCTION__, temp_register); dbg("%s: temp register set to %x by error\n", __FUNCTION__, temp_register);
} }
// Preset return code. It will be changed later if things go okay. /* Preset return code. It will be changed later if things go okay. */
rc = NO_ADAPTER_PRESENT; rc = NO_ADAPTER_PRESENT;
} }
// All F's is an empty slot or an invalid board /* All F's is an empty slot or an invalid board */
if (temp_register != 0xFFFFFFFF) { // Check for a board in the slot if (temp_register != 0xFFFFFFFF) { /* Check for a board in the slot */
res_lists.io_head = ctrl->io_head; res_lists.io_head = ctrl->io_head;
res_lists.mem_head = ctrl->mem_head; res_lists.mem_head = ctrl->mem_head;
res_lists.p_mem_head = ctrl->p_mem_head; res_lists.p_mem_head = ctrl->p_mem_head;
...@@ -1652,7 +1629,6 @@ static u32 board_added(struct pci_func * func, struct controller * ctrl) ...@@ -1652,7 +1629,6 @@ static u32 board_added(struct pci_func * func, struct controller * ctrl)
cpqhp_resource_sort_and_combine(&(ctrl->bus_head)); cpqhp_resource_sort_and_combine(&(ctrl->bus_head));
if (rc) { if (rc) {
// Wait for exclusive access to hardware
down(&ctrl->crit_sect); down(&ctrl->crit_sect);
amber_LED_on (ctrl, hp_slot); amber_LED_on (ctrl, hp_slot);
...@@ -1661,10 +1637,9 @@ static u32 board_added(struct pci_func * func, struct controller * ctrl) ...@@ -1661,10 +1637,9 @@ static u32 board_added(struct pci_func * func, struct controller * ctrl)
set_SOGO(ctrl); set_SOGO(ctrl);
// Wait for SOBS to be unset /* Wait for SOBS to be unset */
wait_for_ctrl_irq (ctrl); wait_for_ctrl_irq (ctrl);
// Done with exclusive hardware access
up(&ctrl->crit_sect); up(&ctrl->crit_sect);
return rc; return rc;
} else { } else {
...@@ -1676,7 +1651,8 @@ static u32 board_added(struct pci_func * func, struct controller * ctrl) ...@@ -1676,7 +1651,8 @@ static u32 board_added(struct pci_func * func, struct controller * ctrl)
func->switch_save = 0x10; func->switch_save = 0x10;
func->is_a_board = 0x01; func->is_a_board = 0x01;
//next, we will instantiate the linux pci_dev structures (with appropriate driver notification, if already present) /* next, we will instantiate the linux pci_dev structures (with
* appropriate driver notification, if already present) */
dbg("%s: configure linux pci_dev structure\n", __FUNCTION__); dbg("%s: configure linux pci_dev structure\n", __FUNCTION__);
index = 0; index = 0;
do { do {
...@@ -1686,20 +1662,17 @@ static u32 board_added(struct pci_func * func, struct controller * ctrl) ...@@ -1686,20 +1662,17 @@ static u32 board_added(struct pci_func * func, struct controller * ctrl)
} }
} while (new_slot); } while (new_slot);
// Wait for exclusive access to hardware
down(&ctrl->crit_sect); down(&ctrl->crit_sect);
green_LED_on (ctrl, hp_slot); green_LED_on (ctrl, hp_slot);
set_SOGO(ctrl); set_SOGO(ctrl);
// Wait for SOBS to be unset /* Wait for SOBS to be unset */
wait_for_ctrl_irq (ctrl); wait_for_ctrl_irq (ctrl);
// Done with exclusive hardware access
up(&ctrl->crit_sect); up(&ctrl->crit_sect);
} else { } else {
// Wait for exclusive access to hardware
down(&ctrl->crit_sect); down(&ctrl->crit_sect);
amber_LED_on (ctrl, hp_slot); amber_LED_on (ctrl, hp_slot);
...@@ -1708,10 +1681,9 @@ static u32 board_added(struct pci_func * func, struct controller * ctrl) ...@@ -1708,10 +1681,9 @@ static u32 board_added(struct pci_func * func, struct controller * ctrl)
set_SOGO(ctrl); set_SOGO(ctrl);
// Wait for SOBS to be unset /* Wait for SOBS to be unset */
wait_for_ctrl_irq (ctrl); wait_for_ctrl_irq (ctrl);
// Done with exclusive hardware access
up(&ctrl->crit_sect); up(&ctrl->crit_sect);
return rc; return rc;
...@@ -1746,15 +1718,15 @@ static u32 remove_board(struct pci_func * func, u32 replace_flag, struct control ...@@ -1746,15 +1718,15 @@ static u32 remove_board(struct pci_func * func, u32 replace_flag, struct control
hp_slot = func->device - ctrl->slot_device_offset; hp_slot = func->device - ctrl->slot_device_offset;
dbg("In %s, hp_slot = %d\n", __FUNCTION__, hp_slot); dbg("In %s, hp_slot = %d\n", __FUNCTION__, hp_slot);
// When we get here, it is safe to change base Address Registers. /* When we get here, it is safe to change base address registers.
// We will attempt to save the base Address Register Lengths * We will attempt to save the base address register lengths */
if (replace_flag || !ctrl->add_support) if (replace_flag || !ctrl->add_support)
rc = cpqhp_save_base_addr_length(ctrl, func); rc = cpqhp_save_base_addr_length(ctrl, func);
else if (!func->bus_head && !func->mem_head && else if (!func->bus_head && !func->mem_head &&
!func->p_mem_head && !func->io_head) { !func->p_mem_head && !func->io_head) {
// Here we check to see if we've saved any of the board's /* Here we check to see if we've saved any of the board's
// resources already. If so, we'll skip the attempt to * resources already. If so, we'll skip the attempt to
// determine what's being used. * determine what's being used. */
index = 0; index = 0;
temp_func = cpqhp_slot_find(func->bus, func->device, index++); temp_func = cpqhp_slot_find(func->bus, func->device, index++);
while (temp_func) { while (temp_func) {
...@@ -1769,12 +1741,11 @@ static u32 remove_board(struct pci_func * func, u32 replace_flag, struct control ...@@ -1769,12 +1741,11 @@ static u32 remove_board(struct pci_func * func, u32 replace_flag, struct control
if (!skip) if (!skip)
rc = cpqhp_save_used_resources(ctrl, func); rc = cpqhp_save_used_resources(ctrl, func);
} }
// Change status to shutdown /* Change status to shutdown */
if (func->is_a_board) if (func->is_a_board)
func->status = 0x01; func->status = 0x01;
func->configured = 0; func->configured = 0;
// Wait for exclusive access to hardware
down(&ctrl->crit_sect); down(&ctrl->crit_sect);
green_LED_off (ctrl, hp_slot); green_LED_off (ctrl, hp_slot);
...@@ -1782,15 +1753,14 @@ static u32 remove_board(struct pci_func * func, u32 replace_flag, struct control ...@@ -1782,15 +1753,14 @@ static u32 remove_board(struct pci_func * func, u32 replace_flag, struct control
set_SOGO(ctrl); set_SOGO(ctrl);
// turn off SERR for slot /* turn off SERR for slot */
temp_byte = readb(ctrl->hpc_reg + SLOT_SERR); temp_byte = readb(ctrl->hpc_reg + SLOT_SERR);
temp_byte &= ~(0x01 << hp_slot); temp_byte &= ~(0x01 << hp_slot);
writeb(temp_byte, ctrl->hpc_reg + SLOT_SERR); writeb(temp_byte, ctrl->hpc_reg + SLOT_SERR);
// Wait for SOBS to be unset /* Wait for SOBS to be unset */
wait_for_ctrl_irq (ctrl); wait_for_ctrl_irq (ctrl);
// Done with exclusive hardware access
up(&ctrl->crit_sect); up(&ctrl->crit_sect);
if (!replace_flag && ctrl->add_support) { if (!replace_flag && ctrl->add_support) {
...@@ -1820,13 +1790,11 @@ static u32 remove_board(struct pci_func * func, u32 replace_flag, struct control ...@@ -1820,13 +1790,11 @@ static u32 remove_board(struct pci_func * func, u32 replace_flag, struct control
func = cpqhp_slot_find(ctrl->bus, device, 0); func = cpqhp_slot_find(ctrl->bus, device, 0);
} }
// Setup slot structure with entry for empty slot /* Setup slot structure with entry for empty slot */
func = cpqhp_slot_create(ctrl->bus); func = cpqhp_slot_create(ctrl->bus);
if (func == NULL) { if (func == NULL)
// Out of memory
return 1; return 1;
}
func->bus = ctrl->bus; func->bus = ctrl->bus;
func->device = device; func->device = device;
...@@ -1847,7 +1815,7 @@ static void pushbutton_helper_thread(unsigned long data) ...@@ -1847,7 +1815,7 @@ static void pushbutton_helper_thread(unsigned long data)
} }
// this is the main worker thread /* this is the main worker thread */
static int event_thread(void* data) static int event_thread(void* data)
{ {
struct controller *ctrl; struct controller *ctrl;
...@@ -1934,7 +1902,7 @@ static void interrupt_event_handler(struct controller *ctrl) ...@@ -1934,7 +1902,7 @@ static void interrupt_event_handler(struct controller *ctrl)
change = 0; change = 0;
for (loop = 0; loop < 10; loop++) { for (loop = 0; loop < 10; loop++) {
//dbg("loop %d\n", loop); /* dbg("loop %d\n", loop); */
if (ctrl->event_queue[loop].event_type != 0) { if (ctrl->event_queue[loop].event_type != 0) {
hp_slot = ctrl->event_queue[loop].hp_slot; hp_slot = ctrl->event_queue[loop].hp_slot;
...@@ -1956,17 +1924,14 @@ static void interrupt_event_handler(struct controller *ctrl) ...@@ -1956,17 +1924,14 @@ static void interrupt_event_handler(struct controller *ctrl)
dbg("button cancel\n"); dbg("button cancel\n");
del_timer(&p_slot->task_event); del_timer(&p_slot->task_event);
// Wait for exclusive access to hardware
down(&ctrl->crit_sect); down(&ctrl->crit_sect);
if (p_slot->state == BLINKINGOFF_STATE) { if (p_slot->state == BLINKINGOFF_STATE) {
// slot is on /* slot is on */
// turn on green LED
dbg("turn on green LED\n"); dbg("turn on green LED\n");
green_LED_on (ctrl, hp_slot); green_LED_on (ctrl, hp_slot);
} else if (p_slot->state == BLINKINGON_STATE) { } else if (p_slot->state == BLINKINGON_STATE) {
// slot is off /* slot is off */
// turn off green LED
dbg("turn off green LED\n"); dbg("turn off green LED\n");
green_LED_off (ctrl, hp_slot); green_LED_off (ctrl, hp_slot);
} }
...@@ -1979,28 +1944,24 @@ static void interrupt_event_handler(struct controller *ctrl) ...@@ -1979,28 +1944,24 @@ static void interrupt_event_handler(struct controller *ctrl)
set_SOGO(ctrl); set_SOGO(ctrl);
// Wait for SOBS to be unset /* Wait for SOBS to be unset */
wait_for_ctrl_irq (ctrl); wait_for_ctrl_irq (ctrl);
// Done with exclusive hardware access
up(&ctrl->crit_sect); up(&ctrl->crit_sect);
} }
// ***********button Released (No action on press...) /*** button Released (No action on press...) */
else if (ctrl->event_queue[loop].event_type == INT_BUTTON_RELEASE) { else if (ctrl->event_queue[loop].event_type == INT_BUTTON_RELEASE) {
dbg("button release\n"); dbg("button release\n");
if (is_slot_enabled (ctrl, hp_slot)) { if (is_slot_enabled (ctrl, hp_slot)) {
// slot is on
dbg("slot is on\n"); dbg("slot is on\n");
p_slot->state = BLINKINGOFF_STATE; p_slot->state = BLINKINGOFF_STATE;
info(msg_button_off, p_slot->number); info(msg_button_off, p_slot->number);
} else { } else {
// slot is off
dbg("slot is off\n"); dbg("slot is off\n");
p_slot->state = BLINKINGON_STATE; p_slot->state = BLINKINGON_STATE;
info(msg_button_on, p_slot->number); info(msg_button_on, p_slot->number);
} }
// Wait for exclusive access to hardware
down(&ctrl->crit_sect); down(&ctrl->crit_sect);
dbg("blink green LED and turn off amber\n"); dbg("blink green LED and turn off amber\n");
...@@ -2010,23 +1971,22 @@ static void interrupt_event_handler(struct controller *ctrl) ...@@ -2010,23 +1971,22 @@ static void interrupt_event_handler(struct controller *ctrl)
set_SOGO(ctrl); set_SOGO(ctrl);
// Wait for SOBS to be unset /* Wait for SOBS to be unset */
wait_for_ctrl_irq (ctrl); wait_for_ctrl_irq (ctrl);
// Done with exclusive hardware access
up(&ctrl->crit_sect); up(&ctrl->crit_sect);
init_timer(&p_slot->task_event); init_timer(&p_slot->task_event);
p_slot->hp_slot = hp_slot; p_slot->hp_slot = hp_slot;
p_slot->ctrl = ctrl; p_slot->ctrl = ctrl;
// p_slot->physical_slot = physical_slot; /* p_slot->physical_slot = physical_slot; */
p_slot->task_event.expires = jiffies + 5 * HZ; // 5 second delay p_slot->task_event.expires = jiffies + 5 * HZ; /* 5 second delay */
p_slot->task_event.function = pushbutton_helper_thread; p_slot->task_event.function = pushbutton_helper_thread;
p_slot->task_event.data = (u32) p_slot; p_slot->task_event.data = (u32) p_slot;
dbg("add_timer p_slot = %p\n", p_slot); dbg("add_timer p_slot = %p\n", p_slot);
add_timer(&p_slot->task_event); add_timer(&p_slot->task_event);
} }
// ***********POWER FAULT /***********POWER FAULT */
else if (ctrl->event_queue[loop].event_type == INT_POWER_FAULT) { else if (ctrl->event_queue[loop].event_type == INT_POWER_FAULT) {
dbg("power fault\n"); dbg("power fault\n");
} else { } else {
...@@ -2039,7 +1999,7 @@ static void interrupt_event_handler(struct controller *ctrl) ...@@ -2039,7 +1999,7 @@ static void interrupt_event_handler(struct controller *ctrl)
change = 1; change = 1;
} }
} // End of FOR loop } /* End of FOR loop */
} }
return; return;
...@@ -2068,7 +2028,7 @@ void cpqhp_pushbutton_thread (unsigned long slot) ...@@ -2068,7 +2028,7 @@ void cpqhp_pushbutton_thread (unsigned long slot)
if (is_slot_enabled (ctrl, hp_slot)) { if (is_slot_enabled (ctrl, hp_slot)) {
p_slot->state = POWEROFF_STATE; p_slot->state = POWEROFF_STATE;
// power Down board /* power Down board */
func = cpqhp_slot_find(p_slot->bus, p_slot->device, 0); func = cpqhp_slot_find(p_slot->bus, p_slot->device, 0);
dbg("In power_down_board, func = %p, ctrl = %p\n", func, ctrl); dbg("In power_down_board, func = %p, ctrl = %p\n", func, ctrl);
if (!func) { if (!func) {
...@@ -2083,7 +2043,7 @@ void cpqhp_pushbutton_thread (unsigned long slot) ...@@ -2083,7 +2043,7 @@ void cpqhp_pushbutton_thread (unsigned long slot)
set_SOGO(ctrl); set_SOGO(ctrl);
// Wait for SOBS to be unset /* Wait for SOBS to be unset */
wait_for_ctrl_irq (ctrl); wait_for_ctrl_irq (ctrl);
} }
} }
...@@ -2091,7 +2051,7 @@ void cpqhp_pushbutton_thread (unsigned long slot) ...@@ -2091,7 +2051,7 @@ void cpqhp_pushbutton_thread (unsigned long slot)
p_slot->state = STATIC_STATE; p_slot->state = STATIC_STATE;
} else { } else {
p_slot->state = POWERON_STATE; p_slot->state = POWERON_STATE;
// slot is off /* slot is off */
func = cpqhp_slot_find(p_slot->bus, p_slot->device, 0); func = cpqhp_slot_find(p_slot->bus, p_slot->device, 0);
dbg("In add_board, func = %p, ctrl = %p\n", func, ctrl); dbg("In add_board, func = %p, ctrl = %p\n", func, ctrl);
...@@ -2107,7 +2067,7 @@ void cpqhp_pushbutton_thread (unsigned long slot) ...@@ -2107,7 +2067,7 @@ void cpqhp_pushbutton_thread (unsigned long slot)
set_SOGO(ctrl); set_SOGO(ctrl);
// Wait for SOBS to be unset /* Wait for SOBS to be unset */
wait_for_ctrl_irq (ctrl); wait_for_ctrl_irq (ctrl);
} }
} }
...@@ -2136,11 +2096,10 @@ int cpqhp_process_SI (struct controller *ctrl, struct pci_func *func) ...@@ -2136,11 +2096,10 @@ int cpqhp_process_SI (struct controller *ctrl, struct pci_func *func)
device = func->device; device = func->device;
hp_slot = device - ctrl->slot_device_offset; hp_slot = device - ctrl->slot_device_offset;
p_slot = cpqhp_find_slot(ctrl, device); p_slot = cpqhp_find_slot(ctrl, device);
if (p_slot) { if (p_slot)
physical_slot = p_slot->number; physical_slot = p_slot->number;
}
// Check to see if the interlock is closed /* Check to see if the interlock is closed */
tempdword = readl(ctrl->hpc_reg + INT_INPUT_CLEAR); tempdword = readl(ctrl->hpc_reg + INT_INPUT_CLEAR);
if (tempdword & (0x01 << hp_slot)) { if (tempdword & (0x01 << hp_slot)) {
...@@ -2150,13 +2109,12 @@ int cpqhp_process_SI (struct controller *ctrl, struct pci_func *func) ...@@ -2150,13 +2109,12 @@ int cpqhp_process_SI (struct controller *ctrl, struct pci_func *func)
if (func->is_a_board) { if (func->is_a_board) {
rc = board_replaced(func, ctrl); rc = board_replaced(func, ctrl);
} else { } else {
// add board /* add board */
slot_remove(func); slot_remove(func);
func = cpqhp_slot_create(ctrl->bus); func = cpqhp_slot_create(ctrl->bus);
if (func == NULL) { if (func == NULL)
return 1; return 1;
}
func->bus = ctrl->bus; func->bus = ctrl->bus;
func->device = device; func->device = device;
...@@ -2164,7 +2122,7 @@ int cpqhp_process_SI (struct controller *ctrl, struct pci_func *func) ...@@ -2164,7 +2122,7 @@ int cpqhp_process_SI (struct controller *ctrl, struct pci_func *func)
func->configured = 0; func->configured = 0;
func->is_a_board = 1; func->is_a_board = 1;
// We have to save the presence info for these slots /* We have to save the presence info for these slots */
temp_word = ctrl->ctrl_int_comp >> 16; temp_word = ctrl->ctrl_int_comp >> 16;
func->presence_save = (temp_word >> hp_slot) & 0x01; func->presence_save = (temp_word >> hp_slot) & 0x01;
func->presence_save |= (temp_word >> (hp_slot + 7)) & 0x02; func->presence_save |= (temp_word >> (hp_slot + 7)) & 0x02;
...@@ -2182,13 +2140,11 @@ int cpqhp_process_SI (struct controller *ctrl, struct pci_func *func) ...@@ -2182,13 +2140,11 @@ int cpqhp_process_SI (struct controller *ctrl, struct pci_func *func)
} else } else
slot_remove(func); slot_remove(func);
// Setup slot structure with entry for empty slot /* Setup slot structure with entry for empty slot */
func = cpqhp_slot_create(ctrl->bus); func = cpqhp_slot_create(ctrl->bus);
if (func == NULL) { if (func == NULL)
// Out of memory
return 1; return 1;
}
func->bus = ctrl->bus; func->bus = ctrl->bus;
func->device = device; func->device = device;
...@@ -2196,7 +2152,7 @@ int cpqhp_process_SI (struct controller *ctrl, struct pci_func *func) ...@@ -2196,7 +2152,7 @@ int cpqhp_process_SI (struct controller *ctrl, struct pci_func *func)
func->configured = 0; func->configured = 0;
func->is_a_board = 0; func->is_a_board = 0;
// We have to save the presence info for these slots /* We have to save the presence info for these slots */
temp_word = ctrl->ctrl_int_comp >> 16; temp_word = ctrl->ctrl_int_comp >> 16;
func->presence_save = (temp_word >> hp_slot) & 0x01; func->presence_save = (temp_word >> hp_slot) & 0x01;
func->presence_save |= func->presence_save |=
...@@ -2239,12 +2195,12 @@ int cpqhp_process_SS (struct controller *ctrl, struct pci_func *func) ...@@ -2239,12 +2195,12 @@ int cpqhp_process_SS (struct controller *ctrl, struct pci_func *func)
physical_slot = p_slot->number; physical_slot = p_slot->number;
} }
// Make sure there are no video controllers here /* Make sure there are no video controllers here */
while (func && !rc) { while (func && !rc) {
pci_bus->number = func->bus; pci_bus->number = func->bus;
devfn = PCI_DEVFN(func->device, func->function); devfn = PCI_DEVFN(func->device, func->function);
// Check the Class Code /* Check the Class Code */
rc = pci_bus_read_config_byte (pci_bus, devfn, 0x0B, &class_code); rc = pci_bus_read_config_byte (pci_bus, devfn, 0x0B, &class_code);
if (rc) if (rc)
return rc; return rc;
...@@ -2253,18 +2209,19 @@ int cpqhp_process_SS (struct controller *ctrl, struct pci_func *func) ...@@ -2253,18 +2209,19 @@ int cpqhp_process_SS (struct controller *ctrl, struct pci_func *func)
/* Display/Video adapter (not supported) */ /* Display/Video adapter (not supported) */
rc = REMOVE_NOT_SUPPORTED; rc = REMOVE_NOT_SUPPORTED;
} else { } else {
// See if it's a bridge /* See if it's a bridge */
rc = pci_bus_read_config_byte (pci_bus, devfn, PCI_HEADER_TYPE, &header_type); rc = pci_bus_read_config_byte (pci_bus, devfn, PCI_HEADER_TYPE, &header_type);
if (rc) if (rc)
return rc; return rc;
// If it's a bridge, check the VGA Enable bit /* If it's a bridge, check the VGA Enable bit */
if ((header_type & 0x7F) == PCI_HEADER_TYPE_BRIDGE) { if ((header_type & 0x7F) == PCI_HEADER_TYPE_BRIDGE) {
rc = pci_bus_read_config_byte (pci_bus, devfn, PCI_BRIDGE_CONTROL, &BCR); rc = pci_bus_read_config_byte (pci_bus, devfn, PCI_BRIDGE_CONTROL, &BCR);
if (rc) if (rc)
return rc; return rc;
// If the VGA Enable bit is set, remove isn't supported /* If the VGA Enable bit is set, remove isn't
* supported */
if (BCR & PCI_BRIDGE_CTL_VGA) { if (BCR & PCI_BRIDGE_CTL_VGA) {
rc = REMOVE_NOT_SUPPORTED; rc = REMOVE_NOT_SUPPORTED;
} }
...@@ -2276,7 +2233,7 @@ int cpqhp_process_SS (struct controller *ctrl, struct pci_func *func) ...@@ -2276,7 +2233,7 @@ int cpqhp_process_SS (struct controller *ctrl, struct pci_func *func)
func = cpqhp_slot_find(ctrl->bus, device, 0); func = cpqhp_slot_find(ctrl->bus, device, 0);
if ((func != NULL) && !rc) { if ((func != NULL) && !rc) {
//FIXME: Replace flag should be passed into process_SS /* FIXME: Replace flag should be passed into process_SS */
replace_flag = !(ctrl->add_support); replace_flag = !(ctrl->add_support);
rc = remove_board(func, replace_flag, ctrl); rc = remove_board(func, replace_flag, ctrl);
} else if (!rc) { } else if (!rc) {
...@@ -2341,7 +2298,6 @@ int cpqhp_hardware_test(struct controller *ctrl, int test_num) ...@@ -2341,7 +2298,6 @@ int cpqhp_hardware_test(struct controller *ctrl, int test_num)
/* so we can restore them later */ /* so we can restore them later */
save_LED = readl(ctrl->hpc_reg + LED_CONTROL); save_LED = readl(ctrl->hpc_reg + LED_CONTROL);
work_LED = 0x01010101; work_LED = 0x01010101;
writel(work_LED, ctrl->hpc_reg + LED_CONTROL);
switch_leds(ctrl, num_of_slots, &work_LED, 0); switch_leds(ctrl, num_of_slots, &work_LED, 0);
switch_leds(ctrl, num_of_slots, &work_LED, 1); switch_leds(ctrl, num_of_slots, &work_LED, 1);
switch_leds(ctrl, num_of_slots, &work_LED, 0); switch_leds(ctrl, num_of_slots, &work_LED, 0);
...@@ -2361,20 +2317,20 @@ int cpqhp_hardware_test(struct controller *ctrl, int test_num) ...@@ -2361,20 +2317,20 @@ int cpqhp_hardware_test(struct controller *ctrl, int test_num)
for (loop = 0; loop < num_of_slots; loop++) { for (loop = 0; loop < num_of_slots; loop++) {
set_SOGO(ctrl); set_SOGO(ctrl);
// Wait for SOGO interrupt /* Wait for SOGO interrupt */
wait_for_ctrl_irq (ctrl); wait_for_ctrl_irq (ctrl);
// Get ready for next iteration /* Get ready for next iteration */
long_delay((3*HZ)/10); long_delay((3*HZ)/10);
work_LED = work_LED >> 16; work_LED = work_LED >> 16;
writel(work_LED, ctrl->hpc_reg + LED_CONTROL); writel(work_LED, ctrl->hpc_reg + LED_CONTROL);
set_SOGO(ctrl); set_SOGO(ctrl);
// Wait for SOGO interrupt /* Wait for SOGO interrupt */
wait_for_ctrl_irq (ctrl); wait_for_ctrl_irq (ctrl);
// Get ready for next iteration /* Get ready for next iteration */
long_delay((3*HZ)/10); long_delay((3*HZ)/10);
work_LED = work_LED << 16; work_LED = work_LED << 16;
writel(work_LED, ctrl->hpc_reg + LED_CONTROL); writel(work_LED, ctrl->hpc_reg + LED_CONTROL);
...@@ -2387,14 +2343,14 @@ int cpqhp_hardware_test(struct controller *ctrl, int test_num) ...@@ -2387,14 +2343,14 @@ int cpqhp_hardware_test(struct controller *ctrl, int test_num)
set_SOGO(ctrl); set_SOGO(ctrl);
// Wait for SOBS to be unset /* Wait for SOBS to be unset */
wait_for_ctrl_irq (ctrl); wait_for_ctrl_irq (ctrl);
break; break;
case 2: case 2:
// Do other stuff here! /* Do other stuff here! */
break; break;
case 3: case 3:
// and more... /* and more... */
break; break;
} }
return 0; return 0;
...@@ -2424,7 +2380,7 @@ static u32 configure_new_device (struct controller * ctrl, struct pci_func * fun ...@@ -2424,7 +2380,7 @@ static u32 configure_new_device (struct controller * ctrl, struct pci_func * fun
new_slot = func; new_slot = func;
dbg("%s\n", __FUNCTION__); dbg("%s\n", __FUNCTION__);
// Check for Multi-function device /* Check for Multi-function device */
ctrl->pci_bus->number = func->bus; ctrl->pci_bus->number = func->bus;
rc = pci_bus_read_config_byte (ctrl->pci_bus, PCI_DEVFN(func->device, func->function), 0x0E, &temp_byte); rc = pci_bus_read_config_byte (ctrl->pci_bus, PCI_DEVFN(func->device, func->function), 0x0E, &temp_byte);
if (rc) { if (rc) {
...@@ -2432,7 +2388,7 @@ static u32 configure_new_device (struct controller * ctrl, struct pci_func * fun ...@@ -2432,7 +2388,7 @@ static u32 configure_new_device (struct controller * ctrl, struct pci_func * fun
return rc; return rc;
} }
if (temp_byte & 0x80) // Multi-function device if (temp_byte & 0x80) /* Multi-function device */
max_functions = 8; max_functions = 8;
else else
max_functions = 1; max_functions = 1;
...@@ -2460,22 +2416,20 @@ static u32 configure_new_device (struct controller * ctrl, struct pci_func * fun ...@@ -2460,22 +2416,20 @@ static u32 configure_new_device (struct controller * ctrl, struct pci_func * fun
stop_it = 0; stop_it = 0;
// The following loop skips to the next present function /* The following loop skips to the next present function
// and creates a board structure * and creates a board structure */
while ((function < max_functions) && (!stop_it)) { while ((function < max_functions) && (!stop_it)) {
pci_bus_read_config_dword (ctrl->pci_bus, PCI_DEVFN(func->device, function), 0x00, &ID); pci_bus_read_config_dword (ctrl->pci_bus, PCI_DEVFN(func->device, function), 0x00, &ID);
if (ID == 0xFFFFFFFF) { // There's nothing there. if (ID == 0xFFFFFFFF) { /* There's nothing there. */
function++; function++;
} else { // There's something there } else { /* There's something there */
// Setup slot structure. /* Setup slot structure. */
new_slot = cpqhp_slot_create(func->bus); new_slot = cpqhp_slot_create(func->bus);
if (new_slot == NULL) { if (new_slot == NULL)
// Out of memory
return 1; return 1;
}
new_slot->bus = func->bus; new_slot->bus = func->bus;
new_slot->device = func->device; new_slot->device = func->device;
...@@ -2546,41 +2500,41 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func ...@@ -2546,41 +2500,41 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func
pci_bus->number = func->bus; pci_bus->number = func->bus;
devfn = PCI_DEVFN(func->device, func->function); devfn = PCI_DEVFN(func->device, func->function);
// Check for Bridge /* Check for Bridge */
rc = pci_bus_read_config_byte(pci_bus, devfn, PCI_HEADER_TYPE, &temp_byte); rc = pci_bus_read_config_byte(pci_bus, devfn, PCI_HEADER_TYPE, &temp_byte);
if (rc) if (rc)
return rc; return rc;
if ((temp_byte & 0x7F) == PCI_HEADER_TYPE_BRIDGE) { // PCI-PCI Bridge if ((temp_byte & 0x7F) == PCI_HEADER_TYPE_BRIDGE) { /* PCI-PCI Bridge */
// set Primary bus /* set Primary bus */
dbg("set Primary bus = %d\n", func->bus); dbg("set Primary bus = %d\n", func->bus);
rc = pci_bus_write_config_byte(pci_bus, devfn, PCI_PRIMARY_BUS, func->bus); rc = pci_bus_write_config_byte(pci_bus, devfn, PCI_PRIMARY_BUS, func->bus);
if (rc) if (rc)
return rc; return rc;
// find range of busses to use /* find range of busses to use */
dbg("find ranges of buses to use\n"); dbg("find ranges of buses to use\n");
bus_node = get_max_resource(&resources->bus_head, 1); bus_node = get_max_resource(&resources->bus_head, 1);
// If we don't have any busses to allocate, we can't continue /* If we don't have any busses to allocate, we can't continue */
if (!bus_node) if (!bus_node)
return -ENOMEM; return -ENOMEM;
// set Secondary bus /* set Secondary bus */
temp_byte = bus_node->base; temp_byte = bus_node->base;
dbg("set Secondary bus = %d\n", bus_node->base); dbg("set Secondary bus = %d\n", bus_node->base);
rc = pci_bus_write_config_byte(pci_bus, devfn, PCI_SECONDARY_BUS, temp_byte); rc = pci_bus_write_config_byte(pci_bus, devfn, PCI_SECONDARY_BUS, temp_byte);
if (rc) if (rc)
return rc; return rc;
// set subordinate bus /* set subordinate bus */
temp_byte = bus_node->base + bus_node->length - 1; temp_byte = bus_node->base + bus_node->length - 1;
dbg("set subordinate bus = %d\n", bus_node->base + bus_node->length - 1); dbg("set subordinate bus = %d\n", bus_node->base + bus_node->length - 1);
rc = pci_bus_write_config_byte(pci_bus, devfn, PCI_SUBORDINATE_BUS, temp_byte); rc = pci_bus_write_config_byte(pci_bus, devfn, PCI_SUBORDINATE_BUS, temp_byte);
if (rc) if (rc)
return rc; return rc;
// set subordinate Latency Timer and base Latency Timer /* set subordinate Latency Timer and base Latency Timer */
temp_byte = 0x40; temp_byte = 0x40;
rc = pci_bus_write_config_byte(pci_bus, devfn, PCI_SEC_LATENCY_TIMER, temp_byte); rc = pci_bus_write_config_byte(pci_bus, devfn, PCI_SEC_LATENCY_TIMER, temp_byte);
if (rc) if (rc)
...@@ -2589,14 +2543,13 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func ...@@ -2589,14 +2543,13 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func
if (rc) if (rc)
return rc; return rc;
// set Cache Line size /* set Cache Line size */
temp_byte = 0x08; temp_byte = 0x08;
rc = pci_bus_write_config_byte(pci_bus, devfn, PCI_CACHE_LINE_SIZE, temp_byte); rc = pci_bus_write_config_byte(pci_bus, devfn, PCI_CACHE_LINE_SIZE, temp_byte);
if (rc) if (rc)
return rc; return rc;
// Setup the IO, memory, and prefetchable windows /* Setup the IO, memory, and prefetchable windows */
io_node = get_max_resource(&(resources->io_head), 0x1000); io_node = get_max_resource(&(resources->io_head), 0x1000);
if (!io_node) if (!io_node)
return -ENOMEM; return -ENOMEM;
...@@ -2617,7 +2570,7 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func ...@@ -2617,7 +2570,7 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func
dbg("(base, len, next) (%x, %x, %p)\n", p_mem_node->base, dbg("(base, len, next) (%x, %x, %p)\n", p_mem_node->base,
p_mem_node->length, p_mem_node->next); p_mem_node->length, p_mem_node->next);
// set up the IRQ info /* set up the IRQ info */
if (!resources->irqs) { if (!resources->irqs) {
irqs.barber_pole = 0; irqs.barber_pole = 0;
irqs.interrupt[0] = 0; irqs.interrupt[0] = 0;
...@@ -2634,16 +2587,16 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func ...@@ -2634,16 +2587,16 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func
irqs.valid_INT = resources->irqs->valid_INT; irqs.valid_INT = resources->irqs->valid_INT;
} }
// set up resource lists that are now aligned on top and bottom /* set up resource lists that are now aligned on top and bottom
// for anything behind the bridge. * for anything behind the bridge. */
temp_resources.bus_head = bus_node; temp_resources.bus_head = bus_node;
temp_resources.io_head = io_node; temp_resources.io_head = io_node;
temp_resources.mem_head = mem_node; temp_resources.mem_head = mem_node;
temp_resources.p_mem_head = p_mem_node; temp_resources.p_mem_head = p_mem_node;
temp_resources.irqs = &irqs; temp_resources.irqs = &irqs;
// Make copies of the nodes we are going to pass down so that /* Make copies of the nodes we are going to pass down so that
// if there is a problem,we can just use these to free resources * if there is a problem,we can just use these to free resources */
hold_bus_node = (struct pci_resource *) kmalloc(sizeof(struct pci_resource), GFP_KERNEL); hold_bus_node = (struct pci_resource *) kmalloc(sizeof(struct pci_resource), GFP_KERNEL);
hold_IO_node = (struct pci_resource *) kmalloc(sizeof(struct pci_resource), GFP_KERNEL); hold_IO_node = (struct pci_resource *) kmalloc(sizeof(struct pci_resource), GFP_KERNEL);
hold_mem_node = (struct pci_resource *) kmalloc(sizeof(struct pci_resource), GFP_KERNEL); hold_mem_node = (struct pci_resource *) kmalloc(sizeof(struct pci_resource), GFP_KERNEL);
...@@ -2674,7 +2627,7 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func ...@@ -2674,7 +2627,7 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func
memcpy(hold_IO_node, io_node, sizeof(struct pci_resource)); memcpy(hold_IO_node, io_node, sizeof(struct pci_resource));
io_node->next = NULL; io_node->next = NULL;
// set IO base and Limit registers /* set IO base and Limit registers */
temp_byte = io_node->base >> 8; temp_byte = io_node->base >> 8;
rc = pci_bus_write_config_byte(pci_bus, devfn, PCI_IO_BASE, temp_byte); rc = pci_bus_write_config_byte(pci_bus, devfn, PCI_IO_BASE, temp_byte);
...@@ -2685,14 +2638,14 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func ...@@ -2685,14 +2638,14 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func
hold_IO_node = NULL; hold_IO_node = NULL;
} }
/* If we have memory resources copy them and fill in the bridge's /* If we have memory resources copy them and fill in the
* memory range registers. Otherwise, fill in the range * bridge's memory range registers. Otherwise, fill in the
* registers with values that disable them. */ * range registers with values that disable them. */
if (mem_node) { if (mem_node) {
memcpy(hold_mem_node, mem_node, sizeof(struct pci_resource)); memcpy(hold_mem_node, mem_node, sizeof(struct pci_resource));
mem_node->next = NULL; mem_node->next = NULL;
// set Mem base and Limit registers /* set Mem base and Limit registers */
temp_word = mem_node->base >> 16; temp_word = mem_node->base >> 16;
rc = pci_bus_write_config_word(pci_bus, devfn, PCI_MEMORY_BASE, temp_word); rc = pci_bus_write_config_word(pci_bus, devfn, PCI_MEMORY_BASE, temp_word);
...@@ -2716,7 +2669,7 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func ...@@ -2716,7 +2669,7 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func
memcpy(hold_p_mem_node, p_mem_node, sizeof(struct pci_resource)); memcpy(hold_p_mem_node, p_mem_node, sizeof(struct pci_resource));
p_mem_node->next = NULL; p_mem_node->next = NULL;
// set Pre Mem base and Limit registers /* set Pre Mem base and Limit registers */
temp_word = p_mem_node->base >> 16; temp_word = p_mem_node->base >> 16;
rc = pci_bus_write_config_word (pci_bus, devfn, PCI_PREF_MEMORY_BASE, temp_word); rc = pci_bus_write_config_word (pci_bus, devfn, PCI_PREF_MEMORY_BASE, temp_word);
...@@ -2733,12 +2686,12 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func ...@@ -2733,12 +2686,12 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func
hold_p_mem_node = NULL; hold_p_mem_node = NULL;
} }
// Adjust this to compensate for extra adjustment in first loop /* Adjust this to compensate for extra adjustment in first loop */
irqs.barber_pole--; irqs.barber_pole--;
rc = 0; rc = 0;
// Here we actually find the devices and configure them /* Here we actually find the devices and configure them */
for (device = 0; (device <= 0x1F) && !rc; device++) { for (device = 0; (device <= 0x1F) && !rc; device++) {
irqs.barber_pole = (irqs.barber_pole + 1) & 0x03; irqs.barber_pole = (irqs.barber_pole + 1) & 0x03;
...@@ -2747,12 +2700,11 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func ...@@ -2747,12 +2700,11 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func
pci_bus_read_config_dword (pci_bus, PCI_DEVFN(device, 0), 0x00, &ID); pci_bus_read_config_dword (pci_bus, PCI_DEVFN(device, 0), 0x00, &ID);
pci_bus->number = func->bus; pci_bus->number = func->bus;
if (ID != 0xFFFFFFFF) { // device Present if (ID != 0xFFFFFFFF) { /* device present */
// Setup slot structure. /* Setup slot structure. */
new_slot = cpqhp_slot_create(hold_bus_node->base); new_slot = cpqhp_slot_create(hold_bus_node->base);
if (new_slot == NULL) { if (new_slot == NULL) {
// Out of memory
rc = -ENOMEM; rc = -ENOMEM;
continue; continue;
} }
...@@ -2765,8 +2717,8 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func ...@@ -2765,8 +2717,8 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func
rc = configure_new_device(ctrl, new_slot, 1, &temp_resources); rc = configure_new_device(ctrl, new_slot, 1, &temp_resources);
dbg("configure_new_device rc=0x%x\n",rc); dbg("configure_new_device rc=0x%x\n",rc);
} // End of IF (device in slot?) } /* End of IF (device in slot?) */
} // End of FOR loop } /* End of FOR loop */
if (rc) { if (rc) {
cpqhp_destroy_resource_list(&temp_resources); cpqhp_destroy_resource_list(&temp_resources);
...@@ -2777,7 +2729,7 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func ...@@ -2777,7 +2729,7 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func
return_resource(&(resources->p_mem_head), hold_p_mem_node); return_resource(&(resources->p_mem_head), hold_p_mem_node);
return rc; return rc;
} }
// save the interrupt routing information /* save the interrupt routing information */
if (resources->irqs) { if (resources->irqs) {
resources->irqs->interrupt[0] = irqs.interrupt[0]; resources->irqs->interrupt[0] = irqs.interrupt[0];
resources->irqs->interrupt[1] = irqs.interrupt[1]; resources->irqs->interrupt[1] = irqs.interrupt[1];
...@@ -2785,7 +2737,7 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func ...@@ -2785,7 +2737,7 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func
resources->irqs->interrupt[3] = irqs.interrupt[3]; resources->irqs->interrupt[3] = irqs.interrupt[3];
resources->irqs->valid_INT = irqs.valid_INT; resources->irqs->valid_INT = irqs.valid_INT;
} else if (!behind_bridge) { } else if (!behind_bridge) {
// We need to hook up the interrupts here /* We need to hook up the interrupts here */
for (cloop = 0; cloop < 4; cloop++) { for (cloop = 0; cloop < 4; cloop++) {
if (irqs.valid_INT & (0x01 << cloop)) { if (irqs.valid_INT & (0x01 << cloop)) {
rc = cpqhp_set_irq(func->bus, func->device, rc = cpqhp_set_irq(func->bus, func->device,
...@@ -2800,10 +2752,11 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func ...@@ -2800,10 +2752,11 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func
return rc; return rc;
} }
} }
} // end of for loop } /* end of for loop */
} }
// Return unused bus resources /* Return unused bus resources
// First use the temporary node to store information for the board * First use the temporary node to store information for
* the board */
if (hold_bus_node && bus_node && temp_resources.bus_head) { if (hold_bus_node && bus_node && temp_resources.bus_head) {
hold_bus_node->length = bus_node->base - hold_bus_node->base; hold_bus_node->length = bus_node->base - hold_bus_node->base;
...@@ -2812,7 +2765,7 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func ...@@ -2812,7 +2765,7 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func
temp_byte = temp_resources.bus_head->base - 1; temp_byte = temp_resources.bus_head->base - 1;
// set subordinate bus /* set subordinate bus */
rc = pci_bus_write_config_byte (pci_bus, devfn, PCI_SUBORDINATE_BUS, temp_byte); rc = pci_bus_write_config_byte (pci_bus, devfn, PCI_SUBORDINATE_BUS, temp_byte);
if (temp_resources.bus_head->length == 0) { if (temp_resources.bus_head->length == 0) {
...@@ -2823,13 +2776,13 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func ...@@ -2823,13 +2776,13 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func
} }
} }
// If we have IO space available and there is some left, /* If we have IO space available and there is some left,
// return the unused portion * return the unused portion */
if (hold_IO_node && temp_resources.io_head) { if (hold_IO_node && temp_resources.io_head) {
io_node = do_pre_bridge_resource_split(&(temp_resources.io_head), io_node = do_pre_bridge_resource_split(&(temp_resources.io_head),
&hold_IO_node, 0x1000); &hold_IO_node, 0x1000);
// Check if we were able to split something off /* Check if we were able to split something off */
if (io_node) { if (io_node) {
hold_IO_node->base = io_node->base + io_node->length; hold_IO_node->base = io_node->base + io_node->length;
...@@ -2841,12 +2794,13 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func ...@@ -2841,12 +2794,13 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func
io_node = do_bridge_resource_split(&(temp_resources.io_head), 0x1000); io_node = do_bridge_resource_split(&(temp_resources.io_head), 0x1000);
// Check if we were able to split something off /* Check if we were able to split something off */
if (io_node) { if (io_node) {
// First use the temporary node to store information for the board /* First use the temporary node to store
* information for the board */
hold_IO_node->length = io_node->base - hold_IO_node->base; hold_IO_node->length = io_node->base - hold_IO_node->base;
// If we used any, add it to the board's list /* If we used any, add it to the board's list */
if (hold_IO_node->length) { if (hold_IO_node->length) {
hold_IO_node->next = func->io_head; hold_IO_node->next = func->io_head;
func->io_head = hold_IO_node; func->io_head = hold_IO_node;
...@@ -2856,7 +2810,7 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func ...@@ -2856,7 +2810,7 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func
return_resource(&(resources->io_head), io_node); return_resource(&(resources->io_head), io_node);
} else { } else {
// it doesn't need any IO /* it doesn't need any IO */
temp_word = 0x0000; temp_word = 0x0000;
rc = pci_bus_write_config_word (pci_bus, devfn, PCI_IO_LIMIT, temp_word); rc = pci_bus_write_config_word (pci_bus, devfn, PCI_IO_LIMIT, temp_word);
...@@ -2864,22 +2818,22 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func ...@@ -2864,22 +2818,22 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func
kfree(hold_IO_node); kfree(hold_IO_node);
} }
} else { } else {
// it used most of the range /* it used most of the range */
hold_IO_node->next = func->io_head; hold_IO_node->next = func->io_head;
func->io_head = hold_IO_node; func->io_head = hold_IO_node;
} }
} else if (hold_IO_node) { } else if (hold_IO_node) {
// it used the whole range /* it used the whole range */
hold_IO_node->next = func->io_head; hold_IO_node->next = func->io_head;
func->io_head = hold_IO_node; func->io_head = hold_IO_node;
} }
// If we have memory space available and there is some left, /* If we have memory space available and there is some left,
// return the unused portion * return the unused portion */
if (hold_mem_node && temp_resources.mem_head) { if (hold_mem_node && temp_resources.mem_head) {
mem_node = do_pre_bridge_resource_split(&(temp_resources. mem_head), mem_node = do_pre_bridge_resource_split(&(temp_resources. mem_head),
&hold_mem_node, 0x100000); &hold_mem_node, 0x100000);
// Check if we were able to split something off /* Check if we were able to split something off */
if (mem_node) { if (mem_node) {
hold_mem_node->base = mem_node->base + mem_node->length; hold_mem_node->base = mem_node->base + mem_node->length;
...@@ -2891,23 +2845,24 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func ...@@ -2891,23 +2845,24 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func
mem_node = do_bridge_resource_split(&(temp_resources.mem_head), 0x100000); mem_node = do_bridge_resource_split(&(temp_resources.mem_head), 0x100000);
// Check if we were able to split something off /* Check if we were able to split something off */
if (mem_node) { if (mem_node) {
// First use the temporary node to store information for the board /* First use the temporary node to store
* information for the board */
hold_mem_node->length = mem_node->base - hold_mem_node->base; hold_mem_node->length = mem_node->base - hold_mem_node->base;
if (hold_mem_node->length) { if (hold_mem_node->length) {
hold_mem_node->next = func->mem_head; hold_mem_node->next = func->mem_head;
func->mem_head = hold_mem_node; func->mem_head = hold_mem_node;
// configure end address /* configure end address */
temp_word = (mem_node->base - 1) >> 16; temp_word = (mem_node->base - 1) >> 16;
rc = pci_bus_write_config_word (pci_bus, devfn, PCI_MEMORY_LIMIT, temp_word); rc = pci_bus_write_config_word (pci_bus, devfn, PCI_MEMORY_LIMIT, temp_word);
// Return unused resources to the pool /* Return unused resources to the pool */
return_resource(&(resources->mem_head), mem_node); return_resource(&(resources->mem_head), mem_node);
} else { } else {
// it doesn't need any Mem /* it doesn't need any Mem */
temp_word = 0x0000; temp_word = 0x0000;
rc = pci_bus_write_config_word (pci_bus, devfn, PCI_MEMORY_LIMIT, temp_word); rc = pci_bus_write_config_word (pci_bus, devfn, PCI_MEMORY_LIMIT, temp_word);
...@@ -2915,22 +2870,22 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func ...@@ -2915,22 +2870,22 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func
kfree(hold_mem_node); kfree(hold_mem_node);
} }
} else { } else {
// it used most of the range /* it used most of the range */
hold_mem_node->next = func->mem_head; hold_mem_node->next = func->mem_head;
func->mem_head = hold_mem_node; func->mem_head = hold_mem_node;
} }
} else if (hold_mem_node) { } else if (hold_mem_node) {
// it used the whole range /* it used the whole range */
hold_mem_node->next = func->mem_head; hold_mem_node->next = func->mem_head;
func->mem_head = hold_mem_node; func->mem_head = hold_mem_node;
} }
// If we have prefetchable memory space available and there is some /* If we have prefetchable memory space available and there
// left at the end, return the unused portion * is some left at the end, return the unused portion */
if (hold_p_mem_node && temp_resources.p_mem_head) { if (hold_p_mem_node && temp_resources.p_mem_head) {
p_mem_node = do_pre_bridge_resource_split(&(temp_resources.p_mem_head), p_mem_node = do_pre_bridge_resource_split(&(temp_resources.p_mem_head),
&hold_p_mem_node, 0x100000); &hold_p_mem_node, 0x100000);
// Check if we were able to split something off /* Check if we were able to split something off */
if (p_mem_node) { if (p_mem_node) {
hold_p_mem_node->base = p_mem_node->base + p_mem_node->length; hold_p_mem_node->base = p_mem_node->base + p_mem_node->length;
...@@ -2942,12 +2897,13 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func ...@@ -2942,12 +2897,13 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func
p_mem_node = do_bridge_resource_split(&(temp_resources.p_mem_head), 0x100000); p_mem_node = do_bridge_resource_split(&(temp_resources.p_mem_head), 0x100000);
// Check if we were able to split something off /* Check if we were able to split something off */
if (p_mem_node) { if (p_mem_node) {
// First use the temporary node to store information for the board /* First use the temporary node to store
* information for the board */
hold_p_mem_node->length = p_mem_node->base - hold_p_mem_node->base; hold_p_mem_node->length = p_mem_node->base - hold_p_mem_node->base;
// If we used any, add it to the board's list /* If we used any, add it to the board's list */
if (hold_p_mem_node->length) { if (hold_p_mem_node->length) {
hold_p_mem_node->next = func->p_mem_head; hold_p_mem_node->next = func->p_mem_head;
func->p_mem_head = hold_p_mem_node; func->p_mem_head = hold_p_mem_node;
...@@ -2957,7 +2913,7 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func ...@@ -2957,7 +2913,7 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func
return_resource(&(resources->p_mem_head), p_mem_node); return_resource(&(resources->p_mem_head), p_mem_node);
} else { } else {
// it doesn't need any PMem /* it doesn't need any PMem */
temp_word = 0x0000; temp_word = 0x0000;
rc = pci_bus_write_config_word (pci_bus, devfn, PCI_PREF_MEMORY_LIMIT, temp_word); rc = pci_bus_write_config_word (pci_bus, devfn, PCI_PREF_MEMORY_LIMIT, temp_word);
...@@ -2965,12 +2921,12 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func ...@@ -2965,12 +2921,12 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func
kfree(hold_p_mem_node); kfree(hold_p_mem_node);
} }
} else { } else {
// it used the most of the range /* it used the most of the range */
hold_p_mem_node->next = func->p_mem_head; hold_p_mem_node->next = func->p_mem_head;
func->p_mem_head = hold_p_mem_node; func->p_mem_head = hold_p_mem_node;
} }
} else if (hold_p_mem_node) { } else if (hold_p_mem_node) {
// it used the whole range /* it used the whole range */
hold_p_mem_node->next = func->p_mem_head; hold_p_mem_node->next = func->p_mem_head;
func->p_mem_head = hold_p_mem_node; func->p_mem_head = hold_p_mem_node;
} }
...@@ -2978,7 +2934,7 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func ...@@ -2978,7 +2934,7 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func
* registers if it needs them. Although we have never seen such * registers if it needs them. Although we have never seen such
* a device */ * a device */
// enable card /* enable card */
command = 0x0157; /* = PCI_COMMAND_IO | command = 0x0157; /* = PCI_COMMAND_IO |
* PCI_COMMAND_MEMORY | * PCI_COMMAND_MEMORY |
* PCI_COMMAND_MASTER | * PCI_COMMAND_MASTER |
...@@ -2987,20 +2943,20 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func ...@@ -2987,20 +2943,20 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func
* PCI_COMMAND_SERR */ * PCI_COMMAND_SERR */
rc = pci_bus_write_config_word (pci_bus, devfn, PCI_COMMAND, command); rc = pci_bus_write_config_word (pci_bus, devfn, PCI_COMMAND, command);
// set Bridge Control Register /* set Bridge Control Register */
command = 0x07; /* = PCI_BRIDGE_CTL_PARITY | command = 0x07; /* = PCI_BRIDGE_CTL_PARITY |
* PCI_BRIDGE_CTL_SERR | * PCI_BRIDGE_CTL_SERR |
* PCI_BRIDGE_CTL_NO_ISA */ * PCI_BRIDGE_CTL_NO_ISA */
rc = pci_bus_write_config_word (pci_bus, devfn, PCI_BRIDGE_CONTROL, command); rc = pci_bus_write_config_word (pci_bus, devfn, PCI_BRIDGE_CONTROL, command);
} else if ((temp_byte & 0x7F) == PCI_HEADER_TYPE_NORMAL) { } else if ((temp_byte & 0x7F) == PCI_HEADER_TYPE_NORMAL) {
// Standard device /* Standard device */
rc = pci_bus_read_config_byte (pci_bus, devfn, 0x0B, &class_code); rc = pci_bus_read_config_byte (pci_bus, devfn, 0x0B, &class_code);
if (class_code == PCI_BASE_CLASS_DISPLAY) { if (class_code == PCI_BASE_CLASS_DISPLAY) {
// Display (video) adapter (not supported) /* Display (video) adapter (not supported) */
return DEVICE_TYPE_NOT_SUPPORTED; return DEVICE_TYPE_NOT_SUPPORTED;
} }
// Figure out IO and memory needs /* Figure out IO and memory needs */
for (cloop = 0x10; cloop <= 0x24; cloop += 4) { for (cloop = 0x10; cloop <= 0x24; cloop += 4) {
temp_register = 0xFFFFFFFF; temp_register = 0xFFFFFFFF;
...@@ -3010,11 +2966,11 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func ...@@ -3010,11 +2966,11 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func
rc = pci_bus_read_config_dword (pci_bus, devfn, cloop, &temp_register); rc = pci_bus_read_config_dword (pci_bus, devfn, cloop, &temp_register);
dbg("CND: base = 0x%x\n", temp_register); dbg("CND: base = 0x%x\n", temp_register);
if (temp_register) { // If this register is implemented if (temp_register) { /* If this register is implemented */
if ((temp_register & 0x03L) == 0x01) { if ((temp_register & 0x03L) == 0x01) {
// Map IO /* Map IO */
// set base = amount of IO space /* set base = amount of IO space */
base = temp_register & 0xFFFFFFFC; base = temp_register & 0xFFFFFFFC;
base = ~base + 1; base = ~base + 1;
...@@ -3024,7 +2980,7 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func ...@@ -3024,7 +2980,7 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func
io_node->base, io_node->length, io_node->next); io_node->base, io_node->length, io_node->next);
dbg("func (%p) io_head (%p)\n", func, func->io_head); dbg("func (%p) io_head (%p)\n", func, func->io_head);
// allocate the resource to the board /* allocate the resource to the board */
if (io_node) { if (io_node) {
base = io_node->base; base = io_node->base;
...@@ -3033,14 +2989,14 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func ...@@ -3033,14 +2989,14 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func
} else } else
return -ENOMEM; return -ENOMEM;
} else if ((temp_register & 0x0BL) == 0x08) { } else if ((temp_register & 0x0BL) == 0x08) {
// Map prefetchable memory /* Map prefetchable memory */
base = temp_register & 0xFFFFFFF0; base = temp_register & 0xFFFFFFF0;
base = ~base + 1; base = ~base + 1;
dbg("CND: length = 0x%x\n", base); dbg("CND: length = 0x%x\n", base);
p_mem_node = get_resource(&(resources->p_mem_head), base); p_mem_node = get_resource(&(resources->p_mem_head), base);
// allocate the resource to the board /* allocate the resource to the board */
if (p_mem_node) { if (p_mem_node) {
base = p_mem_node->base; base = p_mem_node->base;
...@@ -3049,14 +3005,14 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func ...@@ -3049,14 +3005,14 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func
} else } else
return -ENOMEM; return -ENOMEM;
} else if ((temp_register & 0x0BL) == 0x00) { } else if ((temp_register & 0x0BL) == 0x00) {
// Map memory /* Map memory */
base = temp_register & 0xFFFFFFF0; base = temp_register & 0xFFFFFFF0;
base = ~base + 1; base = ~base + 1;
dbg("CND: length = 0x%x\n", base); dbg("CND: length = 0x%x\n", base);
mem_node = get_resource(&(resources->mem_head), base); mem_node = get_resource(&(resources->mem_head), base);
// allocate the resource to the board /* allocate the resource to the board */
if (mem_node) { if (mem_node) {
base = mem_node->base; base = mem_node->base;
...@@ -3065,14 +3021,14 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func ...@@ -3065,14 +3021,14 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func
} else } else
return -ENOMEM; return -ENOMEM;
} else if ((temp_register & 0x0BL) == 0x04) { } else if ((temp_register & 0x0BL) == 0x04) {
// Map memory /* Map memory */
base = temp_register & 0xFFFFFFF0; base = temp_register & 0xFFFFFFF0;
base = ~base + 1; base = ~base + 1;
dbg("CND: length = 0x%x\n", base); dbg("CND: length = 0x%x\n", base);
mem_node = get_resource(&(resources->mem_head), base); mem_node = get_resource(&(resources->mem_head), base);
// allocate the resource to the board /* allocate the resource to the board */
if (mem_node) { if (mem_node) {
base = mem_node->base; base = mem_node->base;
...@@ -3081,42 +3037,44 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func ...@@ -3081,42 +3037,44 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func
} else } else
return -ENOMEM; return -ENOMEM;
} else if ((temp_register & 0x0BL) == 0x06) { } else if ((temp_register & 0x0BL) == 0x06) {
// Those bits are reserved, we can't handle this /* Those bits are reserved, we can't handle this */
return 1; return 1;
} else { } else {
// Requesting space below 1M /* Requesting space below 1M */
return NOT_ENOUGH_RESOURCES; return NOT_ENOUGH_RESOURCES;
} }
rc = pci_bus_write_config_dword(pci_bus, devfn, cloop, base); rc = pci_bus_write_config_dword(pci_bus, devfn, cloop, base);
// Check for 64-bit base /* Check for 64-bit base */
if ((temp_register & 0x07L) == 0x04) { if ((temp_register & 0x07L) == 0x04) {
cloop += 4; cloop += 4;
// Upper 32 bits of address always zero on today's systems /* Upper 32 bits of address always zero
// FIXME this is probably not true on Alpha and ia64??? * on today's systems */
/* FIXME this is probably not true on
* Alpha and ia64??? */
base = 0; base = 0;
rc = pci_bus_write_config_dword(pci_bus, devfn, cloop, base); rc = pci_bus_write_config_dword(pci_bus, devfn, cloop, base);
} }
} }
} // End of base register loop } /* End of base register loop */
if (cpqhp_legacy_mode) { if (cpqhp_legacy_mode) {
// Figure out which interrupt pin this function uses /* Figure out which interrupt pin this function uses */
rc = pci_bus_read_config_byte (pci_bus, devfn, rc = pci_bus_read_config_byte (pci_bus, devfn,
PCI_INTERRUPT_PIN, &temp_byte); PCI_INTERRUPT_PIN, &temp_byte);
// If this function needs an interrupt and we are behind a bridge /* If this function needs an interrupt and we are behind
// and the pin is tied to something that's alread mapped, * a bridge and the pin is tied to something that's
// set this one the same * alread mapped, set this one the same */
if (temp_byte && resources->irqs && if (temp_byte && resources->irqs &&
(resources->irqs->valid_INT & (resources->irqs->valid_INT &
(0x01 << ((temp_byte + resources->irqs->barber_pole - 1) & 0x03)))) { (0x01 << ((temp_byte + resources->irqs->barber_pole - 1) & 0x03)))) {
// We have to share with something already set up /* We have to share with something already set up */
IRQ = resources->irqs->interrupt[(temp_byte + IRQ = resources->irqs->interrupt[(temp_byte +
resources->irqs->barber_pole - 1) & 0x03]; resources->irqs->barber_pole - 1) & 0x03];
} else { } else {
// Program IRQ based on card type /* Program IRQ based on card type */
rc = pci_bus_read_config_byte (pci_bus, devfn, 0x0B, &class_code); rc = pci_bus_read_config_byte (pci_bus, devfn, 0x0B, &class_code);
if (class_code == PCI_BASE_CLASS_STORAGE) { if (class_code == PCI_BASE_CLASS_STORAGE) {
...@@ -3126,7 +3084,7 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func ...@@ -3126,7 +3084,7 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func
} }
} }
// IRQ Line /* IRQ Line */
rc = pci_bus_write_config_byte (pci_bus, devfn, PCI_INTERRUPT_LINE, IRQ); rc = pci_bus_write_config_byte (pci_bus, devfn, PCI_INTERRUPT_LINE, IRQ);
} }
...@@ -3135,27 +3093,28 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func ...@@ -3135,27 +3093,28 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func
if (rc) if (rc)
return 1; return 1;
} else { } else {
//TBD - this code may also belong in the other clause of this If statement /* TBD - this code may also belong in the other clause
* of this If statement */
resources->irqs->interrupt[(temp_byte + resources->irqs->barber_pole - 1) & 0x03] = IRQ; resources->irqs->interrupt[(temp_byte + resources->irqs->barber_pole - 1) & 0x03] = IRQ;
resources->irqs->valid_INT |= 0x01 << (temp_byte + resources->irqs->barber_pole - 1) & 0x03; resources->irqs->valid_INT |= 0x01 << (temp_byte + resources->irqs->barber_pole - 1) & 0x03;
} }
// Latency Timer /* Latency Timer */
temp_byte = 0x40; temp_byte = 0x40;
rc = pci_bus_write_config_byte(pci_bus, devfn, rc = pci_bus_write_config_byte(pci_bus, devfn,
PCI_LATENCY_TIMER, temp_byte); PCI_LATENCY_TIMER, temp_byte);
// Cache Line size /* Cache Line size */
temp_byte = 0x08; temp_byte = 0x08;
rc = pci_bus_write_config_byte(pci_bus, devfn, rc = pci_bus_write_config_byte(pci_bus, devfn,
PCI_CACHE_LINE_SIZE, temp_byte); PCI_CACHE_LINE_SIZE, temp_byte);
// disable ROM base Address /* disable ROM base Address */
temp_dword = 0x00L; temp_dword = 0x00L;
rc = pci_bus_write_config_word(pci_bus, devfn, rc = pci_bus_write_config_word(pci_bus, devfn,
PCI_ROM_ADDRESS, temp_dword); PCI_ROM_ADDRESS, temp_dword);
// enable card /* enable card */
temp_word = 0x0157; /* = PCI_COMMAND_IO | temp_word = 0x0157; /* = PCI_COMMAND_IO |
* PCI_COMMAND_MEMORY | * PCI_COMMAND_MEMORY |
* PCI_COMMAND_MASTER | * PCI_COMMAND_MASTER |
...@@ -3164,8 +3123,8 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func ...@@ -3164,8 +3123,8 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func
* PCI_COMMAND_SERR */ * PCI_COMMAND_SERR */
rc = pci_bus_write_config_word (pci_bus, devfn, rc = pci_bus_write_config_word (pci_bus, devfn,
PCI_COMMAND, temp_word); PCI_COMMAND, temp_word);
} else { // End of Not-A-Bridge else } else { /* End of Not-A-Bridge else */
// It's some strange type of PCI adapter (Cardbus?) /* It's some strange type of PCI adapter (Cardbus?) */
return DEVICE_TYPE_NOT_SUPPORTED; return DEVICE_TYPE_NOT_SUPPORTED;
} }
...@@ -3173,4 +3132,3 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func ...@@ -3173,4 +3132,3 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func
return 0; return 0;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment