iSeries_pci_reset.c
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:5k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

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