blob: 575f611f8b3391b04ec461adf70c65dbe207e812 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef _ISERIES_64_PCI_H
2#define _ISERIES_64_PCI_H
3
Stephen Rothwellfcee3892005-06-21 17:15:34 -07004/*
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 Torvalds1da177e2005-04-16 15:20:36 -070032
33#include <asm/iSeries/HvCallPci.h>
34#include <asm/abs_addr.h>
35
Stephen Rothwellfcee3892005-06-21 17:15:34 -070036struct pci_dev; /* For Forward Reference */
Linus Torvalds1da177e2005-04-16 15:20:36 -070037struct iSeries_Device_Node;
38
Stephen Rothwellfcee3892005-06-21 17:15:34 -070039/*
40 * Gets iSeries Bus, SubBus, DevFn using iSeries_Device_Node structure
41 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070042
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
Stephen Rothwellaab41de2005-06-21 17:15:46 -070047#define ISERIES_DEVNODE(PciDev) ((struct iSeries_Device_Node *)PciDev->sysdata)
Linus Torvalds1da177e2005-04-16 15:20:36 -070048
49#define EADsMaxAgents 7
50
Stephen Rothwellfcee3892005-06-21 17:15:34 -070051/*
52 * Decodes Linux DevFn to iSeries DevFn, bridge device, or function.
53 * For Linux, see PCI_SLOT and PCI_FUNC in include/linux/pci.h
54 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070055
Stephen Rothwellfcee3892005-06-21 17:15:34 -070056#define ISERIES_PCI_AGENTID(idsel, func) \
Stephen Rothwell6b7feec2005-06-21 17:15:35 -070057 (((idsel & 0x0F) << 4) | (func & 0x07))
Stephen Rothwellfcee3892005-06-21 17:15:34 -070058#define ISERIES_ENCODE_DEVICE(agentid) \
59 ((0x10) | ((agentid & 0x20) >> 2) | (agentid & 0x07))
Linus Torvalds1da177e2005-04-16 15:20:36 -070060
Stephen Rothwellfcee3892005-06-21 17:15:34 -070061#define ISERIES_GET_DEVICE_FROM_SUBBUS(subbus) ((subbus >> 5) & 0x7)
62#define ISERIES_GET_FUNCTION_FROM_SUBBUS(subbus) ((subbus >> 2) & 0x7)
Linus Torvalds1da177e2005-04-16 15:20:36 -070063
64/*
Stephen Rothwellfcee3892005-06-21 17:15:34 -070065 * Converts Virtual Address to Real Address for Hypervisor calls
66 */
67#define ISERIES_HV_ADDR(virtaddr) \
68 (0x8000000000000000 | virt_to_abs(virtaddr))
Linus Torvalds1da177e2005-04-16 15:20:36 -070069
Stephen Rothwellfcee3892005-06-21 17:15:34 -070070/*
71 * iSeries Device Information
72 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070073struct iSeries_Device_Node {
74 struct list_head Device_List;
Stephen Rothwellfcee3892005-06-21 17:15:34 -070075 struct pci_dev *PciDev;
76 union HvDsaMap DsaAddr; /* Direct Select Address */
77 /* busNumber, subBusNumber, */
78 /* deviceId, barNumber */
Stephen Rothwellfcee3892005-06-21 17:15:34 -070079 int DevFn; /* Linux devfn */
Stephen Rothwellfcee3892005-06-21 17:15:34 -070080 int Irq; /* Assigned IRQ */
Stephen Rothwellfcee3892005-06-21 17:15:34 -070081 int Flags; /* Possible flags(disable/bist)*/
Stephen Rothwellfcee3892005-06-21 17:15:34 -070082 u8 LogicalSlot; /* Hv Slot Index for Tces */
83 struct iommu_table *iommu_table;/* Device TCE Table */
Linus Torvalds1da177e2005-04-16 15:20:36 -070084};
85
Stephen Rothwell061c0632005-06-21 17:15:48 -070086extern void iSeries_Device_Information(struct pci_dev*, int);
Linus Torvalds1da177e2005-04-16 15:20:36 -070087
88#endif /* _ISERIES_64_PCI_H */