shpchp_hpc.c 29 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130
  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. *
  26. * Send feedback to <greg@kroah.com>,<kristen.c.accardi@intel.com>
  27. *
  28. */
  29. #include <linux/kernel.h>
  30. #include <linux/module.h>
  31. #include <linux/types.h>
  32. #include <linux/pci.h>
  33. #include <linux/interrupt.h>
  34. #include "shpchp.h"
  35. /* Slot Available Register I field definition */
  36. #define SLOT_33MHZ 0x0000001f
  37. #define SLOT_66MHZ_PCIX 0x00001f00
  38. #define SLOT_100MHZ_PCIX 0x001f0000
  39. #define SLOT_133MHZ_PCIX 0x1f000000
  40. /* Slot Available Register II field definition */
  41. #define SLOT_66MHZ 0x0000001f
  42. #define SLOT_66MHZ_PCIX_266 0x00000f00
  43. #define SLOT_100MHZ_PCIX_266 0x0000f000
  44. #define SLOT_133MHZ_PCIX_266 0x000f0000
  45. #define SLOT_66MHZ_PCIX_533 0x00f00000
  46. #define SLOT_100MHZ_PCIX_533 0x0f000000
  47. #define SLOT_133MHZ_PCIX_533 0xf0000000
  48. /* Slot Configuration */
  49. #define SLOT_NUM 0x0000001F
  50. #define FIRST_DEV_NUM 0x00001F00
  51. #define PSN 0x07FF0000
  52. #define UPDOWN 0x20000000
  53. #define MRLSENSOR 0x40000000
  54. #define ATTN_BUTTON 0x80000000
  55. /*
  56. * Interrupt Locator Register definitions
  57. */
  58. #define CMD_INTR_PENDING (1 << 0)
  59. #define SLOT_INTR_PENDING(i) (1 << (i + 1))
  60. /*
  61. * Controller SERR-INT Register
  62. */
  63. #define GLOBAL_INTR_MASK (1 << 0)
  64. #define GLOBAL_SERR_MASK (1 << 1)
  65. #define COMMAND_INTR_MASK (1 << 2)
  66. #define ARBITER_SERR_MASK (1 << 3)
  67. #define COMMAND_DETECTED (1 << 16)
  68. #define ARBITER_DETECTED (1 << 17)
  69. #define SERR_INTR_RSVDZ_MASK 0xfffc0000
  70. /*
  71. * Logical Slot Register definitions
  72. */
  73. #define SLOT_REG(i) (SLOT1 + (4 * i))
  74. #define SLOT_STATE_SHIFT (0)
  75. #define SLOT_STATE_MASK (3 << 0)
  76. #define SLOT_STATE_PWRONLY (1)
  77. #define SLOT_STATE_ENABLED (2)
  78. #define SLOT_STATE_DISABLED (3)
  79. #define PWR_LED_STATE_SHIFT (2)
  80. #define PWR_LED_STATE_MASK (3 << 2)
  81. #define ATN_LED_STATE_SHIFT (4)
  82. #define ATN_LED_STATE_MASK (3 << 4)
  83. #define ATN_LED_STATE_ON (1)
  84. #define ATN_LED_STATE_BLINK (2)
  85. #define ATN_LED_STATE_OFF (3)
  86. #define POWER_FAULT (1 << 6)
  87. #define ATN_BUTTON (1 << 7)
  88. #define MRL_SENSOR (1 << 8)
  89. #define MHZ66_CAP (1 << 9)
  90. #define PRSNT_SHIFT (10)
  91. #define PRSNT_MASK (3 << 10)
  92. #define PCIX_CAP_SHIFT (12)
  93. #define PCIX_CAP_MASK_PI1 (3 << 12)
  94. #define PCIX_CAP_MASK_PI2 (7 << 12)
  95. #define PRSNT_CHANGE_DETECTED (1 << 16)
  96. #define ISO_PFAULT_DETECTED (1 << 17)
  97. #define BUTTON_PRESS_DETECTED (1 << 18)
  98. #define MRL_CHANGE_DETECTED (1 << 19)
  99. #define CON_PFAULT_DETECTED (1 << 20)
  100. #define PRSNT_CHANGE_INTR_MASK (1 << 24)
  101. #define ISO_PFAULT_INTR_MASK (1 << 25)
  102. #define BUTTON_PRESS_INTR_MASK (1 << 26)
  103. #define MRL_CHANGE_INTR_MASK (1 << 27)
  104. #define CON_PFAULT_INTR_MASK (1 << 28)
  105. #define MRL_CHANGE_SERR_MASK (1 << 29)
  106. #define CON_PFAULT_SERR_MASK (1 << 30)
  107. #define SLOT_REG_RSVDZ_MASK (1 << 15) | (7 << 21)
  108. /*
  109. * SHPC Command Code definitnions
  110. *
  111. * Slot Operation 00h - 3Fh
  112. * Set Bus Segment Speed/Mode A 40h - 47h
  113. * Power-Only All Slots 48h
  114. * Enable All Slots 49h
  115. * Set Bus Segment Speed/Mode B (PI=2) 50h - 5Fh
  116. * Reserved Command Codes 60h - BFh
  117. * Vendor Specific Commands C0h - FFh
  118. */
  119. #define SET_SLOT_PWR 0x01 /* Slot Operation */
  120. #define SET_SLOT_ENABLE 0x02
  121. #define SET_SLOT_DISABLE 0x03
  122. #define SET_PWR_ON 0x04
  123. #define SET_PWR_BLINK 0x08
  124. #define SET_PWR_OFF 0x0c
  125. #define SET_ATTN_ON 0x10
  126. #define SET_ATTN_BLINK 0x20
  127. #define SET_ATTN_OFF 0x30
  128. #define SETA_PCI_33MHZ 0x40 /* Set Bus Segment Speed/Mode A */
  129. #define SETA_PCI_66MHZ 0x41
  130. #define SETA_PCIX_66MHZ 0x42
  131. #define SETA_PCIX_100MHZ 0x43
  132. #define SETA_PCIX_133MHZ 0x44
  133. #define SETA_RESERVED1 0x45
  134. #define SETA_RESERVED2 0x46
  135. #define SETA_RESERVED3 0x47
  136. #define SET_PWR_ONLY_ALL 0x48 /* Power-Only All Slots */
  137. #define SET_ENABLE_ALL 0x49 /* Enable All Slots */
  138. #define SETB_PCI_33MHZ 0x50 /* Set Bus Segment Speed/Mode B */
  139. #define SETB_PCI_66MHZ 0x51
  140. #define SETB_PCIX_66MHZ_PM 0x52
  141. #define SETB_PCIX_100MHZ_PM 0x53
  142. #define SETB_PCIX_133MHZ_PM 0x54
  143. #define SETB_PCIX_66MHZ_EM 0x55
  144. #define SETB_PCIX_100MHZ_EM 0x56
  145. #define SETB_PCIX_133MHZ_EM 0x57
  146. #define SETB_PCIX_66MHZ_266 0x58
  147. #define SETB_PCIX_100MHZ_266 0x59
  148. #define SETB_PCIX_133MHZ_266 0x5a
  149. #define SETB_PCIX_66MHZ_533 0x5b
  150. #define SETB_PCIX_100MHZ_533 0x5c
  151. #define SETB_PCIX_133MHZ_533 0x5d
  152. #define SETB_RESERVED1 0x5e
  153. #define SETB_RESERVED2 0x5f
  154. /*
  155. * SHPC controller command error code
  156. */
  157. #define SWITCH_OPEN 0x1
  158. #define INVALID_CMD 0x2
  159. #define INVALID_SPEED_MODE 0x4
  160. /*
  161. * For accessing SHPC Working Register Set via PCI Configuration Space
  162. */
  163. #define DWORD_SELECT 0x2
  164. #define DWORD_DATA 0x4
  165. /* Field Offset in Logical Slot Register - byte boundary */
  166. #define SLOT_EVENT_LATCH 0x2
  167. #define SLOT_SERR_INT_MASK 0x3
  168. static atomic_t shpchp_num_controllers = ATOMIC_INIT(0);
  169. static irqreturn_t shpc_isr(int irq, void *dev_id);
  170. static void start_int_poll_timer(struct controller *ctrl, int sec);
  171. static int hpc_check_cmd_status(struct controller *ctrl);
  172. static inline u8 shpc_readb(struct controller *ctrl, int reg)
  173. {
  174. return readb(ctrl->creg + reg);
  175. }
  176. static inline void shpc_writeb(struct controller *ctrl, int reg, u8 val)
  177. {
  178. writeb(val, ctrl->creg + reg);
  179. }
  180. static inline u16 shpc_readw(struct controller *ctrl, int reg)
  181. {
  182. return readw(ctrl->creg + reg);
  183. }
  184. static inline void shpc_writew(struct controller *ctrl, int reg, u16 val)
  185. {
  186. writew(val, ctrl->creg + reg);
  187. }
  188. static inline u32 shpc_readl(struct controller *ctrl, int reg)
  189. {
  190. return readl(ctrl->creg + reg);
  191. }
  192. static inline void shpc_writel(struct controller *ctrl, int reg, u32 val)
  193. {
  194. writel(val, ctrl->creg + reg);
  195. }
  196. static inline int shpc_indirect_read(struct controller *ctrl, int index,
  197. u32 *value)
  198. {
  199. int rc;
  200. u32 cap_offset = ctrl->cap_offset;
  201. struct pci_dev *pdev = ctrl->pci_dev;
  202. rc = pci_write_config_byte(pdev, cap_offset + DWORD_SELECT, index);
  203. if (rc)
  204. return rc;
  205. return pci_read_config_dword(pdev, cap_offset + DWORD_DATA, value);
  206. }
  207. /*
  208. * This is the interrupt polling timeout function.
  209. */
  210. static void int_poll_timeout(unsigned long data)
  211. {
  212. struct controller *ctrl = (struct controller *)data;
  213. /* Poll for interrupt events. regs == NULL => polling */
  214. shpc_isr(0, ctrl);
  215. init_timer(&ctrl->poll_timer);
  216. if (!shpchp_poll_time)
  217. shpchp_poll_time = 2; /* default polling interval is 2 sec */
  218. start_int_poll_timer(ctrl, shpchp_poll_time);
  219. }
  220. /*
  221. * This function starts the interrupt polling timer.
  222. */
  223. static void start_int_poll_timer(struct controller *ctrl, int sec)
  224. {
  225. /* Clamp to sane value */
  226. if ((sec <= 0) || (sec > 60))
  227. sec = 2;
  228. ctrl->poll_timer.function = &int_poll_timeout;
  229. ctrl->poll_timer.data = (unsigned long)ctrl;
  230. ctrl->poll_timer.expires = jiffies + sec * HZ;
  231. add_timer(&ctrl->poll_timer);
  232. }
  233. static inline int is_ctrl_busy(struct controller *ctrl)
  234. {
  235. u16 cmd_status = shpc_readw(ctrl, CMD_STATUS);
  236. return cmd_status & 0x1;
  237. }
  238. /*
  239. * Returns 1 if SHPC finishes executing a command within 1 sec,
  240. * otherwise returns 0.
  241. */
  242. static inline int shpc_poll_ctrl_busy(struct controller *ctrl)
  243. {
  244. int i;
  245. if (!is_ctrl_busy(ctrl))
  246. return 1;
  247. /* Check every 0.1 sec for a total of 1 sec */
  248. for (i = 0; i < 10; i++) {
  249. msleep(100);
  250. if (!is_ctrl_busy(ctrl))
  251. return 1;
  252. }
  253. return 0;
  254. }
  255. static inline int shpc_wait_cmd(struct controller *ctrl)
  256. {
  257. int retval = 0;
  258. unsigned long timeout = msecs_to_jiffies(1000);
  259. int rc;
  260. if (shpchp_poll_mode)
  261. rc = shpc_poll_ctrl_busy(ctrl);
  262. else
  263. rc = wait_event_interruptible_timeout(ctrl->queue,
  264. !is_ctrl_busy(ctrl), timeout);
  265. if (!rc && is_ctrl_busy(ctrl)) {
  266. retval = -EIO;
  267. ctrl_err(ctrl, "Command not completed in 1000 msec\n");
  268. } else if (rc < 0) {
  269. retval = -EINTR;
  270. ctrl_info(ctrl, "Command was interrupted by a signal\n");
  271. }
  272. return retval;
  273. }
  274. static int shpc_write_cmd(struct slot *slot, u8 t_slot, u8 cmd)
  275. {
  276. struct controller *ctrl = slot->ctrl;
  277. u16 cmd_status;
  278. int retval = 0;
  279. u16 temp_word;
  280. mutex_lock(&slot->ctrl->cmd_lock);
  281. if (!shpc_poll_ctrl_busy(ctrl)) {
  282. /* After 1 sec and and the controller is still busy */
  283. ctrl_err(ctrl, "Controller is still busy after 1 sec\n");
  284. retval = -EBUSY;
  285. goto out;
  286. }
  287. ++t_slot;
  288. temp_word = (t_slot << 8) | (cmd & 0xFF);
  289. ctrl_dbg(ctrl, "%s: t_slot %x cmd %x\n", __func__, t_slot, cmd);
  290. /* To make sure the Controller Busy bit is 0 before we send out the
  291. * command.
  292. */
  293. shpc_writew(ctrl, CMD, temp_word);
  294. /*
  295. * Wait for command completion.
  296. */
  297. retval = shpc_wait_cmd(slot->ctrl);
  298. if (retval)
  299. goto out;
  300. cmd_status = hpc_check_cmd_status(slot->ctrl);
  301. if (cmd_status) {
  302. ctrl_err(ctrl,
  303. "Failed to issued command 0x%x (error code = %d)\n",
  304. cmd, cmd_status);
  305. retval = -EIO;
  306. }
  307. out:
  308. mutex_unlock(&slot->ctrl->cmd_lock);
  309. return retval;
  310. }
  311. static int hpc_check_cmd_status(struct controller *ctrl)
  312. {
  313. int retval = 0;
  314. u16 cmd_status = shpc_readw(ctrl, CMD_STATUS) & 0x000F;
  315. switch (cmd_status >> 1) {
  316. case 0:
  317. retval = 0;
  318. break;
  319. case 1:
  320. retval = SWITCH_OPEN;
  321. ctrl_err(ctrl, "Switch opened!\n");
  322. break;
  323. case 2:
  324. retval = INVALID_CMD;
  325. ctrl_err(ctrl, "Invalid HPC command!\n");
  326. break;
  327. case 4:
  328. retval = INVALID_SPEED_MODE;
  329. ctrl_err(ctrl, "Invalid bus speed/mode!\n");
  330. break;
  331. default:
  332. retval = cmd_status;
  333. }
  334. return retval;
  335. }
  336. static int hpc_get_attention_status(struct slot *slot, u8 *status)
  337. {
  338. struct controller *ctrl = slot->ctrl;
  339. u32 slot_reg = shpc_readl(ctrl, SLOT_REG(slot->hp_slot));
  340. u8 state = (slot_reg & ATN_LED_STATE_MASK) >> ATN_LED_STATE_SHIFT;
  341. switch (state) {
  342. case ATN_LED_STATE_ON:
  343. *status = 1; /* On */
  344. break;
  345. case ATN_LED_STATE_BLINK:
  346. *status = 2; /* Blink */
  347. break;
  348. case ATN_LED_STATE_OFF:
  349. *status = 0; /* Off */
  350. break;
  351. default:
  352. *status = 0xFF; /* Reserved */
  353. break;
  354. }
  355. return 0;
  356. }
  357. static int hpc_get_power_status(struct slot * slot, u8 *status)
  358. {
  359. struct controller *ctrl = slot->ctrl;
  360. u32 slot_reg = shpc_readl(ctrl, SLOT_REG(slot->hp_slot));
  361. u8 state = (slot_reg & SLOT_STATE_MASK) >> SLOT_STATE_SHIFT;
  362. switch (state) {
  363. case SLOT_STATE_PWRONLY:
  364. *status = 2; /* Powered only */
  365. break;
  366. case SLOT_STATE_ENABLED:
  367. *status = 1; /* Enabled */
  368. break;
  369. case SLOT_STATE_DISABLED:
  370. *status = 0; /* Disabled */
  371. break;
  372. default:
  373. *status = 0xFF; /* Reserved */
  374. break;
  375. }
  376. return 0;
  377. }
  378. static int hpc_get_latch_status(struct slot *slot, u8 *status)
  379. {
  380. struct controller *ctrl = slot->ctrl;
  381. u32 slot_reg = shpc_readl(ctrl, SLOT_REG(slot->hp_slot));
  382. *status = !!(slot_reg & MRL_SENSOR); /* 0 -> close; 1 -> open */
  383. return 0;
  384. }
  385. static int hpc_get_adapter_status(struct slot *slot, u8 *status)
  386. {
  387. struct controller *ctrl = slot->ctrl;
  388. u32 slot_reg = shpc_readl(ctrl, SLOT_REG(slot->hp_slot));
  389. u8 state = (slot_reg & PRSNT_MASK) >> PRSNT_SHIFT;
  390. *status = (state != 0x3) ? 1 : 0;
  391. return 0;
  392. }
  393. static int hpc_get_prog_int(struct slot *slot, u8 *prog_int)
  394. {
  395. struct controller *ctrl = slot->ctrl;
  396. *prog_int = shpc_readb(ctrl, PROG_INTERFACE);
  397. return 0;
  398. }
  399. static int hpc_get_adapter_speed(struct slot *slot, enum pci_bus_speed *value)
  400. {
  401. int retval = 0;
  402. struct controller *ctrl = slot->ctrl;
  403. u32 slot_reg = shpc_readl(ctrl, SLOT_REG(slot->hp_slot));
  404. u8 m66_cap = !!(slot_reg & MHZ66_CAP);
  405. u8 pi, pcix_cap;
  406. if ((retval = hpc_get_prog_int(slot, &pi)))
  407. return retval;
  408. switch (pi) {
  409. case 1:
  410. pcix_cap = (slot_reg & PCIX_CAP_MASK_PI1) >> PCIX_CAP_SHIFT;
  411. break;
  412. case 2:
  413. pcix_cap = (slot_reg & PCIX_CAP_MASK_PI2) >> PCIX_CAP_SHIFT;
  414. break;
  415. default:
  416. return -ENODEV;
  417. }
  418. ctrl_dbg(ctrl, "%s: slot_reg = %x, pcix_cap = %x, m66_cap = %x\n",
  419. __func__, slot_reg, pcix_cap, m66_cap);
  420. switch (pcix_cap) {
  421. case 0x0:
  422. *value = m66_cap ? PCI_SPEED_66MHz : PCI_SPEED_33MHz;
  423. break;
  424. case 0x1:
  425. *value = PCI_SPEED_66MHz_PCIX;
  426. break;
  427. case 0x3:
  428. *value = PCI_SPEED_133MHz_PCIX;
  429. break;
  430. case 0x4:
  431. *value = PCI_SPEED_133MHz_PCIX_266;
  432. break;
  433. case 0x5:
  434. *value = PCI_SPEED_133MHz_PCIX_533;
  435. break;
  436. case 0x2:
  437. default:
  438. *value = PCI_SPEED_UNKNOWN;
  439. retval = -ENODEV;
  440. break;
  441. }
  442. ctrl_dbg(ctrl, "Adapter speed = %d\n", *value);
  443. return retval;
  444. }
  445. static int hpc_get_mode1_ECC_cap(struct slot *slot, u8 *mode)
  446. {
  447. int retval = 0;
  448. struct controller *ctrl = slot->ctrl;
  449. u16 sec_bus_status = shpc_readw(ctrl, SEC_BUS_CONFIG);
  450. u8 pi = shpc_readb(ctrl, PROG_INTERFACE);
  451. if (pi == 2) {
  452. *mode = (sec_bus_status & 0x0100) >> 8;
  453. } else {
  454. retval = -1;
  455. }
  456. ctrl_dbg(ctrl, "Mode 1 ECC cap = %d\n", *mode);
  457. return retval;
  458. }
  459. static int hpc_query_power_fault(struct slot * slot)
  460. {
  461. struct controller *ctrl = slot->ctrl;
  462. u32 slot_reg = shpc_readl(ctrl, SLOT_REG(slot->hp_slot));
  463. /* Note: Logic 0 => fault */
  464. return !(slot_reg & POWER_FAULT);
  465. }
  466. static int hpc_set_attention_status(struct slot *slot, u8 value)
  467. {
  468. u8 slot_cmd = 0;
  469. switch (value) {
  470. case 0 :
  471. slot_cmd = SET_ATTN_OFF; /* OFF */
  472. break;
  473. case 1:
  474. slot_cmd = SET_ATTN_ON; /* ON */
  475. break;
  476. case 2:
  477. slot_cmd = SET_ATTN_BLINK; /* BLINK */
  478. break;
  479. default:
  480. return -1;
  481. }
  482. return shpc_write_cmd(slot, slot->hp_slot, slot_cmd);
  483. }
  484. static void hpc_set_green_led_on(struct slot *slot)
  485. {
  486. shpc_write_cmd(slot, slot->hp_slot, SET_PWR_ON);
  487. }
  488. static void hpc_set_green_led_off(struct slot *slot)
  489. {
  490. shpc_write_cmd(slot, slot->hp_slot, SET_PWR_OFF);
  491. }
  492. static void hpc_set_green_led_blink(struct slot *slot)
  493. {
  494. shpc_write_cmd(slot, slot->hp_slot, SET_PWR_BLINK);
  495. }
  496. static void hpc_release_ctlr(struct controller *ctrl)
  497. {
  498. int i;
  499. u32 slot_reg, serr_int;
  500. /*
  501. * Mask event interrupts and SERRs of all slots
  502. */
  503. for (i = 0; i < ctrl->num_slots; i++) {
  504. slot_reg = shpc_readl(ctrl, SLOT_REG(i));
  505. slot_reg |= (PRSNT_CHANGE_INTR_MASK | ISO_PFAULT_INTR_MASK |
  506. BUTTON_PRESS_INTR_MASK | MRL_CHANGE_INTR_MASK |
  507. CON_PFAULT_INTR_MASK | MRL_CHANGE_SERR_MASK |
  508. CON_PFAULT_SERR_MASK);
  509. slot_reg &= ~SLOT_REG_RSVDZ_MASK;
  510. shpc_writel(ctrl, SLOT_REG(i), slot_reg);
  511. }
  512. cleanup_slots(ctrl);
  513. /*
  514. * Mask SERR and System Interrupt generation
  515. */
  516. serr_int = shpc_readl(ctrl, SERR_INTR_ENABLE);
  517. serr_int |= (GLOBAL_INTR_MASK | GLOBAL_SERR_MASK |
  518. COMMAND_INTR_MASK | ARBITER_SERR_MASK);
  519. serr_int &= ~SERR_INTR_RSVDZ_MASK;
  520. shpc_writel(ctrl, SERR_INTR_ENABLE, serr_int);
  521. if (shpchp_poll_mode)
  522. del_timer(&ctrl->poll_timer);
  523. else {
  524. free_irq(ctrl->pci_dev->irq, ctrl);
  525. pci_disable_msi(ctrl->pci_dev);
  526. }
  527. iounmap(ctrl->creg);
  528. release_mem_region(ctrl->mmio_base, ctrl->mmio_size);
  529. /*
  530. * If this is the last controller to be released, destroy the
  531. * shpchpd work queue
  532. */
  533. if (atomic_dec_and_test(&shpchp_num_controllers))
  534. destroy_workqueue(shpchp_wq);
  535. }
  536. static int hpc_power_on_slot(struct slot * slot)
  537. {
  538. int retval;
  539. retval = shpc_write_cmd(slot, slot->hp_slot, SET_SLOT_PWR);
  540. if (retval)
  541. ctrl_err(slot->ctrl, "%s: Write command failed!\n", __func__);
  542. return retval;
  543. }
  544. static int hpc_slot_enable(struct slot * slot)
  545. {
  546. int retval;
  547. /* Slot - Enable, Power Indicator - Blink, Attention Indicator - Off */
  548. retval = shpc_write_cmd(slot, slot->hp_slot,
  549. SET_SLOT_ENABLE | SET_PWR_BLINK | SET_ATTN_OFF);
  550. if (retval)
  551. ctrl_err(slot->ctrl, "%s: Write command failed!\n", __func__);
  552. return retval;
  553. }
  554. static int hpc_slot_disable(struct slot * slot)
  555. {
  556. int retval;
  557. /* Slot - Disable, Power Indicator - Off, Attention Indicator - On */
  558. retval = shpc_write_cmd(slot, slot->hp_slot,
  559. SET_SLOT_DISABLE | SET_PWR_OFF | SET_ATTN_ON);
  560. if (retval)
  561. ctrl_err(slot->ctrl, "%s: Write command failed!\n", __func__);
  562. return retval;
  563. }
  564. static int hpc_set_bus_speed_mode(struct slot * slot, enum pci_bus_speed value)
  565. {
  566. int retval;
  567. struct controller *ctrl = slot->ctrl;
  568. u8 pi, cmd;
  569. pi = shpc_readb(ctrl, PROG_INTERFACE);
  570. if ((pi == 1) && (value > PCI_SPEED_133MHz_PCIX))
  571. return -EINVAL;
  572. switch (value) {
  573. case PCI_SPEED_33MHz:
  574. cmd = SETA_PCI_33MHZ;
  575. break;
  576. case PCI_SPEED_66MHz:
  577. cmd = SETA_PCI_66MHZ;
  578. break;
  579. case PCI_SPEED_66MHz_PCIX:
  580. cmd = SETA_PCIX_66MHZ;
  581. break;
  582. case PCI_SPEED_100MHz_PCIX:
  583. cmd = SETA_PCIX_100MHZ;
  584. break;
  585. case PCI_SPEED_133MHz_PCIX:
  586. cmd = SETA_PCIX_133MHZ;
  587. break;
  588. case PCI_SPEED_66MHz_PCIX_ECC:
  589. cmd = SETB_PCIX_66MHZ_EM;
  590. break;
  591. case PCI_SPEED_100MHz_PCIX_ECC:
  592. cmd = SETB_PCIX_100MHZ_EM;
  593. break;
  594. case PCI_SPEED_133MHz_PCIX_ECC:
  595. cmd = SETB_PCIX_133MHZ_EM;
  596. break;
  597. case PCI_SPEED_66MHz_PCIX_266:
  598. cmd = SETB_PCIX_66MHZ_266;
  599. break;
  600. case PCI_SPEED_100MHz_PCIX_266:
  601. cmd = SETB_PCIX_100MHZ_266;
  602. break;
  603. case PCI_SPEED_133MHz_PCIX_266:
  604. cmd = SETB_PCIX_133MHZ_266;
  605. break;
  606. case PCI_SPEED_66MHz_PCIX_533:
  607. cmd = SETB_PCIX_66MHZ_533;
  608. break;
  609. case PCI_SPEED_100MHz_PCIX_533:
  610. cmd = SETB_PCIX_100MHZ_533;
  611. break;
  612. case PCI_SPEED_133MHz_PCIX_533:
  613. cmd = SETB_PCIX_133MHZ_533;
  614. break;
  615. default:
  616. return -EINVAL;
  617. }
  618. retval = shpc_write_cmd(slot, 0, cmd);
  619. if (retval)
  620. ctrl_err(ctrl, "%s: Write command failed!\n", __func__);
  621. return retval;
  622. }
  623. static irqreturn_t shpc_isr(int irq, void *dev_id)
  624. {
  625. struct controller *ctrl = (struct controller *)dev_id;
  626. u32 serr_int, slot_reg, intr_loc, intr_loc2;
  627. int hp_slot;
  628. /* Check to see if it was our interrupt */
  629. intr_loc = shpc_readl(ctrl, INTR_LOC);
  630. if (!intr_loc)
  631. return IRQ_NONE;
  632. ctrl_dbg(ctrl, "%s: intr_loc = %x\n", __func__, intr_loc);
  633. if(!shpchp_poll_mode) {
  634. /*
  635. * Mask Global Interrupt Mask - see implementation
  636. * note on p. 139 of SHPC spec rev 1.0
  637. */
  638. serr_int = shpc_readl(ctrl, SERR_INTR_ENABLE);
  639. serr_int |= GLOBAL_INTR_MASK;
  640. serr_int &= ~SERR_INTR_RSVDZ_MASK;
  641. shpc_writel(ctrl, SERR_INTR_ENABLE, serr_int);
  642. intr_loc2 = shpc_readl(ctrl, INTR_LOC);
  643. ctrl_dbg(ctrl, "%s: intr_loc2 = %x\n", __func__, intr_loc2);
  644. }
  645. if (intr_loc & CMD_INTR_PENDING) {
  646. /*
  647. * Command Complete Interrupt Pending
  648. * RO only - clear by writing 1 to the Command Completion
  649. * Detect bit in Controller SERR-INT register
  650. */
  651. serr_int = shpc_readl(ctrl, SERR_INTR_ENABLE);
  652. serr_int &= ~SERR_INTR_RSVDZ_MASK;
  653. shpc_writel(ctrl, SERR_INTR_ENABLE, serr_int);
  654. wake_up_interruptible(&ctrl->queue);
  655. }
  656. if (!(intr_loc & ~CMD_INTR_PENDING))
  657. goto out;
  658. for (hp_slot = 0; hp_slot < ctrl->num_slots; hp_slot++) {
  659. /* To find out which slot has interrupt pending */
  660. if (!(intr_loc & SLOT_INTR_PENDING(hp_slot)))
  661. continue;
  662. slot_reg = shpc_readl(ctrl, SLOT_REG(hp_slot));
  663. ctrl_dbg(ctrl, "Slot %x with intr, slot register = %x\n",
  664. hp_slot, slot_reg);
  665. if (slot_reg & MRL_CHANGE_DETECTED)
  666. shpchp_handle_switch_change(hp_slot, ctrl);
  667. if (slot_reg & BUTTON_PRESS_DETECTED)
  668. shpchp_handle_attention_button(hp_slot, ctrl);
  669. if (slot_reg & PRSNT_CHANGE_DETECTED)
  670. shpchp_handle_presence_change(hp_slot, ctrl);
  671. if (slot_reg & (ISO_PFAULT_DETECTED | CON_PFAULT_DETECTED))
  672. shpchp_handle_power_fault(hp_slot, ctrl);
  673. /* Clear all slot events */
  674. slot_reg &= ~SLOT_REG_RSVDZ_MASK;
  675. shpc_writel(ctrl, SLOT_REG(hp_slot), slot_reg);
  676. }
  677. out:
  678. if (!shpchp_poll_mode) {
  679. /* Unmask Global Interrupt Mask */
  680. serr_int = shpc_readl(ctrl, SERR_INTR_ENABLE);
  681. serr_int &= ~(GLOBAL_INTR_MASK | SERR_INTR_RSVDZ_MASK);
  682. shpc_writel(ctrl, SERR_INTR_ENABLE, serr_int);
  683. }
  684. return IRQ_HANDLED;
  685. }
  686. static int hpc_get_max_bus_speed (struct slot *slot, enum pci_bus_speed *value)
  687. {
  688. int retval = 0;
  689. struct controller *ctrl = slot->ctrl;
  690. enum pci_bus_speed bus_speed = PCI_SPEED_UNKNOWN;
  691. u8 pi = shpc_readb(ctrl, PROG_INTERFACE);
  692. u32 slot_avail1 = shpc_readl(ctrl, SLOT_AVAIL1);
  693. u32 slot_avail2 = shpc_readl(ctrl, SLOT_AVAIL2);
  694. if (pi == 2) {
  695. if (slot_avail2 & SLOT_133MHZ_PCIX_533)
  696. bus_speed = PCI_SPEED_133MHz_PCIX_533;
  697. else if (slot_avail2 & SLOT_100MHZ_PCIX_533)
  698. bus_speed = PCI_SPEED_100MHz_PCIX_533;
  699. else if (slot_avail2 & SLOT_66MHZ_PCIX_533)
  700. bus_speed = PCI_SPEED_66MHz_PCIX_533;
  701. else if (slot_avail2 & SLOT_133MHZ_PCIX_266)
  702. bus_speed = PCI_SPEED_133MHz_PCIX_266;
  703. else if (slot_avail2 & SLOT_100MHZ_PCIX_266)
  704. bus_speed = PCI_SPEED_100MHz_PCIX_266;
  705. else if (slot_avail2 & SLOT_66MHZ_PCIX_266)
  706. bus_speed = PCI_SPEED_66MHz_PCIX_266;
  707. }
  708. if (bus_speed == PCI_SPEED_UNKNOWN) {
  709. if (slot_avail1 & SLOT_133MHZ_PCIX)
  710. bus_speed = PCI_SPEED_133MHz_PCIX;
  711. else if (slot_avail1 & SLOT_100MHZ_PCIX)
  712. bus_speed = PCI_SPEED_100MHz_PCIX;
  713. else if (slot_avail1 & SLOT_66MHZ_PCIX)
  714. bus_speed = PCI_SPEED_66MHz_PCIX;
  715. else if (slot_avail2 & SLOT_66MHZ)
  716. bus_speed = PCI_SPEED_66MHz;
  717. else if (slot_avail1 & SLOT_33MHZ)
  718. bus_speed = PCI_SPEED_33MHz;
  719. else
  720. retval = -ENODEV;
  721. }
  722. *value = bus_speed;
  723. ctrl_dbg(ctrl, "Max bus speed = %d\n", bus_speed);
  724. return retval;
  725. }
  726. static int hpc_get_cur_bus_speed (struct slot *slot, enum pci_bus_speed *value)
  727. {
  728. int retval = 0;
  729. struct controller *ctrl = slot->ctrl;
  730. enum pci_bus_speed bus_speed = PCI_SPEED_UNKNOWN;
  731. u16 sec_bus_reg = shpc_readw(ctrl, SEC_BUS_CONFIG);
  732. u8 pi = shpc_readb(ctrl, PROG_INTERFACE);
  733. u8 speed_mode = (pi == 2) ? (sec_bus_reg & 0xF) : (sec_bus_reg & 0x7);
  734. if ((pi == 1) && (speed_mode > 4)) {
  735. *value = PCI_SPEED_UNKNOWN;
  736. return -ENODEV;
  737. }
  738. switch (speed_mode) {
  739. case 0x0:
  740. *value = PCI_SPEED_33MHz;
  741. break;
  742. case 0x1:
  743. *value = PCI_SPEED_66MHz;
  744. break;
  745. case 0x2:
  746. *value = PCI_SPEED_66MHz_PCIX;
  747. break;
  748. case 0x3:
  749. *value = PCI_SPEED_100MHz_PCIX;
  750. break;
  751. case 0x4:
  752. *value = PCI_SPEED_133MHz_PCIX;
  753. break;
  754. case 0x5:
  755. *value = PCI_SPEED_66MHz_PCIX_ECC;
  756. break;
  757. case 0x6:
  758. *value = PCI_SPEED_100MHz_PCIX_ECC;
  759. break;
  760. case 0x7:
  761. *value = PCI_SPEED_133MHz_PCIX_ECC;
  762. break;
  763. case 0x8:
  764. *value = PCI_SPEED_66MHz_PCIX_266;
  765. break;
  766. case 0x9:
  767. *value = PCI_SPEED_100MHz_PCIX_266;
  768. break;
  769. case 0xa:
  770. *value = PCI_SPEED_133MHz_PCIX_266;
  771. break;
  772. case 0xb:
  773. *value = PCI_SPEED_66MHz_PCIX_533;
  774. break;
  775. case 0xc:
  776. *value = PCI_SPEED_100MHz_PCIX_533;
  777. break;
  778. case 0xd:
  779. *value = PCI_SPEED_133MHz_PCIX_533;
  780. break;
  781. default:
  782. *value = PCI_SPEED_UNKNOWN;
  783. retval = -ENODEV;
  784. break;
  785. }
  786. ctrl_dbg(ctrl, "Current bus speed = %d\n", bus_speed);
  787. return retval;
  788. }
  789. static struct hpc_ops shpchp_hpc_ops = {
  790. .power_on_slot = hpc_power_on_slot,
  791. .slot_enable = hpc_slot_enable,
  792. .slot_disable = hpc_slot_disable,
  793. .set_bus_speed_mode = hpc_set_bus_speed_mode,
  794. .set_attention_status = hpc_set_attention_status,
  795. .get_power_status = hpc_get_power_status,
  796. .get_attention_status = hpc_get_attention_status,
  797. .get_latch_status = hpc_get_latch_status,
  798. .get_adapter_status = hpc_get_adapter_status,
  799. .get_max_bus_speed = hpc_get_max_bus_speed,
  800. .get_cur_bus_speed = hpc_get_cur_bus_speed,
  801. .get_adapter_speed = hpc_get_adapter_speed,
  802. .get_mode1_ECC_cap = hpc_get_mode1_ECC_cap,
  803. .get_prog_int = hpc_get_prog_int,
  804. .query_power_fault = hpc_query_power_fault,
  805. .green_led_on = hpc_set_green_led_on,
  806. .green_led_off = hpc_set_green_led_off,
  807. .green_led_blink = hpc_set_green_led_blink,
  808. .release_ctlr = hpc_release_ctlr,
  809. };
  810. int shpc_init(struct controller *ctrl, struct pci_dev *pdev)
  811. {
  812. int rc = -1, num_slots = 0;
  813. u8 hp_slot;
  814. u32 shpc_base_offset;
  815. u32 tempdword, slot_reg, slot_config;
  816. u8 i;
  817. ctrl->pci_dev = pdev; /* pci_dev of the P2P bridge */
  818. ctrl_dbg(ctrl, "Hotplug Controller:\n");
  819. if ((pdev->vendor == PCI_VENDOR_ID_AMD) || (pdev->device ==
  820. PCI_DEVICE_ID_AMD_GOLAM_7450)) {
  821. /* amd shpc driver doesn't use Base Offset; assume 0 */
  822. ctrl->mmio_base = pci_resource_start(pdev, 0);
  823. ctrl->mmio_size = pci_resource_len(pdev, 0);
  824. } else {
  825. ctrl->cap_offset = pci_find_capability(pdev, PCI_CAP_ID_SHPC);
  826. if (!ctrl->cap_offset) {
  827. ctrl_err(ctrl, "Cannot find PCI capability\n");
  828. goto abort;
  829. }
  830. ctrl_dbg(ctrl, " cap_offset = %x\n", ctrl->cap_offset);
  831. rc = shpc_indirect_read(ctrl, 0, &shpc_base_offset);
  832. if (rc) {
  833. ctrl_err(ctrl, "Cannot read base_offset\n");
  834. goto abort;
  835. }
  836. rc = shpc_indirect_read(ctrl, 3, &tempdword);
  837. if (rc) {
  838. ctrl_err(ctrl, "Cannot read slot config\n");
  839. goto abort;
  840. }
  841. num_slots = tempdword & SLOT_NUM;
  842. ctrl_dbg(ctrl, " num_slots (indirect) %x\n", num_slots);
  843. for (i = 0; i < 9 + num_slots; i++) {
  844. rc = shpc_indirect_read(ctrl, i, &tempdword);
  845. if (rc) {
  846. ctrl_err(ctrl,
  847. "Cannot read creg (index = %d)\n", i);
  848. goto abort;
  849. }
  850. ctrl_dbg(ctrl, " offset %d: value %x\n", i, tempdword);
  851. }
  852. ctrl->mmio_base =
  853. pci_resource_start(pdev, 0) + shpc_base_offset;
  854. ctrl->mmio_size = 0x24 + 0x4 * num_slots;
  855. }
  856. ctrl_info(ctrl, "HPC vendor_id %x device_id %x ss_vid %x ss_did %x\n",
  857. pdev->vendor, pdev->device, pdev->subsystem_vendor,
  858. pdev->subsystem_device);
  859. rc = pci_enable_device(pdev);
  860. if (rc) {
  861. ctrl_err(ctrl, "pci_enable_device failed\n");
  862. goto abort;
  863. }
  864. if (!request_mem_region(ctrl->mmio_base, ctrl->mmio_size, MY_NAME)) {
  865. ctrl_err(ctrl, "Cannot reserve MMIO region\n");
  866. rc = -1;
  867. goto abort;
  868. }
  869. ctrl->creg = ioremap(ctrl->mmio_base, ctrl->mmio_size);
  870. if (!ctrl->creg) {
  871. ctrl_err(ctrl, "Cannot remap MMIO region %lx @ %lx\n",
  872. ctrl->mmio_size, ctrl->mmio_base);
  873. release_mem_region(ctrl->mmio_base, ctrl->mmio_size);
  874. rc = -1;
  875. goto abort;
  876. }
  877. ctrl_dbg(ctrl, "ctrl->creg %p\n", ctrl->creg);
  878. mutex_init(&ctrl->crit_sect);
  879. mutex_init(&ctrl->cmd_lock);
  880. /* Setup wait queue */
  881. init_waitqueue_head(&ctrl->queue);
  882. ctrl->hpc_ops = &shpchp_hpc_ops;
  883. /* Return PCI Controller Info */
  884. slot_config = shpc_readl(ctrl, SLOT_CONFIG);
  885. ctrl->slot_device_offset = (slot_config & FIRST_DEV_NUM) >> 8;
  886. ctrl->num_slots = slot_config & SLOT_NUM;
  887. ctrl->first_slot = (slot_config & PSN) >> 16;
  888. ctrl->slot_num_inc = ((slot_config & UPDOWN) >> 29) ? 1 : -1;
  889. /* Mask Global Interrupt Mask & Command Complete Interrupt Mask */
  890. tempdword = shpc_readl(ctrl, SERR_INTR_ENABLE);
  891. ctrl_dbg(ctrl, "SERR_INTR_ENABLE = %x\n", tempdword);
  892. tempdword |= (GLOBAL_INTR_MASK | GLOBAL_SERR_MASK |
  893. COMMAND_INTR_MASK | ARBITER_SERR_MASK);
  894. tempdword &= ~SERR_INTR_RSVDZ_MASK;
  895. shpc_writel(ctrl, SERR_INTR_ENABLE, tempdword);
  896. tempdword = shpc_readl(ctrl, SERR_INTR_ENABLE);
  897. ctrl_dbg(ctrl, "SERR_INTR_ENABLE = %x\n", tempdword);
  898. /* Mask the MRL sensor SERR Mask of individual slot in
  899. * Slot SERR-INT Mask & clear all the existing event if any
  900. */
  901. for (hp_slot = 0; hp_slot < ctrl->num_slots; hp_slot++) {
  902. slot_reg = shpc_readl(ctrl, SLOT_REG(hp_slot));
  903. ctrl_dbg(ctrl, "Default Logical Slot Register %d value %x\n",
  904. hp_slot, slot_reg);
  905. slot_reg |= (PRSNT_CHANGE_INTR_MASK | ISO_PFAULT_INTR_MASK |
  906. BUTTON_PRESS_INTR_MASK | MRL_CHANGE_INTR_MASK |
  907. CON_PFAULT_INTR_MASK | MRL_CHANGE_SERR_MASK |
  908. CON_PFAULT_SERR_MASK);
  909. slot_reg &= ~SLOT_REG_RSVDZ_MASK;
  910. shpc_writel(ctrl, SLOT_REG(hp_slot), slot_reg);
  911. }
  912. if (shpchp_poll_mode) {
  913. /* Install interrupt polling timer. Start with 10 sec delay */
  914. init_timer(&ctrl->poll_timer);
  915. start_int_poll_timer(ctrl, 10);
  916. } else {
  917. /* Installs the interrupt handler */
  918. rc = pci_enable_msi(pdev);
  919. if (rc) {
  920. ctrl_info(ctrl,
  921. "Can't get msi for the hotplug controller\n");
  922. ctrl_info(ctrl,
  923. "Use INTx for the hotplug controller\n");
  924. }
  925. rc = request_irq(ctrl->pci_dev->irq, shpc_isr, IRQF_SHARED,
  926. MY_NAME, (void *)ctrl);
  927. ctrl_dbg(ctrl, "request_irq %d for hpc%d (returns %d)\n",
  928. ctrl->pci_dev->irq,
  929. atomic_read(&shpchp_num_controllers), rc);
  930. if (rc) {
  931. ctrl_err(ctrl, "Can't get irq %d for the hotplug "
  932. "controller\n", ctrl->pci_dev->irq);
  933. goto abort_iounmap;
  934. }
  935. }
  936. ctrl_dbg(ctrl, "HPC at %s irq=%x\n", pci_name(pdev), pdev->irq);
  937. /*
  938. * If this is the first controller to be initialized,
  939. * initialize the shpchpd work queue
  940. */
  941. if (atomic_add_return(1, &shpchp_num_controllers) == 1) {
  942. shpchp_wq = create_singlethread_workqueue("shpchpd");
  943. if (!shpchp_wq) {
  944. rc = -ENOMEM;
  945. goto abort_iounmap;
  946. }
  947. }
  948. /*
  949. * Unmask all event interrupts of all slots
  950. */
  951. for (hp_slot = 0; hp_slot < ctrl->num_slots; hp_slot++) {
  952. slot_reg = shpc_readl(ctrl, SLOT_REG(hp_slot));
  953. ctrl_dbg(ctrl, "Default Logical Slot Register %d value %x\n",
  954. hp_slot, slot_reg);
  955. slot_reg &= ~(PRSNT_CHANGE_INTR_MASK | ISO_PFAULT_INTR_MASK |
  956. BUTTON_PRESS_INTR_MASK | MRL_CHANGE_INTR_MASK |
  957. CON_PFAULT_INTR_MASK | SLOT_REG_RSVDZ_MASK);
  958. shpc_writel(ctrl, SLOT_REG(hp_slot), slot_reg);
  959. }
  960. if (!shpchp_poll_mode) {
  961. /* Unmask all general input interrupts and SERR */
  962. tempdword = shpc_readl(ctrl, SERR_INTR_ENABLE);
  963. tempdword &= ~(GLOBAL_INTR_MASK | COMMAND_INTR_MASK |
  964. SERR_INTR_RSVDZ_MASK);
  965. shpc_writel(ctrl, SERR_INTR_ENABLE, tempdword);
  966. tempdword = shpc_readl(ctrl, SERR_INTR_ENABLE);
  967. ctrl_dbg(ctrl, "SERR_INTR_ENABLE = %x\n", tempdword);
  968. }
  969. return 0;
  970. /* We end up here for the many possible ways to fail this API. */
  971. abort_iounmap:
  972. iounmap(ctrl->creg);
  973. abort:
  974. return rc;
  975. }