]> git.karo-electronics.de Git - mv-sheeva.git/blobdiff - drivers/pci/hotplug/shpchp.h
Merge master.kernel.org:/pub/scm/linux/kernel/git/sfrench/cifs-2.6
[mv-sheeva.git] / drivers / pci / hotplug / shpchp.h
index ce792b3cf9deb5f3d3a2ffb298e761bce3b34235..ea2087c34149f23244401e480b9cf491693b8a7c 100644 (file)
 
 #include <linux/types.h>
 #include <linux/pci.h>
+#include <linux/pci_hotplug.h>
 #include <linux/delay.h>
 #include <linux/sched.h>       /* signal_pending(), struct timer_list */
 #include <linux/mutex.h>
 
-#include "pci_hotplug.h"
-
 #if !defined(MODULE)
        #define MY_NAME "shpchp"
 #else
@@ -46,6 +45,7 @@
 extern int shpchp_poll_mode;
 extern int shpchp_poll_time;
 extern int shpchp_debug;
+extern struct workqueue_struct *shpchp_wq;
 
 /*#define dbg(format, arg...) do { if (shpchp_debug) printk(KERN_DEBUG "%s: " format, MY_NAME , ## arg); } while (0)*/
 #define dbg(format, arg...) do { if (shpchp_debug) printk("%s: " format, MY_NAME , ## arg); } while (0)
@@ -70,26 +70,26 @@ struct slot {
        struct hotplug_slot *hotplug_slot;
        struct list_head        slot_list;
        char name[SLOT_NAME_SIZE];
+       struct work_struct work;        /* work for button event */
+       struct mutex lock;
 };
 
 struct event_info {
        u32 event_type;
-       u8 hp_slot;
+       struct slot *p_slot;
+       struct work_struct work;
 };
 
 struct controller {
-       struct list_head ctrl_list;
        struct mutex crit_sect;         /* critical section mutex */
        struct mutex cmd_lock;          /* command lock */
        struct php_ctlr_state_s *hpc_ctlr_handle; /* HPC controller handle */
        int num_slots;                  /* Number of slots on ctlr */
        int slot_num_inc;               /* 1 or -1 */
        struct pci_dev *pci_dev;
-       struct event_info event_queue[10];
        struct list_head slot_list;
        struct hpc_ops *hpc_ops;
        wait_queue_head_t queue;        /* sleep & wake process */
-       u8 next_event;
        u8 bus;
        u8 device;
        u8 function;
@@ -102,15 +102,8 @@ struct controller {
        u32 cap_offset;
        unsigned long mmio_base;
        unsigned long mmio_size;
-       volatile int cmd_busy;
 };
 
-struct hotplug_params {
-       u8      cache_line_size;
-       u8      latency_timer;
-       u8      enable_serr;
-       u8      enable_perr;
-};
 
 /* Define AMD SHPC ID  */
 #define PCI_DEVICE_ID_AMD_GOLAM_7450   0x7450 
@@ -173,18 +166,15 @@ struct hotplug_params {
  * error Messages
  */
 #define msg_initialization_err "Initialization failure, error=%d\n"
-#define msg_button_on          "PCI slot #%d - powering on due to button press.\n"
-#define msg_button_off         "PCI slot #%d - powering off due to button press.\n"
-#define msg_button_cancel      "PCI slot #%d - action canceled due to button press.\n"
+#define msg_button_on          "PCI slot #%s - powering on due to button press.\n"
+#define msg_button_off         "PCI slot #%s - powering off due to button press.\n"
+#define msg_button_cancel      "PCI slot #%s - action canceled due to button press.\n"
 
 /* sysfs functions for the hotplug controller info */
-extern void shpchp_create_ctrl_files   (struct controller *ctrl);
+extern int __must_check shpchp_create_ctrl_files(struct controller *ctrl);
 
-/* controller functions */
-extern int     shpchp_event_start_thread(void);
-extern void    shpchp_event_stop_thread(void);
-extern int     shpchp_enable_slot(struct slot *slot);
-extern int     shpchp_disable_slot(struct slot *slot);
+extern int     shpchp_sysfs_enable_slot(struct slot *slot);
+extern int     shpchp_sysfs_disable_slot(struct slot *slot);
 
 extern u8      shpchp_handle_attention_button(u8 hp_slot, void *inst_id);
 extern u8      shpchp_handle_switch_change(u8 hp_slot, void *inst_id);
@@ -195,16 +185,28 @@ extern u8 shpchp_handle_power_fault(u8 hp_slot, void *inst_id);
 extern int     shpchp_save_config(struct controller *ctrl, int busnumber, int num_ctlr_slots, int first_device_num);
 extern int     shpchp_configure_device(struct slot *p_slot);
 extern int     shpchp_unconfigure_device(struct slot *p_slot);
-extern void    get_hp_hw_control_from_firmware(struct pci_dev *dev);
-extern void    get_hp_params_from_firmware(struct pci_dev *dev,
-               struct hotplug_params *hpp);
-extern int     shpchprm_get_physical_slot_number(struct controller *ctrl,
-               u32 *sun, u8 busnum, u8 devnum);
 extern void    shpchp_remove_ctrl_files(struct controller *ctrl);
+extern void    cleanup_slots(struct controller *ctrl);
+extern void    queue_pushbutton_work(void *data);
 
 
-/* Global variables */
-extern struct list_head shpchp_ctrl_list;
+#ifdef CONFIG_ACPI
+static inline int get_hp_params_from_firmware(struct pci_dev *dev,
+                       struct hotplug_params *hpp)
+{
+       if (ACPI_FAILURE(acpi_get_hp_params_from_firmware(dev->bus, hpp)))
+                       return -ENODEV;
+       return 0;
+}
+#define get_hp_hw_control_from_firmware(pdev) \
+       do { \
+               if (DEVICE_ACPI_HANDLE(&(pdev->dev))) \
+                       acpi_run_oshp(DEVICE_ACPI_HANDLE(&(pdev->dev))); \
+       } while (0)
+#else
+#define get_hp_params_from_firmware(dev, hpp) (-ENODEV)
+#define get_hp_hw_control_from_firmware(dev) do { } while (0)
+#endif
 
 struct ctrl_reg {
        volatile u32 base_offset;
@@ -325,27 +327,6 @@ static inline struct slot *shpchp_find_slot (struct controller *ctrl, u8 device)
        return NULL;
 }
 
-static inline int wait_for_ctrl_irq (struct controller *ctrl)
-{
-    DECLARE_WAITQUEUE(wait, current);
-       int retval = 0;
-
-       add_wait_queue(&ctrl->queue, &wait);
-
-       if (!shpchp_poll_mode) {
-               /* Sleep for up to 1 second */
-               msleep_interruptible(1000);
-       } else {
-               /* Sleep for up to 2 seconds */
-               msleep_interruptible(2000);
-       }
-       remove_wait_queue(&ctrl->queue, &wait);
-       if (signal_pending(current))
-               retval =  -EINTR;
-
-       return retval;
-}
-
 static inline void amd_pogo_errata_save_misc_reg(struct slot *p_slot)
 {
        u32 pcix_misc2_temp;