Path: blob/master/arch/powerpc/platforms/iseries/call_pci.h
10820 views
/*1* Provides the Hypervisor PCI calls for iSeries Linux Parition.2* Copyright (C) 2001 <Wayne G Holm> <IBM Corporation>3*4* This program is free software; you can redistribute it and/or modify5* it under the terms of the GNU General Public License as published by6* the Free Software Foundation; either version 2 of the License, or7* (at your option) any later version.8*9* This program is distributed in the hope that it will be useful,10* but WITHOUT ANY WARRANTY; without even the implied warranty of11* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12* GNU General Public License for more details.13*14* You should have received a copy of the GNU General Public License15* along with this program; if not, write to the:16* Free Software Foundation, Inc.,17* 59 Temple Place, Suite 330,18* Boston, MA 02111-1307 USA19*20* Change Activity:21* Created, Jan 9, 200122*/2324#ifndef _PLATFORMS_ISERIES_CALL_PCI_H25#define _PLATFORMS_ISERIES_CALL_PCI_H2627#include <asm/iseries/hv_call_sc.h>28#include <asm/iseries/hv_types.h>2930/*31* DSA == Direct Select Address32* this struct must be 64 bits in total33*/34struct HvCallPci_DsaAddr {35u16 busNumber; /* PHB index? */36u8 subBusNumber; /* PCI bus number? */37u8 deviceId; /* device and function? */38u8 barNumber;39u8 reserved[3];40};4142union HvDsaMap {43u64 DsaAddr;44struct HvCallPci_DsaAddr Dsa;45};4647struct HvCallPci_LoadReturn {48u64 rc;49u64 value;50};5152enum HvCallPci_DeviceType {53HvCallPci_NodeDevice = 1,54HvCallPci_SpDevice = 2,55HvCallPci_IopDevice = 3,56HvCallPci_BridgeDevice = 4,57HvCallPci_MultiFunctionDevice = 5,58HvCallPci_IoaDevice = 659};606162struct HvCallPci_DeviceInfo {63u32 deviceType; /* See DeviceType enum for values */64};6566struct HvCallPci_BusUnitInfo {67u32 sizeReturned; /* length of data returned */68u32 deviceType; /* see DeviceType enum for values */69};7071struct HvCallPci_BridgeInfo {72struct HvCallPci_BusUnitInfo busUnitInfo; /* Generic bus unit info */73u8 subBusNumber; /* Bus number of secondary bus */74u8 maxAgents; /* Max idsels on secondary bus */75u8 maxSubBusNumber; /* Max Sub Bus */76u8 logicalSlotNumber; /* Logical Slot Number for IOA */77};787980/*81* Maximum BusUnitInfo buffer size. Provided for clients so82* they can allocate a buffer big enough for any type of bus83* unit. Increase as needed.84*/85enum {HvCallPci_MaxBusUnitInfoSize = 128};8687struct HvCallPci_BarParms {88u64 vaddr;89u64 raddr;90u64 size;91u64 protectStart;92u64 protectEnd;93u64 relocationOffset;94u64 pciAddress;95u64 reserved[3];96};9798enum HvCallPci_VpdType {99HvCallPci_BusVpd = 1,100HvCallPci_BusAdapterVpd = 2101};102103#define HvCallPciConfigLoad8 HvCallPci + 0104#define HvCallPciConfigLoad16 HvCallPci + 1105#define HvCallPciConfigLoad32 HvCallPci + 2106#define HvCallPciConfigStore8 HvCallPci + 3107#define HvCallPciConfigStore16 HvCallPci + 4108#define HvCallPciConfigStore32 HvCallPci + 5109#define HvCallPciEoi HvCallPci + 16110#define HvCallPciGetBarParms HvCallPci + 18111#define HvCallPciMaskFisr HvCallPci + 20112#define HvCallPciUnmaskFisr HvCallPci + 21113#define HvCallPciSetSlotReset HvCallPci + 25114#define HvCallPciGetDeviceInfo HvCallPci + 27115#define HvCallPciGetCardVpd HvCallPci + 28116#define HvCallPciBarLoad8 HvCallPci + 40117#define HvCallPciBarLoad16 HvCallPci + 41118#define HvCallPciBarLoad32 HvCallPci + 42119#define HvCallPciBarLoad64 HvCallPci + 43120#define HvCallPciBarStore8 HvCallPci + 44121#define HvCallPciBarStore16 HvCallPci + 45122#define HvCallPciBarStore32 HvCallPci + 46123#define HvCallPciBarStore64 HvCallPci + 47124#define HvCallPciMaskInterrupts HvCallPci + 48125#define HvCallPciUnmaskInterrupts HvCallPci + 49126#define HvCallPciGetBusUnitInfo HvCallPci + 50127128static inline u64 HvCallPci_configLoad16(u16 busNumber, u8 subBusNumber,129u8 deviceId, u32 offset, u16 *value)130{131struct HvCallPci_DsaAddr dsa;132struct HvCallPci_LoadReturn retVal;133134*((u64*)&dsa) = 0;135136dsa.busNumber = busNumber;137dsa.subBusNumber = subBusNumber;138dsa.deviceId = deviceId;139140HvCall3Ret16(HvCallPciConfigLoad16, &retVal, *(u64 *)&dsa, offset, 0);141142*value = retVal.value;143144return retVal.rc;145}146147static inline u64 HvCallPci_configLoad32(u16 busNumber, u8 subBusNumber,148u8 deviceId, u32 offset, u32 *value)149{150struct HvCallPci_DsaAddr dsa;151struct HvCallPci_LoadReturn retVal;152153*((u64*)&dsa) = 0;154155dsa.busNumber = busNumber;156dsa.subBusNumber = subBusNumber;157dsa.deviceId = deviceId;158159HvCall3Ret16(HvCallPciConfigLoad32, &retVal, *(u64 *)&dsa, offset, 0);160161*value = retVal.value;162163return retVal.rc;164}165166static inline u64 HvCallPci_configStore8(u16 busNumber, u8 subBusNumber,167u8 deviceId, u32 offset, u8 value)168{169struct HvCallPci_DsaAddr dsa;170171*((u64*)&dsa) = 0;172173dsa.busNumber = busNumber;174dsa.subBusNumber = subBusNumber;175dsa.deviceId = deviceId;176177return HvCall4(HvCallPciConfigStore8, *(u64 *)&dsa, offset, value, 0);178}179180static inline u64 HvCallPci_eoi(u16 busNumberParm, u8 subBusParm,181u8 deviceIdParm)182{183struct HvCallPci_DsaAddr dsa;184struct HvCallPci_LoadReturn retVal;185186*((u64*)&dsa) = 0;187188dsa.busNumber = busNumberParm;189dsa.subBusNumber = subBusParm;190dsa.deviceId = deviceIdParm;191192HvCall1Ret16(HvCallPciEoi, &retVal, *(u64*)&dsa);193194return retVal.rc;195}196197static inline u64 HvCallPci_getBarParms(u16 busNumberParm, u8 subBusParm,198u8 deviceIdParm, u8 barNumberParm, u64 parms, u32 sizeofParms)199{200struct HvCallPci_DsaAddr dsa;201202*((u64*)&dsa) = 0;203204dsa.busNumber = busNumberParm;205dsa.subBusNumber = subBusParm;206dsa.deviceId = deviceIdParm;207dsa.barNumber = barNumberParm;208209return HvCall3(HvCallPciGetBarParms, *(u64*)&dsa, parms, sizeofParms);210}211212static inline u64 HvCallPci_maskFisr(u16 busNumberParm, u8 subBusParm,213u8 deviceIdParm, u64 fisrMask)214{215struct HvCallPci_DsaAddr dsa;216217*((u64*)&dsa) = 0;218219dsa.busNumber = busNumberParm;220dsa.subBusNumber = subBusParm;221dsa.deviceId = deviceIdParm;222223return HvCall2(HvCallPciMaskFisr, *(u64*)&dsa, fisrMask);224}225226static inline u64 HvCallPci_unmaskFisr(u16 busNumberParm, u8 subBusParm,227u8 deviceIdParm, u64 fisrMask)228{229struct HvCallPci_DsaAddr dsa;230231*((u64*)&dsa) = 0;232233dsa.busNumber = busNumberParm;234dsa.subBusNumber = subBusParm;235dsa.deviceId = deviceIdParm;236237return HvCall2(HvCallPciUnmaskFisr, *(u64*)&dsa, fisrMask);238}239240static inline u64 HvCallPci_getDeviceInfo(u16 busNumberParm, u8 subBusParm,241u8 deviceNumberParm, u64 parms, u32 sizeofParms)242{243struct HvCallPci_DsaAddr dsa;244245*((u64*)&dsa) = 0;246247dsa.busNumber = busNumberParm;248dsa.subBusNumber = subBusParm;249dsa.deviceId = deviceNumberParm << 4;250251return HvCall3(HvCallPciGetDeviceInfo, *(u64*)&dsa, parms, sizeofParms);252}253254static inline u64 HvCallPci_maskInterrupts(u16 busNumberParm, u8 subBusParm,255u8 deviceIdParm, u64 interruptMask)256{257struct HvCallPci_DsaAddr dsa;258259*((u64*)&dsa) = 0;260261dsa.busNumber = busNumberParm;262dsa.subBusNumber = subBusParm;263dsa.deviceId = deviceIdParm;264265return HvCall2(HvCallPciMaskInterrupts, *(u64*)&dsa, interruptMask);266}267268static inline u64 HvCallPci_unmaskInterrupts(u16 busNumberParm, u8 subBusParm,269u8 deviceIdParm, u64 interruptMask)270{271struct HvCallPci_DsaAddr dsa;272273*((u64*)&dsa) = 0;274275dsa.busNumber = busNumberParm;276dsa.subBusNumber = subBusParm;277dsa.deviceId = deviceIdParm;278279return HvCall2(HvCallPciUnmaskInterrupts, *(u64*)&dsa, interruptMask);280}281282static inline u64 HvCallPci_getBusUnitInfo(u16 busNumberParm, u8 subBusParm,283u8 deviceIdParm, u64 parms, u32 sizeofParms)284{285struct HvCallPci_DsaAddr dsa;286287*((u64*)&dsa) = 0;288289dsa.busNumber = busNumberParm;290dsa.subBusNumber = subBusParm;291dsa.deviceId = deviceIdParm;292293return HvCall3(HvCallPciGetBusUnitInfo, *(u64*)&dsa, parms,294sizeofParms);295}296297static inline int HvCallPci_getBusVpd(u16 busNumParm, u64 destParm,298u16 sizeParm)299{300u64 xRc = HvCall4(HvCallPciGetCardVpd, busNumParm, destParm,301sizeParm, HvCallPci_BusVpd);302if (xRc == -1)303return -1;304else305return xRc & 0xFFFF;306}307308#endif /* _PLATFORMS_ISERIES_CALL_PCI_H */309310311