1 /************************************************************************/
2 /* Provides the Hypervisor PCI calls for iSeries Linux Parition. */
3 /* Copyright (C) 2001 <Wayne G Holm> <IBM Corporation> */
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. */
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. */
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 /************************************************************************/
28 #include <asm/iSeries/HvCallSc.h>
29 #include <asm/iSeries/HvTypes.h>
32 * DSA == Direct Select Address
33 * this struct must be 64 bits in total
35 struct HvCallPci_DsaAddr
{
36 u16 busNumber
; /* PHB index? */
37 u8 subBusNumber
; /* PCI bus number? */
38 u8 deviceId
; /* device and function? */
45 struct HvCallPci_DsaAddr Dsa
;
48 struct HvCallPci_LoadReturn
{
53 enum HvCallPci_DeviceType
{
54 HvCallPci_NodeDevice
= 1,
55 HvCallPci_SpDevice
= 2,
56 HvCallPci_IopDevice
= 3,
57 HvCallPci_BridgeDevice
= 4,
58 HvCallPci_MultiFunctionDevice
= 5,
59 HvCallPci_IoaDevice
= 6
63 struct HvCallPci_DeviceInfo
{
64 u32 deviceType
; // See DeviceType enum for values
67 struct HvCallPci_BusUnitInfo
{
68 u32 sizeReturned
; // length of data returned
69 u32 deviceType
; // see DeviceType enum for values
72 struct HvCallPci_BridgeInfo
{
73 struct HvCallPci_BusUnitInfo busUnitInfo
; // Generic bus unit info
74 u8 subBusNumber
; // Bus number of secondary bus
75 u8 maxAgents
; // Max idsels on secondary bus
76 u8 maxSubBusNumber
; // Max Sub Bus
77 u8 logicalSlotNumber
; // Logical Slot Number for IOA
81 // Maximum BusUnitInfo buffer size. Provided for clients so they can allocate
82 // a buffer big enough for any type of bus unit. Increase as needed.
83 enum {HvCallPci_MaxBusUnitInfoSize
= 128};
85 struct HvCallPci_BarParms
{
96 enum HvCallPci_VpdType
{
98 HvCallPci_BusAdapterVpd
= 2
101 #define HvCallPciConfigLoad8 HvCallPci + 0
102 #define HvCallPciConfigLoad16 HvCallPci + 1
103 #define HvCallPciConfigLoad32 HvCallPci + 2
104 #define HvCallPciConfigStore8 HvCallPci + 3
105 #define HvCallPciConfigStore16 HvCallPci + 4
106 #define HvCallPciConfigStore32 HvCallPci + 5
107 #define HvCallPciEoi HvCallPci + 16
108 #define HvCallPciGetBarParms HvCallPci + 18
109 #define HvCallPciMaskFisr HvCallPci + 20
110 #define HvCallPciUnmaskFisr HvCallPci + 21
111 #define HvCallPciSetSlotReset HvCallPci + 25
112 #define HvCallPciGetDeviceInfo HvCallPci + 27
113 #define HvCallPciGetCardVpd HvCallPci + 28
114 #define HvCallPciBarLoad8 HvCallPci + 40
115 #define HvCallPciBarLoad16 HvCallPci + 41
116 #define HvCallPciBarLoad32 HvCallPci + 42
117 #define HvCallPciBarLoad64 HvCallPci + 43
118 #define HvCallPciBarStore8 HvCallPci + 44
119 #define HvCallPciBarStore16 HvCallPci + 45
120 #define HvCallPciBarStore32 HvCallPci + 46
121 #define HvCallPciBarStore64 HvCallPci + 47
122 #define HvCallPciMaskInterrupts HvCallPci + 48
123 #define HvCallPciUnmaskInterrupts HvCallPci + 49
124 #define HvCallPciGetBusUnitInfo HvCallPci + 50
126 //============================================================================
127 static inline u64
HvCallPci_configLoad8(u16 busNumber
, u8 subBusNumber
,
128 u8 deviceId
, u32 offset
,
131 struct HvCallPci_DsaAddr dsa
;
132 struct HvCallPci_LoadReturn retVal
;
136 dsa
.busNumber
= busNumber
;
137 dsa
.subBusNumber
= subBusNumber
;
138 dsa
.deviceId
= deviceId
;
140 HvCall3Ret16(HvCallPciConfigLoad8
, &retVal
, *(u64
*)&dsa
, offset
, 0);
142 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
144 *value
= retVal
.value
;
148 //============================================================================
149 static inline u64
HvCallPci_configLoad16(u16 busNumber
, u8 subBusNumber
,
150 u8 deviceId
, u32 offset
,
153 struct HvCallPci_DsaAddr dsa
;
154 struct HvCallPci_LoadReturn retVal
;
158 dsa
.busNumber
= busNumber
;
159 dsa
.subBusNumber
= subBusNumber
;
160 dsa
.deviceId
= deviceId
;
162 HvCall3Ret16(HvCallPciConfigLoad16
, &retVal
, *(u64
*)&dsa
, offset
, 0);
164 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
166 *value
= retVal
.value
;
170 //============================================================================
171 static inline u64
HvCallPci_configLoad32(u16 busNumber
, u8 subBusNumber
,
172 u8 deviceId
, u32 offset
,
175 struct HvCallPci_DsaAddr dsa
;
176 struct HvCallPci_LoadReturn retVal
;
180 dsa
.busNumber
= busNumber
;
181 dsa
.subBusNumber
= subBusNumber
;
182 dsa
.deviceId
= deviceId
;
184 HvCall3Ret16(HvCallPciConfigLoad32
, &retVal
, *(u64
*)&dsa
, offset
, 0);
186 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
188 *value
= retVal
.value
;
192 //============================================================================
193 static inline u64
HvCallPci_configStore8(u16 busNumber
, u8 subBusNumber
,
194 u8 deviceId
, u32 offset
,
197 struct HvCallPci_DsaAddr dsa
;
202 dsa
.busNumber
= busNumber
;
203 dsa
.subBusNumber
= subBusNumber
;
204 dsa
.deviceId
= deviceId
;
206 retVal
= HvCall4(HvCallPciConfigStore8
, *(u64
*)&dsa
, offset
, value
, 0);
208 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
212 //============================================================================
213 static inline u64
HvCallPci_configStore16(u16 busNumber
, u8 subBusNumber
,
214 u8 deviceId
, u32 offset
,
217 struct HvCallPci_DsaAddr dsa
;
222 dsa
.busNumber
= busNumber
;
223 dsa
.subBusNumber
= subBusNumber
;
224 dsa
.deviceId
= deviceId
;
226 retVal
= HvCall4(HvCallPciConfigStore16
, *(u64
*)&dsa
, offset
, value
, 0);
228 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
232 //============================================================================
233 static inline u64
HvCallPci_configStore32(u16 busNumber
, u8 subBusNumber
,
234 u8 deviceId
, u32 offset
,
237 struct HvCallPci_DsaAddr dsa
;
242 dsa
.busNumber
= busNumber
;
243 dsa
.subBusNumber
= subBusNumber
;
244 dsa
.deviceId
= deviceId
;
246 retVal
= HvCall4(HvCallPciConfigStore32
, *(u64
*)&dsa
, offset
, value
, 0);
248 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
252 //============================================================================
253 static inline u64
HvCallPci_barLoad8(u16 busNumberParm
,
260 struct HvCallPci_DsaAddr dsa
;
261 struct HvCallPci_LoadReturn retVal
;
265 dsa
.busNumber
= busNumberParm
;
266 dsa
.subBusNumber
= subBusParm
;
267 dsa
.deviceId
= deviceIdParm
;
268 dsa
.barNumber
= barNumberParm
;
270 HvCall3Ret16(HvCallPciBarLoad8
, &retVal
, *(u64
*)&dsa
, offsetParm
, 0);
272 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
274 *valueParm
= retVal
.value
;
278 //============================================================================
279 static inline u64
HvCallPci_barLoad16(u16 busNumberParm
,
286 struct HvCallPci_DsaAddr dsa
;
287 struct HvCallPci_LoadReturn retVal
;
291 dsa
.busNumber
= busNumberParm
;
292 dsa
.subBusNumber
= subBusParm
;
293 dsa
.deviceId
= deviceIdParm
;
294 dsa
.barNumber
= barNumberParm
;
296 HvCall3Ret16(HvCallPciBarLoad16
, &retVal
, *(u64
*)&dsa
, offsetParm
, 0);
298 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
300 *valueParm
= retVal
.value
;
304 //============================================================================
305 static inline u64
HvCallPci_barLoad32(u16 busNumberParm
,
312 struct HvCallPci_DsaAddr dsa
;
313 struct HvCallPci_LoadReturn retVal
;
317 dsa
.busNumber
= busNumberParm
;
318 dsa
.subBusNumber
= subBusParm
;
319 dsa
.deviceId
= deviceIdParm
;
320 dsa
.barNumber
= barNumberParm
;
322 HvCall3Ret16(HvCallPciBarLoad32
, &retVal
, *(u64
*)&dsa
, offsetParm
, 0);
324 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
326 *valueParm
= retVal
.value
;
330 //============================================================================
331 static inline u64
HvCallPci_barLoad64(u16 busNumberParm
,
338 struct HvCallPci_DsaAddr dsa
;
339 struct HvCallPci_LoadReturn retVal
;
343 dsa
.busNumber
= busNumberParm
;
344 dsa
.subBusNumber
= subBusParm
;
345 dsa
.deviceId
= deviceIdParm
;
346 dsa
.barNumber
= barNumberParm
;
348 HvCall3Ret16(HvCallPciBarLoad64
, &retVal
, *(u64
*)&dsa
, offsetParm
, 0);
350 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
352 *valueParm
= retVal
.value
;
356 //============================================================================
357 static inline u64
HvCallPci_barStore8(u16 busNumberParm
,
364 struct HvCallPci_DsaAddr dsa
;
369 dsa
.busNumber
= busNumberParm
;
370 dsa
.subBusNumber
= subBusParm
;
371 dsa
.deviceId
= deviceIdParm
;
372 dsa
.barNumber
= barNumberParm
;
374 retVal
= HvCall4(HvCallPciBarStore8
, *(u64
*)&dsa
, offsetParm
, valueParm
, 0);
376 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
380 //============================================================================
381 static inline u64
HvCallPci_barStore16(u16 busNumberParm
,
388 struct HvCallPci_DsaAddr dsa
;
393 dsa
.busNumber
= busNumberParm
;
394 dsa
.subBusNumber
= subBusParm
;
395 dsa
.deviceId
= deviceIdParm
;
396 dsa
.barNumber
= barNumberParm
;
398 retVal
= HvCall4(HvCallPciBarStore16
, *(u64
*)&dsa
, offsetParm
, valueParm
, 0);
400 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
404 //============================================================================
405 static inline u64
HvCallPci_barStore32(u16 busNumberParm
,
412 struct HvCallPci_DsaAddr dsa
;
417 dsa
.busNumber
= busNumberParm
;
418 dsa
.subBusNumber
= subBusParm
;
419 dsa
.deviceId
= deviceIdParm
;
420 dsa
.barNumber
= barNumberParm
;
422 retVal
= HvCall4(HvCallPciBarStore32
, *(u64
*)&dsa
, offsetParm
, valueParm
, 0);
424 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
428 //============================================================================
429 static inline u64
HvCallPci_barStore64(u16 busNumberParm
,
436 struct HvCallPci_DsaAddr dsa
;
441 dsa
.busNumber
= busNumberParm
;
442 dsa
.subBusNumber
= subBusParm
;
443 dsa
.deviceId
= deviceIdParm
;
444 dsa
.barNumber
= barNumberParm
;
446 retVal
= HvCall4(HvCallPciBarStore64
, *(u64
*)&dsa
, offsetParm
, valueParm
, 0);
448 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
452 //============================================================================
453 static inline u64
HvCallPci_eoi(u16 busNumberParm
,
457 struct HvCallPci_DsaAddr dsa
;
458 struct HvCallPci_LoadReturn retVal
;
462 dsa
.busNumber
= busNumberParm
;
463 dsa
.subBusNumber
= subBusParm
;
464 dsa
.deviceId
= deviceIdParm
;
466 HvCall1Ret16(HvCallPciEoi
, &retVal
, *(u64
*)&dsa
);
468 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
472 //============================================================================
473 static inline u64
HvCallPci_getBarParms(u16 busNumberParm
,
480 struct HvCallPci_DsaAddr dsa
;
485 dsa
.busNumber
= busNumberParm
;
486 dsa
.subBusNumber
= subBusParm
;
487 dsa
.deviceId
= deviceIdParm
;
488 dsa
.barNumber
= barNumberParm
;
490 retVal
= HvCall3(HvCallPciGetBarParms
, *(u64
*)&dsa
, parms
, sizeofParms
);
492 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
496 //============================================================================
497 static inline u64
HvCallPci_maskFisr(u16 busNumberParm
,
502 struct HvCallPci_DsaAddr dsa
;
507 dsa
.busNumber
= busNumberParm
;
508 dsa
.subBusNumber
= subBusParm
;
509 dsa
.deviceId
= deviceIdParm
;
511 retVal
= HvCall2(HvCallPciMaskFisr
, *(u64
*)&dsa
, fisrMask
);
513 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
517 //============================================================================
518 static inline u64
HvCallPci_unmaskFisr(u16 busNumberParm
,
523 struct HvCallPci_DsaAddr dsa
;
528 dsa
.busNumber
= busNumberParm
;
529 dsa
.subBusNumber
= subBusParm
;
530 dsa
.deviceId
= deviceIdParm
;
532 retVal
= HvCall2(HvCallPciUnmaskFisr
, *(u64
*)&dsa
, fisrMask
);
534 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
538 //============================================================================
539 static inline u64
HvCallPci_setSlotReset(u16 busNumberParm
,
544 struct HvCallPci_DsaAddr dsa
;
549 dsa
.busNumber
= busNumberParm
;
550 dsa
.subBusNumber
= subBusParm
;
551 dsa
.deviceId
= deviceIdParm
;
553 retVal
= HvCall2(HvCallPciSetSlotReset
, *(u64
*)&dsa
, onNotOff
);
555 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
559 //============================================================================
560 static inline u64
HvCallPci_getDeviceInfo(u16 busNumberParm
,
566 struct HvCallPci_DsaAddr dsa
;
571 dsa
.busNumber
= busNumberParm
;
572 dsa
.subBusNumber
= subBusParm
;
573 dsa
.deviceId
= deviceNumberParm
<< 4;
575 retVal
= HvCall3(HvCallPciGetDeviceInfo
, *(u64
*)&dsa
, parms
, sizeofParms
);
577 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
581 //============================================================================
582 static inline u64
HvCallPci_maskInterrupts(u16 busNumberParm
,
587 struct HvCallPci_DsaAddr dsa
;
592 dsa
.busNumber
= busNumberParm
;
593 dsa
.subBusNumber
= subBusParm
;
594 dsa
.deviceId
= deviceIdParm
;
596 retVal
= HvCall2(HvCallPciMaskInterrupts
, *(u64
*)&dsa
, interruptMask
);
598 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
602 //============================================================================
603 static inline u64
HvCallPci_unmaskInterrupts(u16 busNumberParm
,
608 struct HvCallPci_DsaAddr dsa
;
613 dsa
.busNumber
= busNumberParm
;
614 dsa
.subBusNumber
= subBusParm
;
615 dsa
.deviceId
= deviceIdParm
;
617 retVal
= HvCall2(HvCallPciUnmaskInterrupts
, *(u64
*)&dsa
, interruptMask
);
619 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
623 //============================================================================
625 static inline u64
HvCallPci_getBusUnitInfo(u16 busNumberParm
,
631 struct HvCallPci_DsaAddr dsa
;
636 dsa
.busNumber
= busNumberParm
;
637 dsa
.subBusNumber
= subBusParm
;
638 dsa
.deviceId
= deviceIdParm
;
640 retVal
= HvCall3(HvCallPciGetBusUnitInfo
, *(u64
*)&dsa
, parms
, sizeofParms
);
642 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
646 //============================================================================
648 static inline int HvCallPci_getBusVpd(u16 busNumParm
, u64 destParm
, u16 sizeParm
)
651 u64 xRc
= HvCall4(HvCallPciGetCardVpd
, busNumParm
, destParm
, sizeParm
, HvCallPci_BusVpd
);
652 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
656 xRetSize
= xRc
& 0xFFFF;
659 //============================================================================
661 static inline int HvCallPci_getBusAdapterVpd(u16 busNumParm
, u64 destParm
, u16 sizeParm
)
664 u64 xRc
= HvCall4(HvCallPciGetCardVpd
, busNumParm
, destParm
, sizeParm
, HvCallPci_BusAdapterVpd
);
665 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
669 xRetSize
= xRc
& 0xFFFF;
672 //============================================================================
673 #endif /* _HVCALLPCI_H */