iSeries_pci.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. #ifndef _ISERIES_64_PCI_H
  2. #define _ISERIES_64_PCI_H
  3. /*
  4. * File iSeries_pci.h created by Allan Trautman on Tue Feb 20, 2001.
  5. *
  6. * Define some useful macros for the iSeries pci routines.
  7. * Copyright (C) 2001 Allan H Trautman, IBM Corporation
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 2 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the:
  21. * Free Software Foundation, Inc.,
  22. * 59 Temple Place, Suite 330,
  23. * Boston, MA 02111-1307 USA
  24. *
  25. * Change Activity:
  26. * Created Feb 20, 2001
  27. * Added device reset, March 22, 2001
  28. * Ported to ppc64, May 25, 2001
  29. * End Change Activity
  30. */
  31. #include <asm/iSeries/HvCallPci.h>
  32. #include <asm/abs_addr.h>
  33. struct pci_dev; /* For Forward Reference */
  34. struct iSeries_Device_Node;
  35. /*
  36. * Gets iSeries Bus, SubBus, DevFn using iSeries_Device_Node structure
  37. */
  38. #define ISERIES_BUS(DevPtr) DevPtr->DsaAddr.Dsa.busNumber
  39. #define ISERIES_SUBBUS(DevPtr) DevPtr->DsaAddr.Dsa.subBusNumber
  40. #define ISERIES_DEVICE(DevPtr) DevPtr->DsaAddr.Dsa.deviceId
  41. #define ISERIES_DSA(DevPtr) DevPtr->DsaAddr.DsaAddr
  42. #define ISERIES_DEVFUN(DevPtr) DevPtr->DevFn
  43. #define ISERIES_DEVNODE(PciDev) ((struct iSeries_Device_Node*)PciDev->sysdata)
  44. #define EADsMaxAgents 7
  45. /*
  46. * Decodes Linux DevFn to iSeries DevFn, bridge device, or function.
  47. * For Linux, see PCI_SLOT and PCI_FUNC in include/linux/pci.h
  48. */
  49. #define ISERIES_PCI_AGENTID(idsel, func) \
  50. ((idsel & 0x0F) << 4) | (func & 0x07)
  51. #define ISERIES_ENCODE_DEVICE(agentid) \
  52. ((0x10) | ((agentid & 0x20) >> 2) | (agentid & 0x07))
  53. #define ISERIES_GET_DEVICE_FROM_SUBBUS(subbus) ((subbus >> 5) & 0x7)
  54. #define ISERIES_GET_FUNCTION_FROM_SUBBUS(subbus) ((subbus >> 2) & 0x7)
  55. /*
  56. * N.B. the ISERIES_DECODE_* macros are not used anywhere, and I think
  57. * the 0x71 (at least) must be wrong - 0x78 maybe? -- paulus.
  58. */
  59. #define ISERIES_DECODE_DEVFN(linuxdevfn) \
  60. (((linuxdevfn & 0x71) << 1) | (linuxdevfn & 0x07))
  61. #define ISERIES_DECODE_DEVICE(linuxdevfn) \
  62. (((linuxdevfn & 0x38) >> 3) | (((linuxdevfn & 0x40) >> 2) + 0x10))
  63. #define ISERIES_DECODE_FUNCTION(linuxdevfn) \
  64. (linuxdevfn & 0x07)
  65. /*
  66. * Converts Virtual Address to Real Address for Hypervisor calls
  67. */
  68. #define ISERIES_HV_ADDR(virtaddr) \
  69. (0x8000000000000000 | virt_to_abs(virtaddr))
  70. /*
  71. * iSeries Device Information
  72. */
  73. struct iSeries_Device_Node {
  74. struct list_head Device_List;
  75. struct pci_dev *PciDev;
  76. union HvDsaMap DsaAddr; /* Direct Select Address */
  77. /* busNumber, subBusNumber, */
  78. /* deviceId, barNumber */
  79. HvAgentId AgentId; /* Hypervisor DevFn */
  80. int DevFn; /* Linux devfn */
  81. int BarOffset;
  82. int Irq; /* Assigned IRQ */
  83. int ReturnCode; /* Return Code Holder */
  84. int IoRetry; /* Current Retry Count */
  85. int Flags; /* Possible flags(disable/bist)*/
  86. u16 Vendor; /* Vendor ID */
  87. u8 LogicalSlot; /* Hv Slot Index for Tces */
  88. struct iommu_table *iommu_table;/* Device TCE Table */
  89. u8 PhbId; /* Phb Card is on. */
  90. u16 Board; /* Board Number */
  91. u8 FrameId; /* iSeries spcn Frame Id */
  92. char CardLocation[4];/* Char format of planar vpd */
  93. char Location[20]; /* Frame 1, Card C10 */
  94. };
  95. extern int iSeries_Device_Information(struct pci_dev*, char*, int);
  96. extern void iSeries_Get_Location_Code(struct iSeries_Device_Node*);
  97. extern int iSeries_Device_ToggleReset(struct pci_dev* PciDev,
  98. int AssertTime, int DelayTime);
  99. #endif /* _ISERIES_64_PCI_H */