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>
43 #define DBG_K_TRACE_ENTRY ((unsigned int)0x00000001) /* On function entry */
44 #define DBG_K_TRACE_EXIT ((unsigned int)0x00000002) /* On function exit */
45 #define DBG_K_INFO ((unsigned int)0x00000004) /* Info messages */
46 #define DBG_K_ERROR ((unsigned int)0x00000008) /* Error messages */
47 #define DBG_K_TRACE (DBG_K_TRACE_ENTRY|DBG_K_TRACE_EXIT)
48 #define DBG_K_STANDARD (DBG_K_INFO|DBG_K_ERROR|DBG_K_TRACE)
49 /* Redefine this flagword to set debug level */
50 #define DEBUG_LEVEL DBG_K_STANDARD
52 #define DEFINE_DBG_BUFFER char __dbg_str_buf[256];
54 #define DBG_PRINT( dbg_flags, args... ) \
56 if ( DEBUG_LEVEL & ( dbg_flags ) ) \
59 len = sprintf( __dbg_str_buf, "%s:%d: %s: ", \
60 __FILE__, __LINE__, __FUNCTION__ ); \
61 sprintf( __dbg_str_buf + len, args ); \
62 printk( KERN_NOTICE "%s\n", __dbg_str_buf ); \
66 #define DBG_ENTER_ROUTINE DBG_PRINT (DBG_K_TRACE_ENTRY, "%s", "[Entry]");
67 #define DBG_LEAVE_ROUTINE DBG_PRINT (DBG_K_TRACE_EXIT, "%s", "[Exit]");
69 #define DEFINE_DBG_BUFFER
70 #define DBG_ENTER_ROUTINE
71 #define DBG_LEAVE_ROUTINE
90 } __attribute__ ((packed
));
92 /* offsets to the controller registers based on the above structure layout */
94 PCIECAPID
= offsetof(struct ctrl_reg
, cap_id
),
95 NXTCAPPTR
= offsetof(struct ctrl_reg
, nxt_ptr
),
96 CAPREG
= offsetof(struct ctrl_reg
, cap_reg
),
97 DEVCAP
= offsetof(struct ctrl_reg
, dev_cap
),
98 DEVCTRL
= offsetof(struct ctrl_reg
, dev_ctrl
),
99 DEVSTATUS
= offsetof(struct ctrl_reg
, dev_status
),
100 LNKCAP
= offsetof(struct ctrl_reg
, lnk_cap
),
101 LNKCTRL
= offsetof(struct ctrl_reg
, lnk_ctrl
),
102 LNKSTATUS
= offsetof(struct ctrl_reg
, lnk_status
),
103 SLOTCAP
= offsetof(struct ctrl_reg
, slot_cap
),
104 SLOTCTRL
= offsetof(struct ctrl_reg
, slot_ctrl
),
105 SLOTSTATUS
= offsetof(struct ctrl_reg
, slot_status
),
106 ROOTCTRL
= offsetof(struct ctrl_reg
, root_ctrl
),
107 ROOTSTATUS
= offsetof(struct ctrl_reg
, root_status
),
109 static int pcie_cap_base
= 0; /* Base of the PCI Express capability item structure */
111 #define PCIE_CAP_ID(cb) ( cb + PCIECAPID )
112 #define NXT_CAP_PTR(cb) ( cb + NXTCAPPTR )
113 #define CAP_REG(cb) ( cb + CAPREG )
114 #define DEV_CAP(cb) ( cb + DEVCAP )
115 #define DEV_CTRL(cb) ( cb + DEVCTRL )
116 #define DEV_STATUS(cb) ( cb + DEVSTATUS )
117 #define LNK_CAP(cb) ( cb + LNKCAP )
118 #define LNK_CTRL(cb) ( cb + LNKCTRL )
119 #define LNK_STATUS(cb) ( cb + LNKSTATUS )
120 #define SLOT_CAP(cb) ( cb + SLOTCAP )
121 #define SLOT_CTRL(cb) ( cb + SLOTCTRL )
122 #define SLOT_STATUS(cb) ( cb + SLOTSTATUS )
123 #define ROOT_CTRL(cb) ( cb + ROOTCTRL )
124 #define ROOT_STATUS(cb) ( cb + ROOTSTATUS )
126 #define hp_register_read_word(pdev, reg , value) \
127 pci_read_config_word(pdev, reg, &value)
129 #define hp_register_read_dword(pdev, reg , value) \
130 pci_read_config_dword(pdev, reg, &value)
132 #define hp_register_write_word(pdev, reg , value) \
133 pci_write_config_word(pdev, reg, value)
135 #define hp_register_dwrite_word(pdev, reg , value) \
136 pci_write_config_dword(pdev, reg, value)
138 /* Field definitions in PCI Express Capabilities Register */
139 #define CAP_VER 0x000F
140 #define DEV_PORT_TYPE 0x00F0
141 #define SLOT_IMPL 0x0100
142 #define MSG_NUM 0x3E00
144 /* Device or Port Type */
145 #define NAT_ENDPT 0x00
146 #define LEG_ENDPT 0x01
147 #define ROOT_PORT 0x04
148 #define UP_STREAM 0x05
149 #define DN_STREAM 0x06
150 #define PCIE_PCI_BRDG 0x07
151 #define PCI_PCIE_BRDG 0x10
153 /* Field definitions in Device Capabilities Register */
154 #define DATTN_BUTTN_PRSN 0x1000
155 #define DATTN_LED_PRSN 0x2000
156 #define DPWR_LED_PRSN 0x4000
158 /* Field definitions in Link Capabilities Register */
159 #define MAX_LNK_SPEED 0x000F
160 #define MAX_LNK_WIDTH 0x03F0
162 /* Link Width Encoding */
171 /*Field definitions of Link Status Register */
172 #define LNK_SPEED 0x000F
173 #define NEG_LINK_WD 0x03F0
174 #define LNK_TRN_ERR 0x0400
175 #define LNK_TRN 0x0800
176 #define SLOT_CLK_CONF 0x1000
178 /* Field definitions in Slot Capabilities Register */
179 #define ATTN_BUTTN_PRSN 0x00000001
180 #define PWR_CTRL_PRSN 0x00000002
181 #define MRL_SENS_PRSN 0x00000004
182 #define ATTN_LED_PRSN 0x00000008
183 #define PWR_LED_PRSN 0x00000010
184 #define HP_SUPR_RM_SUP 0x00000020
185 #define HP_CAP 0x00000040
186 #define SLOT_PWR_VALUE 0x000003F8
187 #define SLOT_PWR_LIMIT 0x00000C00
188 #define PSN 0xFFF80000 /* PSN: Physical Slot Number */
190 /* Field definitions in Slot Control Register */
191 #define ATTN_BUTTN_ENABLE 0x0001
192 #define PWR_FAULT_DETECT_ENABLE 0x0002
193 #define MRL_DETECT_ENABLE 0x0004
194 #define PRSN_DETECT_ENABLE 0x0008
195 #define CMD_CMPL_INTR_ENABLE 0x0010
196 #define HP_INTR_ENABLE 0x0020
197 #define ATTN_LED_CTRL 0x00C0
198 #define PWR_LED_CTRL 0x0300
199 #define PWR_CTRL 0x0400
201 /* Attention indicator and Power indicator states */
203 #define LED_BLINK 0x10
206 /* Power Control Command */
208 #define POWER_OFF 0x0400
210 /* Field definitions in Slot Status Register */
211 #define ATTN_BUTTN_PRESSED 0x0001
212 #define PWR_FAULT_DETECTED 0x0002
213 #define MRL_SENS_CHANGED 0x0004
214 #define PRSN_DETECT_CHANGED 0x0008
215 #define CMD_COMPLETED 0x0010
216 #define MRL_STATE 0x0020
217 #define PRSN_STATE 0x0040
219 static spinlock_t hpc_event_lock
;
221 DEFINE_DBG_BUFFER
/* Debug string buffer for entire HPC defined here */
222 static struct php_ctlr_state_s
*php_ctlr_list_head
; /* HPC state linked list */
223 static int ctlr_seq_num
= 0; /* Controller sequence # */
224 static spinlock_t list_lock
;
226 static irqreturn_t
pcie_isr(int IRQ
, void *dev_id
, struct pt_regs
*regs
);
228 static void start_int_poll_timer(struct php_ctlr_state_s
*php_ctlr
, int seconds
);
230 /* This is the interrupt polling timeout function. */
231 static void int_poll_timeout(unsigned long lphp_ctlr
)
233 struct php_ctlr_state_s
*php_ctlr
= (struct php_ctlr_state_s
*)lphp_ctlr
;
238 err("%s: Invalid HPC controller handle!\n", __FUNCTION__
);
242 /* Poll for interrupt events. regs == NULL => polling */
243 pcie_isr( 0, (void *)php_ctlr
, NULL
);
245 init_timer(&php_ctlr
->int_poll_timer
);
247 if (!pciehp_poll_time
)
248 pciehp_poll_time
= 2; /* reset timer to poll in 2 secs if user doesn't specify at module installation*/
250 start_int_poll_timer(php_ctlr
, pciehp_poll_time
);
255 /* This function starts the interrupt polling timer. */
256 static void start_int_poll_timer(struct php_ctlr_state_s
*php_ctlr
, int seconds
)
259 err("%s: Invalid HPC controller handle!\n", __FUNCTION__
);
263 if ( ( seconds
<= 0 ) || ( seconds
> 60 ) )
264 seconds
= 2; /* Clamp to sane value */
266 php_ctlr
->int_poll_timer
.function
= &int_poll_timeout
;
267 php_ctlr
->int_poll_timer
.data
= (unsigned long)php_ctlr
; /* Instance data */
268 php_ctlr
->int_poll_timer
.expires
= jiffies
+ seconds
* HZ
;
269 add_timer(&php_ctlr
->int_poll_timer
);
274 static int pcie_write_cmd(struct slot
*slot
, u16 cmd
)
276 struct php_ctlr_state_s
*php_ctlr
= slot
->ctrl
->hpc_ctlr_handle
;
283 err("%s: Invalid HPC controller handle!\n", __FUNCTION__
);
287 retval
= hp_register_read_word(php_ctlr
->pci_dev
, SLOT_STATUS(slot
->ctrl
->cap_base
), slot_status
);
289 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__
);
293 if ((slot_status
& CMD_COMPLETED
) == CMD_COMPLETED
) {
294 /* After 1 sec and CMD_COMPLETED still not set, just proceed forward to issue
295 the next command according to spec. Just print out the error message */
296 dbg("%s : CMD_COMPLETED not clear after 1 sec.\n", __FUNCTION__
);
299 retval
= hp_register_write_word(php_ctlr
->pci_dev
, SLOT_CTRL(slot
->ctrl
->cap_base
), cmd
| CMD_CMPL_INTR_ENABLE
);
301 err("%s : hp_register_write_word SLOT_CTRL failed\n", __FUNCTION__
);
309 static int hpc_check_lnk_status(struct controller
*ctrl
)
311 struct php_ctlr_state_s
*php_ctlr
= ctrl
->hpc_ctlr_handle
;
318 err("%s: Invalid HPC controller handle!\n", __FUNCTION__
);
322 retval
= hp_register_read_word(php_ctlr
->pci_dev
, LNK_STATUS(ctrl
->cap_base
), lnk_status
);
325 err("%s : hp_register_read_word LNK_STATUS failed\n", __FUNCTION__
);
329 dbg("%s: lnk_status = %x\n", __FUNCTION__
, lnk_status
);
330 if ( (lnk_status
& LNK_TRN
) || (lnk_status
& LNK_TRN_ERR
) ||
331 !(lnk_status
& NEG_LINK_WD
)) {
332 err("%s : Link Training Error occurs \n", __FUNCTION__
);
342 static int hpc_get_attention_status(struct slot
*slot
, u8
*status
)
344 struct php_ctlr_state_s
*php_ctlr
= slot
->ctrl
->hpc_ctlr_handle
;
352 err("%s: Invalid HPC controller handle!\n", __FUNCTION__
);
356 retval
= hp_register_read_word(php_ctlr
->pci_dev
, SLOT_CTRL(slot
->ctrl
->cap_base
), slot_ctrl
);
359 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__
);
363 dbg("%s: SLOT_CTRL %x, value read %x\n", __FUNCTION__
,SLOT_CTRL(slot
->ctrl
->cap_base
), slot_ctrl
);
365 atten_led_state
= (slot_ctrl
& ATTN_LED_CTRL
) >> 6;
367 switch (atten_led_state
) {
369 *status
= 0xFF; /* Reserved */
372 *status
= 1; /* On */
375 *status
= 2; /* Blink */
378 *status
= 0; /* Off */
389 static int hpc_get_power_status(struct slot
* slot
, u8
*status
)
391 struct php_ctlr_state_s
*php_ctlr
= slot
->ctrl
->hpc_ctlr_handle
;
399 err("%s: Invalid HPC controller handle!\n", __FUNCTION__
);
403 retval
= hp_register_read_word(php_ctlr
->pci_dev
, SLOT_CTRL(slot
->ctrl
->cap_base
), slot_ctrl
);
406 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__
);
409 dbg("%s: SLOT_CTRL %x value read %x\n", __FUNCTION__
, SLOT_CTRL(slot
->ctrl
->cap_base
), slot_ctrl
);
411 pwr_state
= (slot_ctrl
& PWR_CTRL
) >> 10;
430 static int hpc_get_latch_status(struct slot
*slot
, u8
*status
)
432 struct php_ctlr_state_s
*php_ctlr
= slot
->ctrl
->hpc_ctlr_handle
;
439 err("%s: Invalid HPC controller handle!\n", __FUNCTION__
);
443 retval
= hp_register_read_word(php_ctlr
->pci_dev
, SLOT_STATUS(slot
->ctrl
->cap_base
), slot_status
);
446 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__
);
450 *status
= (((slot_status
& MRL_STATE
) >> 5) == 0) ? 0 : 1;
456 static int hpc_get_adapter_status(struct slot
*slot
, u8
*status
)
458 struct php_ctlr_state_s
*php_ctlr
= slot
->ctrl
->hpc_ctlr_handle
;
466 err("%s: Invalid HPC controller handle!\n", __FUNCTION__
);
470 retval
= hp_register_read_word(php_ctlr
->pci_dev
, SLOT_STATUS(slot
->ctrl
->cap_base
), slot_status
);
473 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__
);
476 card_state
= (u8
)((slot_status
& PRSN_STATE
) >> 6);
477 *status
= (card_state
== 1) ? 1 : 0;
483 static int hpc_query_power_fault(struct slot
* slot
)
485 struct php_ctlr_state_s
*php_ctlr
= slot
->ctrl
->hpc_ctlr_handle
;
493 err("%s: Invalid HPC controller handle!\n", __FUNCTION__
);
497 retval
= hp_register_read_word(php_ctlr
->pci_dev
, SLOT_STATUS(slot
->ctrl
->cap_base
), slot_status
);
500 err("%s : Cannot check for power fault\n", __FUNCTION__
);
503 pwr_fault
= (u8
)((slot_status
& PWR_FAULT_DETECTED
) >> 1);
509 static int hpc_set_attention_status(struct slot
*slot
, u8 value
)
511 struct php_ctlr_state_s
*php_ctlr
= slot
->ctrl
->hpc_ctlr_handle
;
519 err("%s: Invalid HPC controller handle!\n", __FUNCTION__
);
523 if (slot
->hp_slot
>= php_ctlr
->num_slots
) {
524 err("%s: Invalid HPC slot number!\n", __FUNCTION__
);
527 rc
= hp_register_read_word(php_ctlr
->pci_dev
, SLOT_CTRL(slot
->ctrl
->cap_base
), slot_ctrl
);
530 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__
);
535 case 0 : /* turn off */
536 slot_cmd
= (slot_ctrl
& ~ATTN_LED_CTRL
) | 0x00C0;
538 case 1: /* turn on */
539 slot_cmd
= (slot_ctrl
& ~ATTN_LED_CTRL
) | 0x0040;
541 case 2: /* turn blink */
542 slot_cmd
= (slot_ctrl
& ~ATTN_LED_CTRL
) | 0x0080;
547 if (!pciehp_poll_mode
)
548 slot_cmd
= slot_cmd
| HP_INTR_ENABLE
;
550 pcie_write_cmd(slot
, slot_cmd
);
551 dbg("%s: SLOT_CTRL %x write cmd %x\n", __FUNCTION__
, SLOT_CTRL(slot
->ctrl
->cap_base
), slot_cmd
);
558 static void hpc_set_green_led_on(struct slot
*slot
)
560 struct php_ctlr_state_s
*php_ctlr
= slot
->ctrl
->hpc_ctlr_handle
;
568 err("%s: Invalid HPC controller handle!\n", __FUNCTION__
);
572 if (slot
->hp_slot
>= php_ctlr
->num_slots
) {
573 err("%s: Invalid HPC slot number!\n", __FUNCTION__
);
577 rc
= hp_register_read_word(php_ctlr
->pci_dev
, SLOT_CTRL(slot
->ctrl
->cap_base
), slot_ctrl
);
580 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__
);
583 slot_cmd
= (slot_ctrl
& ~PWR_LED_CTRL
) | 0x0100;
584 if (!pciehp_poll_mode
)
585 slot_cmd
= slot_cmd
| HP_INTR_ENABLE
;
587 pcie_write_cmd(slot
, slot_cmd
);
589 dbg("%s: SLOT_CTRL %x write cmd %x\n",__FUNCTION__
, SLOT_CTRL(slot
->ctrl
->cap_base
), slot_cmd
);
594 static void hpc_set_green_led_off(struct slot
*slot
)
596 struct php_ctlr_state_s
*php_ctlr
= slot
->ctrl
->hpc_ctlr_handle
;
604 err("%s: Invalid HPC controller handle!\n", __FUNCTION__
);
608 if (slot
->hp_slot
>= php_ctlr
->num_slots
) {
609 err("%s: Invalid HPC slot number!\n", __FUNCTION__
);
613 rc
= hp_register_read_word(php_ctlr
->pci_dev
, SLOT_CTRL(slot
->ctrl
->cap_base
), slot_ctrl
);
616 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__
);
620 slot_cmd
= (slot_ctrl
& ~PWR_LED_CTRL
) | 0x0300;
622 if (!pciehp_poll_mode
)
623 slot_cmd
= slot_cmd
| HP_INTR_ENABLE
;
624 pcie_write_cmd(slot
, slot_cmd
);
625 dbg("%s: SLOT_CTRL %x write cmd %x\n", __FUNCTION__
, SLOT_CTRL(slot
->ctrl
->cap_base
), slot_cmd
);
631 static void hpc_set_green_led_blink(struct slot
*slot
)
633 struct php_ctlr_state_s
*php_ctlr
= slot
->ctrl
->hpc_ctlr_handle
;
641 err("%s: Invalid HPC controller handle!\n", __FUNCTION__
);
645 if (slot
->hp_slot
>= php_ctlr
->num_slots
) {
646 err("%s: Invalid HPC slot number!\n", __FUNCTION__
);
650 rc
= hp_register_read_word(php_ctlr
->pci_dev
, SLOT_CTRL(slot
->ctrl
->cap_base
), slot_ctrl
);
653 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__
);
657 slot_cmd
= (slot_ctrl
& ~PWR_LED_CTRL
) | 0x0200;
659 if (!pciehp_poll_mode
)
660 slot_cmd
= slot_cmd
| HP_INTR_ENABLE
;
661 pcie_write_cmd(slot
, slot_cmd
);
663 dbg("%s: SLOT_CTRL %x write cmd %x\n",__FUNCTION__
, SLOT_CTRL(slot
->ctrl
->cap_base
), slot_cmd
);
668 int pcie_get_ctlr_slot_config(struct controller
*ctrl
,
669 int *num_ctlr_slots
, /* number of slots in this HPC; only 1 in PCIE */
670 int *first_device_num
, /* PCI dev num of the first slot in this PCIE */
671 int *physical_slot_num
, /* phy slot num of the first slot in this PCIE */
674 struct php_ctlr_state_s
*php_ctlr
= ctrl
->hpc_ctlr_handle
;
681 err("%s: Invalid HPC controller handle!\n", __FUNCTION__
);
685 *first_device_num
= 0;
688 rc
= hp_register_read_dword(php_ctlr
->pci_dev
, SLOT_CAP(ctrl
->cap_base
), slot_cap
);
691 err("%s : hp_register_read_dword SLOT_CAP failed\n", __FUNCTION__
);
695 *physical_slot_num
= slot_cap
>> 19;
696 dbg("%s: PSN %d \n", __FUNCTION__
, *physical_slot_num
);
698 *ctrlcap
= slot_cap
& 0x0000007f;
704 static void hpc_release_ctlr(struct controller
*ctrl
)
706 struct php_ctlr_state_s
*php_ctlr
= ctrl
->hpc_ctlr_handle
;
707 struct php_ctlr_state_s
*p
, *p_prev
;
712 err("%s: Invalid HPC controller handle!\n", __FUNCTION__
);
716 if (pciehp_poll_mode
) {
717 del_timer(&php_ctlr
->int_poll_timer
);
720 free_irq(php_ctlr
->irq
, ctrl
);
723 pci_disable_msi(php_ctlr
->pci_dev
);
726 if (php_ctlr
->pci_dev
)
727 php_ctlr
->pci_dev
= NULL
;
729 spin_lock(&list_lock
);
730 p
= php_ctlr_list_head
;
735 p_prev
->pnext
= p
->pnext
;
737 php_ctlr_list_head
= p
->pnext
;
744 spin_unlock(&list_lock
);
752 static int hpc_power_on_slot(struct slot
* slot
)
754 struct php_ctlr_state_s
*php_ctlr
= slot
->ctrl
->hpc_ctlr_handle
;
756 u16 slot_ctrl
, slot_status
;
763 err("%s: Invalid HPC controller handle!\n", __FUNCTION__
);
767 dbg("%s: slot->hp_slot %x\n", __FUNCTION__
, slot
->hp_slot
);
768 if (slot
->hp_slot
>= php_ctlr
->num_slots
) {
769 err("%s: Invalid HPC slot number!\n", __FUNCTION__
);
773 /* Clear sticky power-fault bit from previous power failures */
774 hp_register_read_word(php_ctlr
->pci_dev
,
775 SLOT_STATUS(slot
->ctrl
->cap_base
), slot_status
);
776 slot_status
&= PWR_FAULT_DETECTED
;
778 hp_register_write_word(php_ctlr
->pci_dev
,
779 SLOT_STATUS(slot
->ctrl
->cap_base
), slot_status
);
781 retval
= hp_register_read_word(php_ctlr
->pci_dev
, SLOT_CTRL(slot
->ctrl
->cap_base
), slot_ctrl
);
784 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__
);
788 slot_cmd
= (slot_ctrl
& ~PWR_CTRL
) | POWER_ON
;
790 if (!pciehp_poll_mode
)
791 slot_cmd
= slot_cmd
| HP_INTR_ENABLE
;
793 retval
= pcie_write_cmd(slot
, slot_cmd
);
796 err("%s: Write %x command failed!\n", __FUNCTION__
, slot_cmd
);
799 dbg("%s: SLOT_CTRL %x write cmd %x\n",__FUNCTION__
, SLOT_CTRL(slot
->ctrl
->cap_base
), slot_cmd
);
806 static int hpc_power_off_slot(struct slot
* slot
)
808 struct php_ctlr_state_s
*php_ctlr
= slot
->ctrl
->hpc_ctlr_handle
;
817 err("%s: Invalid HPC controller handle!\n", __FUNCTION__
);
821 dbg("%s: slot->hp_slot %x\n", __FUNCTION__
, slot
->hp_slot
);
823 if (slot
->hp_slot
>= php_ctlr
->num_slots
) {
824 err("%s: Invalid HPC slot number!\n", __FUNCTION__
);
827 retval
= hp_register_read_word(php_ctlr
->pci_dev
, SLOT_CTRL(slot
->ctrl
->cap_base
), slot_ctrl
);
830 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__
);
834 slot_cmd
= (slot_ctrl
& ~PWR_CTRL
) | POWER_OFF
;
836 if (!pciehp_poll_mode
)
837 slot_cmd
= slot_cmd
| HP_INTR_ENABLE
;
839 retval
= pcie_write_cmd(slot
, slot_cmd
);
842 err("%s: Write command failed!\n", __FUNCTION__
);
845 dbg("%s: SLOT_CTRL %x write cmd %x\n",__FUNCTION__
, SLOT_CTRL(slot
->ctrl
->cap_base
), slot_cmd
);
852 static irqreturn_t
pcie_isr(int IRQ
, void *dev_id
, struct pt_regs
*regs
)
854 struct controller
*ctrl
= NULL
;
855 struct php_ctlr_state_s
*php_ctlr
;
856 u8 schedule_flag
= 0;
857 u16 slot_status
, intr_detect
, intr_loc
;
859 int hp_slot
= 0; /* only 1 slot per PCI Express port */
865 if (!pciehp_poll_mode
) {
867 php_ctlr
= ctrl
->hpc_ctlr_handle
;
870 ctrl
= (struct controller
*)php_ctlr
->callback_instance_id
;
874 dbg("%s: dev_id %p ctlr == NULL\n", __FUNCTION__
, (void*) dev_id
);
879 dbg("%s: php_ctlr == NULL\n", __FUNCTION__
);
883 rc
= hp_register_read_word(php_ctlr
->pci_dev
, SLOT_STATUS(ctrl
->cap_base
), slot_status
);
885 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__
);
889 intr_detect
= ( ATTN_BUTTN_PRESSED
| PWR_FAULT_DETECTED
| MRL_SENS_CHANGED
|
890 PRSN_DETECT_CHANGED
| CMD_COMPLETED
);
892 intr_loc
= slot_status
& intr_detect
;
894 /* Check to see if it was our interrupt */
898 dbg("%s: intr_loc %x\n", __FUNCTION__
, intr_loc
);
899 /* Mask Hot-plug Interrupt Enable */
900 if (!pciehp_poll_mode
) {
901 rc
= hp_register_read_word(php_ctlr
->pci_dev
, SLOT_CTRL(ctrl
->cap_base
), temp_word
);
903 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__
);
907 dbg("%s: hp_register_read_word SLOT_CTRL with value %x\n", __FUNCTION__
, temp_word
);
908 temp_word
= (temp_word
& ~HP_INTR_ENABLE
& ~CMD_CMPL_INTR_ENABLE
) | 0x00;
910 rc
= hp_register_write_word(php_ctlr
->pci_dev
, SLOT_CTRL(ctrl
->cap_base
), temp_word
);
912 err("%s : hp_register_write_word SLOT_CTRL failed\n", __FUNCTION__
);
916 rc
= hp_register_read_word(php_ctlr
->pci_dev
, SLOT_STATUS(ctrl
->cap_base
), slot_status
);
918 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__
);
921 dbg("%s: hp_register_read_word SLOT_STATUS with value %x\n", __FUNCTION__
, slot_status
);
923 /* Clear command complete interrupt caused by this write */
925 rc
= hp_register_write_word(php_ctlr
->pci_dev
, SLOT_STATUS(ctrl
->cap_base
), temp_word
);
927 err("%s : hp_register_write_word SLOT_STATUS failed\n", __FUNCTION__
);
932 if (intr_loc
& CMD_COMPLETED
) {
934 * Command Complete Interrupt Pending
936 wake_up_interruptible(&ctrl
->queue
);
939 if ((php_ctlr
->switch_change_callback
) && (intr_loc
& MRL_SENS_CHANGED
))
940 schedule_flag
+= php_ctlr
->switch_change_callback(
941 hp_slot
, php_ctlr
->callback_instance_id
);
942 if ((php_ctlr
->attention_button_callback
) && (intr_loc
& ATTN_BUTTN_PRESSED
))
943 schedule_flag
+= php_ctlr
->attention_button_callback(
944 hp_slot
, php_ctlr
->callback_instance_id
);
945 if ((php_ctlr
->presence_change_callback
) && (intr_loc
& PRSN_DETECT_CHANGED
))
946 schedule_flag
+= php_ctlr
->presence_change_callback(
947 hp_slot
, php_ctlr
->callback_instance_id
);
948 if ((php_ctlr
->power_fault_callback
) && (intr_loc
& PWR_FAULT_DETECTED
))
949 schedule_flag
+= php_ctlr
->power_fault_callback(
950 hp_slot
, php_ctlr
->callback_instance_id
);
952 /* Clear all events after serving them */
954 rc
= hp_register_write_word(php_ctlr
->pci_dev
, SLOT_STATUS(ctrl
->cap_base
), temp_word
);
956 err("%s : hp_register_write_word SLOT_STATUS failed\n", __FUNCTION__
);
959 /* Unmask Hot-plug Interrupt Enable */
960 if (!pciehp_poll_mode
) {
961 rc
= hp_register_read_word(php_ctlr
->pci_dev
, SLOT_CTRL(ctrl
->cap_base
), temp_word
);
963 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__
);
967 dbg("%s: Unmask Hot-plug Interrupt Enable\n", __FUNCTION__
);
968 temp_word
= (temp_word
& ~HP_INTR_ENABLE
) | HP_INTR_ENABLE
;
970 rc
= hp_register_write_word(php_ctlr
->pci_dev
, SLOT_CTRL(ctrl
->cap_base
), temp_word
);
972 err("%s : hp_register_write_word SLOT_CTRL failed\n", __FUNCTION__
);
976 rc
= hp_register_read_word(php_ctlr
->pci_dev
, SLOT_STATUS(ctrl
->cap_base
), slot_status
);
978 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__
);
982 /* Clear command complete interrupt caused by this write */
984 rc
= hp_register_write_word(php_ctlr
->pci_dev
, SLOT_STATUS(ctrl
->cap_base
), temp_word
);
986 err("%s : hp_register_write_word SLOT_STATUS failed\n", __FUNCTION__
);
989 dbg("%s: hp_register_write_word SLOT_STATUS with value %x\n", __FUNCTION__
, temp_word
);
995 static int hpc_get_max_lnk_speed (struct slot
*slot
, enum pci_bus_speed
*value
)
997 struct php_ctlr_state_s
*php_ctlr
= slot
->ctrl
->hpc_ctlr_handle
;
998 enum pcie_link_speed lnk_speed
;
1005 err("%s: Invalid HPC controller handle!\n", __FUNCTION__
);
1009 if (slot
->hp_slot
>= php_ctlr
->num_slots
) {
1010 err("%s: Invalid HPC slot number!\n", __FUNCTION__
);
1014 retval
= hp_register_read_dword(php_ctlr
->pci_dev
, LNK_CAP(slot
->ctrl
->cap_base
), lnk_cap
);
1017 err("%s : hp_register_read_dword LNK_CAP failed\n", __FUNCTION__
);
1021 switch (lnk_cap
& 0x000F) {
1023 lnk_speed
= PCIE_2PT5GB
;
1026 lnk_speed
= PCIE_LNK_SPEED_UNKNOWN
;
1031 dbg("Max link speed = %d\n", lnk_speed
);
1036 static int hpc_get_max_lnk_width (struct slot
*slot
, enum pcie_link_width
*value
)
1038 struct php_ctlr_state_s
*php_ctlr
= slot
->ctrl
->hpc_ctlr_handle
;
1039 enum pcie_link_width lnk_wdth
;
1046 err("%s: Invalid HPC controller handle!\n", __FUNCTION__
);
1050 if (slot
->hp_slot
>= php_ctlr
->num_slots
) {
1051 err("%s: Invalid HPC slot number!\n", __FUNCTION__
);
1055 retval
= hp_register_read_dword(php_ctlr
->pci_dev
, LNK_CAP(slot
->ctrl
->cap_base
), lnk_cap
);
1058 err("%s : hp_register_read_dword LNK_CAP failed\n", __FUNCTION__
);
1062 switch ((lnk_cap
& 0x03F0) >> 4){
1064 lnk_wdth
= PCIE_LNK_WIDTH_RESRV
;
1067 lnk_wdth
= PCIE_LNK_X1
;
1070 lnk_wdth
= PCIE_LNK_X2
;
1073 lnk_wdth
= PCIE_LNK_X4
;
1076 lnk_wdth
= PCIE_LNK_X8
;
1079 lnk_wdth
= PCIE_LNK_X12
;
1082 lnk_wdth
= PCIE_LNK_X16
;
1085 lnk_wdth
= PCIE_LNK_X32
;
1088 lnk_wdth
= PCIE_LNK_WIDTH_UNKNOWN
;
1093 dbg("Max link width = %d\n", lnk_wdth
);
1098 static int hpc_get_cur_lnk_speed (struct slot
*slot
, enum pci_bus_speed
*value
)
1100 struct php_ctlr_state_s
*php_ctlr
= slot
->ctrl
->hpc_ctlr_handle
;
1101 enum pcie_link_speed lnk_speed
= PCI_SPEED_UNKNOWN
;
1108 err("%s: Invalid HPC controller handle!\n", __FUNCTION__
);
1112 if (slot
->hp_slot
>= php_ctlr
->num_slots
) {
1113 err("%s: Invalid HPC slot number!\n", __FUNCTION__
);
1117 retval
= hp_register_read_word(php_ctlr
->pci_dev
, LNK_STATUS(slot
->ctrl
->cap_base
), lnk_status
);
1120 err("%s : hp_register_read_word LNK_STATUS failed\n", __FUNCTION__
);
1124 switch (lnk_status
& 0x0F) {
1126 lnk_speed
= PCIE_2PT5GB
;
1129 lnk_speed
= PCIE_LNK_SPEED_UNKNOWN
;
1134 dbg("Current link speed = %d\n", lnk_speed
);
1139 static int hpc_get_cur_lnk_width (struct slot
*slot
, enum pcie_link_width
*value
)
1141 struct php_ctlr_state_s
*php_ctlr
= slot
->ctrl
->hpc_ctlr_handle
;
1142 enum pcie_link_width lnk_wdth
= PCIE_LNK_WIDTH_UNKNOWN
;
1149 err("%s: Invalid HPC controller handle!\n", __FUNCTION__
);
1153 if (slot
->hp_slot
>= php_ctlr
->num_slots
) {
1154 err("%s: Invalid HPC slot number!\n", __FUNCTION__
);
1158 retval
= hp_register_read_word(php_ctlr
->pci_dev
, LNK_STATUS(slot
->ctrl
->cap_base
), lnk_status
);
1161 err("%s : hp_register_read_word LNK_STATUS failed\n", __FUNCTION__
);
1165 switch ((lnk_status
& 0x03F0) >> 4){
1167 lnk_wdth
= PCIE_LNK_WIDTH_RESRV
;
1170 lnk_wdth
= PCIE_LNK_X1
;
1173 lnk_wdth
= PCIE_LNK_X2
;
1176 lnk_wdth
= PCIE_LNK_X4
;
1179 lnk_wdth
= PCIE_LNK_X8
;
1182 lnk_wdth
= PCIE_LNK_X12
;
1185 lnk_wdth
= PCIE_LNK_X16
;
1188 lnk_wdth
= PCIE_LNK_X32
;
1191 lnk_wdth
= PCIE_LNK_WIDTH_UNKNOWN
;
1196 dbg("Current link width = %d\n", lnk_wdth
);
1201 static struct hpc_ops pciehp_hpc_ops
= {
1202 .power_on_slot
= hpc_power_on_slot
,
1203 .power_off_slot
= hpc_power_off_slot
,
1204 .set_attention_status
= hpc_set_attention_status
,
1205 .get_power_status
= hpc_get_power_status
,
1206 .get_attention_status
= hpc_get_attention_status
,
1207 .get_latch_status
= hpc_get_latch_status
,
1208 .get_adapter_status
= hpc_get_adapter_status
,
1210 .get_max_bus_speed
= hpc_get_max_lnk_speed
,
1211 .get_cur_bus_speed
= hpc_get_cur_lnk_speed
,
1212 .get_max_lnk_width
= hpc_get_max_lnk_width
,
1213 .get_cur_lnk_width
= hpc_get_cur_lnk_width
,
1215 .query_power_fault
= hpc_query_power_fault
,
1216 .green_led_on
= hpc_set_green_led_on
,
1217 .green_led_off
= hpc_set_green_led_off
,
1218 .green_led_blink
= hpc_set_green_led_blink
,
1220 .release_ctlr
= hpc_release_ctlr
,
1221 .check_lnk_status
= hpc_check_lnk_status
,
1224 int pcie_init(struct controller
* ctrl
, struct pcie_device
*dev
)
1226 struct php_ctlr_state_s
*php_ctlr
, *p
;
1227 void *instance_id
= ctrl
;
1229 static int first
= 1;
1232 u16 intr_enable
= 0;
1234 int cap_base
, saved_cap_base
;
1235 u16 slot_status
, slot_ctrl
;
1236 struct pci_dev
*pdev
;
1240 spin_lock_init(&list_lock
);
1241 php_ctlr
= (struct php_ctlr_state_s
*) kmalloc(sizeof(struct php_ctlr_state_s
), GFP_KERNEL
);
1243 if (!php_ctlr
) { /* allocate controller state data */
1244 err("%s: HPC controller memory allocation error!\n", __FUNCTION__
);
1248 memset(php_ctlr
, 0, sizeof(struct php_ctlr_state_s
));
1251 php_ctlr
->pci_dev
= pdev
; /* save pci_dev in context */
1253 dbg("%s: hotplug controller vendor id 0x%x device id 0x%x\n",
1254 __FUNCTION__
, pdev
->vendor
, pdev
->device
);
1256 saved_cap_base
= pcie_cap_base
;
1258 if ((cap_base
= pci_find_capability(pdev
, PCI_CAP_ID_EXP
)) == 0) {
1259 dbg("%s: Can't find PCI_CAP_ID_EXP (0x10)\n", __FUNCTION__
);
1260 goto abort_free_ctlr
;
1263 ctrl
->cap_base
= cap_base
;
1265 dbg("%s: pcie_cap_base %x\n", __FUNCTION__
, pcie_cap_base
);
1267 rc
= hp_register_read_word(pdev
, CAP_REG(ctrl
->cap_base
), cap_reg
);
1269 err("%s : hp_register_read_word CAP_REG failed\n", __FUNCTION__
);
1270 goto abort_free_ctlr
;
1272 dbg("%s: CAP_REG offset %x cap_reg %x\n", __FUNCTION__
, CAP_REG(ctrl
->cap_base
), cap_reg
);
1274 if (((cap_reg
& SLOT_IMPL
) == 0) || (((cap_reg
& DEV_PORT_TYPE
) != 0x0040)
1275 && ((cap_reg
& DEV_PORT_TYPE
) != 0x0060))) {
1276 dbg("%s : This is not a root port or the port is not connected to a slot\n", __FUNCTION__
);
1277 goto abort_free_ctlr
;
1280 rc
= hp_register_read_dword(php_ctlr
->pci_dev
, SLOT_CAP(ctrl
->cap_base
), slot_cap
);
1282 err("%s : hp_register_read_word CAP_REG failed\n", __FUNCTION__
);
1283 goto abort_free_ctlr
;
1285 dbg("%s: SLOT_CAP offset %x slot_cap %x\n", __FUNCTION__
, SLOT_CAP(ctrl
->cap_base
), slot_cap
);
1287 if (!(slot_cap
& HP_CAP
)) {
1288 dbg("%s : This slot is not hot-plug capable\n", __FUNCTION__
);
1289 goto abort_free_ctlr
;
1291 /* For debugging purpose */
1292 rc
= hp_register_read_word(php_ctlr
->pci_dev
, SLOT_STATUS(ctrl
->cap_base
), slot_status
);
1294 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__
);
1295 goto abort_free_ctlr
;
1297 dbg("%s: SLOT_STATUS offset %x slot_status %x\n", __FUNCTION__
, SLOT_STATUS(ctrl
->cap_base
), slot_status
);
1299 rc
= hp_register_read_word(php_ctlr
->pci_dev
, SLOT_CTRL(ctrl
->cap_base
), slot_ctrl
);
1301 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__
);
1302 goto abort_free_ctlr
;
1304 dbg("%s: SLOT_CTRL offset %x slot_ctrl %x\n", __FUNCTION__
, SLOT_CTRL(ctrl
->cap_base
), slot_ctrl
);
1307 spin_lock_init(&hpc_event_lock
);
1311 for ( rc
= 0; rc
< DEVICE_COUNT_RESOURCE
; rc
++)
1312 if (pci_resource_len(pdev
, rc
) > 0)
1313 dbg("pci resource[%d] start=0x%lx(len=0x%lx)\n", rc
,
1314 pci_resource_start(pdev
, rc
), pci_resource_len(pdev
, rc
));
1316 info("HPC vendor_id %x device_id %x ss_vid %x ss_did %x\n", pdev
->vendor
, pdev
->device
,
1317 pdev
->subsystem_vendor
, pdev
->subsystem_device
);
1319 if (pci_enable_device(pdev
))
1320 goto abort_free_ctlr
;
1322 init_MUTEX(&ctrl
->crit_sect
);
1323 /* setup wait queue */
1324 init_waitqueue_head(&ctrl
->queue
);
1327 php_ctlr
->irq
= dev
->irq
;
1329 /* Save interrupt callback info */
1330 php_ctlr
->attention_button_callback
= pciehp_handle_attention_button
;
1331 php_ctlr
->switch_change_callback
= pciehp_handle_switch_change
;
1332 php_ctlr
->presence_change_callback
= pciehp_handle_presence_change
;
1333 php_ctlr
->power_fault_callback
= pciehp_handle_power_fault
;
1334 php_ctlr
->callback_instance_id
= instance_id
;
1336 /* return PCI Controller Info */
1337 php_ctlr
->slot_device_offset
= 0;
1338 php_ctlr
->num_slots
= 1;
1340 /* Mask Hot-plug Interrupt Enable */
1341 rc
= hp_register_read_word(pdev
, SLOT_CTRL(ctrl
->cap_base
), temp_word
);
1343 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__
);
1344 goto abort_free_ctlr
;
1347 dbg("%s: SLOT_CTRL %x value read %x\n", __FUNCTION__
, SLOT_CTRL(ctrl
->cap_base
), temp_word
);
1348 temp_word
= (temp_word
& ~HP_INTR_ENABLE
& ~CMD_CMPL_INTR_ENABLE
) | 0x00;
1350 rc
= hp_register_write_word(pdev
, SLOT_CTRL(ctrl
->cap_base
), temp_word
);
1352 err("%s : hp_register_write_word SLOT_CTRL failed\n", __FUNCTION__
);
1353 goto abort_free_ctlr
;
1356 rc
= hp_register_read_word(php_ctlr
->pci_dev
, SLOT_STATUS(ctrl
->cap_base
), slot_status
);
1358 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__
);
1359 goto abort_free_ctlr
;
1362 temp_word
= 0x1F; /* Clear all events */
1363 rc
= hp_register_write_word(php_ctlr
->pci_dev
, SLOT_STATUS(ctrl
->cap_base
), temp_word
);
1365 err("%s : hp_register_write_word SLOT_STATUS failed\n", __FUNCTION__
);
1366 goto abort_free_ctlr
;
1369 if (pciehp_poll_mode
) {/* Install interrupt polling code */
1370 /* Install and start the interrupt polling timer */
1371 init_timer(&php_ctlr
->int_poll_timer
);
1372 start_int_poll_timer( php_ctlr
, 10 ); /* start with 10 second delay */
1374 /* Installs the interrupt handler */
1375 rc
= request_irq(php_ctlr
->irq
, pcie_isr
, SA_SHIRQ
, MY_NAME
, (void *) ctrl
);
1376 dbg("%s: request_irq %d for hpc%d (returns %d)\n", __FUNCTION__
, php_ctlr
->irq
, ctlr_seq_num
, rc
);
1378 err("Can't get irq %d for the hotplug controller\n", php_ctlr
->irq
);
1379 goto abort_free_ctlr
;
1383 dbg("pciehp ctrl b:d:f:irq=0x%x:%x:%x:%x\n", pdev
->bus
->number
,
1384 PCI_SLOT(pdev
->devfn
), PCI_FUNC(pdev
->devfn
), dev
->irq
);
1386 rc
= hp_register_read_word(pdev
, SLOT_CTRL(ctrl
->cap_base
), temp_word
);
1388 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__
);
1389 goto abort_free_ctlr
;
1392 intr_enable
= intr_enable
| PRSN_DETECT_ENABLE
;
1394 if (ATTN_BUTTN(slot_cap
))
1395 intr_enable
= intr_enable
| ATTN_BUTTN_ENABLE
;
1397 if (POWER_CTRL(slot_cap
))
1398 intr_enable
= intr_enable
| PWR_FAULT_DETECT_ENABLE
;
1400 if (MRL_SENS(slot_cap
))
1401 intr_enable
= intr_enable
| MRL_DETECT_ENABLE
;
1403 temp_word
= (temp_word
& ~intr_enable
) | intr_enable
;
1405 if (pciehp_poll_mode
) {
1406 temp_word
= (temp_word
& ~HP_INTR_ENABLE
) | 0x0;
1408 temp_word
= (temp_word
& ~HP_INTR_ENABLE
) | HP_INTR_ENABLE
;
1411 /* Unmask Hot-plug Interrupt Enable for the interrupt notification mechanism case */
1412 rc
= hp_register_write_word(pdev
, SLOT_CTRL(ctrl
->cap_base
), temp_word
);
1414 err("%s : hp_register_write_word SLOT_CTRL failed\n", __FUNCTION__
);
1415 goto abort_free_ctlr
;
1417 rc
= hp_register_read_word(php_ctlr
->pci_dev
, SLOT_STATUS(ctrl
->cap_base
), slot_status
);
1419 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__
);
1420 goto abort_free_ctlr
;
1423 temp_word
= 0x1F; /* Clear all events */
1424 rc
= hp_register_write_word(php_ctlr
->pci_dev
, SLOT_STATUS(ctrl
->cap_base
), temp_word
);
1426 err("%s : hp_register_write_word SLOT_STATUS failed\n", __FUNCTION__
);
1427 goto abort_free_ctlr
;
1431 dbg("Bypassing BIOS check for pciehp use on %s\n",
1432 pci_name(ctrl
->pci_dev
));
1434 rc
= pciehp_get_hp_hw_control_from_firmware(ctrl
->pci_dev
);
1436 goto abort_free_ctlr
;
1439 /* Add this HPC instance into the HPC list */
1440 spin_lock(&list_lock
);
1441 if (php_ctlr_list_head
== 0) {
1442 php_ctlr_list_head
= php_ctlr
;
1443 p
= php_ctlr_list_head
;
1446 p
= php_ctlr_list_head
;
1451 p
->pnext
= php_ctlr
;
1453 spin_unlock(&list_lock
);
1456 ctrl
->hpc_ctlr_handle
= php_ctlr
;
1457 ctrl
->hpc_ops
= &pciehp_hpc_ops
;
1462 /* We end up here for the many possible ways to fail this API. */
1464 pcie_cap_base
= saved_cap_base
;