#include <linux/kernel.h>
#include <linux/types.h>
#include <linux/proc_fs.h>
-#include <linux/miscdevice.h>
#include <linux/slab.h>
#include <linux/workqueue.h>
#include <linux/pci.h>
#include <asm/uaccess.h>
#include "pciehp.h"
#include "pciehprm.h"
+#include <linux/interrupt.h>
/* Global variables */
int pciehp_debug;
int num_ctlr_slots; /* Not needed; PCI Express has 1 slot per port*/
int first_device_num; /* Not needed */
int physical_slot_num;
- int updown; /* Not needed */
+ u8 ctrlcap;
int rc;
- int flags; /* Not needed */
- rc = pcie_get_ctlr_slot_config(ctrl, &num_ctlr_slots, &first_device_num, &physical_slot_num, &updown, &flags);
+ rc = pcie_get_ctlr_slot_config(ctrl, &num_ctlr_slots, &first_device_num, &physical_slot_num, &ctrlcap);
if (rc) {
err("%s: get_ctlr_slot_config fail for b:d (%x:%x)\n", __FUNCTION__, ctrl->bus, ctrl->device);
return (-1);
ctrl->num_slots = num_ctlr_slots; /* PCI Express has 1 slot per port */
ctrl->slot_device_offset = first_device_num;
ctrl->first_slot = physical_slot_num;
- ctrl->slot_num_inc = updown; /* Not needed */ /* either -1 or 1 */
+ ctrl->ctrlcap = ctrlcap;
- dbg("%s: bus(0x%x) num_slot(0x%x) 1st_dev(0x%x) psn(0x%x) updown(%d) for b:d (%x:%x)\n",
- __FUNCTION__, ctrl->slot_bus, num_ctlr_slots, first_device_num, physical_slot_num, updown,
+ dbg("%s: bus(0x%x) num_slot(0x%x) 1st_dev(0x%x) psn(0x%x) ctrlcap(%x) for b:d (%x:%x)\n",
+ __FUNCTION__, ctrl->slot_bus, num_ctlr_slots, first_device_num, physical_slot_num, ctrlcap,
ctrl->bus, ctrl->device);
return (0);
dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name);
hotplug_slot->info->attention_status = status;
- slot->hpc_ops->set_attention_status(slot, status);
+
+ if (ATTN_LED(slot->ctrl->ctrlcap))
+ slot->hpc_ops->set_attention_status(slot, status);
return 0;
}
return 0;
}
-static int pcie_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
+static int pciehp_probe(struct pcie_device *dev, const struct pcie_port_service_id *id)
{
int rc;
struct controller *ctrl;
int first_device_num = 0 ; /* first PCI device number supported by this PCIE */
int num_ctlr_slots; /* number of slots supported by this HPC */
u8 value;
-
+ struct pci_dev *pdev;
+
+ dbg("%s: Called by hp_drv\n", __FUNCTION__);
ctrl = kmalloc(sizeof(*ctrl), GFP_KERNEL);
if (!ctrl) {
err("%s : out of memory\n", __FUNCTION__);
memset(ctrl, 0, sizeof(struct controller));
dbg("%s: DRV_thread pid = %d\n", __FUNCTION__, current->pid);
+
+ pdev = dev->port;
- rc = pcie_init(ctrl, pdev,
+ rc = pcie_init(ctrl, dev,
(php_intr_callback_t) pciehp_handle_attention_button,
(php_intr_callback_t) pciehp_handle_switch_change,
(php_intr_callback_t) pciehp_handle_presence_change,
t_slot->hpc_ops->get_adapter_status(t_slot, &value); /* Check if slot is occupied */
dbg("%s: adpater value %x\n", __FUNCTION__, value);
- if (!value) {
+
+ if ((POWER_CTRL(ctrl->ctrlcap)) && !value) {
rc = t_slot->hpc_ops->power_off_slot(t_slot); /* Power off slot if not occupied*/
if (rc) {
/* Done with exclusive hardware access */
}
+int hpdriver_context = 0;
-static struct pci_device_id pcied_pci_tbl[] = {
- {
- .class = ((PCI_CLASS_BRIDGE_PCI << 8) | 0x00),
- .class_mask = ~0,
- .vendor = PCI_ANY_ID,
- .device = PCI_ANY_ID,
- .subvendor = PCI_ANY_ID,
- .subdevice = PCI_ANY_ID,
- },
-
- { /* end: all zeroes */ }
-};
-
-MODULE_DEVICE_TABLE(pci, pcied_pci_tbl);
+static void pciehp_remove (struct pcie_device *device)
+{
+ printk("%s ENTRY\n", __FUNCTION__);
+ printk("%s -> Call free_irq for irq = %d\n",
+ __FUNCTION__, device->irq);
+ free_irq(device->irq, &hpdriver_context);
+}
+#ifdef CONFIG_PM
+static int pciehp_suspend (struct pcie_device *dev, u32 state)
+{
+ printk("%s ENTRY\n", __FUNCTION__);
+ return 0;
+}
+static int pciehp_resume (struct pcie_device *dev)
+{
+ printk("%s ENTRY\n", __FUNCTION__);
+ return 0;
+}
+#endif
-static struct pci_driver pcie_driver = {
- .name = PCIE_MODULE_NAME,
- .id_table = pcied_pci_tbl,
- .probe = pcie_probe,
- /* remove: pcie_remove_one, */
+static struct pcie_port_service_id port_pci_ids[] = { {
+ .vendor = PCI_ANY_ID,
+ .device = PCI_ANY_ID,
+ .port_type = PCIE_RC_PORT,
+ .service_type = PCIE_PORT_SERVICE_HP,
+ .driver_data = 0,
+ }, { /* end: all zeroes */ }
};
+static const char device_name[] = "hpdriver";
+static struct pcie_port_service_driver hpdriver_portdrv = {
+ .name = (char *)device_name,
+ .id_table = &port_pci_ids[0],
+ .probe = pciehp_probe,
+ .remove = pciehp_remove,
+
+#ifdef CONFIG_PM
+ .suspend = pciehp_suspend,
+ .resume = pciehp_resume,
+#endif /* PM */
+};
static int __init pcied_init(void)
{
retval = pciehprm_init(PCI);
if (!retval) {
- retval = pci_module_init(&pcie_driver);
- dbg("pci_module_init = %d\n", retval);
- info(DRIVER_DESC " version: " DRIVER_VERSION "\n");
+ retval = pcie_port_service_register(&hpdriver_portdrv);
+ dbg("pcie_port_service_register = %d\n", retval);
+ info(DRIVER_DESC " version: " DRIVER_VERSION "\n");
+ if (retval)
+ dbg("%s: Failure to register service\n", __FUNCTION__);
}
error_hpc_init:
pciehprm_cleanup();
- dbg("pci_unregister_driver\n");
- pci_unregister_driver(&pcie_driver);
+ dbg("pcie_port_service_unregister\n");
+ pcie_port_service_unregister(&hpdriver_portdrv);
info(DRIVER_DESC " version: " DRIVER_VERSION " unloaded\n");
}