2 * PCI Express PCI Hot Plug Driver
4 * Copyright (C) 1995,2001 Compaq Computer Corporation
5 * Copyright (C) 2001 Greg Kroah-Hartman (greg@kroah.com)
6 * Copyright (C) 2001 IBM Corp.
7 * Copyright (C) 2003-2004 Intel Corporation
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or (at
14 * your option) any later version.
16 * This program is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
19 * NON INFRINGEMENT. See the GNU General Public License for more
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 * Send feedback to <greg@kroah.com>,<kristen.c.accardi@intel.com>
30 #include <linux/kernel.h>
31 #include <linux/module.h>
32 #include <linux/types.h>
33 #include <linux/signal.h>
34 #include <linux/jiffies.h>
35 #include <linux/timer.h>
36 #include <linux/pci.h>
37 #include <linux/interrupt.h>
41 #include <acpi/acpi.h>
42 #include <acpi/acpi_bus.h>
43 #include <acpi/actypes.h>
44 #include <linux/pci-acpi.h>
46 #define DBG_K_TRACE_ENTRY ((unsigned int)0x00000001) /* On function entry */
47 #define DBG_K_TRACE_EXIT ((unsigned int)0x00000002) /* On function exit */
48 #define DBG_K_INFO ((unsigned int)0x00000004) /* Info messages */
49 #define DBG_K_ERROR ((unsigned int)0x00000008) /* Error messages */
50 #define DBG_K_TRACE (DBG_K_TRACE_ENTRY|DBG_K_TRACE_EXIT)
51 #define DBG_K_STANDARD (DBG_K_INFO|DBG_K_ERROR|DBG_K_TRACE)
52 /* Redefine this flagword to set debug level */
53 #define DEBUG_LEVEL DBG_K_STANDARD
55 #define DEFINE_DBG_BUFFER char __dbg_str_buf[256];
57 #define DBG_PRINT( dbg_flags, args... ) \
59 if ( DEBUG_LEVEL & ( dbg_flags ) ) \
62 len = sprintf( __dbg_str_buf, "%s:%d: %s: ", \
63 __FILE__, __LINE__, __FUNCTION__ ); \
64 sprintf( __dbg_str_buf + len, args ); \
65 printk( KERN_NOTICE "%s\n", __dbg_str_buf ); \
69 #define DBG_ENTER_ROUTINE DBG_PRINT (DBG_K_TRACE_ENTRY, "%s", "[Entry]");
70 #define DBG_LEAVE_ROUTINE DBG_PRINT (DBG_K_TRACE_EXIT, "%s", "[Exit]");
72 #define DEFINE_DBG_BUFFER
73 #define DBG_ENTER_ROUTINE
74 #define DBG_LEAVE_ROUTINE
93 } __attribute__ ((packed));
95 /* offsets to the controller registers based on the above structure layout */
97 PCIECAPID = offsetof(struct ctrl_reg, cap_id),
98 NXTCAPPTR = offsetof(struct ctrl_reg, nxt_ptr),
99 CAPREG = offsetof(struct ctrl_reg, cap_reg),
100 DEVCAP = offsetof(struct ctrl_reg, dev_cap),
101 DEVCTRL = offsetof(struct ctrl_reg, dev_ctrl),
102 DEVSTATUS = offsetof(struct ctrl_reg, dev_status),
103 LNKCAP = offsetof(struct ctrl_reg, lnk_cap),
104 LNKCTRL = offsetof(struct ctrl_reg, lnk_ctrl),
105 LNKSTATUS = offsetof(struct ctrl_reg, lnk_status),
106 SLOTCAP = offsetof(struct ctrl_reg, slot_cap),
107 SLOTCTRL = offsetof(struct ctrl_reg, slot_ctrl),
108 SLOTSTATUS = offsetof(struct ctrl_reg, slot_status),
109 ROOTCTRL = offsetof(struct ctrl_reg, root_ctrl),
110 ROOTSTATUS = offsetof(struct ctrl_reg, root_status),
112 static int pcie_cap_base = 0; /* Base of the PCI Express capability item structure */
114 #define PCIE_CAP_ID(cb) ( cb + PCIECAPID )
115 #define NXT_CAP_PTR(cb) ( cb + NXTCAPPTR )
116 #define CAP_REG(cb) ( cb + CAPREG )
117 #define DEV_CAP(cb) ( cb + DEVCAP )
118 #define DEV_CTRL(cb) ( cb + DEVCTRL )
119 #define DEV_STATUS(cb) ( cb + DEVSTATUS )
120 #define LNK_CAP(cb) ( cb + LNKCAP )
121 #define LNK_CTRL(cb) ( cb + LNKCTRL )
122 #define LNK_STATUS(cb) ( cb + LNKSTATUS )
123 #define SLOT_CAP(cb) ( cb + SLOTCAP )
124 #define SLOT_CTRL(cb) ( cb + SLOTCTRL )
125 #define SLOT_STATUS(cb) ( cb + SLOTSTATUS )
126 #define ROOT_CTRL(cb) ( cb + ROOTCTRL )
127 #define ROOT_STATUS(cb) ( cb + ROOTSTATUS )
129 #define hp_register_read_word(pdev, reg , value) \
130 pci_read_config_word(pdev, reg, &value)
132 #define hp_register_read_dword(pdev, reg , value) \
133 pci_read_config_dword(pdev, reg, &value)
135 #define hp_register_write_word(pdev, reg , value) \
136 pci_write_config_word(pdev, reg, value)
138 #define hp_register_dwrite_word(pdev, reg , value) \
139 pci_write_config_dword(pdev, reg, value)
141 /* Field definitions in PCI Express Capabilities Register */
142 #define CAP_VER 0x000F
143 #define DEV_PORT_TYPE 0x00F0
144 #define SLOT_IMPL 0x0100
145 #define MSG_NUM 0x3E00
147 /* Device or Port Type */
148 #define NAT_ENDPT 0x00
149 #define LEG_ENDPT 0x01
150 #define ROOT_PORT 0x04
151 #define UP_STREAM 0x05
152 #define DN_STREAM 0x06
153 #define PCIE_PCI_BRDG 0x07
154 #define PCI_PCIE_BRDG 0x10
156 /* Field definitions in Device Capabilities Register */
157 #define DATTN_BUTTN_PRSN 0x1000
158 #define DATTN_LED_PRSN 0x2000
159 #define DPWR_LED_PRSN 0x4000
161 /* Field definitions in Link Capabilities Register */
162 #define MAX_LNK_SPEED 0x000F
163 #define MAX_LNK_WIDTH 0x03F0
165 /* Link Width Encoding */
174 /*Field definitions of Link Status Register */
175 #define LNK_SPEED 0x000F
176 #define NEG_LINK_WD 0x03F0
177 #define LNK_TRN_ERR 0x0400
178 #define LNK_TRN 0x0800
179 #define SLOT_CLK_CONF 0x1000
181 /* Field definitions in Slot Capabilities Register */
182 #define ATTN_BUTTN_PRSN 0x00000001
183 #define PWR_CTRL_PRSN 0x00000002
184 #define MRL_SENS_PRSN 0x00000004
185 #define ATTN_LED_PRSN 0x00000008
186 #define PWR_LED_PRSN 0x00000010
187 #define HP_SUPR_RM_SUP 0x00000020
188 #define HP_CAP 0x00000040
189 #define SLOT_PWR_VALUE 0x000003F8
190 #define SLOT_PWR_LIMIT 0x00000C00
191 #define PSN 0xFFF80000 /* PSN: Physical Slot Number */
193 /* Field definitions in Slot Control Register */
194 #define ATTN_BUTTN_ENABLE 0x0001
195 #define PWR_FAULT_DETECT_ENABLE 0x0002
196 #define MRL_DETECT_ENABLE 0x0004
197 #define PRSN_DETECT_ENABLE 0x0008
198 #define CMD_CMPL_INTR_ENABLE 0x0010
199 #define HP_INTR_ENABLE 0x0020
200 #define ATTN_LED_CTRL 0x00C0
201 #define PWR_LED_CTRL 0x0300
202 #define PWR_CTRL 0x0400
204 /* Attention indicator and Power indicator states */
206 #define LED_BLINK 0x10
209 /* Power Control Command */
211 #define POWER_OFF 0x0400
213 /* Field definitions in Slot Status Register */
214 #define ATTN_BUTTN_PRESSED 0x0001
215 #define PWR_FAULT_DETECTED 0x0002
216 #define MRL_SENS_CHANGED 0x0004
217 #define PRSN_DETECT_CHANGED 0x0008
218 #define CMD_COMPLETED 0x0010
219 #define MRL_STATE 0x0020
220 #define PRSN_STATE 0x0040
222 static spinlock_t hpc_event_lock;
224 DEFINE_DBG_BUFFER /* Debug string buffer for entire HPC defined here */
225 static struct php_ctlr_state_s *php_ctlr_list_head; /* HPC state linked list */
226 static int ctlr_seq_num = 0; /* Controller sequence # */
227 static spinlock_t list_lock;
229 static irqreturn_t pcie_isr(int IRQ, void *dev_id, struct pt_regs *regs);
231 static void start_int_poll_timer(struct php_ctlr_state_s *php_ctlr, int seconds);
233 /* This is the interrupt polling timeout function. */
234 static void int_poll_timeout(unsigned long lphp_ctlr)
236 struct php_ctlr_state_s *php_ctlr = (struct php_ctlr_state_s *)lphp_ctlr;
241 err("%s: Invalid HPC controller handle!\n", __FUNCTION__);
245 /* Poll for interrupt events. regs == NULL => polling */
246 pcie_isr( 0, (void *)php_ctlr, NULL );
248 init_timer(&php_ctlr->int_poll_timer);
250 if (!pciehp_poll_time)
251 pciehp_poll_time = 2; /* reset timer to poll in 2 secs if user doesn't specify at module installation*/
253 start_int_poll_timer(php_ctlr, pciehp_poll_time);
258 /* This function starts the interrupt polling timer. */
259 static void start_int_poll_timer(struct php_ctlr_state_s *php_ctlr, int seconds)
262 err("%s: Invalid HPC controller handle!\n", __FUNCTION__);
266 if ( ( seconds <= 0 ) || ( seconds > 60 ) )
267 seconds = 2; /* Clamp to sane value */
269 php_ctlr->int_poll_timer.function = &int_poll_timeout;
270 php_ctlr->int_poll_timer.data = (unsigned long)php_ctlr; /* Instance data */
271 php_ctlr->int_poll_timer.expires = jiffies + seconds * HZ;
272 add_timer(&php_ctlr->int_poll_timer);
277 static int pcie_write_cmd(struct slot *slot, u16 cmd)
279 struct php_ctlr_state_s *php_ctlr = slot->ctrl->hpc_ctlr_handle;
286 err("%s: Invalid HPC controller handle!\n", __FUNCTION__);
290 retval = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS(slot->ctrl->cap_base), slot_status);
292 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__);
296 if ((slot_status & CMD_COMPLETED) == CMD_COMPLETED ) {
297 /* After 1 sec and CMD_COMPLETED still not set, just proceed forward to issue
298 the next command according to spec. Just print out the error message */
299 dbg("%s : CMD_COMPLETED not clear after 1 sec.\n", __FUNCTION__);
302 retval = hp_register_write_word(php_ctlr->pci_dev, SLOT_CTRL(slot->ctrl->cap_base), cmd | CMD_CMPL_INTR_ENABLE);
304 err("%s : hp_register_write_word SLOT_CTRL failed\n", __FUNCTION__);
312 static int hpc_check_lnk_status(struct controller *ctrl)
314 struct php_ctlr_state_s *php_ctlr = ctrl->hpc_ctlr_handle;
321 err("%s: Invalid HPC controller handle!\n", __FUNCTION__);
325 retval = hp_register_read_word(php_ctlr->pci_dev, LNK_STATUS(ctrl->cap_base), lnk_status);
328 err("%s : hp_register_read_word LNK_STATUS failed\n", __FUNCTION__);
332 dbg("%s: lnk_status = %x\n", __FUNCTION__, lnk_status);
333 if ( (lnk_status & LNK_TRN) || (lnk_status & LNK_TRN_ERR) ||
334 !(lnk_status & NEG_LINK_WD)) {
335 err("%s : Link Training Error occurs \n", __FUNCTION__);
345 static int hpc_get_attention_status(struct slot *slot, u8 *status)
347 struct php_ctlr_state_s *php_ctlr = slot->ctrl->hpc_ctlr_handle;
355 err("%s: Invalid HPC controller handle!\n", __FUNCTION__);
359 retval = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL(slot->ctrl->cap_base), slot_ctrl);
362 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__);
366 dbg("%s: SLOT_CTRL %x, value read %x\n", __FUNCTION__,SLOT_CTRL(slot->ctrl->cap_base), slot_ctrl);
368 atten_led_state = (slot_ctrl & ATTN_LED_CTRL) >> 6;
370 switch (atten_led_state) {
372 *status = 0xFF; /* Reserved */
375 *status = 1; /* On */
378 *status = 2; /* Blink */
381 *status = 0; /* Off */
392 static int hpc_get_power_status(struct slot * slot, u8 *status)
394 struct php_ctlr_state_s *php_ctlr = slot->ctrl->hpc_ctlr_handle;
402 err("%s: Invalid HPC controller handle!\n", __FUNCTION__);
406 retval = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL(slot->ctrl->cap_base), slot_ctrl);
409 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__);
412 dbg("%s: SLOT_CTRL %x value read %x\n", __FUNCTION__, SLOT_CTRL(slot->ctrl->cap_base), slot_ctrl);
414 pwr_state = (slot_ctrl & PWR_CTRL) >> 10;
433 static int hpc_get_latch_status(struct slot *slot, u8 *status)
435 struct php_ctlr_state_s *php_ctlr = slot->ctrl->hpc_ctlr_handle;
442 err("%s: Invalid HPC controller handle!\n", __FUNCTION__);
446 retval = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS(slot->ctrl->cap_base), slot_status);
449 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__);
453 *status = (((slot_status & MRL_STATE) >> 5) == 0) ? 0 : 1;
459 static int hpc_get_adapter_status(struct slot *slot, u8 *status)
461 struct php_ctlr_state_s *php_ctlr = slot->ctrl->hpc_ctlr_handle;
469 err("%s: Invalid HPC controller handle!\n", __FUNCTION__);
473 retval = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS(slot->ctrl->cap_base), slot_status);
476 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__);
479 card_state = (u8)((slot_status & PRSN_STATE) >> 6);
480 *status = (card_state == 1) ? 1 : 0;
486 static int hpc_query_power_fault(struct slot * slot)
488 struct php_ctlr_state_s *php_ctlr = slot->ctrl->hpc_ctlr_handle;
496 err("%s: Invalid HPC controller handle!\n", __FUNCTION__);
500 retval = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS(slot->ctrl->cap_base), slot_status);
503 err("%s : Cannot check for power fault\n", __FUNCTION__);
506 pwr_fault = (u8)((slot_status & PWR_FAULT_DETECTED) >> 1);
512 static int hpc_set_attention_status(struct slot *slot, u8 value)
514 struct php_ctlr_state_s *php_ctlr = slot->ctrl->hpc_ctlr_handle;
522 err("%s: Invalid HPC controller handle!\n", __FUNCTION__);
526 if (slot->hp_slot >= php_ctlr->num_slots) {
527 err("%s: Invalid HPC slot number!\n", __FUNCTION__);
530 rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL(slot->ctrl->cap_base), slot_ctrl);
533 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__);
538 case 0 : /* turn off */
539 slot_cmd = (slot_ctrl & ~ATTN_LED_CTRL) | 0x00C0;
541 case 1: /* turn on */
542 slot_cmd = (slot_ctrl & ~ATTN_LED_CTRL) | 0x0040;
544 case 2: /* turn blink */
545 slot_cmd = (slot_ctrl & ~ATTN_LED_CTRL) | 0x0080;
550 if (!pciehp_poll_mode)
551 slot_cmd = slot_cmd | HP_INTR_ENABLE;
553 pcie_write_cmd(slot, slot_cmd);
554 dbg("%s: SLOT_CTRL %x write cmd %x\n", __FUNCTION__, SLOT_CTRL(slot->ctrl->cap_base), slot_cmd);
561 static void hpc_set_green_led_on(struct slot *slot)
563 struct php_ctlr_state_s *php_ctlr = slot->ctrl->hpc_ctlr_handle;
571 err("%s: Invalid HPC controller handle!\n", __FUNCTION__);
575 if (slot->hp_slot >= php_ctlr->num_slots) {
576 err("%s: Invalid HPC slot number!\n", __FUNCTION__);
580 rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL(slot->ctrl->cap_base), slot_ctrl);
583 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__);
586 slot_cmd = (slot_ctrl & ~PWR_LED_CTRL) | 0x0100;
587 if (!pciehp_poll_mode)
588 slot_cmd = slot_cmd | HP_INTR_ENABLE;
590 pcie_write_cmd(slot, slot_cmd);
592 dbg("%s: SLOT_CTRL %x write cmd %x\n",__FUNCTION__, SLOT_CTRL(slot->ctrl->cap_base), slot_cmd);
597 static void hpc_set_green_led_off(struct slot *slot)
599 struct php_ctlr_state_s *php_ctlr = slot->ctrl->hpc_ctlr_handle;
607 err("%s: Invalid HPC controller handle!\n", __FUNCTION__);
611 if (slot->hp_slot >= php_ctlr->num_slots) {
612 err("%s: Invalid HPC slot number!\n", __FUNCTION__);
616 rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL(slot->ctrl->cap_base), slot_ctrl);
619 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__);
623 slot_cmd = (slot_ctrl & ~PWR_LED_CTRL) | 0x0300;
625 if (!pciehp_poll_mode)
626 slot_cmd = slot_cmd | HP_INTR_ENABLE;
627 pcie_write_cmd(slot, slot_cmd);
628 dbg("%s: SLOT_CTRL %x write cmd %x\n", __FUNCTION__, SLOT_CTRL(slot->ctrl->cap_base), slot_cmd);
634 static void hpc_set_green_led_blink(struct slot *slot)
636 struct php_ctlr_state_s *php_ctlr = slot->ctrl->hpc_ctlr_handle;
644 err("%s: Invalid HPC controller handle!\n", __FUNCTION__);
648 if (slot->hp_slot >= php_ctlr->num_slots) {
649 err("%s: Invalid HPC slot number!\n", __FUNCTION__);
653 rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL(slot->ctrl->cap_base), slot_ctrl);
656 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__);
660 slot_cmd = (slot_ctrl & ~PWR_LED_CTRL) | 0x0200;
662 if (!pciehp_poll_mode)
663 slot_cmd = slot_cmd | HP_INTR_ENABLE;
664 pcie_write_cmd(slot, slot_cmd);
666 dbg("%s: SLOT_CTRL %x write cmd %x\n",__FUNCTION__, SLOT_CTRL(slot->ctrl->cap_base), slot_cmd);
671 int pcie_get_ctlr_slot_config(struct controller *ctrl,
672 int *num_ctlr_slots, /* number of slots in this HPC; only 1 in PCIE */
673 int *first_device_num, /* PCI dev num of the first slot in this PCIE */
674 int *physical_slot_num, /* phy slot num of the first slot in this PCIE */
677 struct php_ctlr_state_s *php_ctlr = ctrl->hpc_ctlr_handle;
684 err("%s: Invalid HPC controller handle!\n", __FUNCTION__);
688 *first_device_num = 0;
691 rc = hp_register_read_dword(php_ctlr->pci_dev, SLOT_CAP(ctrl->cap_base), slot_cap);
694 err("%s : hp_register_read_dword SLOT_CAP failed\n", __FUNCTION__);
698 *physical_slot_num = slot_cap >> 19;
699 dbg("%s: PSN %d \n", __FUNCTION__, *physical_slot_num);
701 *ctrlcap = slot_cap & 0x0000007f;
707 static void hpc_release_ctlr(struct controller *ctrl)
709 struct php_ctlr_state_s *php_ctlr = ctrl->hpc_ctlr_handle;
710 struct php_ctlr_state_s *p, *p_prev;
715 err("%s: Invalid HPC controller handle!\n", __FUNCTION__);
719 if (pciehp_poll_mode) {
720 del_timer(&php_ctlr->int_poll_timer);
723 free_irq(php_ctlr->irq, ctrl);
726 pci_disable_msi(php_ctlr->pci_dev);
729 if (php_ctlr->pci_dev)
730 php_ctlr->pci_dev = NULL;
732 spin_lock(&list_lock);
733 p = php_ctlr_list_head;
738 p_prev->pnext = p->pnext;
740 php_ctlr_list_head = p->pnext;
747 spin_unlock(&list_lock);
755 static int hpc_power_on_slot(struct slot * slot)
757 struct php_ctlr_state_s *php_ctlr = slot->ctrl->hpc_ctlr_handle;
759 u16 slot_ctrl, slot_status;
766 err("%s: Invalid HPC controller handle!\n", __FUNCTION__);
770 dbg("%s: slot->hp_slot %x\n", __FUNCTION__, slot->hp_slot);
771 if (slot->hp_slot >= php_ctlr->num_slots) {
772 err("%s: Invalid HPC slot number!\n", __FUNCTION__);
776 /* Clear sticky power-fault bit from previous power failures */
777 hp_register_read_word(php_ctlr->pci_dev,
778 SLOT_STATUS(slot->ctrl->cap_base), slot_status);
779 slot_status &= PWR_FAULT_DETECTED;
781 hp_register_write_word(php_ctlr->pci_dev,
782 SLOT_STATUS(slot->ctrl->cap_base), slot_status);
784 retval = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL(slot->ctrl->cap_base), slot_ctrl);
787 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__);
791 slot_cmd = (slot_ctrl & ~PWR_CTRL) | POWER_ON;
793 /* Enable detection that we turned off at slot power-off time */
794 if (!pciehp_poll_mode)
795 slot_cmd = slot_cmd |
796 PWR_FAULT_DETECT_ENABLE |
801 retval = pcie_write_cmd(slot, slot_cmd);
804 err("%s: Write %x command failed!\n", __FUNCTION__, slot_cmd);
807 dbg("%s: SLOT_CTRL %x write cmd %x\n",__FUNCTION__, SLOT_CTRL(slot->ctrl->cap_base), slot_cmd);
814 static int hpc_power_off_slot(struct slot * slot)
816 struct php_ctlr_state_s *php_ctlr = slot->ctrl->hpc_ctlr_handle;
825 err("%s: Invalid HPC controller handle!\n", __FUNCTION__);
829 dbg("%s: slot->hp_slot %x\n", __FUNCTION__, slot->hp_slot);
831 if (slot->hp_slot >= php_ctlr->num_slots) {
832 err("%s: Invalid HPC slot number!\n", __FUNCTION__);
835 retval = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL(slot->ctrl->cap_base), slot_ctrl);
838 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__);
842 slot_cmd = (slot_ctrl & ~PWR_CTRL) | POWER_OFF;
845 * If we get MRL or presence detect interrupts now, the isr
846 * will notice the sticky power-fault bit too and issue power
847 * indicator change commands. This will lead to an endless loop
848 * of command completions, since the power-fault bit remains on
849 * till the slot is powered on again.
851 if (!pciehp_poll_mode)
852 slot_cmd = (slot_cmd &
853 ~PWR_FAULT_DETECT_ENABLE &
855 ~PRSN_DETECT_ENABLE) | HP_INTR_ENABLE;
857 retval = pcie_write_cmd(slot, slot_cmd);
860 err("%s: Write command failed!\n", __FUNCTION__);
863 dbg("%s: SLOT_CTRL %x write cmd %x\n",__FUNCTION__, SLOT_CTRL(slot->ctrl->cap_base), slot_cmd);
870 static irqreturn_t pcie_isr(int IRQ, void *dev_id, struct pt_regs *regs)
872 struct controller *ctrl = NULL;
873 struct php_ctlr_state_s *php_ctlr;
874 u8 schedule_flag = 0;
875 u16 slot_status, intr_detect, intr_loc;
877 int hp_slot = 0; /* only 1 slot per PCI Express port */
883 if (!pciehp_poll_mode) {
885 php_ctlr = ctrl->hpc_ctlr_handle;
888 ctrl = (struct controller *)php_ctlr->callback_instance_id;
892 dbg("%s: dev_id %p ctlr == NULL\n", __FUNCTION__, (void*) dev_id);
897 dbg("%s: php_ctlr == NULL\n", __FUNCTION__);
901 rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS(ctrl->cap_base), slot_status);
903 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__);
907 intr_detect = ( ATTN_BUTTN_PRESSED | PWR_FAULT_DETECTED | MRL_SENS_CHANGED |
908 PRSN_DETECT_CHANGED | CMD_COMPLETED );
910 intr_loc = slot_status & intr_detect;
912 /* Check to see if it was our interrupt */
916 dbg("%s: intr_loc %x\n", __FUNCTION__, intr_loc);
917 /* Mask Hot-plug Interrupt Enable */
918 if (!pciehp_poll_mode) {
919 rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL(ctrl->cap_base), temp_word);
921 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__);
925 dbg("%s: hp_register_read_word SLOT_CTRL with value %x\n", __FUNCTION__, temp_word);
926 temp_word = (temp_word & ~HP_INTR_ENABLE & ~CMD_CMPL_INTR_ENABLE) | 0x00;
928 rc = hp_register_write_word(php_ctlr->pci_dev, SLOT_CTRL(ctrl->cap_base), temp_word);
930 err("%s : hp_register_write_word SLOT_CTRL failed\n", __FUNCTION__);
934 rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS(ctrl->cap_base), slot_status);
936 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__);
939 dbg("%s: hp_register_read_word SLOT_STATUS with value %x\n", __FUNCTION__, slot_status);
941 /* Clear command complete interrupt caused by this write */
943 rc = hp_register_write_word(php_ctlr->pci_dev, SLOT_STATUS(ctrl->cap_base), temp_word);
945 err("%s : hp_register_write_word SLOT_STATUS failed\n", __FUNCTION__);
950 if (intr_loc & CMD_COMPLETED) {
952 * Command Complete Interrupt Pending
954 wake_up_interruptible(&ctrl->queue);
957 if ((php_ctlr->switch_change_callback) && (intr_loc & MRL_SENS_CHANGED))
958 schedule_flag += php_ctlr->switch_change_callback(
959 hp_slot, php_ctlr->callback_instance_id);
960 if ((php_ctlr->attention_button_callback) && (intr_loc & ATTN_BUTTN_PRESSED))
961 schedule_flag += php_ctlr->attention_button_callback(
962 hp_slot, php_ctlr->callback_instance_id);
963 if ((php_ctlr->presence_change_callback) && (intr_loc & PRSN_DETECT_CHANGED))
964 schedule_flag += php_ctlr->presence_change_callback(
965 hp_slot , php_ctlr->callback_instance_id);
966 if ((php_ctlr->power_fault_callback) && (intr_loc & PWR_FAULT_DETECTED))
967 schedule_flag += php_ctlr->power_fault_callback(
968 hp_slot, php_ctlr->callback_instance_id);
970 /* Clear all events after serving them */
972 rc = hp_register_write_word(php_ctlr->pci_dev, SLOT_STATUS(ctrl->cap_base), temp_word);
974 err("%s : hp_register_write_word SLOT_STATUS failed\n", __FUNCTION__);
977 /* Unmask Hot-plug Interrupt Enable */
978 if (!pciehp_poll_mode) {
979 rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL(ctrl->cap_base), temp_word);
981 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__);
985 dbg("%s: Unmask Hot-plug Interrupt Enable\n", __FUNCTION__);
986 temp_word = (temp_word & ~HP_INTR_ENABLE) | HP_INTR_ENABLE;
988 rc = hp_register_write_word(php_ctlr->pci_dev, SLOT_CTRL(ctrl->cap_base), temp_word);
990 err("%s : hp_register_write_word SLOT_CTRL failed\n", __FUNCTION__);
994 rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS(ctrl->cap_base), slot_status);
996 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__);
1000 /* Clear command complete interrupt caused by this write */
1002 rc = hp_register_write_word(php_ctlr->pci_dev, SLOT_STATUS(ctrl->cap_base), temp_word);
1004 err("%s : hp_register_write_word SLOT_STATUS failed\n", __FUNCTION__);
1007 dbg("%s: hp_register_write_word SLOT_STATUS with value %x\n", __FUNCTION__, temp_word);
1013 static int hpc_get_max_lnk_speed (struct slot *slot, enum pci_bus_speed *value)
1015 struct php_ctlr_state_s *php_ctlr = slot->ctrl->hpc_ctlr_handle;
1016 enum pcie_link_speed lnk_speed;
1023 err("%s: Invalid HPC controller handle!\n", __FUNCTION__);
1027 if (slot->hp_slot >= php_ctlr->num_slots) {
1028 err("%s: Invalid HPC slot number!\n", __FUNCTION__);
1032 retval = hp_register_read_dword(php_ctlr->pci_dev, LNK_CAP(slot->ctrl->cap_base), lnk_cap);
1035 err("%s : hp_register_read_dword LNK_CAP failed\n", __FUNCTION__);
1039 switch (lnk_cap & 0x000F) {
1041 lnk_speed = PCIE_2PT5GB;
1044 lnk_speed = PCIE_LNK_SPEED_UNKNOWN;
1049 dbg("Max link speed = %d\n", lnk_speed);
1054 static int hpc_get_max_lnk_width (struct slot *slot, enum pcie_link_width *value)
1056 struct php_ctlr_state_s *php_ctlr = slot->ctrl->hpc_ctlr_handle;
1057 enum pcie_link_width lnk_wdth;
1064 err("%s: Invalid HPC controller handle!\n", __FUNCTION__);
1068 if (slot->hp_slot >= php_ctlr->num_slots) {
1069 err("%s: Invalid HPC slot number!\n", __FUNCTION__);
1073 retval = hp_register_read_dword(php_ctlr->pci_dev, LNK_CAP(slot->ctrl->cap_base), lnk_cap);
1076 err("%s : hp_register_read_dword LNK_CAP failed\n", __FUNCTION__);
1080 switch ((lnk_cap & 0x03F0) >> 4){
1082 lnk_wdth = PCIE_LNK_WIDTH_RESRV;
1085 lnk_wdth = PCIE_LNK_X1;
1088 lnk_wdth = PCIE_LNK_X2;
1091 lnk_wdth = PCIE_LNK_X4;
1094 lnk_wdth = PCIE_LNK_X8;
1097 lnk_wdth = PCIE_LNK_X12;
1100 lnk_wdth = PCIE_LNK_X16;
1103 lnk_wdth = PCIE_LNK_X32;
1106 lnk_wdth = PCIE_LNK_WIDTH_UNKNOWN;
1111 dbg("Max link width = %d\n", lnk_wdth);
1116 static int hpc_get_cur_lnk_speed (struct slot *slot, enum pci_bus_speed *value)
1118 struct php_ctlr_state_s *php_ctlr = slot->ctrl->hpc_ctlr_handle;
1119 enum pcie_link_speed lnk_speed = PCI_SPEED_UNKNOWN;
1126 err("%s: Invalid HPC controller handle!\n", __FUNCTION__);
1130 if (slot->hp_slot >= php_ctlr->num_slots) {
1131 err("%s: Invalid HPC slot number!\n", __FUNCTION__);
1135 retval = hp_register_read_word(php_ctlr->pci_dev, LNK_STATUS(slot->ctrl->cap_base), lnk_status);
1138 err("%s : hp_register_read_word LNK_STATUS failed\n", __FUNCTION__);
1142 switch (lnk_status & 0x0F) {
1144 lnk_speed = PCIE_2PT5GB;
1147 lnk_speed = PCIE_LNK_SPEED_UNKNOWN;
1152 dbg("Current link speed = %d\n", lnk_speed);
1157 static int hpc_get_cur_lnk_width (struct slot *slot, enum pcie_link_width *value)
1159 struct php_ctlr_state_s *php_ctlr = slot->ctrl->hpc_ctlr_handle;
1160 enum pcie_link_width lnk_wdth = PCIE_LNK_WIDTH_UNKNOWN;
1167 err("%s: Invalid HPC controller handle!\n", __FUNCTION__);
1171 if (slot->hp_slot >= php_ctlr->num_slots) {
1172 err("%s: Invalid HPC slot number!\n", __FUNCTION__);
1176 retval = hp_register_read_word(php_ctlr->pci_dev, LNK_STATUS(slot->ctrl->cap_base), lnk_status);
1179 err("%s : hp_register_read_word LNK_STATUS failed\n", __FUNCTION__);
1183 switch ((lnk_status & 0x03F0) >> 4){
1185 lnk_wdth = PCIE_LNK_WIDTH_RESRV;
1188 lnk_wdth = PCIE_LNK_X1;
1191 lnk_wdth = PCIE_LNK_X2;
1194 lnk_wdth = PCIE_LNK_X4;
1197 lnk_wdth = PCIE_LNK_X8;
1200 lnk_wdth = PCIE_LNK_X12;
1203 lnk_wdth = PCIE_LNK_X16;
1206 lnk_wdth = PCIE_LNK_X32;
1209 lnk_wdth = PCIE_LNK_WIDTH_UNKNOWN;
1214 dbg("Current link width = %d\n", lnk_wdth);
1219 static struct hpc_ops pciehp_hpc_ops = {
1220 .power_on_slot = hpc_power_on_slot,
1221 .power_off_slot = hpc_power_off_slot,
1222 .set_attention_status = hpc_set_attention_status,
1223 .get_power_status = hpc_get_power_status,
1224 .get_attention_status = hpc_get_attention_status,
1225 .get_latch_status = hpc_get_latch_status,
1226 .get_adapter_status = hpc_get_adapter_status,
1228 .get_max_bus_speed = hpc_get_max_lnk_speed,
1229 .get_cur_bus_speed = hpc_get_cur_lnk_speed,
1230 .get_max_lnk_width = hpc_get_max_lnk_width,
1231 .get_cur_lnk_width = hpc_get_cur_lnk_width,
1233 .query_power_fault = hpc_query_power_fault,
1234 .green_led_on = hpc_set_green_led_on,
1235 .green_led_off = hpc_set_green_led_off,
1236 .green_led_blink = hpc_set_green_led_blink,
1238 .release_ctlr = hpc_release_ctlr,
1239 .check_lnk_status = hpc_check_lnk_status,
1243 int pciehp_acpi_get_hp_hw_control_from_firmware(struct pci_dev *dev)
1246 acpi_handle chandle, handle = DEVICE_ACPI_HANDLE(&(dev->dev));
1247 struct pci_dev *pdev = dev;
1248 struct pci_bus *parent;
1249 struct acpi_buffer string = { ACPI_ALLOCATE_BUFFER, NULL };
1252 * Per PCI firmware specification, we should run the ACPI _OSC
1253 * method to get control of hotplug hardware before using it.
1254 * If an _OSC is missing, we look for an OSHP to do the same thing.
1255 * To handle different BIOS behavior, we look for _OSC and OSHP
1256 * within the scope of the hotplug controller and its parents, upto
1257 * the host bridge under which this controller exists.
1261 * This hotplug controller was not listed in the ACPI name
1262 * space at all. Try to get acpi handle of parent pci bus.
1264 if (!pdev || !pdev->bus->parent)
1266 parent = pdev->bus->parent;
1267 dbg("Could not find %s in acpi namespace, trying parent\n",
1270 /* Parent must be a host bridge */
1271 handle = acpi_get_pci_rootbridge_handle(
1272 pci_domain_nr(parent),
1275 handle = DEVICE_ACPI_HANDLE(
1276 &(parent->self->dev));
1277 pdev = parent->self;
1281 acpi_get_name(handle, ACPI_FULL_PATHNAME, &string);
1282 dbg("Trying to get hotplug control for %s \n",
1283 (char *)string.pointer);
1284 status = pci_osc_control_set(handle,
1285 OSC_PCI_EXPRESS_NATIVE_HP_CONTROL);
1286 if (status == AE_NOT_FOUND)
1287 status = acpi_run_oshp(handle);
1288 if (ACPI_SUCCESS(status)) {
1289 dbg("Gained control for hotplug HW for pci %s (%s)\n",
1290 pci_name(dev), (char *)string.pointer);
1291 kfree(string.pointer);
1294 if (acpi_root_bridge(handle))
1297 status = acpi_get_parent(chandle, &handle);
1298 if (ACPI_FAILURE(status))
1302 err("Cannot get control of hotplug hardware for pci %s\n",
1305 kfree(string.pointer);
1312 int pcie_init(struct controller * ctrl, struct pcie_device *dev)
1314 struct php_ctlr_state_s *php_ctlr, *p;
1315 void *instance_id = ctrl;
1317 static int first = 1;
1320 u16 intr_enable = 0;
1322 int cap_base, saved_cap_base;
1323 u16 slot_status, slot_ctrl;
1324 struct pci_dev *pdev;
1328 spin_lock_init(&list_lock);
1329 php_ctlr = (struct php_ctlr_state_s *) kmalloc(sizeof(struct php_ctlr_state_s), GFP_KERNEL);
1331 if (!php_ctlr) { /* allocate controller state data */
1332 err("%s: HPC controller memory allocation error!\n", __FUNCTION__);
1336 memset(php_ctlr, 0, sizeof(struct php_ctlr_state_s));
1339 php_ctlr->pci_dev = pdev; /* save pci_dev in context */
1341 dbg("%s: hotplug controller vendor id 0x%x device id 0x%x\n",
1342 __FUNCTION__, pdev->vendor, pdev->device);
1344 saved_cap_base = pcie_cap_base;
1346 if ((cap_base = pci_find_capability(pdev, PCI_CAP_ID_EXP)) == 0) {
1347 dbg("%s: Can't find PCI_CAP_ID_EXP (0x10)\n", __FUNCTION__);
1348 goto abort_free_ctlr;
1351 ctrl->cap_base = cap_base;
1353 dbg("%s: pcie_cap_base %x\n", __FUNCTION__, pcie_cap_base);
1355 rc = hp_register_read_word(pdev, CAP_REG(ctrl->cap_base), cap_reg);
1357 err("%s : hp_register_read_word CAP_REG failed\n", __FUNCTION__);
1358 goto abort_free_ctlr;
1360 dbg("%s: CAP_REG offset %x cap_reg %x\n", __FUNCTION__, CAP_REG(ctrl->cap_base), cap_reg);
1362 if (((cap_reg & SLOT_IMPL) == 0) || (((cap_reg & DEV_PORT_TYPE) != 0x0040)
1363 && ((cap_reg & DEV_PORT_TYPE) != 0x0060))) {
1364 dbg("%s : This is not a root port or the port is not connected to a slot\n", __FUNCTION__);
1365 goto abort_free_ctlr;
1368 rc = hp_register_read_dword(php_ctlr->pci_dev, SLOT_CAP(ctrl->cap_base), slot_cap);
1370 err("%s : hp_register_read_word CAP_REG failed\n", __FUNCTION__);
1371 goto abort_free_ctlr;
1373 dbg("%s: SLOT_CAP offset %x slot_cap %x\n", __FUNCTION__, SLOT_CAP(ctrl->cap_base), slot_cap);
1375 if (!(slot_cap & HP_CAP)) {
1376 dbg("%s : This slot is not hot-plug capable\n", __FUNCTION__);
1377 goto abort_free_ctlr;
1379 /* For debugging purpose */
1380 rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS(ctrl->cap_base), slot_status);
1382 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__);
1383 goto abort_free_ctlr;
1385 dbg("%s: SLOT_STATUS offset %x slot_status %x\n", __FUNCTION__, SLOT_STATUS(ctrl->cap_base), slot_status);
1387 rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL(ctrl->cap_base), slot_ctrl);
1389 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__);
1390 goto abort_free_ctlr;
1392 dbg("%s: SLOT_CTRL offset %x slot_ctrl %x\n", __FUNCTION__, SLOT_CTRL(ctrl->cap_base), slot_ctrl);
1395 spin_lock_init(&hpc_event_lock);
1399 for ( rc = 0; rc < DEVICE_COUNT_RESOURCE; rc++)
1400 if (pci_resource_len(pdev, rc) > 0)
1401 dbg("pci resource[%d] start=0x%llx(len=0x%llx)\n", rc,
1402 (unsigned long long)pci_resource_start(pdev, rc),
1403 (unsigned long long)pci_resource_len(pdev, rc));
1405 info("HPC vendor_id %x device_id %x ss_vid %x ss_did %x\n", pdev->vendor, pdev->device,
1406 pdev->subsystem_vendor, pdev->subsystem_device);
1408 mutex_init(&ctrl->crit_sect);
1409 /* setup wait queue */
1410 init_waitqueue_head(&ctrl->queue);
1413 php_ctlr->irq = dev->irq;
1415 /* Save interrupt callback info */
1416 php_ctlr->attention_button_callback = pciehp_handle_attention_button;
1417 php_ctlr->switch_change_callback = pciehp_handle_switch_change;
1418 php_ctlr->presence_change_callback = pciehp_handle_presence_change;
1419 php_ctlr->power_fault_callback = pciehp_handle_power_fault;
1420 php_ctlr->callback_instance_id = instance_id;
1422 /* return PCI Controller Info */
1423 php_ctlr->slot_device_offset = 0;
1424 php_ctlr->num_slots = 1;
1426 /* Mask Hot-plug Interrupt Enable */
1427 rc = hp_register_read_word(pdev, SLOT_CTRL(ctrl->cap_base), temp_word);
1429 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__);
1430 goto abort_free_ctlr;
1433 dbg("%s: SLOT_CTRL %x value read %x\n", __FUNCTION__, SLOT_CTRL(ctrl->cap_base), temp_word);
1434 temp_word = (temp_word & ~HP_INTR_ENABLE & ~CMD_CMPL_INTR_ENABLE) | 0x00;
1436 rc = hp_register_write_word(pdev, SLOT_CTRL(ctrl->cap_base), temp_word);
1438 err("%s : hp_register_write_word SLOT_CTRL failed\n", __FUNCTION__);
1439 goto abort_free_ctlr;
1442 rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS(ctrl->cap_base), slot_status);
1444 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__);
1445 goto abort_free_ctlr;
1448 temp_word = 0x1F; /* Clear all events */
1449 rc = hp_register_write_word(php_ctlr->pci_dev, SLOT_STATUS(ctrl->cap_base), temp_word);
1451 err("%s : hp_register_write_word SLOT_STATUS failed\n", __FUNCTION__);
1452 goto abort_free_ctlr;
1455 if (pciehp_poll_mode) {/* Install interrupt polling code */
1456 /* Install and start the interrupt polling timer */
1457 init_timer(&php_ctlr->int_poll_timer);
1458 start_int_poll_timer( php_ctlr, 10 ); /* start with 10 second delay */
1460 /* Installs the interrupt handler */
1461 rc = request_irq(php_ctlr->irq, pcie_isr, IRQF_SHARED, MY_NAME, (void *) ctrl);
1462 dbg("%s: request_irq %d for hpc%d (returns %d)\n", __FUNCTION__, php_ctlr->irq, ctlr_seq_num, rc);
1464 err("Can't get irq %d for the hotplug controller\n", php_ctlr->irq);
1465 goto abort_free_ctlr;
1469 dbg("pciehp ctrl b:d:f:irq=0x%x:%x:%x:%x\n", pdev->bus->number,
1470 PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn), dev->irq);
1472 rc = hp_register_read_word(pdev, SLOT_CTRL(ctrl->cap_base), temp_word);
1474 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__);
1475 goto abort_free_irq;
1478 intr_enable = intr_enable | PRSN_DETECT_ENABLE;
1480 if (ATTN_BUTTN(slot_cap))
1481 intr_enable = intr_enable | ATTN_BUTTN_ENABLE;
1483 if (POWER_CTRL(slot_cap))
1484 intr_enable = intr_enable | PWR_FAULT_DETECT_ENABLE;
1486 if (MRL_SENS(slot_cap))
1487 intr_enable = intr_enable | MRL_DETECT_ENABLE;
1489 temp_word = (temp_word & ~intr_enable) | intr_enable;
1491 if (pciehp_poll_mode) {
1492 temp_word = (temp_word & ~HP_INTR_ENABLE) | 0x0;
1494 temp_word = (temp_word & ~HP_INTR_ENABLE) | HP_INTR_ENABLE;
1497 /* Unmask Hot-plug Interrupt Enable for the interrupt notification mechanism case */
1498 rc = hp_register_write_word(pdev, SLOT_CTRL(ctrl->cap_base), temp_word);
1500 err("%s : hp_register_write_word SLOT_CTRL failed\n", __FUNCTION__);
1501 goto abort_free_irq;
1503 rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS(ctrl->cap_base), slot_status);
1505 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__);
1506 goto abort_disable_intr;
1509 temp_word = 0x1F; /* Clear all events */
1510 rc = hp_register_write_word(php_ctlr->pci_dev, SLOT_STATUS(ctrl->cap_base), temp_word);
1512 err("%s : hp_register_write_word SLOT_STATUS failed\n", __FUNCTION__);
1513 goto abort_disable_intr;
1517 dbg("Bypassing BIOS check for pciehp use on %s\n",
1518 pci_name(ctrl->pci_dev));
1520 rc = pciehp_get_hp_hw_control_from_firmware(ctrl->pci_dev);
1522 goto abort_disable_intr;
1525 /* Add this HPC instance into the HPC list */
1526 spin_lock(&list_lock);
1527 if (php_ctlr_list_head == 0) {
1528 php_ctlr_list_head = php_ctlr;
1529 p = php_ctlr_list_head;
1532 p = php_ctlr_list_head;
1537 p->pnext = php_ctlr;
1539 spin_unlock(&list_lock);
1542 ctrl->hpc_ctlr_handle = php_ctlr;
1543 ctrl->hpc_ops = &pciehp_hpc_ops;
1548 /* We end up here for the many possible ways to fail this API. */
1550 rc = hp_register_read_word(pdev, SLOT_CTRL(ctrl->cap_base), temp_word);
1552 temp_word &= ~(intr_enable | HP_INTR_ENABLE);
1553 rc = hp_register_write_word(pdev, SLOT_CTRL(ctrl->cap_base), temp_word);
1556 err("%s : disabling interrupts failed\n", __FUNCTION__);
1559 if (pciehp_poll_mode)
1560 del_timer_sync(&php_ctlr->int_poll_timer);
1562 free_irq(php_ctlr->irq, ctrl);
1565 pcie_cap_base = saved_cap_base;