call_pci.h 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. /*
  2. * Provides the Hypervisor PCI calls for iSeries Linux Parition.
  3. * Copyright (C) 2001 <Wayne G Holm> <IBM Corporation>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the:
  17. * Free Software Foundation, Inc.,
  18. * 59 Temple Place, Suite 330,
  19. * Boston, MA 02111-1307 USA
  20. *
  21. * Change Activity:
  22. * Created, Jan 9, 2001
  23. */
  24. #ifndef _PLATFORMS_ISERIES_CALL_PCI_H
  25. #define _PLATFORMS_ISERIES_CALL_PCI_H
  26. #include <asm/iseries/hv_call_sc.h>
  27. #include <asm/iseries/hv_types.h>
  28. /*
  29. * DSA == Direct Select Address
  30. * this struct must be 64 bits in total
  31. */
  32. struct HvCallPci_DsaAddr {
  33. u16 busNumber; /* PHB index? */
  34. u8 subBusNumber; /* PCI bus number? */
  35. u8 deviceId; /* device and function? */
  36. u8 barNumber;
  37. u8 reserved[3];
  38. };
  39. union HvDsaMap {
  40. u64 DsaAddr;
  41. struct HvCallPci_DsaAddr Dsa;
  42. };
  43. struct HvCallPci_LoadReturn {
  44. u64 rc;
  45. u64 value;
  46. };
  47. enum HvCallPci_DeviceType {
  48. HvCallPci_NodeDevice = 1,
  49. HvCallPci_SpDevice = 2,
  50. HvCallPci_IopDevice = 3,
  51. HvCallPci_BridgeDevice = 4,
  52. HvCallPci_MultiFunctionDevice = 5,
  53. HvCallPci_IoaDevice = 6
  54. };
  55. struct HvCallPci_DeviceInfo {
  56. u32 deviceType; /* See DeviceType enum for values */
  57. };
  58. struct HvCallPci_BusUnitInfo {
  59. u32 sizeReturned; /* length of data returned */
  60. u32 deviceType; /* see DeviceType enum for values */
  61. };
  62. struct HvCallPci_BridgeInfo {
  63. struct HvCallPci_BusUnitInfo busUnitInfo; /* Generic bus unit info */
  64. u8 subBusNumber; /* Bus number of secondary bus */
  65. u8 maxAgents; /* Max idsels on secondary bus */
  66. u8 maxSubBusNumber; /* Max Sub Bus */
  67. u8 logicalSlotNumber; /* Logical Slot Number for IOA */
  68. };
  69. /*
  70. * Maximum BusUnitInfo buffer size. Provided for clients so
  71. * they can allocate a buffer big enough for any type of bus
  72. * unit. Increase as needed.
  73. */
  74. enum {HvCallPci_MaxBusUnitInfoSize = 128};
  75. struct HvCallPci_BarParms {
  76. u64 vaddr;
  77. u64 raddr;
  78. u64 size;
  79. u64 protectStart;
  80. u64 protectEnd;
  81. u64 relocationOffset;
  82. u64 pciAddress;
  83. u64 reserved[3];
  84. };
  85. enum HvCallPci_VpdType {
  86. HvCallPci_BusVpd = 1,
  87. HvCallPci_BusAdapterVpd = 2
  88. };
  89. #define HvCallPciConfigLoad8 HvCallPci + 0
  90. #define HvCallPciConfigLoad16 HvCallPci + 1
  91. #define HvCallPciConfigLoad32 HvCallPci + 2
  92. #define HvCallPciConfigStore8 HvCallPci + 3
  93. #define HvCallPciConfigStore16 HvCallPci + 4
  94. #define HvCallPciConfigStore32 HvCallPci + 5
  95. #define HvCallPciEoi HvCallPci + 16
  96. #define HvCallPciGetBarParms HvCallPci + 18
  97. #define HvCallPciMaskFisr HvCallPci + 20
  98. #define HvCallPciUnmaskFisr HvCallPci + 21
  99. #define HvCallPciSetSlotReset HvCallPci + 25
  100. #define HvCallPciGetDeviceInfo HvCallPci + 27
  101. #define HvCallPciGetCardVpd HvCallPci + 28
  102. #define HvCallPciBarLoad8 HvCallPci + 40
  103. #define HvCallPciBarLoad16 HvCallPci + 41
  104. #define HvCallPciBarLoad32 HvCallPci + 42
  105. #define HvCallPciBarLoad64 HvCallPci + 43
  106. #define HvCallPciBarStore8 HvCallPci + 44
  107. #define HvCallPciBarStore16 HvCallPci + 45
  108. #define HvCallPciBarStore32 HvCallPci + 46
  109. #define HvCallPciBarStore64 HvCallPci + 47
  110. #define HvCallPciMaskInterrupts HvCallPci + 48
  111. #define HvCallPciUnmaskInterrupts HvCallPci + 49
  112. #define HvCallPciGetBusUnitInfo HvCallPci + 50
  113. static inline u64 HvCallPci_configLoad16(u16 busNumber, u8 subBusNumber,
  114. u8 deviceId, u32 offset, u16 *value)
  115. {
  116. struct HvCallPci_DsaAddr dsa;
  117. struct HvCallPci_LoadReturn retVal;
  118. *((u64*)&dsa) = 0;
  119. dsa.busNumber = busNumber;
  120. dsa.subBusNumber = subBusNumber;
  121. dsa.deviceId = deviceId;
  122. HvCall3Ret16(HvCallPciConfigLoad16, &retVal, *(u64 *)&dsa, offset, 0);
  123. *value = retVal.value;
  124. return retVal.rc;
  125. }
  126. static inline u64 HvCallPci_configStore8(u16 busNumber, u8 subBusNumber,
  127. u8 deviceId, u32 offset, u8 value)
  128. {
  129. struct HvCallPci_DsaAddr dsa;
  130. *((u64*)&dsa) = 0;
  131. dsa.busNumber = busNumber;
  132. dsa.subBusNumber = subBusNumber;
  133. dsa.deviceId = deviceId;
  134. return HvCall4(HvCallPciConfigStore8, *(u64 *)&dsa, offset, value, 0);
  135. }
  136. static inline u64 HvCallPci_eoi(u16 busNumberParm, u8 subBusParm,
  137. u8 deviceIdParm)
  138. {
  139. struct HvCallPci_DsaAddr dsa;
  140. struct HvCallPci_LoadReturn retVal;
  141. *((u64*)&dsa) = 0;
  142. dsa.busNumber = busNumberParm;
  143. dsa.subBusNumber = subBusParm;
  144. dsa.deviceId = deviceIdParm;
  145. HvCall1Ret16(HvCallPciEoi, &retVal, *(u64*)&dsa);
  146. return retVal.rc;
  147. }
  148. static inline u64 HvCallPci_getBarParms(u16 busNumberParm, u8 subBusParm,
  149. u8 deviceIdParm, u8 barNumberParm, u64 parms, u32 sizeofParms)
  150. {
  151. struct HvCallPci_DsaAddr dsa;
  152. *((u64*)&dsa) = 0;
  153. dsa.busNumber = busNumberParm;
  154. dsa.subBusNumber = subBusParm;
  155. dsa.deviceId = deviceIdParm;
  156. dsa.barNumber = barNumberParm;
  157. return HvCall3(HvCallPciGetBarParms, *(u64*)&dsa, parms, sizeofParms);
  158. }
  159. static inline u64 HvCallPci_maskFisr(u16 busNumberParm, u8 subBusParm,
  160. u8 deviceIdParm, u64 fisrMask)
  161. {
  162. struct HvCallPci_DsaAddr dsa;
  163. *((u64*)&dsa) = 0;
  164. dsa.busNumber = busNumberParm;
  165. dsa.subBusNumber = subBusParm;
  166. dsa.deviceId = deviceIdParm;
  167. return HvCall2(HvCallPciMaskFisr, *(u64*)&dsa, fisrMask);
  168. }
  169. static inline u64 HvCallPci_unmaskFisr(u16 busNumberParm, u8 subBusParm,
  170. u8 deviceIdParm, u64 fisrMask)
  171. {
  172. struct HvCallPci_DsaAddr dsa;
  173. *((u64*)&dsa) = 0;
  174. dsa.busNumber = busNumberParm;
  175. dsa.subBusNumber = subBusParm;
  176. dsa.deviceId = deviceIdParm;
  177. return HvCall2(HvCallPciUnmaskFisr, *(u64*)&dsa, fisrMask);
  178. }
  179. static inline u64 HvCallPci_getDeviceInfo(u16 busNumberParm, u8 subBusParm,
  180. u8 deviceNumberParm, u64 parms, u32 sizeofParms)
  181. {
  182. struct HvCallPci_DsaAddr dsa;
  183. *((u64*)&dsa) = 0;
  184. dsa.busNumber = busNumberParm;
  185. dsa.subBusNumber = subBusParm;
  186. dsa.deviceId = deviceNumberParm << 4;
  187. return HvCall3(HvCallPciGetDeviceInfo, *(u64*)&dsa, parms, sizeofParms);
  188. }
  189. static inline u64 HvCallPci_maskInterrupts(u16 busNumberParm, u8 subBusParm,
  190. u8 deviceIdParm, u64 interruptMask)
  191. {
  192. struct HvCallPci_DsaAddr dsa;
  193. *((u64*)&dsa) = 0;
  194. dsa.busNumber = busNumberParm;
  195. dsa.subBusNumber = subBusParm;
  196. dsa.deviceId = deviceIdParm;
  197. return HvCall2(HvCallPciMaskInterrupts, *(u64*)&dsa, interruptMask);
  198. }
  199. static inline u64 HvCallPci_unmaskInterrupts(u16 busNumberParm, u8 subBusParm,
  200. u8 deviceIdParm, u64 interruptMask)
  201. {
  202. struct HvCallPci_DsaAddr dsa;
  203. *((u64*)&dsa) = 0;
  204. dsa.busNumber = busNumberParm;
  205. dsa.subBusNumber = subBusParm;
  206. dsa.deviceId = deviceIdParm;
  207. return HvCall2(HvCallPciUnmaskInterrupts, *(u64*)&dsa, interruptMask);
  208. }
  209. static inline u64 HvCallPci_getBusUnitInfo(u16 busNumberParm, u8 subBusParm,
  210. u8 deviceIdParm, u64 parms, u32 sizeofParms)
  211. {
  212. struct HvCallPci_DsaAddr dsa;
  213. *((u64*)&dsa) = 0;
  214. dsa.busNumber = busNumberParm;
  215. dsa.subBusNumber = subBusParm;
  216. dsa.deviceId = deviceIdParm;
  217. return HvCall3(HvCallPciGetBusUnitInfo, *(u64*)&dsa, parms,
  218. sizeofParms);
  219. }
  220. static inline int HvCallPci_getBusVpd(u16 busNumParm, u64 destParm,
  221. u16 sizeParm)
  222. {
  223. u64 xRc = HvCall4(HvCallPciGetCardVpd, busNumParm, destParm,
  224. sizeParm, HvCallPci_BusVpd);
  225. if (xRc == -1)
  226. return -1;
  227. else
  228. return xRc & 0xFFFF;
  229. }
  230. #endif /* _PLATFORMS_ISERIES_CALL_PCI_H */