2 * Standard 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/pci.h>
37 #define DBG_K_TRACE_ENTRY ((unsigned int)0x00000001) /* On function entry */
38 #define DBG_K_TRACE_EXIT ((unsigned int)0x00000002) /* On function exit */
39 #define DBG_K_INFO ((unsigned int)0x00000004) /* Info messages */
40 #define DBG_K_ERROR ((unsigned int)0x00000008) /* Error messages */
41 #define DBG_K_TRACE (DBG_K_TRACE_ENTRY|DBG_K_TRACE_EXIT)
42 #define DBG_K_STANDARD (DBG_K_INFO|DBG_K_ERROR|DBG_K_TRACE)
43 /* Redefine this flagword to set debug level */
44 #define DEBUG_LEVEL DBG_K_STANDARD
46 #define DEFINE_DBG_BUFFER char __dbg_str_buf[256];
48 #define DBG_PRINT( dbg_flags, args... ) \
50 if ( DEBUG_LEVEL & ( dbg_flags ) ) \
53 len = sprintf( __dbg_str_buf, "%s:%d: %s: ", \
54 __FILE__, __LINE__, __FUNCTION__ ); \
55 sprintf( __dbg_str_buf + len, args ); \
56 printk( KERN_NOTICE "%s\n", __dbg_str_buf ); \
60 #define DBG_ENTER_ROUTINE DBG_PRINT (DBG_K_TRACE_ENTRY, "%s", "[Entry]");
61 #define DBG_LEAVE_ROUTINE DBG_PRINT (DBG_K_TRACE_EXIT, "%s", "[Exit]");
63 #define DEFINE_DBG_BUFFER
64 #define DBG_ENTER_ROUTINE
65 #define DBG_LEAVE_ROUTINE
68 /* Slot Available Register I field definition */
69 #define SLOT_33MHZ 0x0000001f
70 #define SLOT_66MHZ_PCIX 0x00001f00
71 #define SLOT_100MHZ_PCIX 0x001f0000
72 #define SLOT_133MHZ_PCIX 0x1f000000
74 /* Slot Available Register II field definition */
75 #define SLOT_66MHZ 0x0000001f
76 #define SLOT_66MHZ_PCIX_266 0x00000f00
77 #define SLOT_100MHZ_PCIX_266 0x0000f000
78 #define SLOT_133MHZ_PCIX_266 0x000f0000
79 #define SLOT_66MHZ_PCIX_533 0x00f00000
80 #define SLOT_100MHZ_PCIX_533 0x0f000000
81 #define SLOT_133MHZ_PCIX_533 0xf0000000
84 /* Secondary Bus Configuration Register */
85 /* For PI = 1, Bits 0 to 2 have been encoded as follows to show current bus speed/mode */
88 #define PCIX_66MHZ 0x2
89 #define PCIX_100MHZ 0x3
90 #define PCIX_133MHZ 0x4
92 /* For PI = 2, Bits 0 to 3 have been encoded as follows to show current bus speed/mode */
95 #define PCIX_66MHZ 0x2
96 #define PCIX_100MHZ 0x3
97 #define PCIX_133MHZ 0x4
98 #define PCIX_66MHZ_ECC 0x5
99 #define PCIX_100MHZ_ECC 0x6
100 #define PCIX_133MHZ_ECC 0x7
101 #define PCIX_66MHZ_266 0x9
102 #define PCIX_100MHZ_266 0xa
103 #define PCIX_133MHZ_266 0xb
104 #define PCIX_66MHZ_533 0x11
105 #define PCIX_100MHZ_533 0x12
106 #define PCIX_133MHZ_533 0x13
108 /* Slot Configuration */
109 #define SLOT_NUM 0x0000001F
110 #define FIRST_DEV_NUM 0x00001F00
111 #define PSN 0x07FF0000
112 #define UPDOWN 0x20000000
113 #define MRLSENSOR 0x40000000
114 #define ATTN_BUTTON 0x80000000
116 /* Slot Status Field Definitions */
118 #define PWR_ONLY 0x0001
119 #define ENABLED 0x0002
120 #define DISABLED 0x0003
122 /* Power Indicator State */
123 #define PWR_LED_ON 0x0004
124 #define PWR_LED_BLINK 0x0008
125 #define PWR_LED_OFF 0x000c
127 /* Attention Indicator State */
128 #define ATTEN_LED_ON 0x0010
129 #define ATTEN_LED_BLINK 0x0020
130 #define ATTEN_LED_OFF 0x0030
133 #define pwr_fault 0x0040
135 /* Attention Button */
136 #define ATTEN_BUTTON 0x0080
139 #define MRL_SENSOR 0x0100
142 #define IS_66MHZ_CAP 0x0200
144 /* PRSNT1#/PRSNT2# */
145 #define SLOT_EMP 0x0c00
147 /* PCI-X Capability */
148 #define NON_PCIX 0x0000
149 #define PCIX_66 0x1000
150 #define PCIX_133 0x3000
151 #define PCIX_266 0x4000 /* For PI = 2 only */
152 #define PCIX_533 0x5000 /* For PI = 2 only */
154 /* SHPC 'write' operations/commands */
156 /* Slot operation - 0x00h to 0x3Fh */
158 #define NO_CHANGE 0x00
160 /* Slot state - Bits 0 & 1 of controller command register */
161 #define SET_SLOT_PWR 0x01
162 #define SET_SLOT_ENABLE 0x02
163 #define SET_SLOT_DISABLE 0x03
165 /* Power indicator state - Bits 2 & 3 of controller command register*/
166 #define SET_PWR_ON 0x04
167 #define SET_PWR_BLINK 0x08
168 #define SET_PWR_OFF 0x0C
170 /* Attention indicator state - Bits 4 & 5 of controller command register*/
171 #define SET_ATTN_ON 0x010
172 #define SET_ATTN_BLINK 0x020
173 #define SET_ATTN_OFF 0x030
175 /* Set bus speed/mode A - 0x40h to 0x47h */
176 #define SETA_PCI_33MHZ 0x40
177 #define SETA_PCI_66MHZ 0x41
178 #define SETA_PCIX_66MHZ 0x42
179 #define SETA_PCIX_100MHZ 0x43
180 #define SETA_PCIX_133MHZ 0x44
181 #define RESERV_1 0x45
182 #define RESERV_2 0x46
183 #define RESERV_3 0x47
185 /* Set bus speed/mode B - 0x50h to 0x5fh */
186 #define SETB_PCI_33MHZ 0x50
187 #define SETB_PCI_66MHZ 0x51
188 #define SETB_PCIX_66MHZ_PM 0x52
189 #define SETB_PCIX_100MHZ_PM 0x53
190 #define SETB_PCIX_133MHZ_PM 0x54
191 #define SETB_PCIX_66MHZ_EM 0x55
192 #define SETB_PCIX_100MHZ_EM 0x56
193 #define SETB_PCIX_133MHZ_EM 0x57
194 #define SETB_PCIX_66MHZ_266 0x58
195 #define SETB_PCIX_100MHZ_266 0x59
196 #define SETB_PCIX_133MHZ_266 0x5a
197 #define SETB_PCIX_66MHZ_533 0x5b
198 #define SETB_PCIX_100MHZ_533 0x5c
199 #define SETB_PCIX_133MHZ_533 0x5d
202 /* Power-on all slots - 0x48h */
203 #define SET_PWR_ON_ALL 0x48
205 /* Enable all slots - 0x49h */
206 #define SET_ENABLE_ALL 0x49
208 /* SHPC controller command error code */
209 #define SWITCH_OPEN 0x1
210 #define INVALID_CMD 0x2
211 #define INVALID_SPEED_MODE 0x4
213 /* For accessing SHPC Working Register Set */
214 #define DWORD_SELECT 0x2
215 #define DWORD_DATA 0x4
216 #define BASE_OFFSET 0x0
218 /* Field Offset in Logical Slot Register - byte boundary */
219 #define SLOT_EVENT_LATCH 0x2
220 #define SLOT_SERR_INT_MASK 0x3
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 sequenc # */
227 static spinlock_t list_lock
;
229 static irqreturn_t
shpc_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 shpc_isr( 0, (void *)php_ctlr
, NULL
);
248 init_timer(&php_ctlr
->int_poll_timer
);
249 if (!shpchp_poll_time
)
250 shpchp_poll_time
= 2; /* reset timer to poll in 2 secs if user doesn't specify at module installation*/
252 start_int_poll_timer(php_ctlr
, shpchp_poll_time
);
257 /* This function starts the interrupt polling timer. */
258 static void start_int_poll_timer(struct php_ctlr_state_s
*php_ctlr
, int seconds
)
261 err("%s: Invalid HPC controller handle!\n", __FUNCTION__
);
265 if ( ( seconds
<= 0 ) || ( seconds
> 60 ) )
266 seconds
= 2; /* Clamp to sane value */
268 php_ctlr
->int_poll_timer
.function
= &int_poll_timeout
;
269 php_ctlr
->int_poll_timer
.data
= (unsigned long)php_ctlr
; /* Instance data */
270 php_ctlr
->int_poll_timer
.expires
= jiffies
+ seconds
* HZ
;
271 add_timer(&php_ctlr
->int_poll_timer
);
276 static int shpc_write_cmd(struct slot
*slot
, u8 t_slot
, u8 cmd
)
278 struct php_ctlr_state_s
*php_ctlr
= slot
->ctrl
->hpc_ctlr_handle
;
287 err("%s: Invalid HPC controller handle!\n", __FUNCTION__
);
291 for (i
= 0; i
< 10; i
++) {
292 cmd_status
= readw(php_ctlr
->creg
+ CMD_STATUS
);
294 if (!(cmd_status
& 0x1))
296 /* Check every 0.1 sec for a total of 1 sec*/
300 cmd_status
= readw(php_ctlr
->creg
+ CMD_STATUS
);
302 if (cmd_status
& 0x1) {
303 /* After 1 sec and and the controller is still busy */
304 err("%s : Controller is still busy after 1 sec.\n", __FUNCTION__
);
309 temp_word
= (t_slot
<< 8) | (cmd
& 0xFF);
310 dbg("%s: t_slot %x cmd %x\n", __FUNCTION__
, t_slot
, cmd
);
312 /* To make sure the Controller Busy bit is 0 before we send out the
315 writew(temp_word
, php_ctlr
->creg
+ CMD
);
321 static int hpc_check_cmd_status(struct controller
*ctrl
)
323 struct php_ctlr_state_s
*php_ctlr
= ctrl
->hpc_ctlr_handle
;
329 if (!ctrl
->hpc_ctlr_handle
) {
330 err("%s: Invalid HPC controller handle!\n", __FUNCTION__
);
334 cmd_status
= readw(php_ctlr
->creg
+ CMD_STATUS
) & 0x000F;
336 switch (cmd_status
>> 1) {
341 retval
= SWITCH_OPEN
;
342 err("%s: Switch opened!\n", __FUNCTION__
);
345 retval
= INVALID_CMD
;
346 err("%s: Invalid HPC command!\n", __FUNCTION__
);
349 retval
= INVALID_SPEED_MODE
;
350 err("%s: Invalid bus speed/mode!\n", __FUNCTION__
);
361 static int hpc_get_attention_status(struct slot
*slot
, u8
*status
)
363 struct php_ctlr_state_s
*php_ctlr
= slot
->ctrl
->hpc_ctlr_handle
;
370 if (!slot
->ctrl
->hpc_ctlr_handle
) {
371 err("%s: Invalid HPC controller handle!\n", __FUNCTION__
);
375 slot_reg
= readl(php_ctlr
->creg
+ SLOT1
+ 4*(slot
->hp_slot
));
376 slot_status
= (u16
) slot_reg
;
377 atten_led_state
= (slot_status
& 0x0030) >> 4;
379 switch (atten_led_state
) {
381 *status
= 0xFF; /* Reserved */
384 *status
= 1; /* On */
387 *status
= 2; /* Blink */
390 *status
= 0; /* Off */
401 static int hpc_get_power_status(struct slot
* slot
, u8
*status
)
403 struct php_ctlr_state_s
*php_ctlr
= slot
->ctrl
->hpc_ctlr_handle
;
411 if (!slot
->ctrl
->hpc_ctlr_handle
) {
412 err("%s: Invalid HPC controller handle!\n", __FUNCTION__
);
416 slot_reg
= readl(php_ctlr
->creg
+ SLOT1
+ 4*(slot
->hp_slot
));
417 slot_status
= (u16
) slot_reg
;
418 slot_state
= (slot_status
& 0x0003);
420 switch (slot_state
) {
425 *status
= 2; /* Powered only */
428 *status
= 1; /* Enabled */
431 *status
= 0; /* Disabled */
443 static int hpc_get_latch_status(struct slot
*slot
, u8
*status
)
445 struct php_ctlr_state_s
*php_ctlr
= slot
->ctrl
->hpc_ctlr_handle
;
451 if (!slot
->ctrl
->hpc_ctlr_handle
) {
452 err("%s: Invalid HPC controller handle!\n", __FUNCTION__
);
456 slot_reg
= readl(php_ctlr
->creg
+ SLOT1
+ 4*(slot
->hp_slot
));
457 slot_status
= (u16
)slot_reg
;
459 *status
= ((slot_status
& 0x0100) == 0) ? 0 : 1; /* 0 -> close; 1 -> open */
466 static int hpc_get_adapter_status(struct slot
*slot
, u8
*status
)
468 struct php_ctlr_state_s
*php_ctlr
= slot
->ctrl
->hpc_ctlr_handle
;
475 if (!slot
->ctrl
->hpc_ctlr_handle
) {
476 err("%s: Invalid HPC controller handle!\n", __FUNCTION__
);
480 slot_reg
= readl(php_ctlr
->creg
+ SLOT1
+ 4*(slot
->hp_slot
));
481 slot_status
= (u16
)slot_reg
;
482 card_state
= (u8
)((slot_status
& 0x0C00) >> 10);
483 *status
= (card_state
!= 0x3) ? 1 : 0;
489 static int hpc_get_prog_int(struct slot
*slot
, u8
*prog_int
)
491 struct php_ctlr_state_s
*php_ctlr
= slot
->ctrl
->hpc_ctlr_handle
;
495 if (!slot
->ctrl
->hpc_ctlr_handle
) {
496 err("%s: Invalid HPC controller handle!\n", __FUNCTION__
);
500 *prog_int
= readb(php_ctlr
->creg
+ PROG_INTERFACE
);
506 static int hpc_get_adapter_speed(struct slot
*slot
, enum pci_bus_speed
*value
)
508 struct php_ctlr_state_s
*php_ctlr
= slot
->ctrl
->hpc_ctlr_handle
;
510 u16 slot_status
, sec_bus_status
;
511 u8 m66_cap
, pcix_cap
, pi
;
516 if (!slot
->ctrl
->hpc_ctlr_handle
) {
517 err("%s: Invalid HPC controller handle!\n", __FUNCTION__
);
521 if (slot
->hp_slot
>= php_ctlr
->num_slots
) {
522 err("%s: Invalid HPC slot number!\n", __FUNCTION__
);
526 pi
= readb(php_ctlr
->creg
+ PROG_INTERFACE
);
527 slot_reg
= readl(php_ctlr
->creg
+ SLOT1
+ 4*(slot
->hp_slot
));
528 dbg("%s: pi = %d, slot_reg = %x\n", __FUNCTION__
, pi
, slot_reg
);
529 slot_status
= (u16
) slot_reg
;
530 dbg("%s: slot_status = %x\n", __FUNCTION__
, slot_status
);
531 sec_bus_status
= readw(php_ctlr
->creg
+ SEC_BUS_CONFIG
);
533 pcix_cap
= (u8
) ((slot_status
& 0x3000) >> 12);
534 dbg("%s: pcix_cap = %x\n", __FUNCTION__
, pcix_cap
);
535 m66_cap
= (u8
) ((slot_status
& 0x0200) >> 9);
536 dbg("%s: m66_cap = %x\n", __FUNCTION__
, m66_cap
);
542 *value
= m66_cap
? PCI_SPEED_66MHz
: PCI_SPEED_33MHz
;
545 *value
= PCI_SPEED_66MHz_PCIX
;
548 *value
= PCI_SPEED_133MHz_PCIX
;
551 *value
= PCI_SPEED_133MHz_PCIX_266
;
554 *value
= PCI_SPEED_133MHz_PCIX_533
;
556 case 2: /* Reserved */
558 *value
= PCI_SPEED_UNKNOWN
;
565 *value
= m66_cap
? PCI_SPEED_66MHz
: PCI_SPEED_33MHz
;
568 *value
= PCI_SPEED_66MHz_PCIX
;
571 *value
= PCI_SPEED_133MHz_PCIX
;
573 case 2: /* Reserved */
575 *value
= PCI_SPEED_UNKNOWN
;
581 dbg("Adapter speed = %d\n", *value
);
587 static int hpc_get_mode1_ECC_cap(struct slot
*slot
, u8
*mode
)
589 struct php_ctlr_state_s
*php_ctlr
= slot
->ctrl
->hpc_ctlr_handle
;
596 if (!slot
->ctrl
->hpc_ctlr_handle
) {
597 err("%s: Invalid HPC controller handle!\n", __FUNCTION__
);
601 pi
= readb(php_ctlr
->creg
+ PROG_INTERFACE
);
602 sec_bus_status
= readw(php_ctlr
->creg
+ SEC_BUS_CONFIG
);
605 *mode
= (sec_bus_status
& 0x0100) >> 7;
610 dbg("Mode 1 ECC cap = %d\n", *mode
);
616 static int hpc_query_power_fault(struct slot
* slot
)
618 struct php_ctlr_state_s
*php_ctlr
= slot
->ctrl
->hpc_ctlr_handle
;
621 u8 pwr_fault_state
, status
;
625 if (!slot
->ctrl
->hpc_ctlr_handle
) {
626 err("%s: Invalid HPC controller handle!\n", __FUNCTION__
);
630 slot_reg
= readl(php_ctlr
->creg
+ SLOT1
+ 4*(slot
->hp_slot
));
631 slot_status
= (u16
) slot_reg
;
632 pwr_fault_state
= (slot_status
& 0x0040) >> 7;
633 status
= (pwr_fault_state
== 1) ? 0 : 1;
636 /* Note: Logic 0 => fault */
640 static int hpc_set_attention_status(struct slot
*slot
, u8 value
)
642 struct php_ctlr_state_s
*php_ctlr
= slot
->ctrl
->hpc_ctlr_handle
;
646 if (!slot
->ctrl
->hpc_ctlr_handle
) {
647 err("%s: Invalid HPC controller handle!\n", __FUNCTION__
);
651 if (slot
->hp_slot
>= php_ctlr
->num_slots
) {
652 err("%s: Invalid HPC slot number!\n", __FUNCTION__
);
658 slot_cmd
= 0x30; /* OFF */
661 slot_cmd
= 0x10; /* ON */
664 slot_cmd
= 0x20; /* BLINK */
670 shpc_write_cmd(slot
, slot
->hp_slot
, slot_cmd
);
676 static void hpc_set_green_led_on(struct slot
*slot
)
678 struct php_ctlr_state_s
*php_ctlr
= slot
->ctrl
->hpc_ctlr_handle
;
681 if (!slot
->ctrl
->hpc_ctlr_handle
) {
682 err("%s: Invalid HPC controller handle!\n", __FUNCTION__
);
686 if (slot
->hp_slot
>= php_ctlr
->num_slots
) {
687 err("%s: Invalid HPC slot number!\n", __FUNCTION__
);
693 shpc_write_cmd(slot
, slot
->hp_slot
, slot_cmd
);
698 static void hpc_set_green_led_off(struct slot
*slot
)
700 struct php_ctlr_state_s
*php_ctlr
= slot
->ctrl
->hpc_ctlr_handle
;
703 if (!slot
->ctrl
->hpc_ctlr_handle
) {
704 err("%s: Invalid HPC controller handle!\n", __FUNCTION__
);
708 if (slot
->hp_slot
>= php_ctlr
->num_slots
) {
709 err("%s: Invalid HPC slot number!\n", __FUNCTION__
);
715 shpc_write_cmd(slot
, slot
->hp_slot
, slot_cmd
);
720 static void hpc_set_green_led_blink(struct slot
*slot
)
722 struct php_ctlr_state_s
*php_ctlr
= slot
->ctrl
->hpc_ctlr_handle
;
725 if (!slot
->ctrl
->hpc_ctlr_handle
) {
726 err("%s: Invalid HPC controller handle!\n", __FUNCTION__
);
730 if (slot
->hp_slot
>= php_ctlr
->num_slots
) {
731 err("%s: Invalid HPC slot number!\n", __FUNCTION__
);
737 shpc_write_cmd(slot
, slot
->hp_slot
, slot_cmd
);
742 int shpc_get_ctlr_slot_config(struct controller
*ctrl
,
743 int *num_ctlr_slots
, /* number of slots in this HPC */
744 int *first_device_num
, /* PCI dev num of the first slot in this SHPC */
745 int *physical_slot_num
, /* phy slot num of the first slot in this SHPC */
746 int *updown
, /* physical_slot_num increament: 1 or -1 */
749 struct php_ctlr_state_s
*php_ctlr
= ctrl
->hpc_ctlr_handle
;
753 if (!ctrl
->hpc_ctlr_handle
) {
754 err("%s: Invalid HPC controller handle!\n", __FUNCTION__
);
758 *first_device_num
= php_ctlr
->slot_device_offset
; /* Obtained in shpc_init() */
759 *num_ctlr_slots
= php_ctlr
->num_slots
; /* Obtained in shpc_init() */
761 *physical_slot_num
= (readl(php_ctlr
->creg
+ SLOT_CONFIG
) & PSN
) >> 16;
762 dbg("%s: physical_slot_num = %x\n", __FUNCTION__
, *physical_slot_num
);
763 *updown
= ((readl(php_ctlr
->creg
+ SLOT_CONFIG
) & UPDOWN
) >> 29) ? 1 : -1;
769 static void hpc_release_ctlr(struct controller
*ctrl
)
771 struct php_ctlr_state_s
*php_ctlr
= ctrl
->hpc_ctlr_handle
;
772 struct php_ctlr_state_s
*p
, *p_prev
;
776 if (!ctrl
->hpc_ctlr_handle
) {
777 err("%s: Invalid HPC controller handle!\n", __FUNCTION__
);
781 if (shpchp_poll_mode
) {
782 del_timer(&php_ctlr
->int_poll_timer
);
785 free_irq(php_ctlr
->irq
, ctrl
);
787 pci_disable_msi(php_ctlr
->pci_dev
);
790 if (php_ctlr
->pci_dev
) {
791 iounmap(php_ctlr
->creg
);
792 release_mem_region(pci_resource_start(php_ctlr
->pci_dev
, 0), pci_resource_len(php_ctlr
->pci_dev
, 0));
793 php_ctlr
->pci_dev
= NULL
;
796 spin_lock(&list_lock
);
797 p
= php_ctlr_list_head
;
802 p_prev
->pnext
= p
->pnext
;
804 php_ctlr_list_head
= p
->pnext
;
811 spin_unlock(&list_lock
);
819 static int hpc_power_on_slot(struct slot
* slot
)
821 struct php_ctlr_state_s
*php_ctlr
= slot
->ctrl
->hpc_ctlr_handle
;
827 if (!slot
->ctrl
->hpc_ctlr_handle
) {
828 err("%s: Invalid HPC controller handle!\n", __FUNCTION__
);
832 if (slot
->hp_slot
>= php_ctlr
->num_slots
) {
833 err("%s: Invalid HPC slot number!\n", __FUNCTION__
);
838 retval
= shpc_write_cmd(slot
, slot
->hp_slot
, slot_cmd
);
841 err("%s: Write command failed!\n", __FUNCTION__
);
850 static int hpc_slot_enable(struct slot
* slot
)
852 struct php_ctlr_state_s
*php_ctlr
= slot
->ctrl
->hpc_ctlr_handle
;
858 if (!slot
->ctrl
->hpc_ctlr_handle
) {
859 err("%s: Invalid HPC controller handle!\n", __FUNCTION__
);
863 if (slot
->hp_slot
>= php_ctlr
->num_slots
) {
864 err("%s: Invalid HPC slot number!\n", __FUNCTION__
);
867 /* 3A => Slot - Enable, Power Indicator - Blink, Attention Indicator - Off */
870 retval
= shpc_write_cmd(slot
, slot
->hp_slot
, slot_cmd
);
873 err("%s: Write command failed!\n", __FUNCTION__
);
881 static int hpc_slot_disable(struct slot
* slot
)
883 struct php_ctlr_state_s
*php_ctlr
= slot
->ctrl
->hpc_ctlr_handle
;
889 if (!slot
->ctrl
->hpc_ctlr_handle
) {
890 err("%s: Invalid HPC controller handle!\n", __FUNCTION__
);
894 if (slot
->hp_slot
>= php_ctlr
->num_slots
) {
895 err("%s: Invalid HPC slot number!\n", __FUNCTION__
);
899 /* 1F => Slot - Disable, Power Indicator - Off, Attention Indicator - On */
902 retval
= shpc_write_cmd(slot
, slot
->hp_slot
, slot_cmd
);
905 err("%s: Write command failed!\n", __FUNCTION__
);
913 static int hpc_set_bus_speed_mode(struct slot
* slot
, enum pci_bus_speed value
)
918 struct php_ctlr_state_s
*php_ctlr
= slot
->ctrl
->hpc_ctlr_handle
;
922 if (!slot
->ctrl
->hpc_ctlr_handle
) {
923 err("%s: Invalid HPC controller handle!\n", __FUNCTION__
);
927 pi
= readb(php_ctlr
->creg
+ PROG_INTERFACE
);
932 slot_cmd
= SETA_PCI_33MHZ
;
935 slot_cmd
= SETA_PCI_66MHZ
;
938 slot_cmd
= SETA_PCIX_66MHZ
;
941 slot_cmd
= SETA_PCIX_100MHZ
;
944 slot_cmd
= SETA_PCIX_133MHZ
;
947 slot_cmd
= PCI_SPEED_UNKNOWN
;
954 slot_cmd
= SETB_PCI_33MHZ
;
957 slot_cmd
= SETB_PCI_66MHZ
;
960 slot_cmd
= SETB_PCIX_66MHZ_PM
;
963 slot_cmd
= SETB_PCIX_100MHZ_PM
;
966 slot_cmd
= SETB_PCIX_133MHZ_PM
;
969 slot_cmd
= SETB_PCIX_66MHZ_EM
;
972 slot_cmd
= SETB_PCIX_100MHZ_EM
;
975 slot_cmd
= SETB_PCIX_133MHZ_EM
;
978 slot_cmd
= SETB_PCIX_66MHZ_266
;
981 slot_cmd
= SETB_PCIX_100MHZ_266
;
984 slot_cmd
= SETB_PCIX_133MHZ_266
;
987 slot_cmd
= SETB_PCIX_66MHZ_533
;
990 slot_cmd
= SETB_PCIX_100MHZ_533
;
993 slot_cmd
= SETB_PCIX_133MHZ_533
;
996 slot_cmd
= PCI_SPEED_UNKNOWN
;
1002 retval
= shpc_write_cmd(slot
, 0, slot_cmd
);
1004 err("%s: Write command failed!\n", __FUNCTION__
);
1012 static irqreturn_t
shpc_isr(int IRQ
, void *dev_id
, struct pt_regs
*regs
)
1014 struct controller
*ctrl
= NULL
;
1015 struct php_ctlr_state_s
*php_ctlr
;
1016 u8 schedule_flag
= 0;
1018 u32 temp_dword
, intr_loc
, intr_loc2
;
1024 if (!shpchp_poll_mode
) {
1025 ctrl
= (struct controller
*)dev_id
;
1026 php_ctlr
= ctrl
->hpc_ctlr_handle
;
1028 php_ctlr
= (struct php_ctlr_state_s
*) dev_id
;
1029 ctrl
= (struct controller
*)php_ctlr
->callback_instance_id
;
1035 if (!php_ctlr
|| !php_ctlr
->creg
)
1038 /* Check to see if it was our interrupt */
1039 intr_loc
= readl(php_ctlr
->creg
+ INTR_LOC
);
1043 dbg("%s: intr_loc = %x\n",__FUNCTION__
, intr_loc
);
1045 if(!shpchp_poll_mode
) {
1046 /* Mask Global Interrupt Mask - see implementation note on p. 139 */
1047 /* of SHPC spec rev 1.0*/
1048 temp_dword
= readl(php_ctlr
->creg
+ SERR_INTR_ENABLE
);
1049 temp_dword
|= 0x00000001;
1050 writel(temp_dword
, php_ctlr
->creg
+ SERR_INTR_ENABLE
);
1052 intr_loc2
= readl(php_ctlr
->creg
+ INTR_LOC
);
1053 dbg("%s: intr_loc2 = %x\n",__FUNCTION__
, intr_loc2
);
1056 if (intr_loc
& 0x0001) {
1058 * Command Complete Interrupt Pending
1059 * RO only - clear by writing 0 to the Command Completion
1060 * Detect bit in Controller SERR-INT register
1062 temp_dword
= readl(php_ctlr
->creg
+ SERR_INTR_ENABLE
);
1063 temp_dword
&= 0xfffeffff;
1064 writel(temp_dword
, php_ctlr
->creg
+ SERR_INTR_ENABLE
);
1065 wake_up_interruptible(&ctrl
->queue
);
1068 if ((intr_loc
= (intr_loc
>> 1)) == 0) {
1069 /* Unmask Global Interrupt Mask */
1070 temp_dword
= readl(php_ctlr
->creg
+ SERR_INTR_ENABLE
);
1071 temp_dword
&= 0xfffffffe;
1072 writel(temp_dword
, php_ctlr
->creg
+ SERR_INTR_ENABLE
);
1077 for (hp_slot
= 0; hp_slot
< ctrl
->num_slots
; hp_slot
++) {
1078 /* To find out which slot has interrupt pending */
1079 if ((intr_loc
>> hp_slot
) & 0x01) {
1080 temp_dword
= readl(php_ctlr
->creg
+ SLOT1
+ (4*hp_slot
));
1081 dbg("%s: Slot %x with intr, slot register = %x\n",
1082 __FUNCTION__
, hp_slot
, temp_dword
);
1083 temp_byte
= (temp_dword
>> 16) & 0xFF;
1084 if ((php_ctlr
->switch_change_callback
) && (temp_byte
& 0x08))
1085 schedule_flag
+= php_ctlr
->switch_change_callback(
1086 hp_slot
, php_ctlr
->callback_instance_id
);
1087 if ((php_ctlr
->attention_button_callback
) && (temp_byte
& 0x04))
1088 schedule_flag
+= php_ctlr
->attention_button_callback(
1089 hp_slot
, php_ctlr
->callback_instance_id
);
1090 if ((php_ctlr
->presence_change_callback
) && (temp_byte
& 0x01))
1091 schedule_flag
+= php_ctlr
->presence_change_callback(
1092 hp_slot
, php_ctlr
->callback_instance_id
);
1093 if ((php_ctlr
->power_fault_callback
) && (temp_byte
& 0x12))
1094 schedule_flag
+= php_ctlr
->power_fault_callback(
1095 hp_slot
, php_ctlr
->callback_instance_id
);
1097 /* Clear all slot events */
1098 temp_dword
= 0xe01f3fff;
1099 writel(temp_dword
, php_ctlr
->creg
+ SLOT1
+ (4*hp_slot
));
1101 intr_loc2
= readl(php_ctlr
->creg
+ INTR_LOC
);
1102 dbg("%s: intr_loc2 = %x\n",__FUNCTION__
, intr_loc2
);
1105 if (!shpchp_poll_mode
) {
1106 /* Unmask Global Interrupt Mask */
1107 temp_dword
= readl(php_ctlr
->creg
+ SERR_INTR_ENABLE
);
1108 temp_dword
&= 0xfffffffe;
1109 writel(temp_dword
, php_ctlr
->creg
+ SERR_INTR_ENABLE
);
1115 static int hpc_get_max_bus_speed (struct slot
*slot
, enum pci_bus_speed
*value
)
1117 struct php_ctlr_state_s
*php_ctlr
= slot
->ctrl
->hpc_ctlr_handle
;
1118 enum pci_bus_speed bus_speed
= PCI_SPEED_UNKNOWN
;
1121 u32 slot_avail1
, slot_avail2
;
1126 if (!slot
->ctrl
->hpc_ctlr_handle
) {
1127 err("%s: Invalid HPC controller handle!\n", __FUNCTION__
);
1131 if (slot
->hp_slot
>= php_ctlr
->num_slots
) {
1132 err("%s: Invalid HPC slot number!\n", __FUNCTION__
);
1136 pi
= readb(php_ctlr
->creg
+ PROG_INTERFACE
);
1137 slot_avail1
= readl(php_ctlr
->creg
+ SLOT_AVAIL1
);
1138 slot_avail2
= readl(php_ctlr
->creg
+ SLOT_AVAIL2
);
1141 if ((slot_num
= ((slot_avail2
& SLOT_133MHZ_PCIX_533
) >> 27) ) != 0 )
1142 bus_speed
= PCIX_133MHZ_533
;
1143 else if ((slot_num
= ((slot_avail2
& SLOT_100MHZ_PCIX_533
) >> 23) ) != 0 )
1144 bus_speed
= PCIX_100MHZ_533
;
1145 else if ((slot_num
= ((slot_avail2
& SLOT_66MHZ_PCIX_533
) >> 19) ) != 0 )
1146 bus_speed
= PCIX_66MHZ_533
;
1147 else if ((slot_num
= ((slot_avail2
& SLOT_133MHZ_PCIX_266
) >> 15) ) != 0 )
1148 bus_speed
= PCIX_133MHZ_266
;
1149 else if ((slot_num
= ((slot_avail2
& SLOT_100MHZ_PCIX_266
) >> 11) ) != 0 )
1150 bus_speed
= PCIX_100MHZ_266
;
1151 else if ((slot_num
= ((slot_avail2
& SLOT_66MHZ_PCIX_266
) >> 7) ) != 0 )
1152 bus_speed
= PCIX_66MHZ_266
;
1153 else if ((slot_num
= ((slot_avail1
& SLOT_133MHZ_PCIX
) >> 23) ) != 0 )
1154 bus_speed
= PCIX_133MHZ
;
1155 else if ((slot_num
= ((slot_avail1
& SLOT_100MHZ_PCIX
) >> 15) ) != 0 )
1156 bus_speed
= PCIX_100MHZ
;
1157 else if ((slot_num
= ((slot_avail1
& SLOT_66MHZ_PCIX
) >> 7) ) != 0 )
1158 bus_speed
= PCIX_66MHZ
;
1159 else if ((slot_num
= (slot_avail2
& SLOT_66MHZ
)) != 0 )
1160 bus_speed
= PCI_66MHZ
;
1161 else if ((slot_num
= (slot_avail1
& SLOT_33MHZ
)) != 0 )
1162 bus_speed
= PCI_33MHZ
;
1163 else bus_speed
= PCI_SPEED_UNKNOWN
;
1165 if ((slot_num
= ((slot_avail1
& SLOT_133MHZ_PCIX
) >> 23) ) != 0 )
1166 bus_speed
= PCIX_133MHZ
;
1167 else if ((slot_num
= ((slot_avail1
& SLOT_100MHZ_PCIX
) >> 15) ) != 0 )
1168 bus_speed
= PCIX_100MHZ
;
1169 else if ((slot_num
= ((slot_avail1
& SLOT_66MHZ_PCIX
) >> 7) ) != 0 )
1170 bus_speed
= PCIX_66MHZ
;
1171 else if ((slot_num
= (slot_avail2
& SLOT_66MHZ
)) != 0 )
1172 bus_speed
= PCI_66MHZ
;
1173 else if ((slot_num
= (slot_avail1
& SLOT_33MHZ
)) != 0 )
1174 bus_speed
= PCI_33MHZ
;
1175 else bus_speed
= PCI_SPEED_UNKNOWN
;
1179 dbg("Max bus speed = %d\n", bus_speed
);
1184 static int hpc_get_cur_bus_speed (struct slot
*slot
, enum pci_bus_speed
*value
)
1186 struct php_ctlr_state_s
*php_ctlr
= slot
->ctrl
->hpc_ctlr_handle
;
1187 enum pci_bus_speed bus_speed
= PCI_SPEED_UNKNOWN
;
1194 if (!slot
->ctrl
->hpc_ctlr_handle
) {
1195 err("%s: Invalid HPC controller handle!\n", __FUNCTION__
);
1199 if (slot
->hp_slot
>= php_ctlr
->num_slots
) {
1200 err("%s: Invalid HPC slot number!\n", __FUNCTION__
);
1204 pi
= readb(php_ctlr
->creg
+ PROG_INTERFACE
);
1205 sec_bus_status
= readw(php_ctlr
->creg
+ SEC_BUS_CONFIG
);
1208 switch (sec_bus_status
& 0x000f) {
1210 bus_speed
= PCI_SPEED_33MHz
;
1213 bus_speed
= PCI_SPEED_66MHz
;
1216 bus_speed
= PCI_SPEED_66MHz_PCIX
;
1219 bus_speed
= PCI_SPEED_100MHz_PCIX
;
1222 bus_speed
= PCI_SPEED_133MHz_PCIX
;
1225 bus_speed
= PCI_SPEED_66MHz_PCIX_ECC
;
1228 bus_speed
= PCI_SPEED_100MHz_PCIX_ECC
;
1231 bus_speed
= PCI_SPEED_133MHz_PCIX_ECC
;
1234 bus_speed
= PCI_SPEED_66MHz_PCIX_266
;
1237 bus_speed
= PCI_SPEED_100MHz_PCIX_266
;
1240 bus_speed
= PCI_SPEED_133MHz_PCIX_266
;
1243 bus_speed
= PCI_SPEED_66MHz_PCIX_533
;
1246 bus_speed
= PCI_SPEED_100MHz_PCIX_533
;
1249 bus_speed
= PCI_SPEED_133MHz_PCIX_533
;
1254 bus_speed
= PCI_SPEED_UNKNOWN
;
1258 /* In the case where pi is undefined, default it to 1 */
1259 switch (sec_bus_status
& 0x0007) {
1261 bus_speed
= PCI_SPEED_33MHz
;
1264 bus_speed
= PCI_SPEED_66MHz
;
1267 bus_speed
= PCI_SPEED_66MHz_PCIX
;
1270 bus_speed
= PCI_SPEED_100MHz_PCIX
;
1273 bus_speed
= PCI_SPEED_133MHz_PCIX
;
1276 bus_speed
= PCI_SPEED_UNKNOWN
; /* Reserved */
1279 bus_speed
= PCI_SPEED_UNKNOWN
; /* Reserved */
1282 bus_speed
= PCI_SPEED_UNKNOWN
; /* Reserved */
1285 bus_speed
= PCI_SPEED_UNKNOWN
;
1291 dbg("Current bus speed = %d\n", bus_speed
);
1296 static struct hpc_ops shpchp_hpc_ops
= {
1297 .power_on_slot
= hpc_power_on_slot
,
1298 .slot_enable
= hpc_slot_enable
,
1299 .slot_disable
= hpc_slot_disable
,
1300 .set_bus_speed_mode
= hpc_set_bus_speed_mode
,
1301 .set_attention_status
= hpc_set_attention_status
,
1302 .get_power_status
= hpc_get_power_status
,
1303 .get_attention_status
= hpc_get_attention_status
,
1304 .get_latch_status
= hpc_get_latch_status
,
1305 .get_adapter_status
= hpc_get_adapter_status
,
1307 .get_max_bus_speed
= hpc_get_max_bus_speed
,
1308 .get_cur_bus_speed
= hpc_get_cur_bus_speed
,
1309 .get_adapter_speed
= hpc_get_adapter_speed
,
1310 .get_mode1_ECC_cap
= hpc_get_mode1_ECC_cap
,
1311 .get_prog_int
= hpc_get_prog_int
,
1313 .query_power_fault
= hpc_query_power_fault
,
1314 .green_led_on
= hpc_set_green_led_on
,
1315 .green_led_off
= hpc_set_green_led_off
,
1316 .green_led_blink
= hpc_set_green_led_blink
,
1318 .release_ctlr
= hpc_release_ctlr
,
1319 .check_cmd_status
= hpc_check_cmd_status
,
1322 int shpc_init(struct controller
* ctrl
, struct pci_dev
* pdev
)
1324 struct php_ctlr_state_s
*php_ctlr
, *p
;
1325 void *instance_id
= ctrl
;
1328 static int first
= 1;
1329 u32 shpc_cap_offset
, shpc_base_offset
;
1330 u32 tempdword
, slot_reg
;
1335 spin_lock_init(&list_lock
);
1336 php_ctlr
= (struct php_ctlr_state_s
*) kmalloc(sizeof(struct php_ctlr_state_s
), GFP_KERNEL
);
1338 if (!php_ctlr
) { /* allocate controller state data */
1339 err("%s: HPC controller memory allocation error!\n", __FUNCTION__
);
1343 memset(php_ctlr
, 0, sizeof(struct php_ctlr_state_s
));
1345 php_ctlr
->pci_dev
= pdev
; /* save pci_dev in context */
1347 if ((pdev
->vendor
== PCI_VENDOR_ID_AMD
) || (pdev
->device
==
1348 PCI_DEVICE_ID_AMD_GOLAM_7450
)) {
1349 shpc_base_offset
= 0; /* amd shpc driver doesn't use this; assume 0 */
1351 if ((shpc_cap_offset
= pci_find_capability(pdev
, PCI_CAP_ID_SHPC
)) == 0) {
1352 err("%s : shpc_cap_offset == 0\n", __FUNCTION__
);
1353 goto abort_free_ctlr
;
1355 dbg("%s: shpc_cap_offset = %x\n", __FUNCTION__
, shpc_cap_offset
);
1357 rc
= pci_write_config_byte(pdev
, (u8
)shpc_cap_offset
+ DWORD_SELECT
, BASE_OFFSET
);
1359 err("%s : pci_word_config_byte failed\n", __FUNCTION__
);
1360 goto abort_free_ctlr
;
1363 rc
= pci_read_config_dword(pdev
, (u8
)shpc_cap_offset
+ DWORD_DATA
, &shpc_base_offset
);
1365 err("%s : pci_read_config_dword failed\n", __FUNCTION__
);
1366 goto abort_free_ctlr
;
1369 for (i
= 0; i
<= 14; i
++) {
1370 rc
= pci_write_config_byte(pdev
, (u8
)shpc_cap_offset
+ DWORD_SELECT
, i
);
1372 err("%s : pci_word_config_byte failed\n", __FUNCTION__
);
1373 goto abort_free_ctlr
;
1376 rc
= pci_read_config_dword(pdev
, (u8
)shpc_cap_offset
+ DWORD_DATA
, &tempdword
);
1378 err("%s : pci_read_config_dword failed\n", __FUNCTION__
);
1379 goto abort_free_ctlr
;
1381 dbg("%s: offset %d: value %x\n", __FUNCTION__
,i
,
1387 spin_lock_init(&hpc_event_lock
);
1391 info("HPC vendor_id %x device_id %x ss_vid %x ss_did %x\n", pdev
->vendor
, pdev
->device
, pdev
->subsystem_vendor
,
1392 pdev
->subsystem_device
);
1394 if (pci_enable_device(pdev
))
1395 goto abort_free_ctlr
;
1397 if (!request_mem_region(pci_resource_start(pdev
, 0) + shpc_base_offset
, pci_resource_len(pdev
, 0), MY_NAME
)) {
1398 err("%s: cannot reserve MMIO region\n", __FUNCTION__
);
1399 goto abort_free_ctlr
;
1402 php_ctlr
->creg
= ioremap(pci_resource_start(pdev
, 0) + shpc_base_offset
, pci_resource_len(pdev
, 0));
1403 if (!php_ctlr
->creg
) {
1404 err("%s: cannot remap MMIO region %lx @ %lx\n", __FUNCTION__
, pci_resource_len(pdev
, 0),
1405 pci_resource_start(pdev
, 0) + shpc_base_offset
);
1406 release_mem_region(pci_resource_start(pdev
, 0) + shpc_base_offset
, pci_resource_len(pdev
, 0));
1407 goto abort_free_ctlr
;
1409 dbg("%s: php_ctlr->creg %p\n", __FUNCTION__
, php_ctlr
->creg
);
1411 init_MUTEX(&ctrl
->crit_sect
);
1412 /* Setup wait queue */
1413 init_waitqueue_head(&ctrl
->queue
);
1416 php_ctlr
->irq
= pdev
->irq
;
1417 php_ctlr
->attention_button_callback
= shpchp_handle_attention_button
,
1418 php_ctlr
->switch_change_callback
= shpchp_handle_switch_change
;
1419 php_ctlr
->presence_change_callback
= shpchp_handle_presence_change
;
1420 php_ctlr
->power_fault_callback
= shpchp_handle_power_fault
;
1421 php_ctlr
->callback_instance_id
= instance_id
;
1423 /* Return PCI Controller Info */
1424 php_ctlr
->slot_device_offset
= (readl(php_ctlr
->creg
+ SLOT_CONFIG
) & FIRST_DEV_NUM
) >> 8;
1425 php_ctlr
->num_slots
= readl(php_ctlr
->creg
+ SLOT_CONFIG
) & SLOT_NUM
;
1426 dbg("%s: slot_device_offset %x\n", __FUNCTION__
, php_ctlr
->slot_device_offset
);
1427 dbg("%s: num_slots %x\n", __FUNCTION__
, php_ctlr
->num_slots
);
1429 /* Mask Global Interrupt Mask & Command Complete Interrupt Mask */
1430 tempdword
= readl(php_ctlr
->creg
+ SERR_INTR_ENABLE
);
1431 dbg("%s: SERR_INTR_ENABLE = %x\n", __FUNCTION__
, tempdword
);
1432 tempdword
= 0x0003000f;
1433 writel(tempdword
, php_ctlr
->creg
+ SERR_INTR_ENABLE
);
1434 tempdword
= readl(php_ctlr
->creg
+ SERR_INTR_ENABLE
);
1435 dbg("%s: SERR_INTR_ENABLE = %x\n", __FUNCTION__
, tempdword
);
1437 /* Mask the MRL sensor SERR Mask of individual slot in
1438 * Slot SERR-INT Mask & clear all the existing event if any
1440 for (hp_slot
= 0; hp_slot
< php_ctlr
->num_slots
; hp_slot
++) {
1441 slot_reg
= readl(php_ctlr
->creg
+ SLOT1
+ 4*hp_slot
);
1442 dbg("%s: Default Logical Slot Register %d value %x\n", __FUNCTION__
,
1444 tempdword
= 0xffff3fff;
1445 writel(tempdword
, php_ctlr
->creg
+ SLOT1
+ (4*hp_slot
));
1448 if (shpchp_poll_mode
) {/* Install interrupt polling code */
1449 /* Install and start the interrupt polling timer */
1450 init_timer(&php_ctlr
->int_poll_timer
);
1451 start_int_poll_timer( php_ctlr
, 10 ); /* start with 10 second delay */
1453 /* Installs the interrupt handler */
1454 rc
= pci_enable_msi(pdev
);
1456 info("Can't get msi for the hotplug controller\n");
1457 info("Use INTx for the hotplug controller\n");
1459 php_ctlr
->irq
= pdev
->irq
;
1461 rc
= request_irq(php_ctlr
->irq
, shpc_isr
, SA_SHIRQ
, 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
;
1468 dbg("%s: HPC at b:d:f:irq=0x%x:%x:%x:%x\n", __FUNCTION__
,
1469 pdev
->bus
->number
, PCI_SLOT(pdev
->devfn
),
1470 PCI_FUNC(pdev
->devfn
), pdev
->irq
);
1471 get_hp_hw_control_from_firmware(pdev
);
1473 /* Add this HPC instance into the HPC list */
1474 spin_lock(&list_lock
);
1475 if (php_ctlr_list_head
== 0) {
1476 php_ctlr_list_head
= php_ctlr
;
1477 p
= php_ctlr_list_head
;
1480 p
= php_ctlr_list_head
;
1485 p
->pnext
= php_ctlr
;
1487 spin_unlock(&list_lock
);
1491 ctrl
->hpc_ctlr_handle
= php_ctlr
;
1492 ctrl
->hpc_ops
= &shpchp_hpc_ops
;
1494 for (hp_slot
= 0; hp_slot
< php_ctlr
->num_slots
; hp_slot
++) {
1495 slot_reg
= readl(php_ctlr
->creg
+ SLOT1
+ 4*hp_slot
);
1496 dbg("%s: Default Logical Slot Register %d value %x\n", __FUNCTION__
,
1498 tempdword
= 0xe01f3fff;
1499 writel(tempdword
, php_ctlr
->creg
+ SLOT1
+ (4*hp_slot
));
1501 if (!shpchp_poll_mode
) {
1502 /* Unmask all general input interrupts and SERR */
1503 tempdword
= readl(php_ctlr
->creg
+ SERR_INTR_ENABLE
);
1504 tempdword
= 0x0000000a;
1505 writel(tempdword
, php_ctlr
->creg
+ SERR_INTR_ENABLE
);
1506 tempdword
= readl(php_ctlr
->creg
+ SERR_INTR_ENABLE
);
1507 dbg("%s: SERR_INTR_ENABLE = %x\n", __FUNCTION__
, tempdword
);
1513 /* We end up here for the many possible ways to fail this API. */