X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Fpci%2Fhotplug%2Fcpqphp.h;h=4da5bac0fd99dc45b766ff836d9686f2c099e02f;hb=746550cff061581f89c687ada8523670768364f2;hp=444d2109024a65e13f343aa452b98baf12aa0ddb;hpb=86090fcac5e27b630656fe3d963a6b80e26dac44;p=linux-2.6.git diff --git a/drivers/pci/hotplug/cpqphp.h b/drivers/pci/hotplug/cpqphp.h index 444d21090..4da5bac0f 100644 --- a/drivers/pci/hotplug/cpqphp.h +++ b/drivers/pci/hotplug/cpqphp.h @@ -33,11 +33,7 @@ #include /* for read? and write? functions */ #include /* for delays */ -#if !defined(CONFIG_HOTPLUG_PCI_COMPAQ_MODULE) - #define MY_NAME "cpqphp.o" -#else - #define MY_NAME THIS_MODULE->name -#endif +#define MY_NAME "cpqphp" #define dbg(fmt, arg...) do { if (cpqhp_debug) printk(KERN_DEBUG "%s: " fmt , MY_NAME , ## arg); } while (0) #define err(format, arg...) printk(KERN_ERR "%s: " format , MY_NAME , ## arg) @@ -257,9 +253,7 @@ struct pci_func { struct pci_dev* pci_dev; }; -#define SLOT_MAGIC 0x67267321 struct slot { - u32 magic; struct slot *next; u8 bus; u8 device; @@ -377,11 +371,8 @@ struct resource_lists { #define PCISLOT_66_MHZ_SUPPORTED 0x00000100 #define PCISLOT_64_BIT_SUPPORTED 0x00000200 - - #define PCI_TO_PCI_BRIDGE_CLASS 0x00060400 - #define INTERLOCK_OPEN 0x00000002 #define ADD_NOT_SUPPORTED 0x00000003 #define CARD_FUNCTIONING 0x00000005 @@ -440,7 +431,6 @@ extern int cpqhp_return_board_resources (struct pci_func * func, struct resource extern void cpqhp_destroy_resource_list (struct resource_lists * resources); extern int cpqhp_configure_device (struct controller* ctrl, struct pci_func* func); extern int cpqhp_unconfigure_device (struct pci_func* func); -extern struct slot *cpqhp_find_slot (struct controller *ctrl, u8 device); /* Global variables */ extern int cpqhp_debug; @@ -453,50 +443,15 @@ extern u8 cpqhp_nic_irq; extern u8 cpqhp_disk_irq; - /* inline functions */ - -/* Inline functions to check the sanity of a pointer that is passed to us */ -static inline int slot_paranoia_check (struct slot *slot, const char *function) -{ - if (!slot) { - dbg("%s - slot == NULL", function); - return -1; - } - if (slot->magic != SLOT_MAGIC) { - dbg("%s - bad magic number for slot", function); - return -1; - } - if (!slot->hotplug_slot) { - dbg("%s - slot->hotplug_slot == NULL!", function); - return -1; - } - return 0; -} - -static inline struct slot *get_slot (struct hotplug_slot *hotplug_slot, const char *function) -{ - struct slot *slot; - - if (!hotplug_slot) { - dbg("%s - hotplug_slot == NULL\n", function); - return NULL; - } - - slot = (struct slot *)hotplug_slot->private; - if (slot_paranoia_check (slot, function)) - return NULL; - return slot; -} - /* * return_resource * * Puts node back in the resource list pointed to by head * */ -static inline void return_resource (struct pci_resource **head, struct pci_resource *node) +static inline void return_resource(struct pci_resource **head, struct pci_resource *node) { if (!node || !head) return; @@ -504,7 +459,7 @@ static inline void return_resource (struct pci_resource **head, struct pci_resou *head = node; } -static inline void set_SOGO (struct controller *ctrl) +static inline void set_SOGO(struct controller *ctrl) { u16 misc; @@ -514,7 +469,7 @@ static inline void set_SOGO (struct controller *ctrl) } -static inline void amber_LED_on (struct controller *ctrl, u8 slot) +static inline void amber_LED_on(struct controller *ctrl, u8 slot) { u32 led_control; @@ -524,7 +479,7 @@ static inline void amber_LED_on (struct controller *ctrl, u8 slot) } -static inline void amber_LED_off (struct controller *ctrl, u8 slot) +static inline void amber_LED_off(struct controller *ctrl, u8 slot) { u32 led_control; @@ -534,7 +489,7 @@ static inline void amber_LED_off (struct controller *ctrl, u8 slot) } -static inline int read_amber_LED (struct controller *ctrl, u8 slot) +static inline int read_amber_LED(struct controller *ctrl, u8 slot) { u32 led_control; @@ -545,7 +500,7 @@ static inline int read_amber_LED (struct controller *ctrl, u8 slot) } -static inline void green_LED_on (struct controller *ctrl, u8 slot) +static inline void green_LED_on(struct controller *ctrl, u8 slot) { u32 led_control; @@ -554,7 +509,7 @@ static inline void green_LED_on (struct controller *ctrl, u8 slot) writel(led_control, ctrl->hpc_reg + LED_CONTROL); } -static inline void green_LED_off (struct controller *ctrl, u8 slot) +static inline void green_LED_off(struct controller *ctrl, u8 slot) { u32 led_control; @@ -564,7 +519,7 @@ static inline void green_LED_off (struct controller *ctrl, u8 slot) } -static inline void green_LED_blink (struct controller *ctrl, u8 slot) +static inline void green_LED_blink(struct controller *ctrl, u8 slot) { u32 led_control; @@ -575,7 +530,7 @@ static inline void green_LED_blink (struct controller *ctrl, u8 slot) } -static inline void slot_disable (struct controller *ctrl, u8 slot) +static inline void slot_disable(struct controller *ctrl, u8 slot) { u8 slot_enable; @@ -585,7 +540,7 @@ static inline void slot_disable (struct controller *ctrl, u8 slot) } -static inline void slot_enable (struct controller *ctrl, u8 slot) +static inline void slot_enable(struct controller *ctrl, u8 slot) { u8 slot_enable; @@ -595,7 +550,7 @@ static inline void slot_enable (struct controller *ctrl, u8 slot) } -static inline u8 is_slot_enabled (struct controller *ctrl, u8 slot) +static inline u8 is_slot_enabled(struct controller *ctrl, u8 slot) { u8 slot_enable; @@ -605,7 +560,7 @@ static inline u8 is_slot_enabled (struct controller *ctrl, u8 slot) } -static inline u8 read_slot_enable (struct controller *ctrl) +static inline u8 read_slot_enable(struct controller *ctrl) { return readb(ctrl->hpc_reg + SLOT_ENABLE); } @@ -619,7 +574,7 @@ static inline u8 read_slot_enable (struct controller *ctrl) * Returns controller speed. * */ -static inline u8 get_controller_speed (struct controller *ctrl) +static inline u8 get_controller_speed(struct controller *ctrl) { u8 curr_freq; u16 misc; @@ -652,7 +607,7 @@ static inline u8 get_controller_speed (struct controller *ctrl) * Returns adapter speed. * */ -static inline u8 get_adapter_speed (struct controller *ctrl, u8 hp_slot) +static inline u8 get_adapter_speed(struct controller *ctrl, u8 hp_slot) { u32 temp_dword = readl(ctrl->hpc_reg + NON_INT_INPUT); dbg("slot: %d, PCIXCAP: %8x\n", hp_slot, temp_dword); @@ -669,7 +624,7 @@ static inline u8 get_adapter_speed (struct controller *ctrl, u8 hp_slot) return PCI_SPEED_33MHz; } -static inline void enable_slot_power (struct controller *ctrl, u8 slot) +static inline void enable_slot_power(struct controller *ctrl, u8 slot) { u8 slot_power; @@ -678,7 +633,7 @@ static inline void enable_slot_power (struct controller *ctrl, u8 slot) writeb(slot_power, ctrl->hpc_reg + SLOT_POWER); } -static inline void disable_slot_power (struct controller *ctrl, u8 slot) +static inline void disable_slot_power(struct controller *ctrl, u8 slot) { u8 slot_power; @@ -688,40 +643,31 @@ static inline void disable_slot_power (struct controller *ctrl, u8 slot) } -static inline int cpq_get_attention_status (struct controller *ctrl, struct slot *slot) +static inline int cpq_get_attention_status(struct controller *ctrl, struct slot *slot) { u8 hp_slot; - if (slot == NULL) - return 1; - hp_slot = slot->device - ctrl->slot_device_offset; - return read_amber_LED (ctrl, hp_slot); + return read_amber_LED(ctrl, hp_slot); } -static inline int get_slot_enabled (struct controller *ctrl, struct slot *slot) +static inline int get_slot_enabled(struct controller *ctrl, struct slot *slot) { u8 hp_slot; - if (slot == NULL) - return 1; - hp_slot = slot->device - ctrl->slot_device_offset; - return is_slot_enabled (ctrl, hp_slot); + return is_slot_enabled(ctrl, hp_slot); } -static inline int cpq_get_latch_status (struct controller *ctrl, struct slot *slot) +static inline int cpq_get_latch_status(struct controller *ctrl, struct slot *slot) { u32 status; u8 hp_slot; - if (slot == NULL) - return 1; - hp_slot = slot->device - ctrl->slot_device_offset; dbg("%s: slot->device = %d, ctrl->slot_device_offset = %d \n", __FUNCTION__, slot->device, ctrl->slot_device_offset); @@ -732,15 +678,12 @@ static inline int cpq_get_latch_status (struct controller *ctrl, struct slot *sl } -static inline int get_presence_status (struct controller *ctrl, struct slot *slot) +static inline int get_presence_status(struct controller *ctrl, struct slot *slot) { int presence_save = 0; u8 hp_slot; u32 tempdword; - if (slot == NULL) - return 0; - hp_slot = slot->device - ctrl->slot_device_offset; tempdword = readl(ctrl->hpc_reg + INT_INPUT_CLEAR); @@ -751,13 +694,13 @@ static inline int get_presence_status (struct controller *ctrl, struct slot *slo #define SLOT_NAME_SIZE 10 -static inline void make_slot_name (char *buffer, int buffer_size, struct slot *slot) +static inline void make_slot_name(char *buffer, int buffer_size, struct slot *slot) { - snprintf (buffer, buffer_size, "%d", slot->number); + snprintf(buffer, buffer_size, "%d", slot->number); } -static inline int wait_for_ctrl_irq (struct controller *ctrl) +static inline int wait_for_ctrl_irq(struct controller *ctrl) { DECLARE_WAITQUEUE(wait, current); int retval = 0; @@ -775,138 +718,5 @@ static inline int wait_for_ctrl_irq (struct controller *ctrl) return retval; } - -/** - * set_controller_speed - set the frequency and/or mode of a specific - * controller segment. - * - * @ctrl: controller to change frequency/mode for. - * @adapter_speed: the speed of the adapter we want to match. - * @hp_slot: the slot number where the adapter is installed. - * - * Returns 0 if we successfully change frequency and/or mode to match the - * adapter speed. - * - */ -static inline u8 set_controller_speed(struct controller *ctrl, u8 adapter_speed, u8 hp_slot) -{ - struct slot *slot; - u8 reg; - u8 slot_power = readb(ctrl->hpc_reg + SLOT_POWER); - u16 reg16; - u32 leds = readl(ctrl->hpc_reg + LED_CONTROL); - - if (ctrl->speed == adapter_speed) - return 0; - - /* We don't allow freq/mode changes if we find another adapter running - * in another slot on this controller */ - for(slot = ctrl->slot; slot; slot = slot->next) { - if (slot->device == (hp_slot + ctrl->slot_device_offset)) - continue; - if (!slot->hotplug_slot && !slot->hotplug_slot->info) - continue; - if (slot->hotplug_slot->info->adapter_status == 0) - continue; - /* If another adapter is running on the same segment but at a - * lower speed/mode, we allow the new adapter to function at - * this rate if supported */ - if (ctrl->speed < adapter_speed) - return 0; - - return 1; - } - - /* If the controller doesn't support freq/mode changes and the - * controller is running at a higher mode, we bail */ - if ((ctrl->speed > adapter_speed) && (!ctrl->pcix_speed_capability)) - return 1; - - /* But we allow the adapter to run at a lower rate if possible */ - if ((ctrl->speed < adapter_speed) && (!ctrl->pcix_speed_capability)) - return 0; - - /* We try to set the max speed supported by both the adapter and - * controller */ - if (ctrl->speed_capability < adapter_speed) { - if (ctrl->speed == ctrl->speed_capability) - return 0; - adapter_speed = ctrl->speed_capability; - } - - writel(0x0L, ctrl->hpc_reg + LED_CONTROL); - writeb(0x00, ctrl->hpc_reg + SLOT_ENABLE); - - set_SOGO(ctrl); - wait_for_ctrl_irq(ctrl); - - if (adapter_speed != PCI_SPEED_133MHz_PCIX) - reg = 0xF5; - else - reg = 0xF4; - pci_write_config_byte(ctrl->pci_dev, 0x41, reg); - - reg16 = readw(ctrl->hpc_reg + NEXT_CURR_FREQ); - reg16 &= ~0x000F; - switch(adapter_speed) { - case(PCI_SPEED_133MHz_PCIX): - reg = 0x75; - reg16 |= 0xB; - break; - case(PCI_SPEED_100MHz_PCIX): - reg = 0x74; - reg16 |= 0xA; - break; - case(PCI_SPEED_66MHz_PCIX): - reg = 0x73; - reg16 |= 0x9; - break; - case(PCI_SPEED_66MHz): - reg = 0x73; - reg16 |= 0x1; - break; - default: /* 33MHz PCI 2.2 */ - reg = 0x71; - break; - - } - reg16 |= 0xB << 12; - writew(reg16, ctrl->hpc_reg + NEXT_CURR_FREQ); - - mdelay(5); - - /* Reenable interrupts */ - writel(0, ctrl->hpc_reg + INT_MASK); - - pci_write_config_byte(ctrl->pci_dev, 0x41, reg); - - /* Restart state machine */ - reg = ~0xF; - pci_read_config_byte(ctrl->pci_dev, 0x43, ®); - pci_write_config_byte(ctrl->pci_dev, 0x43, reg); - - /* Only if mode change...*/ - if (((ctrl->speed == PCI_SPEED_66MHz) && (adapter_speed == PCI_SPEED_66MHz_PCIX)) || - ((ctrl->speed == PCI_SPEED_66MHz_PCIX) && (adapter_speed == PCI_SPEED_66MHz))) - set_SOGO(ctrl); - - wait_for_ctrl_irq(ctrl); - mdelay(1100); - - /* Restore LED/Slot state */ - writel(leds, ctrl->hpc_reg + LED_CONTROL); - writeb(slot_power, ctrl->hpc_reg + SLOT_ENABLE); - - set_SOGO(ctrl); - wait_for_ctrl_irq(ctrl); - - ctrl->speed = adapter_speed; - slot = cpqhp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset); - - info("Successfully changed frequency/mode for adapter in slot %d\n", - slot->number); - return 0; -} - #endif