X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Fpci%2Fhotplug%2Fcpqphp.h;h=298ad7f3f4f43aada7d324f97a12d39c082fc37e;hb=97bf2856c6014879bd04983a3e9dfcdac1e7fe85;hp=444d2109024a65e13f343aa452b98baf12aa0ddb;hpb=5273a3df6485dc2ad6aa7ddd441b9a21970f003b;p=linux-2.6.git diff --git a/drivers/pci/hotplug/cpqphp.h b/drivers/pci/hotplug/cpqphp.h index 444d21090..298ad7f3f 100644 --- a/drivers/pci/hotplug/cpqphp.h +++ b/drivers/pci/hotplug/cpqphp.h @@ -28,16 +28,12 @@ #ifndef _CPQPHP_H #define _CPQPHP_H -#include "pci_hotplug.h" #include #include /* for read? and write? functions */ #include /* for delays */ +#include -#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; @@ -274,7 +268,7 @@ struct slot { struct timer_list task_event; u8 hp_slot; struct controller *ctrl; - void *p_sm_slot; + void __iomem *p_sm_slot; struct hotplug_slot *hotplug_slot; }; @@ -292,8 +286,8 @@ struct event_info { struct controller { struct controller *next; u32 ctrl_int_comp; - struct semaphore crit_sect; /* critical section semaphore */ - void *hpc_reg; /* cookie for our pci controller location */ + struct mutex crit_sect; /* critical section mutex */ + void __iomem *hpc_reg; /* cookie for our pci controller location */ struct pci_resource *mem_head; struct pci_resource *p_mem_head; struct pci_resource *io_head; @@ -323,6 +317,7 @@ struct controller { u16 vendor_id; struct work_struct int_task_event; wait_queue_head_t queue; /* sleep & wake process */ + struct dentry *dentry; /* debugfs dentry */ }; struct irq_mapping { @@ -377,11 +372,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 @@ -408,13 +400,16 @@ struct resource_lists { #define msg_button_ignore "PCI slot #%d - button press ignored. (action in progress...)\n" -/* sysfs functions for the hotplug controller info */ -extern void cpqhp_create_ctrl_files (struct controller *ctrl); +/* debugfs functions for the hotplug controller info */ +extern void cpqhp_initialize_debugfs (void); +extern void cpqhp_shutdown_debugfs (void); +extern void cpqhp_create_debugfs_files (struct controller *ctrl); +extern void cpqhp_remove_debugfs_files (struct controller *ctrl); /* controller functions */ extern void cpqhp_pushbutton_thread (unsigned long event_pointer); -extern irqreturn_t cpqhp_ctrl_intr (int IRQ, void *data, struct pt_regs *regs); -extern int cpqhp_find_available_resources (struct controller *ctrl, void *rom_start); +extern irqreturn_t cpqhp_ctrl_intr (int IRQ, void *data); +extern int cpqhp_find_available_resources (struct controller *ctrl, void __iomem *rom_start); extern int cpqhp_event_start_thread (void); extern void cpqhp_event_stop_thread (void); extern struct pci_func *cpqhp_slot_create (unsigned char busnumber); @@ -440,7 +435,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 +447,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 +463,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 +473,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 +483,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 +493,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 +504,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 +513,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 +523,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 +534,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 +544,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 +554,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 +564,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 +578,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 +611,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 +628,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 +637,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 +647,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 +682,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,22 +698,21 @@ 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; dbg("%s - start\n", __FUNCTION__); add_wait_queue(&ctrl->queue, &wait); - set_current_state(TASK_INTERRUPTIBLE); /* Sleep for up to 1 second to wait for the LED to change. */ - schedule_timeout(1*HZ); + msleep_interruptible(1000); remove_wait_queue(&ctrl->queue, &wait); if (signal_pending(current)) retval = -EINTR; @@ -775,138 +721,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