blob: 53cc163d468922d8a2cd8b183d09b8f656175996 [file] [log] [blame]
Stephen Rothwell45dc76a2005-06-21 17:15:33 -07001/*
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 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070024
Stephen Rothwellc6d2ea92005-10-14 17:16:17 +100025#ifndef _PLATFORMS_ISERIES_CALL_PCI_H
26#define _PLATFORMS_ISERIES_CALL_PCI_H
Linus Torvalds1da177e2005-04-16 15:20:36 -070027
Kelly Daly50592f52005-11-02 11:37:22 +110028#include <asm/iseries/hv_call_sc.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070029#include <asm/iSeries/HvTypes.h>
30
31/*
32 * DSA == Direct Select Address
33 * this struct must be 64 bits in total
34 */
35struct HvCallPci_DsaAddr {
36 u16 busNumber; /* PHB index? */
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070037 u8 subBusNumber; /* PCI bus number? */
38 u8 deviceId; /* device and function? */
Linus Torvalds1da177e2005-04-16 15:20:36 -070039 u8 barNumber;
40 u8 reserved[3];
41};
42
43union HvDsaMap {
44 u64 DsaAddr;
45 struct HvCallPci_DsaAddr Dsa;
46};
47
48struct HvCallPci_LoadReturn {
49 u64 rc;
50 u64 value;
51};
52
53enum HvCallPci_DeviceType {
54 HvCallPci_NodeDevice = 1,
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070055 HvCallPci_SpDevice = 2,
56 HvCallPci_IopDevice = 3,
57 HvCallPci_BridgeDevice = 4,
58 HvCallPci_MultiFunctionDevice = 5,
59 HvCallPci_IoaDevice = 6
Linus Torvalds1da177e2005-04-16 15:20:36 -070060};
61
62
63struct HvCallPci_DeviceInfo {
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070064 u32 deviceType; /* See DeviceType enum for values */
Linus Torvalds1da177e2005-04-16 15:20:36 -070065};
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070066
Linus Torvalds1da177e2005-04-16 15:20:36 -070067struct HvCallPci_BusUnitInfo {
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070068 u32 sizeReturned; /* length of data returned */
69 u32 deviceType; /* see DeviceType enum for values */
Linus Torvalds1da177e2005-04-16 15:20:36 -070070};
71
72struct HvCallPci_BridgeInfo {
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070073 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 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070078};
Linus Torvalds1da177e2005-04-16 15:20:36 -070079
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070080
81/*
82 * Maximum BusUnitInfo buffer size. Provided for clients so
83 * they can allocate a buffer big enough for any type of bus
84 * unit. Increase as needed.
85 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070086enum {HvCallPci_MaxBusUnitInfoSize = 128};
87
88struct HvCallPci_BarParms {
89 u64 vaddr;
90 u64 raddr;
91 u64 size;
92 u64 protectStart;
93 u64 protectEnd;
94 u64 relocationOffset;
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070095 u64 pciAddress;
Linus Torvalds1da177e2005-04-16 15:20:36 -070096 u64 reserved[3];
Stephen Rothwell45dc76a2005-06-21 17:15:33 -070097};
Linus Torvalds1da177e2005-04-16 15:20:36 -070098
99enum HvCallPci_VpdType {
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700100 HvCallPci_BusVpd = 1,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700101 HvCallPci_BusAdapterVpd = 2
102};
103
104#define HvCallPciConfigLoad8 HvCallPci + 0
105#define HvCallPciConfigLoad16 HvCallPci + 1
106#define HvCallPciConfigLoad32 HvCallPci + 2
107#define HvCallPciConfigStore8 HvCallPci + 3
108#define HvCallPciConfigStore16 HvCallPci + 4
109#define HvCallPciConfigStore32 HvCallPci + 5
110#define HvCallPciEoi HvCallPci + 16
111#define HvCallPciGetBarParms HvCallPci + 18
112#define HvCallPciMaskFisr HvCallPci + 20
113#define HvCallPciUnmaskFisr HvCallPci + 21
114#define HvCallPciSetSlotReset HvCallPci + 25
115#define HvCallPciGetDeviceInfo HvCallPci + 27
116#define HvCallPciGetCardVpd HvCallPci + 28
117#define HvCallPciBarLoad8 HvCallPci + 40
118#define HvCallPciBarLoad16 HvCallPci + 41
119#define HvCallPciBarLoad32 HvCallPci + 42
120#define HvCallPciBarLoad64 HvCallPci + 43
121#define HvCallPciBarStore8 HvCallPci + 44
122#define HvCallPciBarStore16 HvCallPci + 45
123#define HvCallPciBarStore32 HvCallPci + 46
124#define HvCallPciBarStore64 HvCallPci + 47
125#define HvCallPciMaskInterrupts HvCallPci + 48
126#define HvCallPciUnmaskInterrupts HvCallPci + 49
127#define HvCallPciGetBusUnitInfo HvCallPci + 50
128
Linus Torvalds1da177e2005-04-16 15:20:36 -0700129static inline u64 HvCallPci_configLoad16(u16 busNumber, u8 subBusNumber,
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700130 u8 deviceId, u32 offset, u16 *value)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700131{
132 struct HvCallPci_DsaAddr dsa;
133 struct HvCallPci_LoadReturn retVal;
134
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700135 *((u64*)&dsa) = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700136
137 dsa.busNumber = busNumber;
138 dsa.subBusNumber = subBusNumber;
139 dsa.deviceId = deviceId;
140
141 HvCall3Ret16(HvCallPciConfigLoad16, &retVal, *(u64 *)&dsa, offset, 0);
142
Linus Torvalds1da177e2005-04-16 15:20:36 -0700143 *value = retVal.value;
144
145 return retVal.rc;
146}
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700147
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700148static inline u64 HvCallPci_configStore8(u16 busNumber, u8 subBusNumber,
149 u8 deviceId, u32 offset, u8 value)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700150{
151 struct HvCallPci_DsaAddr dsa;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700152
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700153 *((u64*)&dsa) = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700154
155 dsa.busNumber = busNumber;
156 dsa.subBusNumber = subBusNumber;
157 dsa.deviceId = deviceId;
158
Stephen Rothwell6b7feec2005-06-21 17:15:35 -0700159 return HvCall4(HvCallPciConfigStore8, *(u64 *)&dsa, offset, value, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700160}
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700161
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700162static inline u64 HvCallPci_eoi(u16 busNumberParm, u8 subBusParm,
163 u8 deviceIdParm)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700164{
165 struct HvCallPci_DsaAddr dsa;
166 struct HvCallPci_LoadReturn retVal;
167
168 *((u64*)&dsa) = 0;
169
170 dsa.busNumber = busNumberParm;
171 dsa.subBusNumber = subBusParm;
172 dsa.deviceId = deviceIdParm;
173
174 HvCall1Ret16(HvCallPciEoi, &retVal, *(u64*)&dsa);
175
Linus Torvalds1da177e2005-04-16 15:20:36 -0700176 return retVal.rc;
177}
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700178
179static inline u64 HvCallPci_getBarParms(u16 busNumberParm, u8 subBusParm,
180 u8 deviceIdParm, u8 barNumberParm, u64 parms, u32 sizeofParms)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700181{
182 struct HvCallPci_DsaAddr dsa;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700183
184 *((u64*)&dsa) = 0;
185
186 dsa.busNumber = busNumberParm;
187 dsa.subBusNumber = subBusParm;
188 dsa.deviceId = deviceIdParm;
189 dsa.barNumber = barNumberParm;
190
Stephen Rothwell6b7feec2005-06-21 17:15:35 -0700191 return HvCall3(HvCallPciGetBarParms, *(u64*)&dsa, parms, sizeofParms);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700192}
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700193
194static inline u64 HvCallPci_maskFisr(u16 busNumberParm, u8 subBusParm,
195 u8 deviceIdParm, u64 fisrMask)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700196{
197 struct HvCallPci_DsaAddr dsa;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700198
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700199 *((u64*)&dsa) = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700200
201 dsa.busNumber = busNumberParm;
202 dsa.subBusNumber = subBusParm;
203 dsa.deviceId = deviceIdParm;
204
Stephen Rothwell6b7feec2005-06-21 17:15:35 -0700205 return HvCall2(HvCallPciMaskFisr, *(u64*)&dsa, fisrMask);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700206}
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700207
208static inline u64 HvCallPci_unmaskFisr(u16 busNumberParm, u8 subBusParm,
209 u8 deviceIdParm, u64 fisrMask)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700210{
211 struct HvCallPci_DsaAddr dsa;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700212
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700213 *((u64*)&dsa) = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700214
215 dsa.busNumber = busNumberParm;
216 dsa.subBusNumber = subBusParm;
217 dsa.deviceId = deviceIdParm;
218
Stephen Rothwell6b7feec2005-06-21 17:15:35 -0700219 return HvCall2(HvCallPciUnmaskFisr, *(u64*)&dsa, fisrMask);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700220}
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700221
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700222static inline u64 HvCallPci_getDeviceInfo(u16 busNumberParm, u8 subBusParm,
223 u8 deviceNumberParm, u64 parms, u32 sizeofParms)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700224{
225 struct HvCallPci_DsaAddr dsa;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700226
227 *((u64*)&dsa) = 0;
228
229 dsa.busNumber = busNumberParm;
230 dsa.subBusNumber = subBusParm;
231 dsa.deviceId = deviceNumberParm << 4;
232
Stephen Rothwell6b7feec2005-06-21 17:15:35 -0700233 return HvCall3(HvCallPciGetDeviceInfo, *(u64*)&dsa, parms, sizeofParms);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700234}
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700235
236static inline u64 HvCallPci_maskInterrupts(u16 busNumberParm, u8 subBusParm,
237 u8 deviceIdParm, u64 interruptMask)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700238{
239 struct HvCallPci_DsaAddr dsa;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700240
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700241 *((u64*)&dsa) = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700242
243 dsa.busNumber = busNumberParm;
244 dsa.subBusNumber = subBusParm;
245 dsa.deviceId = deviceIdParm;
246
Stephen Rothwell6b7feec2005-06-21 17:15:35 -0700247 return HvCall2(HvCallPciMaskInterrupts, *(u64*)&dsa, interruptMask);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700248}
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700249
250static inline u64 HvCallPci_unmaskInterrupts(u16 busNumberParm, u8 subBusParm,
251 u8 deviceIdParm, u64 interruptMask)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700252{
253 struct HvCallPci_DsaAddr dsa;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700254
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700255 *((u64*)&dsa) = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700256
257 dsa.busNumber = busNumberParm;
258 dsa.subBusNumber = subBusParm;
259 dsa.deviceId = deviceIdParm;
260
Stephen Rothwell6b7feec2005-06-21 17:15:35 -0700261 return HvCall2(HvCallPciUnmaskInterrupts, *(u64*)&dsa, interruptMask);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700262}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700263
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700264static inline u64 HvCallPci_getBusUnitInfo(u16 busNumberParm, u8 subBusParm,
265 u8 deviceIdParm, u64 parms, u32 sizeofParms)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700266{
267 struct HvCallPci_DsaAddr dsa;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700268
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700269 *((u64*)&dsa) = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700270
271 dsa.busNumber = busNumberParm;
272 dsa.subBusNumber = subBusParm;
273 dsa.deviceId = deviceIdParm;
274
Stephen Rothwell6b7feec2005-06-21 17:15:35 -0700275 return HvCall3(HvCallPciGetBusUnitInfo, *(u64*)&dsa, parms,
276 sizeofParms);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700277}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700278
Stephen Rothwell45dc76a2005-06-21 17:15:33 -0700279static inline int HvCallPci_getBusVpd(u16 busNumParm, u64 destParm,
280 u16 sizeParm)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700281{
Stephen Rothwell6b7feec2005-06-21 17:15:35 -0700282 u64 xRc = HvCall4(HvCallPciGetCardVpd, busNumParm, destParm,
283 sizeParm, HvCallPci_BusVpd);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700284 if (xRc == -1)
Stephen Rothwell6b7feec2005-06-21 17:15:35 -0700285 return -1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700286 else
Stephen Rothwell6b7feec2005-06-21 17:15:35 -0700287 return xRc & 0xFFFF;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700288}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700289
Stephen Rothwellc6d2ea92005-10-14 17:16:17 +1000290#endif /* _PLATFORMS_ISERIES_CALL_PCI_H */