30 #include <linux/module.h>
32 #include <linux/kernel.h>
33 #include <linux/slab.h>
34 #include <linux/types.h>
35 #include <linux/pci.h>
38 #include <linux/time.h>
47 #define DRIVER_VERSION "0.4"
49 #define DRIVER_DESC "PCI Express Hot Plug Controller Driver"
64 #define PCIE_MODULE_NAME "pciehp"
66 static int set_attention_status (
struct hotplug_slot *
slot,
u8 value);
67 static int enable_slot (
struct hotplug_slot *
slot);
68 static int disable_slot (
struct hotplug_slot *
slot);
69 static int get_power_status (
struct hotplug_slot *
slot,
u8 *
value);
70 static int get_attention_status (
struct hotplug_slot *
slot,
u8 *
value);
71 static int get_latch_status (
struct hotplug_slot *
slot,
u8 *
value);
72 static int get_adapter_status (
struct hotplug_slot *
slot,
u8 *
value);
78 static void release_slot(
struct hotplug_slot *hotplug_slot)
80 struct slot *
slot = hotplug_slot->private;
83 __func__, hotplug_slot_name(hotplug_slot));
85 kfree(hotplug_slot->ops);
86 kfree(hotplug_slot->info);
92 struct slot *slot = ctrl->
slot;
93 struct hotplug_slot *hotplug =
NULL;
99 hotplug = kzalloc(
sizeof(*hotplug),
GFP_KERNEL);
123 hotplug->info =
info;
124 hotplug->private =
slot;
125 hotplug->release = &release_slot;
130 ctrl_dbg(ctrl,
"Registering domain:bus:dev=%04x:%02x:00 sun=%x\n",
132 ctrl->
pcie->port->subordinate->number,
PSN(ctrl));
134 ctrl->
pcie->port->subordinate, 0, name);
137 "pci_hp_register failed with error %d\n", retval);
147 static void cleanup_slot(
struct controller *ctrl)
157 struct slot *slot = hotplug_slot->private;
160 __func__, slot_name(slot));
166 static int enable_slot(
struct hotplug_slot *hotplug_slot)
168 struct slot *slot = hotplug_slot->private;
171 __func__, slot_name(slot));
177 static int disable_slot(
struct hotplug_slot *hotplug_slot)
179 struct slot *slot = hotplug_slot->private;
182 __func__, slot_name(slot));
187 static int get_power_status(
struct hotplug_slot *hotplug_slot,
u8 *
value)
189 struct slot *slot = hotplug_slot->private;
192 __func__, slot_name(slot));
197 static int get_attention_status(
struct hotplug_slot *hotplug_slot,
u8 *value)
199 struct slot *slot = hotplug_slot->private;
202 __func__, slot_name(slot));
207 static int get_latch_status(
struct hotplug_slot *hotplug_slot,
u8 *value)
209 struct slot *slot = hotplug_slot->private;
212 __func__, slot_name(slot));
217 static int get_adapter_status(
struct hotplug_slot *hotplug_slot,
u8 *value)
219 struct slot *slot = hotplug_slot->private;
222 __func__, slot_name(slot));
232 u8 occupied, poweron;
236 "Bypassing BIOS check for pciehp use on %s\n",
237 pci_name(dev->
port));
246 set_service_data(dev, ctrl);
249 rc = init_slot(ctrl);
252 ctrl_warn(ctrl,
"Slot already registered by another "
255 ctrl_err(ctrl,
"Slot initialization failed\n");
256 goto err_out_release_ctlr;
262 ctrl_err(ctrl,
"Notification initialization failed\n");
263 goto err_out_free_ctrl_slot;
278 err_out_free_ctrl_slot:
280 err_out_release_ctlr:
288 struct controller *ctrl = get_service_data(dev);
295 static int pciehp_suspend (
struct pcie_device *dev)
308 ctrl = get_service_data(dev);
330 .probe = pciehp_probe,
331 .remove = pciehp_remove,
334 .suspend = pciehp_suspend,
335 .resume = pciehp_resume,
339 static int __init pcied_init(
void)
349 dbg(
"pcie_port_service_register = %d\n", retval);
353 dbg(
"Failure to register service\n");
358 static void __exit pcied_cleanup(
void)
360 dbg(
"unload_pciehpd()\n");