call_pci.h 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  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_configLoad32(u16 busNumber, u8 subBusNumber,
  127. u8 deviceId, u32 offset, u32 *value)
  128. {
  129. struct HvCallPci_DsaAddr dsa;
  130. struct HvCallPci_LoadReturn retVal;
  131. *((u64*)&dsa) = 0;
  132. dsa.busNumber = busNumber;
  133. dsa.subBusNumber = subBusNumber;
  134. dsa.deviceId = deviceId;
  135. HvCall3Ret16(HvCallPciConfigLoad32, &retVal, *(u64 *)&dsa, offset, 0);
  136. *value = retVal.value;
  137. return retVal.rc;
  138. }
  139. static inline u64 HvCallPci_configStore8(u16 busNumber, u8 subBusNumber,
  140. u8 deviceId, u32 offset, u8 value)
  141. {
  142. struct HvCallPci_DsaAddr dsa;
  143. *((u64*)&dsa) = 0;
  144. dsa.busNumber = busNumber;
  145. dsa.subBusNumber = subBusNumber;
  146. dsa.deviceId = deviceId;
  147. return HvCall4(HvCallPciConfigStore8, *(u64 *)&dsa, offset, value, 0);
  148. }
  149. static inline u64 HvCallPci_eoi(u16 busNumberParm, u8 subBusParm,
  150. u8 deviceIdParm)
  151. {
  152. struct HvCallPci_DsaAddr dsa;
  153. struct HvCallPci_LoadReturn retVal;
  154. *((u64*)&dsa) = 0;
  155. dsa.busNumber = busNumberParm;
  156. dsa.subBusNumber = subBusParm;
  157. dsa.deviceId = deviceIdParm;
  158. HvCall1Ret16(HvCallPciEoi, &retVal, *(u64*)&dsa);
  159. return retVal.rc;
  160. }
  161. static inline u64 HvCallPci_getBarParms(u16 busNumberParm, u8 subBusParm,
  162. u8 deviceIdParm, u8 barNumberParm, u64 parms, u32 sizeofParms)
  163. {
  164. struct HvCallPci_DsaAddr dsa;
  165. *((u64*)&dsa) = 0;
  166. dsa.busNumber = busNumberParm;
  167. dsa.subBusNumber = subBusParm;
  168. dsa.deviceId = deviceIdParm;
  169. dsa.barNumber = barNumberParm;
  170. return HvCall3(HvCallPciGetBarParms, *(u64*)&dsa, parms, sizeofParms);
  171. }
  172. static inline u64 HvCallPci_maskFisr(u16 busNumberParm, u8 subBusParm,
  173. u8 deviceIdParm, u64 fisrMask)
  174. {
  175. struct HvCallPci_DsaAddr dsa;
  176. *((u64*)&dsa) = 0;
  177. dsa.busNumber = busNumberParm;
  178. dsa.subBusNumber = subBusParm;
  179. dsa.deviceId = deviceIdParm;
  180. return HvCall2(HvCallPciMaskFisr, *(u64*)&dsa, fisrMask);
  181. }
  182. static inline u64 HvCallPci_unmaskFisr(u16 busNumberParm, u8 subBusParm,
  183. u8 deviceIdParm, u64 fisrMask)
  184. {
  185. struct HvCallPci_DsaAddr dsa;
  186. *((u64*)&dsa) = 0;
  187. dsa.busNumber = busNumberParm;
  188. dsa.subBusNumber = subBusParm;
  189. dsa.deviceId = deviceIdParm;
  190. return HvCall2(HvCallPciUnmaskFisr, *(u64*)&dsa, fisrMask);
  191. }
  192. static inline u64 HvCallPci_getDeviceInfo(u16 busNumberParm, u8 subBusParm,
  193. u8 deviceNumberParm, u64 parms, u32 sizeofParms)
  194. {
  195. struct HvCallPci_DsaAddr dsa;
  196. *((u64*)&dsa) = 0;
  197. dsa.busNumber = busNumberParm;
  198. dsa.subBusNumber = subBusParm;
  199. dsa.deviceId = deviceNumberParm << 4;
  200. return HvCall3(HvCallPciGetDeviceInfo, *(u64*)&dsa, parms, sizeofParms);
  201. }
  202. static inline u64 HvCallPci_maskInterrupts(u16 busNumberParm, u8 subBusParm,
  203. u8 deviceIdParm, u64 interruptMask)
  204. {
  205. struct HvCallPci_DsaAddr dsa;
  206. *((u64*)&dsa) = 0;
  207. dsa.busNumber = busNumberParm;
  208. dsa.subBusNumber = subBusParm;
  209. dsa.deviceId = deviceIdParm;
  210. return HvCall2(HvCallPciMaskInterrupts, *(u64*)&dsa, interruptMask);
  211. }
  212. static inline u64 HvCallPci_unmaskInterrupts(u16 busNumberParm, u8 subBusParm,
  213. u8 deviceIdParm, u64 interruptMask)
  214. {
  215. struct HvCallPci_DsaAddr dsa;
  216. *((u64*)&dsa) = 0;
  217. dsa.busNumber = busNumberParm;
  218. dsa.subBusNumber = subBusParm;
  219. dsa.deviceId = deviceIdParm;
  220. return HvCall2(HvCallPciUnmaskInterrupts, *(u64*)&dsa, interruptMask);
  221. }
  222. static inline u64 HvCallPci_getBusUnitInfo(u16 busNumberParm, u8 subBusParm,
  223. u8 deviceIdParm, u64 parms, u32 sizeofParms)
  224. {
  225. struct HvCallPci_DsaAddr dsa;
  226. *((u64*)&dsa) = 0;
  227. dsa.busNumber = busNumberParm;
  228. dsa.subBusNumber = subBusParm;
  229. dsa.deviceId = deviceIdParm;
  230. return HvCall3(HvCallPciGetBusUnitInfo, *(u64*)&dsa, parms,
  231. sizeofParms);
  232. }
  233. static inline int HvCallPci_getBusVpd(u16 busNumParm, u64 destParm,
  234. u16 sizeParm)
  235. {
  236. u64 xRc = HvCall4(HvCallPciGetCardVpd, busNumParm, destParm,
  237. sizeParm, HvCallPci_BusVpd);
  238. if (xRc == -1)
  239. return -1;
  240. else
  241. return xRc & 0xFFFF;
  242. }
  243. #endif /* _PLATFORMS_ISERIES_CALL_PCI_H */