30 #include <linux/module.h>
31 #include <linux/kernel.h>
32 #include <linux/types.h>
33 #include <linux/slab.h>
34 #include <linux/pci.h>
63 ctrl_dbg(ctrl,
"Attention button interrupt received\n");
68 ctrl_info(ctrl,
"Button pressed on Slot(%s)\n", slot_name(p_slot));
71 queue_interrupt_event(p_slot, event_type);
83 ctrl_dbg(ctrl,
"Switch interrupt received\n");
90 ctrl_info(ctrl,
"Latch open on Slot(%s)\n", slot_name(p_slot));
96 ctrl_info(ctrl,
"Latch close on Slot(%s)\n", slot_name(p_slot));
100 queue_interrupt_event(p_slot, event_type);
112 ctrl_dbg(ctrl,
"Presence/Notify input change\n");
122 ctrl_info(ctrl,
"Card present on Slot(%s)\n", slot_name(p_slot));
128 ctrl_info(ctrl,
"Card not present on Slot(%s)\n",
133 queue_interrupt_event(p_slot, event_type);
144 ctrl_dbg(ctrl,
"Power fault interrupt received\n");
145 ctrl_err(ctrl,
"Power fault on slot %s\n", slot_name(p_slot));
147 ctrl_info(ctrl,
"Power fault bit %x set\n", 0);
148 queue_interrupt_event(p_slot, event_type);
163 "Issue of Slot Power Off command failed\n");
180 "Issue of Set Attention Led command failed\n");
193 static int board_added(
struct slot *p_slot)
212 ctrl_err(ctrl,
"Failed to check link status\n");
218 ctrl_err(ctrl,
"Power fault on slot %s\n", slot_name(p_slot));
225 ctrl_err(ctrl,
"Cannot add device at %04x:%02x:00\n",
236 set_slot_off(ctrl, p_slot);
244 static int remove_board(
struct slot *p_slot)
258 "Issue of Slot Disable command failed\n");
295 switch (p_slot->
state) {
299 "Disabling domain:bus:device=%04x:%02x:00\n",
301 p_slot->
ctrl->pcie->port->subordinate->number);
336 switch (p_slot->
state) {
355 static void handle_button_press_event(
struct slot *p_slot)
360 switch (p_slot->
state) {
366 "PCI slot #%s - powering off due to button "
367 "press.\n", slot_name(p_slot));
371 "PCI slot #%s - powering on due to button "
372 "press.\n", slot_name(p_slot));
389 ctrl_info(ctrl,
"Button cancel on Slot(%s)\n", slot_name(p_slot));
400 ctrl_info(ctrl,
"PCI slot #%s - action canceled "
401 "due to button press\n", slot_name(p_slot));
411 ctrl_info(ctrl,
"Button ignore on Slot(%s)\n", slot_name(p_slot));
422 static void handle_surprise_event(
struct slot *p_slot)
445 static void interrupt_event_handler(
struct work_struct *work)
454 handle_button_press_event(p_slot);
468 ctrl_dbg(ctrl,
"Surprise Removal\n");
469 handle_surprise_event(p_slot);
486 if (rc || !getstatus) {
487 ctrl_info(ctrl,
"No adapter on slot(%s)\n", slot_name(p_slot));
492 if (rc || getstatus) {
493 ctrl_info(ctrl,
"Latch open on slot(%s)\n",
501 if (rc || getstatus) {
502 ctrl_info(ctrl,
"Already enabled on slot(%s)\n",
510 rc = board_added(p_slot);
529 if (ret || !getstatus) {
530 ctrl_info(ctrl,
"No adapter on slot(%s)\n",
538 if (ret || getstatus) {
539 ctrl_info(ctrl,
"Latch open on slot(%s)\n",
547 if (ret || !getstatus) {
548 ctrl_info(ctrl,
"Already disabled on slot(%s)\n",
554 return remove_board(p_slot);
563 switch (p_slot->
state) {
574 ctrl_info(ctrl,
"Slot %s is already in powering on state\n",
579 ctrl_info(ctrl,
"Already enabled on slot %s\n",
583 ctrl_err(ctrl,
"Not a valid state on slot %s\n",
598 switch (p_slot->
state) {
609 ctrl_info(ctrl,
"Slot %s is already in powering off state\n",
614 ctrl_info(ctrl,
"Already disabled on slot %s\n",
618 ctrl_err(ctrl,
"Not a valid state on slot %s\n",