/arch/ppc64/kernel/iSeries_pci_reset.c

https://bitbucket.org/evzijst/gittest · C · 104 lines · 56 code · 7 blank · 41 comment · 11 complexity · 8bd64fab357dc5b91376398c7f58c47f MD5 · raw file

  1. #define PCIFR(...)
  2. /************************************************************************/
  3. /* File iSeries_pci_reset.c created by Allan Trautman on Mar 21 2001. */
  4. /************************************************************************/
  5. /* This code supports the pci interface on the IBM iSeries systems. */
  6. /* Copyright (C) 20yy <Allan H Trautman> <IBM Corp> */
  7. /* */
  8. /* This program is free software; you can redistribute it and/or modify */
  9. /* it under the terms of the GNU General Public License as published by */
  10. /* the Free Software Foundation; either version 2 of the License, or */
  11. /* (at your option) any later version. */
  12. /* */
  13. /* This program is distributed in the hope that it will be useful, */
  14. /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
  15. /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
  16. /* GNU General Public License for more details. */
  17. /* */
  18. /* You should have received a copy of the GNU General Public License */
  19. /* along with this program; if not, write to the: */
  20. /* Free Software Foundation, Inc., */
  21. /* 59 Temple Place, Suite 330, */
  22. /* Boston, MA 02111-1307 USA */
  23. /************************************************************************/
  24. /* Change Activity: */
  25. /* Created, March 20, 2001 */
  26. /* April 30, 2001, Added return codes on functions. */
  27. /* September 10, 2001, Ported to ppc64. */
  28. /* End Change Activity */
  29. /************************************************************************/
  30. #include <linux/kernel.h>
  31. #include <linux/init.h>
  32. #include <linux/module.h>
  33. #include <linux/pci.h>
  34. #include <linux/irq.h>
  35. #include <linux/delay.h>
  36. #include <asm/io.h>
  37. #include <asm/iSeries/HvCallPci.h>
  38. #include <asm/iSeries/HvTypes.h>
  39. #include <asm/iSeries/mf.h>
  40. #include <asm/pci.h>
  41. #include <asm/iSeries/iSeries_pci.h>
  42. #include "pci.h"
  43. /*
  44. * Interface to toggle the reset line
  45. * Time is in .1 seconds, need for seconds.
  46. */
  47. int iSeries_Device_ToggleReset(struct pci_dev *PciDev, int AssertTime,
  48. int DelayTime)
  49. {
  50. unsigned int AssertDelay, WaitDelay;
  51. struct iSeries_Device_Node *DeviceNode =
  52. (struct iSeries_Device_Node *)PciDev->sysdata;
  53. if (DeviceNode == NULL) {
  54. printk("PCI: Pci Reset Failed, Device Node not found for pci_dev %p\n",
  55. PciDev);
  56. return -1;
  57. }
  58. /*
  59. * Set defaults, Assert is .5 second, Wait is 3 seconds.
  60. */
  61. if (AssertTime == 0)
  62. AssertDelay = 500;
  63. else
  64. AssertDelay = AssertTime * 100;
  65. if (DelayTime == 0)
  66. WaitDelay = 3000;
  67. else
  68. WaitDelay = DelayTime * 100;
  69. /*
  70. * Assert reset
  71. */
  72. DeviceNode->ReturnCode = HvCallPci_setSlotReset(ISERIES_BUS(DeviceNode),
  73. 0x00, DeviceNode->AgentId, 1);
  74. if (DeviceNode->ReturnCode == 0) {
  75. msleep(AssertDelay); /* Sleep for the time */
  76. DeviceNode->ReturnCode =
  77. HvCallPci_setSlotReset(ISERIES_BUS(DeviceNode),
  78. 0x00, DeviceNode->AgentId, 0);
  79. /*
  80. * Wait for device to reset
  81. */
  82. msleep(WaitDelay);
  83. }
  84. if (DeviceNode->ReturnCode == 0)
  85. PCIFR("Slot 0x%04X.%02 Reset\n", ISERIES_BUS(DeviceNode),
  86. DeviceNode->AgentId);
  87. else {
  88. printk("PCI: Slot 0x%04X.%02X Reset Failed, RCode: %04X\n",
  89. ISERIES_BUS(DeviceNode), DeviceNode->AgentId,
  90. DeviceNode->ReturnCode);
  91. PCIFR("Slot 0x%04X.%02X Reset Failed, RCode: %04X\n",
  92. ISERIES_BUS(DeviceNode), DeviceNode->AgentId,
  93. DeviceNode->ReturnCode);
  94. }
  95. return DeviceNode->ReturnCode;
  96. }
  97. EXPORT_SYMBOL(iSeries_Device_ToggleReset);