Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Standard PCI Hot Plug Driver |
| 3 | * |
| 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 |
| 8 | * |
| 9 | * All rights reserved. |
| 10 | * |
| 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. |
| 15 | * |
| 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 |
| 20 | * details. |
| 21 | * |
| 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. |
| 25 | * |
Kristen Accardi | 8cf4c19 | 2005-08-16 15:16:10 -0700 | [diff] [blame] | 26 | * Send feedback to <greg@kroah.com>,<kristen.c.accardi@intel.com> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | * |
| 28 | */ |
| 29 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | #include <linux/kernel.h> |
| 31 | #include <linux/module.h> |
| 32 | #include <linux/types.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | #include <linux/pci.h> |
Andrew Morton | d4d28dd | 2005-11-13 16:06:40 -0800 | [diff] [blame] | 34 | #include <linux/interrupt.h> |
| 35 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | #include "shpchp.h" |
| 37 | |
| 38 | #ifdef DEBUG |
| 39 | #define DBG_K_TRACE_ENTRY ((unsigned int)0x00000001) /* On function entry */ |
| 40 | #define DBG_K_TRACE_EXIT ((unsigned int)0x00000002) /* On function exit */ |
| 41 | #define DBG_K_INFO ((unsigned int)0x00000004) /* Info messages */ |
| 42 | #define DBG_K_ERROR ((unsigned int)0x00000008) /* Error messages */ |
| 43 | #define DBG_K_TRACE (DBG_K_TRACE_ENTRY|DBG_K_TRACE_EXIT) |
| 44 | #define DBG_K_STANDARD (DBG_K_INFO|DBG_K_ERROR|DBG_K_TRACE) |
| 45 | /* Redefine this flagword to set debug level */ |
| 46 | #define DEBUG_LEVEL DBG_K_STANDARD |
| 47 | |
| 48 | #define DEFINE_DBG_BUFFER char __dbg_str_buf[256]; |
| 49 | |
| 50 | #define DBG_PRINT( dbg_flags, args... ) \ |
| 51 | do { \ |
| 52 | if ( DEBUG_LEVEL & ( dbg_flags ) ) \ |
| 53 | { \ |
| 54 | int len; \ |
| 55 | len = sprintf( __dbg_str_buf, "%s:%d: %s: ", \ |
| 56 | __FILE__, __LINE__, __FUNCTION__ ); \ |
| 57 | sprintf( __dbg_str_buf + len, args ); \ |
| 58 | printk( KERN_NOTICE "%s\n", __dbg_str_buf ); \ |
| 59 | } \ |
| 60 | } while (0) |
| 61 | |
| 62 | #define DBG_ENTER_ROUTINE DBG_PRINT (DBG_K_TRACE_ENTRY, "%s", "[Entry]"); |
| 63 | #define DBG_LEAVE_ROUTINE DBG_PRINT (DBG_K_TRACE_EXIT, "%s", "[Exit]"); |
| 64 | #else |
| 65 | #define DEFINE_DBG_BUFFER |
| 66 | #define DBG_ENTER_ROUTINE |
| 67 | #define DBG_LEAVE_ROUTINE |
| 68 | #endif /* DEBUG */ |
| 69 | |
| 70 | /* Slot Available Register I field definition */ |
| 71 | #define SLOT_33MHZ 0x0000001f |
| 72 | #define SLOT_66MHZ_PCIX 0x00001f00 |
| 73 | #define SLOT_100MHZ_PCIX 0x001f0000 |
| 74 | #define SLOT_133MHZ_PCIX 0x1f000000 |
| 75 | |
| 76 | /* Slot Available Register II field definition */ |
| 77 | #define SLOT_66MHZ 0x0000001f |
| 78 | #define SLOT_66MHZ_PCIX_266 0x00000f00 |
| 79 | #define SLOT_100MHZ_PCIX_266 0x0000f000 |
| 80 | #define SLOT_133MHZ_PCIX_266 0x000f0000 |
| 81 | #define SLOT_66MHZ_PCIX_533 0x00f00000 |
| 82 | #define SLOT_100MHZ_PCIX_533 0x0f000000 |
| 83 | #define SLOT_133MHZ_PCIX_533 0xf0000000 |
| 84 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 | /* Slot Configuration */ |
| 86 | #define SLOT_NUM 0x0000001F |
| 87 | #define FIRST_DEV_NUM 0x00001F00 |
| 88 | #define PSN 0x07FF0000 |
| 89 | #define UPDOWN 0x20000000 |
| 90 | #define MRLSENSOR 0x40000000 |
| 91 | #define ATTN_BUTTON 0x80000000 |
| 92 | |
Kenji Kaneshige | 2b34da7 | 2006-05-02 11:09:42 +0900 | [diff] [blame^] | 93 | /* |
| 94 | * Logical Slot Register definitions |
| 95 | */ |
| 96 | #define SLOT_REG(i) (SLOT1 + (4 * i)) |
| 97 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 98 | /* Slot Status Field Definitions */ |
| 99 | /* Slot State */ |
| 100 | #define PWR_ONLY 0x0001 |
| 101 | #define ENABLED 0x0002 |
| 102 | #define DISABLED 0x0003 |
| 103 | |
| 104 | /* Power Indicator State */ |
| 105 | #define PWR_LED_ON 0x0004 |
| 106 | #define PWR_LED_BLINK 0x0008 |
| 107 | #define PWR_LED_OFF 0x000c |
| 108 | |
| 109 | /* Attention Indicator State */ |
| 110 | #define ATTEN_LED_ON 0x0010 |
| 111 | #define ATTEN_LED_BLINK 0x0020 |
| 112 | #define ATTEN_LED_OFF 0x0030 |
| 113 | |
| 114 | /* Power Fault */ |
| 115 | #define pwr_fault 0x0040 |
| 116 | |
| 117 | /* Attention Button */ |
| 118 | #define ATTEN_BUTTON 0x0080 |
| 119 | |
| 120 | /* MRL Sensor */ |
| 121 | #define MRL_SENSOR 0x0100 |
| 122 | |
| 123 | /* 66 MHz Capable */ |
| 124 | #define IS_66MHZ_CAP 0x0200 |
| 125 | |
| 126 | /* PRSNT1#/PRSNT2# */ |
| 127 | #define SLOT_EMP 0x0c00 |
| 128 | |
| 129 | /* PCI-X Capability */ |
| 130 | #define NON_PCIX 0x0000 |
| 131 | #define PCIX_66 0x1000 |
| 132 | #define PCIX_133 0x3000 |
| 133 | #define PCIX_266 0x4000 /* For PI = 2 only */ |
| 134 | #define PCIX_533 0x5000 /* For PI = 2 only */ |
| 135 | |
| 136 | /* SHPC 'write' operations/commands */ |
| 137 | |
| 138 | /* Slot operation - 0x00h to 0x3Fh */ |
| 139 | |
| 140 | #define NO_CHANGE 0x00 |
| 141 | |
| 142 | /* Slot state - Bits 0 & 1 of controller command register */ |
| 143 | #define SET_SLOT_PWR 0x01 |
| 144 | #define SET_SLOT_ENABLE 0x02 |
| 145 | #define SET_SLOT_DISABLE 0x03 |
| 146 | |
| 147 | /* Power indicator state - Bits 2 & 3 of controller command register*/ |
| 148 | #define SET_PWR_ON 0x04 |
| 149 | #define SET_PWR_BLINK 0x08 |
| 150 | #define SET_PWR_OFF 0x0C |
| 151 | |
| 152 | /* Attention indicator state - Bits 4 & 5 of controller command register*/ |
| 153 | #define SET_ATTN_ON 0x010 |
| 154 | #define SET_ATTN_BLINK 0x020 |
| 155 | #define SET_ATTN_OFF 0x030 |
| 156 | |
| 157 | /* Set bus speed/mode A - 0x40h to 0x47h */ |
| 158 | #define SETA_PCI_33MHZ 0x40 |
| 159 | #define SETA_PCI_66MHZ 0x41 |
| 160 | #define SETA_PCIX_66MHZ 0x42 |
| 161 | #define SETA_PCIX_100MHZ 0x43 |
| 162 | #define SETA_PCIX_133MHZ 0x44 |
| 163 | #define RESERV_1 0x45 |
| 164 | #define RESERV_2 0x46 |
| 165 | #define RESERV_3 0x47 |
| 166 | |
| 167 | /* Set bus speed/mode B - 0x50h to 0x5fh */ |
| 168 | #define SETB_PCI_33MHZ 0x50 |
| 169 | #define SETB_PCI_66MHZ 0x51 |
| 170 | #define SETB_PCIX_66MHZ_PM 0x52 |
| 171 | #define SETB_PCIX_100MHZ_PM 0x53 |
| 172 | #define SETB_PCIX_133MHZ_PM 0x54 |
| 173 | #define SETB_PCIX_66MHZ_EM 0x55 |
| 174 | #define SETB_PCIX_100MHZ_EM 0x56 |
| 175 | #define SETB_PCIX_133MHZ_EM 0x57 |
| 176 | #define SETB_PCIX_66MHZ_266 0x58 |
| 177 | #define SETB_PCIX_100MHZ_266 0x59 |
| 178 | #define SETB_PCIX_133MHZ_266 0x5a |
| 179 | #define SETB_PCIX_66MHZ_533 0x5b |
| 180 | #define SETB_PCIX_100MHZ_533 0x5c |
| 181 | #define SETB_PCIX_133MHZ_533 0x5d |
| 182 | |
| 183 | |
| 184 | /* Power-on all slots - 0x48h */ |
| 185 | #define SET_PWR_ON_ALL 0x48 |
| 186 | |
| 187 | /* Enable all slots - 0x49h */ |
| 188 | #define SET_ENABLE_ALL 0x49 |
| 189 | |
| 190 | /* SHPC controller command error code */ |
| 191 | #define SWITCH_OPEN 0x1 |
| 192 | #define INVALID_CMD 0x2 |
| 193 | #define INVALID_SPEED_MODE 0x4 |
| 194 | |
| 195 | /* For accessing SHPC Working Register Set */ |
| 196 | #define DWORD_SELECT 0x2 |
| 197 | #define DWORD_DATA 0x4 |
| 198 | #define BASE_OFFSET 0x0 |
| 199 | |
| 200 | /* Field Offset in Logical Slot Register - byte boundary */ |
| 201 | #define SLOT_EVENT_LATCH 0x2 |
| 202 | #define SLOT_SERR_INT_MASK 0x3 |
| 203 | |
| 204 | static spinlock_t hpc_event_lock; |
| 205 | |
| 206 | DEFINE_DBG_BUFFER /* Debug string buffer for entire HPC defined here */ |
| 207 | static struct php_ctlr_state_s *php_ctlr_list_head; /* HPC state linked list */ |
| 208 | static int ctlr_seq_num = 0; /* Controller sequenc # */ |
| 209 | static spinlock_t list_lock; |
| 210 | |
| 211 | static irqreturn_t shpc_isr(int IRQ, void *dev_id, struct pt_regs *regs); |
| 212 | |
| 213 | static void start_int_poll_timer(struct php_ctlr_state_s *php_ctlr, int seconds); |
Kenji Kaneshige | d29aadd | 2006-01-26 09:59:24 +0900 | [diff] [blame] | 214 | static int hpc_check_cmd_status(struct controller *ctrl); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 215 | |
Kenji Kaneshige | 75d97c5 | 2006-05-02 11:08:42 +0900 | [diff] [blame] | 216 | static inline u8 shpc_readb(struct controller *ctrl, int reg) |
| 217 | { |
| 218 | return readb(ctrl->hpc_ctlr_handle->creg + reg); |
| 219 | } |
| 220 | |
| 221 | static inline void shpc_writeb(struct controller *ctrl, int reg, u8 val) |
| 222 | { |
| 223 | writeb(val, ctrl->hpc_ctlr_handle->creg + reg); |
| 224 | } |
| 225 | |
| 226 | static inline u16 shpc_readw(struct controller *ctrl, int reg) |
| 227 | { |
| 228 | return readw(ctrl->hpc_ctlr_handle->creg + reg); |
| 229 | } |
| 230 | |
| 231 | static inline void shpc_writew(struct controller *ctrl, int reg, u16 val) |
| 232 | { |
| 233 | writew(val, ctrl->hpc_ctlr_handle->creg + reg); |
| 234 | } |
| 235 | |
| 236 | static inline u32 shpc_readl(struct controller *ctrl, int reg) |
| 237 | { |
| 238 | return readl(ctrl->hpc_ctlr_handle->creg + reg); |
| 239 | } |
| 240 | |
| 241 | static inline void shpc_writel(struct controller *ctrl, int reg, u32 val) |
| 242 | { |
| 243 | writel(val, ctrl->hpc_ctlr_handle->creg + reg); |
| 244 | } |
| 245 | |
| 246 | static inline int shpc_indirect_read(struct controller *ctrl, int index, |
| 247 | u32 *value) |
| 248 | { |
| 249 | int rc; |
| 250 | u32 cap_offset = ctrl->cap_offset; |
| 251 | struct pci_dev *pdev = ctrl->pci_dev; |
| 252 | |
| 253 | rc = pci_write_config_byte(pdev, cap_offset + DWORD_SELECT, index); |
| 254 | if (rc) |
| 255 | return rc; |
| 256 | return pci_read_config_dword(pdev, cap_offset + DWORD_DATA, value); |
| 257 | } |
| 258 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 259 | /* This is the interrupt polling timeout function. */ |
| 260 | static void int_poll_timeout(unsigned long lphp_ctlr) |
| 261 | { |
| 262 | struct php_ctlr_state_s *php_ctlr = (struct php_ctlr_state_s *)lphp_ctlr; |
| 263 | |
| 264 | DBG_ENTER_ROUTINE |
| 265 | |
| 266 | if ( !php_ctlr ) { |
| 267 | err("%s: Invalid HPC controller handle!\n", __FUNCTION__); |
| 268 | return; |
| 269 | } |
| 270 | |
| 271 | /* Poll for interrupt events. regs == NULL => polling */ |
| 272 | shpc_isr( 0, (void *)php_ctlr, NULL ); |
| 273 | |
| 274 | init_timer(&php_ctlr->int_poll_timer); |
| 275 | if (!shpchp_poll_time) |
| 276 | shpchp_poll_time = 2; /* reset timer to poll in 2 secs if user doesn't specify at module installation*/ |
| 277 | |
| 278 | start_int_poll_timer(php_ctlr, shpchp_poll_time); |
| 279 | |
| 280 | return; |
| 281 | } |
| 282 | |
| 283 | /* This function starts the interrupt polling timer. */ |
| 284 | static void start_int_poll_timer(struct php_ctlr_state_s *php_ctlr, int seconds) |
| 285 | { |
| 286 | if (!php_ctlr) { |
| 287 | err("%s: Invalid HPC controller handle!\n", __FUNCTION__); |
| 288 | return; |
| 289 | } |
| 290 | |
| 291 | if ( ( seconds <= 0 ) || ( seconds > 60 ) ) |
| 292 | seconds = 2; /* Clamp to sane value */ |
| 293 | |
| 294 | php_ctlr->int_poll_timer.function = &int_poll_timeout; |
| 295 | php_ctlr->int_poll_timer.data = (unsigned long)php_ctlr; /* Instance data */ |
| 296 | php_ctlr->int_poll_timer.expires = jiffies + seconds * HZ; |
| 297 | add_timer(&php_ctlr->int_poll_timer); |
| 298 | |
| 299 | return; |
| 300 | } |
| 301 | |
Kenji Kaneshige | bd62e27 | 2005-11-25 12:28:53 +0900 | [diff] [blame] | 302 | static inline int shpc_wait_cmd(struct controller *ctrl) |
| 303 | { |
| 304 | int retval = 0; |
| 305 | unsigned int timeout_msec = shpchp_poll_mode ? 2000 : 1000; |
| 306 | unsigned long timeout = msecs_to_jiffies(timeout_msec); |
| 307 | int rc = wait_event_interruptible_timeout(ctrl->queue, |
| 308 | !ctrl->cmd_busy, timeout); |
| 309 | if (!rc) { |
| 310 | retval = -EIO; |
| 311 | err("Command not completed in %d msec\n", timeout_msec); |
| 312 | } else if (rc < 0) { |
| 313 | retval = -EINTR; |
| 314 | info("Command was interrupted by a signal\n"); |
| 315 | } |
| 316 | ctrl->cmd_busy = 0; |
| 317 | |
| 318 | return retval; |
| 319 | } |
| 320 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 321 | static int shpc_write_cmd(struct slot *slot, u8 t_slot, u8 cmd) |
| 322 | { |
rajesh.shah@intel.com | ee13833 | 2005-10-13 12:05:42 -0700 | [diff] [blame] | 323 | struct php_ctlr_state_s *php_ctlr = slot->ctrl->hpc_ctlr_handle; |
Kenji Kaneshige | 75d97c5 | 2006-05-02 11:08:42 +0900 | [diff] [blame] | 324 | struct controller *ctrl = slot->ctrl; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 325 | u16 cmd_status; |
| 326 | int retval = 0; |
| 327 | u16 temp_word; |
| 328 | int i; |
| 329 | |
| 330 | DBG_ENTER_ROUTINE |
Kenji Kaneshige | d29aadd | 2006-01-26 09:59:24 +0900 | [diff] [blame] | 331 | |
| 332 | mutex_lock(&slot->ctrl->cmd_lock); |
| 333 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 334 | if (!php_ctlr) { |
| 335 | err("%s: Invalid HPC controller handle!\n", __FUNCTION__); |
Kenji Kaneshige | d29aadd | 2006-01-26 09:59:24 +0900 | [diff] [blame] | 336 | retval = -EINVAL; |
| 337 | goto out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 338 | } |
| 339 | |
| 340 | for (i = 0; i < 10; i++) { |
Kenji Kaneshige | 75d97c5 | 2006-05-02 11:08:42 +0900 | [diff] [blame] | 341 | cmd_status = shpc_readw(ctrl, CMD_STATUS); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 342 | |
| 343 | if (!(cmd_status & 0x1)) |
| 344 | break; |
| 345 | /* Check every 0.1 sec for a total of 1 sec*/ |
| 346 | msleep(100); |
| 347 | } |
| 348 | |
Kenji Kaneshige | 75d97c5 | 2006-05-02 11:08:42 +0900 | [diff] [blame] | 349 | cmd_status = shpc_readw(ctrl, CMD_STATUS); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 350 | |
| 351 | if (cmd_status & 0x1) { |
| 352 | /* After 1 sec and and the controller is still busy */ |
| 353 | err("%s : Controller is still busy after 1 sec.\n", __FUNCTION__); |
Kenji Kaneshige | d29aadd | 2006-01-26 09:59:24 +0900 | [diff] [blame] | 354 | retval = -EBUSY; |
| 355 | goto out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 356 | } |
| 357 | |
| 358 | ++t_slot; |
| 359 | temp_word = (t_slot << 8) | (cmd & 0xFF); |
| 360 | dbg("%s: t_slot %x cmd %x\n", __FUNCTION__, t_slot, cmd); |
| 361 | |
| 362 | /* To make sure the Controller Busy bit is 0 before we send out the |
| 363 | * command. |
| 364 | */ |
Kenji Kaneshige | bd62e27 | 2005-11-25 12:28:53 +0900 | [diff] [blame] | 365 | slot->ctrl->cmd_busy = 1; |
Kenji Kaneshige | 75d97c5 | 2006-05-02 11:08:42 +0900 | [diff] [blame] | 366 | shpc_writew(ctrl, CMD, temp_word); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 367 | |
Kenji Kaneshige | bd62e27 | 2005-11-25 12:28:53 +0900 | [diff] [blame] | 368 | /* |
| 369 | * Wait for command completion. |
| 370 | */ |
| 371 | retval = shpc_wait_cmd(slot->ctrl); |
Kenji Kaneshige | d29aadd | 2006-01-26 09:59:24 +0900 | [diff] [blame] | 372 | if (retval) |
| 373 | goto out; |
| 374 | |
| 375 | cmd_status = hpc_check_cmd_status(slot->ctrl); |
| 376 | if (cmd_status) { |
| 377 | err("%s: Failed to issued command 0x%x (error code = %d)\n", |
| 378 | __FUNCTION__, cmd, cmd_status); |
| 379 | retval = -EIO; |
| 380 | } |
| 381 | out: |
| 382 | mutex_unlock(&slot->ctrl->cmd_lock); |
Kenji Kaneshige | bd62e27 | 2005-11-25 12:28:53 +0900 | [diff] [blame] | 383 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 384 | DBG_LEAVE_ROUTINE |
| 385 | return retval; |
| 386 | } |
| 387 | |
| 388 | static int hpc_check_cmd_status(struct controller *ctrl) |
| 389 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 390 | u16 cmd_status; |
| 391 | int retval = 0; |
| 392 | |
| 393 | DBG_ENTER_ROUTINE |
| 394 | |
| 395 | if (!ctrl->hpc_ctlr_handle) { |
| 396 | err("%s: Invalid HPC controller handle!\n", __FUNCTION__); |
| 397 | return -1; |
| 398 | } |
| 399 | |
Kenji Kaneshige | 75d97c5 | 2006-05-02 11:08:42 +0900 | [diff] [blame] | 400 | cmd_status = shpc_readw(ctrl, CMD_STATUS) & 0x000F; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 401 | |
| 402 | switch (cmd_status >> 1) { |
| 403 | case 0: |
| 404 | retval = 0; |
| 405 | break; |
| 406 | case 1: |
| 407 | retval = SWITCH_OPEN; |
| 408 | err("%s: Switch opened!\n", __FUNCTION__); |
| 409 | break; |
| 410 | case 2: |
| 411 | retval = INVALID_CMD; |
| 412 | err("%s: Invalid HPC command!\n", __FUNCTION__); |
| 413 | break; |
| 414 | case 4: |
| 415 | retval = INVALID_SPEED_MODE; |
| 416 | err("%s: Invalid bus speed/mode!\n", __FUNCTION__); |
| 417 | break; |
| 418 | default: |
| 419 | retval = cmd_status; |
| 420 | } |
| 421 | |
| 422 | DBG_LEAVE_ROUTINE |
| 423 | return retval; |
| 424 | } |
| 425 | |
| 426 | |
| 427 | static int hpc_get_attention_status(struct slot *slot, u8 *status) |
| 428 | { |
Kenji Kaneshige | 75d97c5 | 2006-05-02 11:08:42 +0900 | [diff] [blame] | 429 | struct controller *ctrl = slot->ctrl; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 430 | u32 slot_reg; |
| 431 | u16 slot_status; |
| 432 | u8 atten_led_state; |
| 433 | |
| 434 | DBG_ENTER_ROUTINE |
| 435 | |
| 436 | if (!slot->ctrl->hpc_ctlr_handle) { |
| 437 | err("%s: Invalid HPC controller handle!\n", __FUNCTION__); |
| 438 | return -1; |
| 439 | } |
| 440 | |
Kenji Kaneshige | 2b34da7 | 2006-05-02 11:09:42 +0900 | [diff] [blame^] | 441 | slot_reg = shpc_readl(ctrl, SLOT_REG(slot->hp_slot)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 442 | slot_status = (u16) slot_reg; |
| 443 | atten_led_state = (slot_status & 0x0030) >> 4; |
| 444 | |
| 445 | switch (atten_led_state) { |
| 446 | case 0: |
| 447 | *status = 0xFF; /* Reserved */ |
| 448 | break; |
| 449 | case 1: |
| 450 | *status = 1; /* On */ |
| 451 | break; |
| 452 | case 2: |
| 453 | *status = 2; /* Blink */ |
| 454 | break; |
| 455 | case 3: |
| 456 | *status = 0; /* Off */ |
| 457 | break; |
| 458 | default: |
| 459 | *status = 0xFF; |
| 460 | break; |
| 461 | } |
| 462 | |
| 463 | DBG_LEAVE_ROUTINE |
| 464 | return 0; |
| 465 | } |
| 466 | |
| 467 | static int hpc_get_power_status(struct slot * slot, u8 *status) |
| 468 | { |
Kenji Kaneshige | 75d97c5 | 2006-05-02 11:08:42 +0900 | [diff] [blame] | 469 | struct controller *ctrl = slot->ctrl; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 470 | u32 slot_reg; |
| 471 | u16 slot_status; |
| 472 | u8 slot_state; |
| 473 | int retval = 0; |
| 474 | |
| 475 | DBG_ENTER_ROUTINE |
| 476 | |
| 477 | if (!slot->ctrl->hpc_ctlr_handle) { |
| 478 | err("%s: Invalid HPC controller handle!\n", __FUNCTION__); |
| 479 | return -1; |
| 480 | } |
| 481 | |
Kenji Kaneshige | 2b34da7 | 2006-05-02 11:09:42 +0900 | [diff] [blame^] | 482 | slot_reg = shpc_readl(ctrl, SLOT_REG(slot->hp_slot)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 483 | slot_status = (u16) slot_reg; |
| 484 | slot_state = (slot_status & 0x0003); |
| 485 | |
| 486 | switch (slot_state) { |
| 487 | case 0: |
| 488 | *status = 0xFF; |
| 489 | break; |
| 490 | case 1: |
| 491 | *status = 2; /* Powered only */ |
| 492 | break; |
| 493 | case 2: |
| 494 | *status = 1; /* Enabled */ |
| 495 | break; |
| 496 | case 3: |
| 497 | *status = 0; /* Disabled */ |
| 498 | break; |
| 499 | default: |
| 500 | *status = 0xFF; |
| 501 | break; |
| 502 | } |
| 503 | |
| 504 | DBG_LEAVE_ROUTINE |
| 505 | return retval; |
| 506 | } |
| 507 | |
| 508 | |
| 509 | static int hpc_get_latch_status(struct slot *slot, u8 *status) |
| 510 | { |
Kenji Kaneshige | 75d97c5 | 2006-05-02 11:08:42 +0900 | [diff] [blame] | 511 | struct controller *ctrl = slot->ctrl; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 512 | u32 slot_reg; |
| 513 | u16 slot_status; |
| 514 | |
| 515 | DBG_ENTER_ROUTINE |
| 516 | |
| 517 | if (!slot->ctrl->hpc_ctlr_handle) { |
| 518 | err("%s: Invalid HPC controller handle!\n", __FUNCTION__); |
| 519 | return -1; |
| 520 | } |
| 521 | |
Kenji Kaneshige | 2b34da7 | 2006-05-02 11:09:42 +0900 | [diff] [blame^] | 522 | slot_reg = shpc_readl(ctrl, SLOT_REG(slot->hp_slot)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 523 | slot_status = (u16)slot_reg; |
| 524 | |
| 525 | *status = ((slot_status & 0x0100) == 0) ? 0 : 1; /* 0 -> close; 1 -> open */ |
| 526 | |
| 527 | |
| 528 | DBG_LEAVE_ROUTINE |
| 529 | return 0; |
| 530 | } |
| 531 | |
| 532 | static int hpc_get_adapter_status(struct slot *slot, u8 *status) |
| 533 | { |
Kenji Kaneshige | 75d97c5 | 2006-05-02 11:08:42 +0900 | [diff] [blame] | 534 | struct controller *ctrl = slot->ctrl; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 535 | u32 slot_reg; |
| 536 | u16 slot_status; |
| 537 | u8 card_state; |
| 538 | |
| 539 | DBG_ENTER_ROUTINE |
| 540 | |
| 541 | if (!slot->ctrl->hpc_ctlr_handle) { |
| 542 | err("%s: Invalid HPC controller handle!\n", __FUNCTION__); |
| 543 | return -1; |
| 544 | } |
| 545 | |
Kenji Kaneshige | 2b34da7 | 2006-05-02 11:09:42 +0900 | [diff] [blame^] | 546 | slot_reg = shpc_readl(ctrl, SLOT_REG(slot->hp_slot)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 547 | slot_status = (u16)slot_reg; |
| 548 | card_state = (u8)((slot_status & 0x0C00) >> 10); |
| 549 | *status = (card_state != 0x3) ? 1 : 0; |
| 550 | |
| 551 | DBG_LEAVE_ROUTINE |
| 552 | return 0; |
| 553 | } |
| 554 | |
| 555 | static int hpc_get_prog_int(struct slot *slot, u8 *prog_int) |
| 556 | { |
Kenji Kaneshige | 75d97c5 | 2006-05-02 11:08:42 +0900 | [diff] [blame] | 557 | struct controller *ctrl = slot->ctrl; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 558 | |
| 559 | DBG_ENTER_ROUTINE |
| 560 | |
| 561 | if (!slot->ctrl->hpc_ctlr_handle) { |
| 562 | err("%s: Invalid HPC controller handle!\n", __FUNCTION__); |
| 563 | return -1; |
| 564 | } |
| 565 | |
Kenji Kaneshige | 75d97c5 | 2006-05-02 11:08:42 +0900 | [diff] [blame] | 566 | *prog_int = shpc_readb(ctrl, PROG_INTERFACE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 567 | |
| 568 | DBG_LEAVE_ROUTINE |
| 569 | return 0; |
| 570 | } |
| 571 | |
| 572 | static int hpc_get_adapter_speed(struct slot *slot, enum pci_bus_speed *value) |
| 573 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 574 | int retval = 0; |
Kenji Kaneshige | 75d97c5 | 2006-05-02 11:08:42 +0900 | [diff] [blame] | 575 | struct controller *ctrl = slot->ctrl; |
Kenji Kaneshige | 2b34da7 | 2006-05-02 11:09:42 +0900 | [diff] [blame^] | 576 | u32 slot_reg = shpc_readl(ctrl, SLOT_REG(slot->hp_slot)); |
Kenji Kaneshige | 0afabe9 | 2006-03-01 14:55:11 +0900 | [diff] [blame] | 577 | u8 pcix_cap = (slot_reg >> 12) & 7; |
| 578 | u8 m66_cap = (slot_reg >> 9) & 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 579 | |
| 580 | DBG_ENTER_ROUTINE |
| 581 | |
Kenji Kaneshige | 0afabe9 | 2006-03-01 14:55:11 +0900 | [diff] [blame] | 582 | dbg("%s: slot_reg = %x, pcix_cap = %x, m66_cap = %x\n", |
| 583 | __FUNCTION__, slot_reg, pcix_cap, m66_cap); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 584 | |
Kenji Kaneshige | 0afabe9 | 2006-03-01 14:55:11 +0900 | [diff] [blame] | 585 | switch (pcix_cap) { |
| 586 | case 0x0: |
| 587 | *value = m66_cap ? PCI_SPEED_66MHz : PCI_SPEED_33MHz; |
| 588 | break; |
| 589 | case 0x1: |
| 590 | *value = PCI_SPEED_66MHz_PCIX; |
| 591 | break; |
| 592 | case 0x3: |
| 593 | *value = PCI_SPEED_133MHz_PCIX; |
| 594 | break; |
| 595 | case 0x4: |
| 596 | *value = PCI_SPEED_133MHz_PCIX_266; |
| 597 | break; |
| 598 | case 0x5: |
| 599 | *value = PCI_SPEED_133MHz_PCIX_533; |
| 600 | break; |
| 601 | case 0x2: |
| 602 | default: |
| 603 | *value = PCI_SPEED_UNKNOWN; |
| 604 | retval = -ENODEV; |
| 605 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 606 | } |
| 607 | |
| 608 | dbg("Adapter speed = %d\n", *value); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 609 | DBG_LEAVE_ROUTINE |
| 610 | return retval; |
| 611 | } |
| 612 | |
| 613 | static int hpc_get_mode1_ECC_cap(struct slot *slot, u8 *mode) |
| 614 | { |
Kenji Kaneshige | 75d97c5 | 2006-05-02 11:08:42 +0900 | [diff] [blame] | 615 | struct controller *ctrl = slot->ctrl; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 616 | u16 sec_bus_status; |
| 617 | u8 pi; |
| 618 | int retval = 0; |
| 619 | |
| 620 | DBG_ENTER_ROUTINE |
| 621 | |
| 622 | if (!slot->ctrl->hpc_ctlr_handle) { |
| 623 | err("%s: Invalid HPC controller handle!\n", __FUNCTION__); |
| 624 | return -1; |
| 625 | } |
| 626 | |
Kenji Kaneshige | 75d97c5 | 2006-05-02 11:08:42 +0900 | [diff] [blame] | 627 | pi = shpc_readb(ctrl, PROG_INTERFACE); |
| 628 | sec_bus_status = shpc_readw(ctrl, SEC_BUS_CONFIG); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 629 | |
| 630 | if (pi == 2) { |
Kenji Kaneshige | 87d6c55 | 2005-11-24 11:35:05 +0900 | [diff] [blame] | 631 | *mode = (sec_bus_status & 0x0100) >> 8; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 632 | } else { |
| 633 | retval = -1; |
| 634 | } |
| 635 | |
| 636 | dbg("Mode 1 ECC cap = %d\n", *mode); |
| 637 | |
| 638 | DBG_LEAVE_ROUTINE |
| 639 | return retval; |
| 640 | } |
| 641 | |
| 642 | static int hpc_query_power_fault(struct slot * slot) |
| 643 | { |
Kenji Kaneshige | 75d97c5 | 2006-05-02 11:08:42 +0900 | [diff] [blame] | 644 | struct controller *ctrl = slot->ctrl; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 645 | u32 slot_reg; |
| 646 | u16 slot_status; |
| 647 | u8 pwr_fault_state, status; |
| 648 | |
| 649 | DBG_ENTER_ROUTINE |
| 650 | |
| 651 | if (!slot->ctrl->hpc_ctlr_handle) { |
| 652 | err("%s: Invalid HPC controller handle!\n", __FUNCTION__); |
| 653 | return -1; |
| 654 | } |
| 655 | |
Kenji Kaneshige | 2b34da7 | 2006-05-02 11:09:42 +0900 | [diff] [blame^] | 656 | slot_reg = shpc_readl(ctrl, SLOT_REG(slot->hp_slot)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 657 | slot_status = (u16) slot_reg; |
| 658 | pwr_fault_state = (slot_status & 0x0040) >> 7; |
| 659 | status = (pwr_fault_state == 1) ? 0 : 1; |
| 660 | |
| 661 | DBG_LEAVE_ROUTINE |
| 662 | /* Note: Logic 0 => fault */ |
| 663 | return status; |
| 664 | } |
| 665 | |
| 666 | static int hpc_set_attention_status(struct slot *slot, u8 value) |
| 667 | { |
rajesh.shah@intel.com | ee13833 | 2005-10-13 12:05:42 -0700 | [diff] [blame] | 668 | struct php_ctlr_state_s *php_ctlr = slot->ctrl->hpc_ctlr_handle; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 669 | u8 slot_cmd = 0; |
| 670 | int rc = 0; |
| 671 | |
| 672 | if (!slot->ctrl->hpc_ctlr_handle) { |
| 673 | err("%s: Invalid HPC controller handle!\n", __FUNCTION__); |
| 674 | return -1; |
| 675 | } |
| 676 | |
| 677 | if (slot->hp_slot >= php_ctlr->num_slots) { |
| 678 | err("%s: Invalid HPC slot number!\n", __FUNCTION__); |
| 679 | return -1; |
| 680 | } |
| 681 | |
| 682 | switch (value) { |
| 683 | case 0 : |
| 684 | slot_cmd = 0x30; /* OFF */ |
| 685 | break; |
| 686 | case 1: |
| 687 | slot_cmd = 0x10; /* ON */ |
| 688 | break; |
| 689 | case 2: |
| 690 | slot_cmd = 0x20; /* BLINK */ |
| 691 | break; |
| 692 | default: |
| 693 | return -1; |
| 694 | } |
| 695 | |
| 696 | shpc_write_cmd(slot, slot->hp_slot, slot_cmd); |
| 697 | |
| 698 | return rc; |
| 699 | } |
| 700 | |
| 701 | |
| 702 | static void hpc_set_green_led_on(struct slot *slot) |
| 703 | { |
rajesh.shah@intel.com | ee13833 | 2005-10-13 12:05:42 -0700 | [diff] [blame] | 704 | struct php_ctlr_state_s *php_ctlr = slot->ctrl->hpc_ctlr_handle; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 705 | u8 slot_cmd; |
| 706 | |
| 707 | if (!slot->ctrl->hpc_ctlr_handle) { |
| 708 | err("%s: Invalid HPC controller handle!\n", __FUNCTION__); |
| 709 | return ; |
| 710 | } |
| 711 | |
| 712 | if (slot->hp_slot >= php_ctlr->num_slots) { |
| 713 | err("%s: Invalid HPC slot number!\n", __FUNCTION__); |
| 714 | return ; |
| 715 | } |
| 716 | |
| 717 | slot_cmd = 0x04; |
| 718 | |
| 719 | shpc_write_cmd(slot, slot->hp_slot, slot_cmd); |
| 720 | |
| 721 | return; |
| 722 | } |
| 723 | |
| 724 | static void hpc_set_green_led_off(struct slot *slot) |
| 725 | { |
rajesh.shah@intel.com | ee13833 | 2005-10-13 12:05:42 -0700 | [diff] [blame] | 726 | struct php_ctlr_state_s *php_ctlr = slot->ctrl->hpc_ctlr_handle; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 727 | u8 slot_cmd; |
| 728 | |
| 729 | if (!slot->ctrl->hpc_ctlr_handle) { |
| 730 | err("%s: Invalid HPC controller handle!\n", __FUNCTION__); |
| 731 | return ; |
| 732 | } |
| 733 | |
| 734 | if (slot->hp_slot >= php_ctlr->num_slots) { |
| 735 | err("%s: Invalid HPC slot number!\n", __FUNCTION__); |
| 736 | return ; |
| 737 | } |
| 738 | |
| 739 | slot_cmd = 0x0C; |
| 740 | |
| 741 | shpc_write_cmd(slot, slot->hp_slot, slot_cmd); |
| 742 | |
| 743 | return; |
| 744 | } |
| 745 | |
| 746 | static void hpc_set_green_led_blink(struct slot *slot) |
| 747 | { |
rajesh.shah@intel.com | ee13833 | 2005-10-13 12:05:42 -0700 | [diff] [blame] | 748 | struct php_ctlr_state_s *php_ctlr = slot->ctrl->hpc_ctlr_handle; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 749 | u8 slot_cmd; |
| 750 | |
| 751 | if (!slot->ctrl->hpc_ctlr_handle) { |
| 752 | err("%s: Invalid HPC controller handle!\n", __FUNCTION__); |
| 753 | return ; |
| 754 | } |
| 755 | |
| 756 | if (slot->hp_slot >= php_ctlr->num_slots) { |
| 757 | err("%s: Invalid HPC slot number!\n", __FUNCTION__); |
| 758 | return ; |
| 759 | } |
| 760 | |
| 761 | slot_cmd = 0x08; |
| 762 | |
| 763 | shpc_write_cmd(slot, slot->hp_slot, slot_cmd); |
| 764 | |
| 765 | return; |
| 766 | } |
| 767 | |
| 768 | int shpc_get_ctlr_slot_config(struct controller *ctrl, |
| 769 | int *num_ctlr_slots, /* number of slots in this HPC */ |
| 770 | int *first_device_num, /* PCI dev num of the first slot in this SHPC */ |
| 771 | int *physical_slot_num, /* phy slot num of the first slot in this SHPC */ |
| 772 | int *updown, /* physical_slot_num increament: 1 or -1 */ |
| 773 | int *flags) |
| 774 | { |
Kenji Kaneshige | 75d97c5 | 2006-05-02 11:08:42 +0900 | [diff] [blame] | 775 | u32 slot_config; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 776 | |
| 777 | DBG_ENTER_ROUTINE |
| 778 | |
| 779 | if (!ctrl->hpc_ctlr_handle) { |
| 780 | err("%s: Invalid HPC controller handle!\n", __FUNCTION__); |
| 781 | return -1; |
| 782 | } |
| 783 | |
Kenji Kaneshige | 75d97c5 | 2006-05-02 11:08:42 +0900 | [diff] [blame] | 784 | slot_config = shpc_readl(ctrl, SLOT_CONFIG); |
| 785 | *first_device_num = (slot_config & FIRST_DEV_NUM) >> 8; |
| 786 | *num_ctlr_slots = slot_config & SLOT_NUM; |
| 787 | *physical_slot_num = (slot_config & PSN) >> 16; |
| 788 | *updown = ((slot_config & UPDOWN) >> 29) ? 1 : -1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 789 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 790 | dbg("%s: physical_slot_num = %x\n", __FUNCTION__, *physical_slot_num); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 791 | |
| 792 | DBG_LEAVE_ROUTINE |
| 793 | return 0; |
| 794 | } |
| 795 | |
| 796 | static void hpc_release_ctlr(struct controller *ctrl) |
| 797 | { |
rajesh.shah@intel.com | ee13833 | 2005-10-13 12:05:42 -0700 | [diff] [blame] | 798 | struct php_ctlr_state_s *php_ctlr = ctrl->hpc_ctlr_handle; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 799 | struct php_ctlr_state_s *p, *p_prev; |
Kenji Kaneshige | f7391f5 | 2006-02-21 15:45:45 -0800 | [diff] [blame] | 800 | int i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 801 | |
| 802 | DBG_ENTER_ROUTINE |
| 803 | |
| 804 | if (!ctrl->hpc_ctlr_handle) { |
| 805 | err("%s: Invalid HPC controller handle!\n", __FUNCTION__); |
| 806 | return ; |
| 807 | } |
| 808 | |
Kenji Kaneshige | f7391f5 | 2006-02-21 15:45:45 -0800 | [diff] [blame] | 809 | /* |
| 810 | * Mask all slot event interrupts |
| 811 | */ |
| 812 | for (i = 0; i < ctrl->num_slots; i++) |
Kenji Kaneshige | 2b34da7 | 2006-05-02 11:09:42 +0900 | [diff] [blame^] | 813 | shpc_writel(ctrl, SLOT_REG(i), 0xffff3fff); |
Kenji Kaneshige | f7391f5 | 2006-02-21 15:45:45 -0800 | [diff] [blame] | 814 | |
| 815 | cleanup_slots(ctrl); |
| 816 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 817 | if (shpchp_poll_mode) { |
| 818 | del_timer(&php_ctlr->int_poll_timer); |
| 819 | } else { |
| 820 | if (php_ctlr->irq) { |
| 821 | free_irq(php_ctlr->irq, ctrl); |
| 822 | php_ctlr->irq = 0; |
| 823 | pci_disable_msi(php_ctlr->pci_dev); |
| 824 | } |
| 825 | } |
Kenji Kaneshige | f7391f5 | 2006-02-21 15:45:45 -0800 | [diff] [blame] | 826 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 827 | if (php_ctlr->pci_dev) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 828 | iounmap(php_ctlr->creg); |
Kenji Kaneshige | 0455986 | 2005-11-24 11:36:59 +0900 | [diff] [blame] | 829 | release_mem_region(ctrl->mmio_base, ctrl->mmio_size); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 830 | php_ctlr->pci_dev = NULL; |
| 831 | } |
| 832 | |
| 833 | spin_lock(&list_lock); |
| 834 | p = php_ctlr_list_head; |
| 835 | p_prev = NULL; |
| 836 | while (p) { |
| 837 | if (p == php_ctlr) { |
| 838 | if (p_prev) |
| 839 | p_prev->pnext = p->pnext; |
| 840 | else |
| 841 | php_ctlr_list_head = p->pnext; |
| 842 | break; |
| 843 | } else { |
| 844 | p_prev = p; |
| 845 | p = p->pnext; |
| 846 | } |
| 847 | } |
| 848 | spin_unlock(&list_lock); |
| 849 | |
| 850 | kfree(php_ctlr); |
| 851 | |
| 852 | DBG_LEAVE_ROUTINE |
| 853 | |
| 854 | } |
| 855 | |
| 856 | static int hpc_power_on_slot(struct slot * slot) |
| 857 | { |
rajesh.shah@intel.com | ee13833 | 2005-10-13 12:05:42 -0700 | [diff] [blame] | 858 | struct php_ctlr_state_s *php_ctlr = slot->ctrl->hpc_ctlr_handle; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 859 | u8 slot_cmd; |
| 860 | int retval = 0; |
| 861 | |
| 862 | DBG_ENTER_ROUTINE |
| 863 | |
| 864 | if (!slot->ctrl->hpc_ctlr_handle) { |
| 865 | err("%s: Invalid HPC controller handle!\n", __FUNCTION__); |
| 866 | return -1; |
| 867 | } |
| 868 | |
| 869 | if (slot->hp_slot >= php_ctlr->num_slots) { |
| 870 | err("%s: Invalid HPC slot number!\n", __FUNCTION__); |
| 871 | return -1; |
| 872 | } |
| 873 | slot_cmd = 0x01; |
| 874 | |
| 875 | retval = shpc_write_cmd(slot, slot->hp_slot, slot_cmd); |
| 876 | |
| 877 | if (retval) { |
| 878 | err("%s: Write command failed!\n", __FUNCTION__); |
| 879 | return -1; |
| 880 | } |
| 881 | |
| 882 | DBG_LEAVE_ROUTINE |
| 883 | |
| 884 | return retval; |
| 885 | } |
| 886 | |
| 887 | static int hpc_slot_enable(struct slot * slot) |
| 888 | { |
rajesh.shah@intel.com | ee13833 | 2005-10-13 12:05:42 -0700 | [diff] [blame] | 889 | struct php_ctlr_state_s *php_ctlr = slot->ctrl->hpc_ctlr_handle; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 890 | u8 slot_cmd; |
| 891 | int retval = 0; |
| 892 | |
| 893 | DBG_ENTER_ROUTINE |
| 894 | |
| 895 | if (!slot->ctrl->hpc_ctlr_handle) { |
| 896 | err("%s: Invalid HPC controller handle!\n", __FUNCTION__); |
| 897 | return -1; |
| 898 | } |
| 899 | |
| 900 | if (slot->hp_slot >= php_ctlr->num_slots) { |
| 901 | err("%s: Invalid HPC slot number!\n", __FUNCTION__); |
| 902 | return -1; |
| 903 | } |
| 904 | /* 3A => Slot - Enable, Power Indicator - Blink, Attention Indicator - Off */ |
| 905 | slot_cmd = 0x3A; |
| 906 | |
| 907 | retval = shpc_write_cmd(slot, slot->hp_slot, slot_cmd); |
| 908 | |
| 909 | if (retval) { |
| 910 | err("%s: Write command failed!\n", __FUNCTION__); |
| 911 | return -1; |
| 912 | } |
| 913 | |
| 914 | DBG_LEAVE_ROUTINE |
| 915 | return retval; |
| 916 | } |
| 917 | |
| 918 | static int hpc_slot_disable(struct slot * slot) |
| 919 | { |
rajesh.shah@intel.com | ee13833 | 2005-10-13 12:05:42 -0700 | [diff] [blame] | 920 | struct php_ctlr_state_s *php_ctlr = slot->ctrl->hpc_ctlr_handle; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 921 | u8 slot_cmd; |
| 922 | int retval = 0; |
| 923 | |
| 924 | DBG_ENTER_ROUTINE |
| 925 | |
| 926 | if (!slot->ctrl->hpc_ctlr_handle) { |
| 927 | err("%s: Invalid HPC controller handle!\n", __FUNCTION__); |
| 928 | return -1; |
| 929 | } |
| 930 | |
| 931 | if (slot->hp_slot >= php_ctlr->num_slots) { |
| 932 | err("%s: Invalid HPC slot number!\n", __FUNCTION__); |
| 933 | return -1; |
| 934 | } |
| 935 | |
| 936 | /* 1F => Slot - Disable, Power Indicator - Off, Attention Indicator - On */ |
| 937 | slot_cmd = 0x1F; |
| 938 | |
| 939 | retval = shpc_write_cmd(slot, slot->hp_slot, slot_cmd); |
| 940 | |
| 941 | if (retval) { |
| 942 | err("%s: Write command failed!\n", __FUNCTION__); |
| 943 | return -1; |
| 944 | } |
| 945 | |
| 946 | DBG_LEAVE_ROUTINE |
| 947 | return retval; |
| 948 | } |
| 949 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 950 | static int hpc_set_bus_speed_mode(struct slot * slot, enum pci_bus_speed value) |
| 951 | { |
Kenji Kaneshige | 0afabe9 | 2006-03-01 14:55:11 +0900 | [diff] [blame] | 952 | int retval; |
Kenji Kaneshige | 75d97c5 | 2006-05-02 11:08:42 +0900 | [diff] [blame] | 953 | struct controller *ctrl = slot->ctrl; |
Kenji Kaneshige | 0afabe9 | 2006-03-01 14:55:11 +0900 | [diff] [blame] | 954 | u8 pi, cmd; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 955 | |
| 956 | DBG_ENTER_ROUTINE |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 957 | |
Kenji Kaneshige | 75d97c5 | 2006-05-02 11:08:42 +0900 | [diff] [blame] | 958 | pi = shpc_readb(ctrl, PROG_INTERFACE); |
Kenji Kaneshige | 0afabe9 | 2006-03-01 14:55:11 +0900 | [diff] [blame] | 959 | if ((pi == 1) && (value > PCI_SPEED_133MHz_PCIX)) |
| 960 | return -EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 961 | |
Kenji Kaneshige | 0afabe9 | 2006-03-01 14:55:11 +0900 | [diff] [blame] | 962 | switch (value) { |
| 963 | case PCI_SPEED_33MHz: |
| 964 | cmd = SETA_PCI_33MHZ; |
| 965 | break; |
| 966 | case PCI_SPEED_66MHz: |
| 967 | cmd = SETA_PCI_66MHZ; |
| 968 | break; |
| 969 | case PCI_SPEED_66MHz_PCIX: |
| 970 | cmd = SETA_PCIX_66MHZ; |
| 971 | break; |
| 972 | case PCI_SPEED_100MHz_PCIX: |
| 973 | cmd = SETA_PCIX_100MHZ; |
| 974 | break; |
| 975 | case PCI_SPEED_133MHz_PCIX: |
| 976 | cmd = SETA_PCIX_133MHZ; |
| 977 | break; |
| 978 | case PCI_SPEED_66MHz_PCIX_ECC: |
| 979 | cmd = SETB_PCIX_66MHZ_EM; |
| 980 | break; |
| 981 | case PCI_SPEED_100MHz_PCIX_ECC: |
| 982 | cmd = SETB_PCIX_100MHZ_EM; |
| 983 | break; |
| 984 | case PCI_SPEED_133MHz_PCIX_ECC: |
| 985 | cmd = SETB_PCIX_133MHZ_EM; |
| 986 | break; |
| 987 | case PCI_SPEED_66MHz_PCIX_266: |
| 988 | cmd = SETB_PCIX_66MHZ_266; |
| 989 | break; |
| 990 | case PCI_SPEED_100MHz_PCIX_266: |
| 991 | cmd = SETB_PCIX_100MHZ_266; |
| 992 | break; |
| 993 | case PCI_SPEED_133MHz_PCIX_266: |
| 994 | cmd = SETB_PCIX_133MHZ_266; |
| 995 | break; |
| 996 | case PCI_SPEED_66MHz_PCIX_533: |
| 997 | cmd = SETB_PCIX_66MHZ_533; |
| 998 | break; |
| 999 | case PCI_SPEED_100MHz_PCIX_533: |
| 1000 | cmd = SETB_PCIX_100MHZ_533; |
| 1001 | break; |
| 1002 | case PCI_SPEED_133MHz_PCIX_533: |
| 1003 | cmd = SETB_PCIX_133MHZ_533; |
| 1004 | break; |
| 1005 | default: |
| 1006 | return -EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1007 | } |
Kenji Kaneshige | 0afabe9 | 2006-03-01 14:55:11 +0900 | [diff] [blame] | 1008 | |
| 1009 | retval = shpc_write_cmd(slot, 0, cmd); |
| 1010 | if (retval) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1011 | err("%s: Write command failed!\n", __FUNCTION__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1012 | |
| 1013 | DBG_LEAVE_ROUTINE |
| 1014 | return retval; |
| 1015 | } |
| 1016 | |
| 1017 | static irqreturn_t shpc_isr(int IRQ, void *dev_id, struct pt_regs *regs) |
| 1018 | { |
| 1019 | struct controller *ctrl = NULL; |
| 1020 | struct php_ctlr_state_s *php_ctlr; |
| 1021 | u8 schedule_flag = 0; |
| 1022 | u8 temp_byte; |
| 1023 | u32 temp_dword, intr_loc, intr_loc2; |
| 1024 | int hp_slot; |
| 1025 | |
| 1026 | if (!dev_id) |
| 1027 | return IRQ_NONE; |
| 1028 | |
| 1029 | if (!shpchp_poll_mode) { |
| 1030 | ctrl = (struct controller *)dev_id; |
| 1031 | php_ctlr = ctrl->hpc_ctlr_handle; |
| 1032 | } else { |
| 1033 | php_ctlr = (struct php_ctlr_state_s *) dev_id; |
| 1034 | ctrl = (struct controller *)php_ctlr->callback_instance_id; |
| 1035 | } |
| 1036 | |
| 1037 | if (!ctrl) |
| 1038 | return IRQ_NONE; |
| 1039 | |
| 1040 | if (!php_ctlr || !php_ctlr->creg) |
| 1041 | return IRQ_NONE; |
| 1042 | |
| 1043 | /* Check to see if it was our interrupt */ |
Kenji Kaneshige | 75d97c5 | 2006-05-02 11:08:42 +0900 | [diff] [blame] | 1044 | intr_loc = shpc_readl(ctrl, INTR_LOC); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1045 | |
| 1046 | if (!intr_loc) |
| 1047 | return IRQ_NONE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1048 | dbg("%s: intr_loc = %x\n",__FUNCTION__, intr_loc); |
| 1049 | |
| 1050 | if(!shpchp_poll_mode) { |
| 1051 | /* Mask Global Interrupt Mask - see implementation note on p. 139 */ |
| 1052 | /* of SHPC spec rev 1.0*/ |
Kenji Kaneshige | 75d97c5 | 2006-05-02 11:08:42 +0900 | [diff] [blame] | 1053 | temp_dword = shpc_readl(ctrl, SERR_INTR_ENABLE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1054 | temp_dword |= 0x00000001; |
Kenji Kaneshige | 75d97c5 | 2006-05-02 11:08:42 +0900 | [diff] [blame] | 1055 | shpc_writel(ctrl, SERR_INTR_ENABLE, temp_dword); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1056 | |
Kenji Kaneshige | 75d97c5 | 2006-05-02 11:08:42 +0900 | [diff] [blame] | 1057 | intr_loc2 = shpc_readl(ctrl, INTR_LOC); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1058 | dbg("%s: intr_loc2 = %x\n",__FUNCTION__, intr_loc2); |
| 1059 | } |
| 1060 | |
| 1061 | if (intr_loc & 0x0001) { |
| 1062 | /* |
| 1063 | * Command Complete Interrupt Pending |
Kenji Kaneshige | f467f61 | 2005-11-24 11:39:29 +0900 | [diff] [blame] | 1064 | * RO only - clear by writing 1 to the Command Completion |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1065 | * Detect bit in Controller SERR-INT register |
| 1066 | */ |
Kenji Kaneshige | 75d97c5 | 2006-05-02 11:08:42 +0900 | [diff] [blame] | 1067 | temp_dword = shpc_readl(ctrl, SERR_INTR_ENABLE); |
Kenji Kaneshige | f467f61 | 2005-11-24 11:39:29 +0900 | [diff] [blame] | 1068 | temp_dword &= 0xfffdffff; |
Kenji Kaneshige | 75d97c5 | 2006-05-02 11:08:42 +0900 | [diff] [blame] | 1069 | shpc_writel(ctrl, SERR_INTR_ENABLE, temp_dword); |
Kenji Kaneshige | bd62e27 | 2005-11-25 12:28:53 +0900 | [diff] [blame] | 1070 | ctrl->cmd_busy = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1071 | wake_up_interruptible(&ctrl->queue); |
| 1072 | } |
| 1073 | |
Kenji Kaneshige | e4e7304 | 2006-01-26 10:05:57 +0900 | [diff] [blame] | 1074 | if ((intr_loc = (intr_loc >> 1)) == 0) |
| 1075 | goto out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1076 | |
| 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) { |
Kenji Kaneshige | 2b34da7 | 2006-05-02 11:09:42 +0900 | [diff] [blame^] | 1080 | temp_dword = shpc_readl(ctrl, SLOT_REG(hp_slot)); |
rajesh.shah@intel.com | 7c8942f | 2005-10-13 12:05:43 -0700 | [diff] [blame] | 1081 | dbg("%s: Slot %x with intr, slot register = %x\n", |
| 1082 | __FUNCTION__, hp_slot, temp_dword); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1083 | temp_byte = (temp_dword >> 16) & 0xFF; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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); |
| 1096 | |
| 1097 | /* Clear all slot events */ |
| 1098 | temp_dword = 0xe01f3fff; |
Kenji Kaneshige | 2b34da7 | 2006-05-02 11:09:42 +0900 | [diff] [blame^] | 1099 | shpc_writel(ctrl, SLOT_REG(hp_slot), temp_dword); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1100 | |
Kenji Kaneshige | 75d97c5 | 2006-05-02 11:08:42 +0900 | [diff] [blame] | 1101 | intr_loc2 = shpc_readl(ctrl, INTR_LOC); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1102 | dbg("%s: intr_loc2 = %x\n",__FUNCTION__, intr_loc2); |
| 1103 | } |
| 1104 | } |
Kenji Kaneshige | e4e7304 | 2006-01-26 10:05:57 +0900 | [diff] [blame] | 1105 | out: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1106 | if (!shpchp_poll_mode) { |
| 1107 | /* Unmask Global Interrupt Mask */ |
Kenji Kaneshige | 75d97c5 | 2006-05-02 11:08:42 +0900 | [diff] [blame] | 1108 | temp_dword = shpc_readl(ctrl, SERR_INTR_ENABLE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1109 | temp_dword &= 0xfffffffe; |
Kenji Kaneshige | 75d97c5 | 2006-05-02 11:08:42 +0900 | [diff] [blame] | 1110 | shpc_writel(ctrl, SERR_INTR_ENABLE, temp_dword); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1111 | } |
| 1112 | |
| 1113 | return IRQ_HANDLED; |
| 1114 | } |
| 1115 | |
| 1116 | static int hpc_get_max_bus_speed (struct slot *slot, enum pci_bus_speed *value) |
| 1117 | { |
Kenji Kaneshige | 0afabe9 | 2006-03-01 14:55:11 +0900 | [diff] [blame] | 1118 | int retval = 0; |
Kenji Kaneshige | 75d97c5 | 2006-05-02 11:08:42 +0900 | [diff] [blame] | 1119 | struct controller *ctrl = slot->ctrl; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1120 | enum pci_bus_speed bus_speed = PCI_SPEED_UNKNOWN; |
Kenji Kaneshige | 75d97c5 | 2006-05-02 11:08:42 +0900 | [diff] [blame] | 1121 | u8 pi = shpc_readb(ctrl, PROG_INTERFACE); |
| 1122 | u32 slot_avail1 = shpc_readl(ctrl, SLOT_AVAIL1); |
| 1123 | u32 slot_avail2 = shpc_readl(ctrl, SLOT_AVAIL2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1124 | |
| 1125 | DBG_ENTER_ROUTINE |
| 1126 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1127 | if (pi == 2) { |
Kenji Kaneshige | 6558b6a | 2005-11-24 13:44:01 +0900 | [diff] [blame] | 1128 | if (slot_avail2 & SLOT_133MHZ_PCIX_533) |
Kenji Kaneshige | 0afabe9 | 2006-03-01 14:55:11 +0900 | [diff] [blame] | 1129 | bus_speed = PCI_SPEED_133MHz_PCIX_533; |
Kenji Kaneshige | 6558b6a | 2005-11-24 13:44:01 +0900 | [diff] [blame] | 1130 | else if (slot_avail2 & SLOT_100MHZ_PCIX_533) |
Kenji Kaneshige | 0afabe9 | 2006-03-01 14:55:11 +0900 | [diff] [blame] | 1131 | bus_speed = PCI_SPEED_100MHz_PCIX_533; |
Kenji Kaneshige | 6558b6a | 2005-11-24 13:44:01 +0900 | [diff] [blame] | 1132 | else if (slot_avail2 & SLOT_66MHZ_PCIX_533) |
Kenji Kaneshige | 0afabe9 | 2006-03-01 14:55:11 +0900 | [diff] [blame] | 1133 | bus_speed = PCI_SPEED_66MHz_PCIX_533; |
Kenji Kaneshige | 6558b6a | 2005-11-24 13:44:01 +0900 | [diff] [blame] | 1134 | else if (slot_avail2 & SLOT_133MHZ_PCIX_266) |
Kenji Kaneshige | 0afabe9 | 2006-03-01 14:55:11 +0900 | [diff] [blame] | 1135 | bus_speed = PCI_SPEED_133MHz_PCIX_266; |
Kenji Kaneshige | 6558b6a | 2005-11-24 13:44:01 +0900 | [diff] [blame] | 1136 | else if (slot_avail2 & SLOT_100MHZ_PCIX_266) |
Kenji Kaneshige | 0afabe9 | 2006-03-01 14:55:11 +0900 | [diff] [blame] | 1137 | bus_speed = PCI_SPEED_100MHz_PCIX_266; |
Kenji Kaneshige | 6558b6a | 2005-11-24 13:44:01 +0900 | [diff] [blame] | 1138 | else if (slot_avail2 & SLOT_66MHZ_PCIX_266) |
Kenji Kaneshige | 0afabe9 | 2006-03-01 14:55:11 +0900 | [diff] [blame] | 1139 | bus_speed = PCI_SPEED_66MHz_PCIX_266; |
| 1140 | } |
| 1141 | |
| 1142 | if (bus_speed == PCI_SPEED_UNKNOWN) { |
Kenji Kaneshige | 6558b6a | 2005-11-24 13:44:01 +0900 | [diff] [blame] | 1143 | if (slot_avail1 & SLOT_133MHZ_PCIX) |
Kenji Kaneshige | 0afabe9 | 2006-03-01 14:55:11 +0900 | [diff] [blame] | 1144 | bus_speed = PCI_SPEED_133MHz_PCIX; |
Kenji Kaneshige | 6558b6a | 2005-11-24 13:44:01 +0900 | [diff] [blame] | 1145 | else if (slot_avail1 & SLOT_100MHZ_PCIX) |
Kenji Kaneshige | 0afabe9 | 2006-03-01 14:55:11 +0900 | [diff] [blame] | 1146 | bus_speed = PCI_SPEED_100MHz_PCIX; |
Kenji Kaneshige | 6558b6a | 2005-11-24 13:44:01 +0900 | [diff] [blame] | 1147 | else if (slot_avail1 & SLOT_66MHZ_PCIX) |
Kenji Kaneshige | 0afabe9 | 2006-03-01 14:55:11 +0900 | [diff] [blame] | 1148 | bus_speed = PCI_SPEED_66MHz_PCIX; |
Kenji Kaneshige | 6558b6a | 2005-11-24 13:44:01 +0900 | [diff] [blame] | 1149 | else if (slot_avail2 & SLOT_66MHZ) |
Kenji Kaneshige | 0afabe9 | 2006-03-01 14:55:11 +0900 | [diff] [blame] | 1150 | bus_speed = PCI_SPEED_66MHz; |
Kenji Kaneshige | 6558b6a | 2005-11-24 13:44:01 +0900 | [diff] [blame] | 1151 | else if (slot_avail1 & SLOT_33MHZ) |
Kenji Kaneshige | 0afabe9 | 2006-03-01 14:55:11 +0900 | [diff] [blame] | 1152 | bus_speed = PCI_SPEED_33MHz; |
| 1153 | else |
| 1154 | retval = -ENODEV; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1155 | } |
| 1156 | |
| 1157 | *value = bus_speed; |
| 1158 | dbg("Max bus speed = %d\n", bus_speed); |
| 1159 | DBG_LEAVE_ROUTINE |
| 1160 | return retval; |
| 1161 | } |
| 1162 | |
| 1163 | static int hpc_get_cur_bus_speed (struct slot *slot, enum pci_bus_speed *value) |
| 1164 | { |
Kenji Kaneshige | 0afabe9 | 2006-03-01 14:55:11 +0900 | [diff] [blame] | 1165 | int retval = 0; |
Kenji Kaneshige | 75d97c5 | 2006-05-02 11:08:42 +0900 | [diff] [blame] | 1166 | struct controller *ctrl = slot->ctrl; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1167 | enum pci_bus_speed bus_speed = PCI_SPEED_UNKNOWN; |
Kenji Kaneshige | 75d97c5 | 2006-05-02 11:08:42 +0900 | [diff] [blame] | 1168 | u16 sec_bus_reg = shpc_readw(ctrl, SEC_BUS_CONFIG); |
| 1169 | u8 pi = shpc_readb(ctrl, PROG_INTERFACE); |
Kenji Kaneshige | 0afabe9 | 2006-03-01 14:55:11 +0900 | [diff] [blame] | 1170 | u8 speed_mode = (pi == 2) ? (sec_bus_reg & 0xF) : (sec_bus_reg & 0x7); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1171 | |
| 1172 | DBG_ENTER_ROUTINE |
| 1173 | |
Kenji Kaneshige | 0afabe9 | 2006-03-01 14:55:11 +0900 | [diff] [blame] | 1174 | if ((pi == 1) && (speed_mode > 4)) { |
| 1175 | *value = PCI_SPEED_UNKNOWN; |
| 1176 | return -ENODEV; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1177 | } |
| 1178 | |
Kenji Kaneshige | 0afabe9 | 2006-03-01 14:55:11 +0900 | [diff] [blame] | 1179 | switch (speed_mode) { |
| 1180 | case 0x0: |
| 1181 | *value = PCI_SPEED_33MHz; |
| 1182 | break; |
| 1183 | case 0x1: |
| 1184 | *value = PCI_SPEED_66MHz; |
| 1185 | break; |
| 1186 | case 0x2: |
| 1187 | *value = PCI_SPEED_66MHz_PCIX; |
| 1188 | break; |
| 1189 | case 0x3: |
| 1190 | *value = PCI_SPEED_100MHz_PCIX; |
| 1191 | break; |
| 1192 | case 0x4: |
| 1193 | *value = PCI_SPEED_133MHz_PCIX; |
| 1194 | break; |
| 1195 | case 0x5: |
| 1196 | *value = PCI_SPEED_66MHz_PCIX_ECC; |
| 1197 | break; |
| 1198 | case 0x6: |
| 1199 | *value = PCI_SPEED_100MHz_PCIX_ECC; |
| 1200 | break; |
| 1201 | case 0x7: |
| 1202 | *value = PCI_SPEED_133MHz_PCIX_ECC; |
| 1203 | break; |
| 1204 | case 0x8: |
| 1205 | *value = PCI_SPEED_66MHz_PCIX_266; |
| 1206 | break; |
| 1207 | case 0x9: |
| 1208 | *value = PCI_SPEED_100MHz_PCIX_266; |
| 1209 | break; |
| 1210 | case 0xa: |
| 1211 | *value = PCI_SPEED_133MHz_PCIX_266; |
| 1212 | break; |
| 1213 | case 0xb: |
| 1214 | *value = PCI_SPEED_66MHz_PCIX_533; |
| 1215 | break; |
| 1216 | case 0xc: |
| 1217 | *value = PCI_SPEED_100MHz_PCIX_533; |
| 1218 | break; |
| 1219 | case 0xd: |
| 1220 | *value = PCI_SPEED_133MHz_PCIX_533; |
| 1221 | break; |
| 1222 | default: |
| 1223 | *value = PCI_SPEED_UNKNOWN; |
| 1224 | retval = -ENODEV; |
| 1225 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1226 | } |
| 1227 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1228 | dbg("Current bus speed = %d\n", bus_speed); |
| 1229 | DBG_LEAVE_ROUTINE |
| 1230 | return retval; |
| 1231 | } |
| 1232 | |
| 1233 | static struct hpc_ops shpchp_hpc_ops = { |
| 1234 | .power_on_slot = hpc_power_on_slot, |
| 1235 | .slot_enable = hpc_slot_enable, |
| 1236 | .slot_disable = hpc_slot_disable, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1237 | .set_bus_speed_mode = hpc_set_bus_speed_mode, |
| 1238 | .set_attention_status = hpc_set_attention_status, |
| 1239 | .get_power_status = hpc_get_power_status, |
| 1240 | .get_attention_status = hpc_get_attention_status, |
| 1241 | .get_latch_status = hpc_get_latch_status, |
| 1242 | .get_adapter_status = hpc_get_adapter_status, |
| 1243 | |
| 1244 | .get_max_bus_speed = hpc_get_max_bus_speed, |
| 1245 | .get_cur_bus_speed = hpc_get_cur_bus_speed, |
| 1246 | .get_adapter_speed = hpc_get_adapter_speed, |
| 1247 | .get_mode1_ECC_cap = hpc_get_mode1_ECC_cap, |
| 1248 | .get_prog_int = hpc_get_prog_int, |
| 1249 | |
| 1250 | .query_power_fault = hpc_query_power_fault, |
| 1251 | .green_led_on = hpc_set_green_led_on, |
| 1252 | .green_led_off = hpc_set_green_led_off, |
| 1253 | .green_led_blink = hpc_set_green_led_blink, |
| 1254 | |
| 1255 | .release_ctlr = hpc_release_ctlr, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1256 | }; |
| 1257 | |
rajesh.shah@intel.com | ee13833 | 2005-10-13 12:05:42 -0700 | [diff] [blame] | 1258 | int shpc_init(struct controller * ctrl, struct pci_dev * pdev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1259 | { |
| 1260 | struct php_ctlr_state_s *php_ctlr, *p; |
| 1261 | void *instance_id = ctrl; |
Kenji Kaneshige | 0455986 | 2005-11-24 11:36:59 +0900 | [diff] [blame] | 1262 | int rc, num_slots = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1263 | u8 hp_slot; |
| 1264 | static int first = 1; |
Kenji Kaneshige | 0455986 | 2005-11-24 11:36:59 +0900 | [diff] [blame] | 1265 | u32 shpc_base_offset; |
Kenji Kaneshige | 75d97c5 | 2006-05-02 11:08:42 +0900 | [diff] [blame] | 1266 | u32 tempdword, slot_reg, slot_config; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1267 | u8 i; |
| 1268 | |
| 1269 | DBG_ENTER_ROUTINE |
| 1270 | |
Kenji Kaneshige | 0455986 | 2005-11-24 11:36:59 +0900 | [diff] [blame] | 1271 | ctrl->pci_dev = pdev; /* pci_dev of the P2P bridge */ |
| 1272 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1273 | spin_lock_init(&list_lock); |
Kenji Kaneshige | 57c95c0 | 2006-01-26 10:02:41 +0900 | [diff] [blame] | 1274 | php_ctlr = kzalloc(sizeof(*php_ctlr), GFP_KERNEL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1275 | |
| 1276 | if (!php_ctlr) { /* allocate controller state data */ |
| 1277 | err("%s: HPC controller memory allocation error!\n", __FUNCTION__); |
| 1278 | goto abort; |
| 1279 | } |
| 1280 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1281 | php_ctlr->pci_dev = pdev; /* save pci_dev in context */ |
| 1282 | |
rajesh.shah@intel.com | ee13833 | 2005-10-13 12:05:42 -0700 | [diff] [blame] | 1283 | if ((pdev->vendor == PCI_VENDOR_ID_AMD) || (pdev->device == |
| 1284 | PCI_DEVICE_ID_AMD_GOLAM_7450)) { |
Kenji Kaneshige | 0455986 | 2005-11-24 11:36:59 +0900 | [diff] [blame] | 1285 | /* amd shpc driver doesn't use Base Offset; assume 0 */ |
| 1286 | ctrl->mmio_base = pci_resource_start(pdev, 0); |
| 1287 | ctrl->mmio_size = pci_resource_len(pdev, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1288 | } else { |
Kenji Kaneshige | 0455986 | 2005-11-24 11:36:59 +0900 | [diff] [blame] | 1289 | ctrl->cap_offset = pci_find_capability(pdev, PCI_CAP_ID_SHPC); |
| 1290 | if (!ctrl->cap_offset) { |
| 1291 | err("%s : cap_offset == 0\n", __FUNCTION__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1292 | goto abort_free_ctlr; |
| 1293 | } |
Kenji Kaneshige | 0455986 | 2005-11-24 11:36:59 +0900 | [diff] [blame] | 1294 | dbg("%s: cap_offset = %x\n", __FUNCTION__, ctrl->cap_offset); |
| 1295 | |
Kenji Kaneshige | 75d97c5 | 2006-05-02 11:08:42 +0900 | [diff] [blame] | 1296 | rc = shpc_indirect_read(ctrl, 0, &shpc_base_offset); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1297 | if (rc) { |
Kenji Kaneshige | 0455986 | 2005-11-24 11:36:59 +0900 | [diff] [blame] | 1298 | err("%s: cannot read base_offset\n", __FUNCTION__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1299 | goto abort_free_ctlr; |
| 1300 | } |
| 1301 | |
Kenji Kaneshige | 75d97c5 | 2006-05-02 11:08:42 +0900 | [diff] [blame] | 1302 | rc = shpc_indirect_read(ctrl, 3, &tempdword); |
Kenji Kaneshige | 0455986 | 2005-11-24 11:36:59 +0900 | [diff] [blame] | 1303 | if (rc) { |
| 1304 | err("%s: cannot read slot config\n", __FUNCTION__); |
| 1305 | goto abort_free_ctlr; |
| 1306 | } |
| 1307 | num_slots = tempdword & SLOT_NUM; |
| 1308 | dbg("%s: num_slots (indirect) %x\n", __FUNCTION__, num_slots); |
| 1309 | |
| 1310 | for (i = 0; i < 9 + num_slots; i++) { |
Kenji Kaneshige | 75d97c5 | 2006-05-02 11:08:42 +0900 | [diff] [blame] | 1311 | rc = shpc_indirect_read(ctrl, i, &tempdword); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1312 | if (rc) { |
Kenji Kaneshige | 0455986 | 2005-11-24 11:36:59 +0900 | [diff] [blame] | 1313 | err("%s: cannot read creg (index = %d)\n", |
| 1314 | __FUNCTION__, i); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1315 | goto abort_free_ctlr; |
| 1316 | } |
rajesh.shah@intel.com | 7c8942f | 2005-10-13 12:05:43 -0700 | [diff] [blame] | 1317 | dbg("%s: offset %d: value %x\n", __FUNCTION__,i, |
| 1318 | tempdword); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1319 | } |
Kenji Kaneshige | 0455986 | 2005-11-24 11:36:59 +0900 | [diff] [blame] | 1320 | |
| 1321 | ctrl->mmio_base = |
| 1322 | pci_resource_start(pdev, 0) + shpc_base_offset; |
| 1323 | ctrl->mmio_size = 0x24 + 0x4 * num_slots; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1324 | } |
| 1325 | |
| 1326 | if (first) { |
| 1327 | spin_lock_init(&hpc_event_lock); |
| 1328 | first = 0; |
| 1329 | } |
| 1330 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1331 | info("HPC vendor_id %x device_id %x ss_vid %x ss_did %x\n", pdev->vendor, pdev->device, pdev->subsystem_vendor, |
| 1332 | pdev->subsystem_device); |
| 1333 | |
| 1334 | if (pci_enable_device(pdev)) |
| 1335 | goto abort_free_ctlr; |
| 1336 | |
Kenji Kaneshige | 0455986 | 2005-11-24 11:36:59 +0900 | [diff] [blame] | 1337 | if (!request_mem_region(ctrl->mmio_base, ctrl->mmio_size, MY_NAME)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1338 | err("%s: cannot reserve MMIO region\n", __FUNCTION__); |
| 1339 | goto abort_free_ctlr; |
| 1340 | } |
| 1341 | |
Kenji Kaneshige | 0455986 | 2005-11-24 11:36:59 +0900 | [diff] [blame] | 1342 | php_ctlr->creg = ioremap(ctrl->mmio_base, ctrl->mmio_size); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1343 | if (!php_ctlr->creg) { |
Kenji Kaneshige | 0455986 | 2005-11-24 11:36:59 +0900 | [diff] [blame] | 1344 | err("%s: cannot remap MMIO region %lx @ %lx\n", __FUNCTION__, |
| 1345 | ctrl->mmio_size, ctrl->mmio_base); |
| 1346 | release_mem_region(ctrl->mmio_base, ctrl->mmio_size); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1347 | goto abort_free_ctlr; |
| 1348 | } |
| 1349 | dbg("%s: php_ctlr->creg %p\n", __FUNCTION__, php_ctlr->creg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1350 | |
Ingo Molnar | 6aa4cdd | 2006-01-13 16:02:15 +0100 | [diff] [blame] | 1351 | mutex_init(&ctrl->crit_sect); |
Kenji Kaneshige | d29aadd | 2006-01-26 09:59:24 +0900 | [diff] [blame] | 1352 | mutex_init(&ctrl->cmd_lock); |
| 1353 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1354 | /* Setup wait queue */ |
| 1355 | init_waitqueue_head(&ctrl->queue); |
| 1356 | |
| 1357 | /* Find the IRQ */ |
| 1358 | php_ctlr->irq = pdev->irq; |
rajesh.shah@intel.com | ee13833 | 2005-10-13 12:05:42 -0700 | [diff] [blame] | 1359 | php_ctlr->attention_button_callback = shpchp_handle_attention_button, |
| 1360 | php_ctlr->switch_change_callback = shpchp_handle_switch_change; |
| 1361 | php_ctlr->presence_change_callback = shpchp_handle_presence_change; |
| 1362 | php_ctlr->power_fault_callback = shpchp_handle_power_fault; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1363 | php_ctlr->callback_instance_id = instance_id; |
| 1364 | |
Kenji Kaneshige | 75d97c5 | 2006-05-02 11:08:42 +0900 | [diff] [blame] | 1365 | ctrl->hpc_ctlr_handle = php_ctlr; |
| 1366 | ctrl->hpc_ops = &shpchp_hpc_ops; |
| 1367 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1368 | /* Return PCI Controller Info */ |
Kenji Kaneshige | 75d97c5 | 2006-05-02 11:08:42 +0900 | [diff] [blame] | 1369 | slot_config = shpc_readl(ctrl, SLOT_CONFIG); |
| 1370 | php_ctlr->slot_device_offset = (slot_config & FIRST_DEV_NUM) >> 8; |
| 1371 | php_ctlr->num_slots = slot_config & SLOT_NUM; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1372 | dbg("%s: slot_device_offset %x\n", __FUNCTION__, php_ctlr->slot_device_offset); |
| 1373 | dbg("%s: num_slots %x\n", __FUNCTION__, php_ctlr->num_slots); |
| 1374 | |
| 1375 | /* Mask Global Interrupt Mask & Command Complete Interrupt Mask */ |
Kenji Kaneshige | 75d97c5 | 2006-05-02 11:08:42 +0900 | [diff] [blame] | 1376 | tempdword = shpc_readl(ctrl, SERR_INTR_ENABLE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1377 | dbg("%s: SERR_INTR_ENABLE = %x\n", __FUNCTION__, tempdword); |
| 1378 | tempdword = 0x0003000f; |
Kenji Kaneshige | 75d97c5 | 2006-05-02 11:08:42 +0900 | [diff] [blame] | 1379 | shpc_writel(ctrl, SERR_INTR_ENABLE, tempdword); |
| 1380 | tempdword = shpc_readl(ctrl, SERR_INTR_ENABLE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1381 | dbg("%s: SERR_INTR_ENABLE = %x\n", __FUNCTION__, tempdword); |
| 1382 | |
| 1383 | /* Mask the MRL sensor SERR Mask of individual slot in |
| 1384 | * Slot SERR-INT Mask & clear all the existing event if any |
| 1385 | */ |
| 1386 | for (hp_slot = 0; hp_slot < php_ctlr->num_slots; hp_slot++) { |
Kenji Kaneshige | 2b34da7 | 2006-05-02 11:09:42 +0900 | [diff] [blame^] | 1387 | slot_reg = shpc_readl(ctrl, SLOT_REG(hp_slot)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1388 | dbg("%s: Default Logical Slot Register %d value %x\n", __FUNCTION__, |
| 1389 | hp_slot, slot_reg); |
| 1390 | tempdword = 0xffff3fff; |
Kenji Kaneshige | 2b34da7 | 2006-05-02 11:09:42 +0900 | [diff] [blame^] | 1391 | shpc_writel(ctrl, SLOT_REG(hp_slot), tempdword); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1392 | } |
| 1393 | |
| 1394 | if (shpchp_poll_mode) {/* Install interrupt polling code */ |
| 1395 | /* Install and start the interrupt polling timer */ |
| 1396 | init_timer(&php_ctlr->int_poll_timer); |
| 1397 | start_int_poll_timer( php_ctlr, 10 ); /* start with 10 second delay */ |
| 1398 | } else { |
| 1399 | /* Installs the interrupt handler */ |
| 1400 | rc = pci_enable_msi(pdev); |
| 1401 | if (rc) { |
| 1402 | info("Can't get msi for the hotplug controller\n"); |
| 1403 | info("Use INTx for the hotplug controller\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1404 | } else |
| 1405 | php_ctlr->irq = pdev->irq; |
| 1406 | |
| 1407 | rc = request_irq(php_ctlr->irq, shpc_isr, SA_SHIRQ, MY_NAME, (void *) ctrl); |
| 1408 | dbg("%s: request_irq %d for hpc%d (returns %d)\n", __FUNCTION__, php_ctlr->irq, ctlr_seq_num, rc); |
| 1409 | if (rc) { |
| 1410 | err("Can't get irq %d for the hotplug controller\n", php_ctlr->irq); |
| 1411 | goto abort_free_ctlr; |
| 1412 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1413 | } |
rajesh.shah@intel.com | 7c8942f | 2005-10-13 12:05:43 -0700 | [diff] [blame] | 1414 | dbg("%s: HPC at b:d:f:irq=0x%x:%x:%x:%x\n", __FUNCTION__, |
| 1415 | pdev->bus->number, PCI_SLOT(pdev->devfn), |
| 1416 | PCI_FUNC(pdev->devfn), pdev->irq); |
rajesh.shah@intel.com | 424600f | 2005-10-13 12:05:38 -0700 | [diff] [blame] | 1417 | get_hp_hw_control_from_firmware(pdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1418 | |
| 1419 | /* Add this HPC instance into the HPC list */ |
| 1420 | spin_lock(&list_lock); |
| 1421 | if (php_ctlr_list_head == 0) { |
| 1422 | php_ctlr_list_head = php_ctlr; |
| 1423 | p = php_ctlr_list_head; |
| 1424 | p->pnext = NULL; |
| 1425 | } else { |
| 1426 | p = php_ctlr_list_head; |
| 1427 | |
| 1428 | while (p->pnext) |
| 1429 | p = p->pnext; |
| 1430 | |
| 1431 | p->pnext = php_ctlr; |
| 1432 | } |
| 1433 | spin_unlock(&list_lock); |
| 1434 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1435 | ctlr_seq_num++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1436 | |
| 1437 | for (hp_slot = 0; hp_slot < php_ctlr->num_slots; hp_slot++) { |
Kenji Kaneshige | 2b34da7 | 2006-05-02 11:09:42 +0900 | [diff] [blame^] | 1438 | slot_reg = shpc_readl(ctrl, SLOT_REG(hp_slot)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1439 | dbg("%s: Default Logical Slot Register %d value %x\n", __FUNCTION__, |
| 1440 | hp_slot, slot_reg); |
| 1441 | tempdword = 0xe01f3fff; |
Kenji Kaneshige | 2b34da7 | 2006-05-02 11:09:42 +0900 | [diff] [blame^] | 1442 | shpc_writel(ctrl, SLOT_REG(hp_slot), tempdword); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1443 | } |
| 1444 | if (!shpchp_poll_mode) { |
| 1445 | /* Unmask all general input interrupts and SERR */ |
Kenji Kaneshige | 75d97c5 | 2006-05-02 11:08:42 +0900 | [diff] [blame] | 1446 | tempdword = shpc_readl(ctrl, SERR_INTR_ENABLE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1447 | tempdword = 0x0000000a; |
Kenji Kaneshige | 75d97c5 | 2006-05-02 11:08:42 +0900 | [diff] [blame] | 1448 | shpc_writel(ctrl, SERR_INTR_ENABLE, tempdword); |
| 1449 | tempdword = shpc_readl(ctrl, SERR_INTR_ENABLE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1450 | dbg("%s: SERR_INTR_ENABLE = %x\n", __FUNCTION__, tempdword); |
| 1451 | } |
| 1452 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1453 | DBG_LEAVE_ROUTINE |
| 1454 | return 0; |
| 1455 | |
| 1456 | /* We end up here for the many possible ways to fail this API. */ |
| 1457 | abort_free_ctlr: |
| 1458 | kfree(php_ctlr); |
| 1459 | abort: |
| 1460 | DBG_LEAVE_ROUTINE |
| 1461 | return -1; |
| 1462 | } |