Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef _ISERIES_64_PCI_H |
| 2 | #define _ISERIES_64_PCI_H |
| 3 | |
Stephen Rothwell | fcee389 | 2005-06-21 17:15:34 -0700 | [diff] [blame^] | 4 | /* |
| 5 | * File iSeries_pci.h created by Allan Trautman on Tue Feb 20, 2001. |
| 6 | * |
| 7 | * Define some useful macros for the iSeries pci routines. |
| 8 | * Copyright (C) 2001 Allan H Trautman, IBM Corporation |
| 9 | * |
| 10 | * This program is free software; you can redistribute it and/or modify |
| 11 | * it under the terms of the GNU General Public License as published by |
| 12 | * the Free Software Foundation; either version 2 of the License, or |
| 13 | * (at your option) any later version. |
| 14 | * |
| 15 | * This program is distributed in the hope that it will be useful, |
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 | * GNU General Public License for more details. |
| 19 | * |
| 20 | * You should have received a copy of the GNU General Public License |
| 21 | * along with this program; if not, write to the: |
| 22 | * Free Software Foundation, Inc., |
| 23 | * 59 Temple Place, Suite 330, |
| 24 | * Boston, MA 02111-1307 USA |
| 25 | * |
| 26 | * Change Activity: |
| 27 | * Created Feb 20, 2001 |
| 28 | * Added device reset, March 22, 2001 |
| 29 | * Ported to ppc64, May 25, 2001 |
| 30 | * End Change Activity |
| 31 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | |
| 33 | #include <asm/iSeries/HvCallPci.h> |
| 34 | #include <asm/abs_addr.h> |
| 35 | |
Stephen Rothwell | fcee389 | 2005-06-21 17:15:34 -0700 | [diff] [blame^] | 36 | struct pci_dev; /* For Forward Reference */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | struct iSeries_Device_Node; |
| 38 | |
Stephen Rothwell | fcee389 | 2005-06-21 17:15:34 -0700 | [diff] [blame^] | 39 | /* |
| 40 | * Gets iSeries Bus, SubBus, DevFn using iSeries_Device_Node structure |
| 41 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | |
| 43 | #define ISERIES_BUS(DevPtr) DevPtr->DsaAddr.Dsa.busNumber |
| 44 | #define ISERIES_SUBBUS(DevPtr) DevPtr->DsaAddr.Dsa.subBusNumber |
| 45 | #define ISERIES_DEVICE(DevPtr) DevPtr->DsaAddr.Dsa.deviceId |
| 46 | #define ISERIES_DSA(DevPtr) DevPtr->DsaAddr.DsaAddr |
| 47 | #define ISERIES_DEVFUN(DevPtr) DevPtr->DevFn |
Stephen Rothwell | fcee389 | 2005-06-21 17:15:34 -0700 | [diff] [blame^] | 48 | #define ISERIES_DEVNODE(PciDev) ((struct iSeries_Device_Node*)PciDev->sysdata) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | |
| 50 | #define EADsMaxAgents 7 |
| 51 | |
Stephen Rothwell | fcee389 | 2005-06-21 17:15:34 -0700 | [diff] [blame^] | 52 | /* |
| 53 | * Decodes Linux DevFn to iSeries DevFn, bridge device, or function. |
| 54 | * For Linux, see PCI_SLOT and PCI_FUNC in include/linux/pci.h |
| 55 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 56 | |
Stephen Rothwell | fcee389 | 2005-06-21 17:15:34 -0700 | [diff] [blame^] | 57 | #define ISERIES_PCI_AGENTID(idsel, func) \ |
| 58 | ((idsel & 0x0F) << 4) | (func & 0x07) |
| 59 | #define ISERIES_ENCODE_DEVICE(agentid) \ |
| 60 | ((0x10) | ((agentid & 0x20) >> 2) | (agentid & 0x07)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | |
Stephen Rothwell | fcee389 | 2005-06-21 17:15:34 -0700 | [diff] [blame^] | 62 | #define ISERIES_GET_DEVICE_FROM_SUBBUS(subbus) ((subbus >> 5) & 0x7) |
| 63 | #define ISERIES_GET_FUNCTION_FROM_SUBBUS(subbus) ((subbus >> 2) & 0x7) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 64 | |
| 65 | /* |
| 66 | * N.B. the ISERIES_DECODE_* macros are not used anywhere, and I think |
| 67 | * the 0x71 (at least) must be wrong - 0x78 maybe? -- paulus. |
| 68 | */ |
Stephen Rothwell | fcee389 | 2005-06-21 17:15:34 -0700 | [diff] [blame^] | 69 | #define ISERIES_DECODE_DEVFN(linuxdevfn) \ |
| 70 | (((linuxdevfn & 0x71) << 1) | (linuxdevfn & 0x07)) |
| 71 | #define ISERIES_DECODE_DEVICE(linuxdevfn) \ |
| 72 | (((linuxdevfn & 0x38) >> 3) | (((linuxdevfn & 0x40) >> 2) + 0x10)) |
| 73 | #define ISERIES_DECODE_FUNCTION(linuxdevfn) \ |
| 74 | (linuxdevfn & 0x07) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 75 | |
Stephen Rothwell | fcee389 | 2005-06-21 17:15:34 -0700 | [diff] [blame^] | 76 | /* |
| 77 | * Converts Virtual Address to Real Address for Hypervisor calls |
| 78 | */ |
| 79 | #define ISERIES_HV_ADDR(virtaddr) \ |
| 80 | (0x8000000000000000 | virt_to_abs(virtaddr)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 81 | |
Stephen Rothwell | fcee389 | 2005-06-21 17:15:34 -0700 | [diff] [blame^] | 82 | /* |
| 83 | * iSeries Device Information |
| 84 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 | struct iSeries_Device_Node { |
| 86 | struct list_head Device_List; |
Stephen Rothwell | fcee389 | 2005-06-21 17:15:34 -0700 | [diff] [blame^] | 87 | struct pci_dev *PciDev; |
| 88 | union HvDsaMap DsaAddr; /* Direct Select Address */ |
| 89 | /* busNumber, subBusNumber, */ |
| 90 | /* deviceId, barNumber */ |
| 91 | HvAgentId AgentId; /* Hypervisor DevFn */ |
| 92 | int DevFn; /* Linux devfn */ |
| 93 | int BarOffset; |
| 94 | int Irq; /* Assigned IRQ */ |
| 95 | int ReturnCode; /* Return Code Holder */ |
| 96 | int IoRetry; /* Current Retry Count */ |
| 97 | int Flags; /* Possible flags(disable/bist)*/ |
| 98 | u16 Vendor; /* Vendor ID */ |
| 99 | u8 LogicalSlot; /* Hv Slot Index for Tces */ |
| 100 | struct iommu_table *iommu_table;/* Device TCE Table */ |
| 101 | u8 PhbId; /* Phb Card is on. */ |
| 102 | u16 Board; /* Board Number */ |
| 103 | u8 FrameId; /* iSeries spcn Frame Id */ |
| 104 | char CardLocation[4];/* Char format of planar vpd */ |
| 105 | char Location[20]; /* Frame 1, Card C10 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 106 | }; |
| 107 | |
Stephen Rothwell | fcee389 | 2005-06-21 17:15:34 -0700 | [diff] [blame^] | 108 | extern int iSeries_Device_Information(struct pci_dev*, char*, int); |
| 109 | extern void iSeries_Get_Location_Code(struct iSeries_Device_Node*); |
| 110 | extern int iSeries_Device_ToggleReset(struct pci_dev* PciDev, |
| 111 | int AssertTime, int DelayTime); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 112 | |
| 113 | #endif /* _ISERIES_64_PCI_H */ |