vserver 1.9.5.x5
[linux-2.6.git] / include / asm-parisc / pci.h
1 #ifndef __ASM_PARISC_PCI_H
2 #define __ASM_PARISC_PCI_H
3
4 #include <linux/config.h>
5 #include <asm/scatterlist.h>
6
7
8
9 /*
10 ** HP PCI platforms generally support multiple bus adapters.
11 **    (workstations 1-~4, servers 2-~32)
12 **
13 ** Newer platforms number the busses across PCI bus adapters *sparsely*.
14 ** E.g. 0, 8, 16, ...
15 **
16 ** Under a PCI bus, most HP platforms support PPBs up to two or three
17 ** levels deep. See "Bit3" product line. 
18 */
19 #define PCI_MAX_BUSSES  256
20
21 /*
22 ** pci_hba_data (aka H2P_OBJECT in HP/UX)
23 **
24 ** This is the "common" or "base" data structure which HBA drivers
25 ** (eg Dino or LBA) are required to place at the top of their own
26 ** platform_data structure.  I've heard this called "C inheritance" too.
27 **
28 ** Data needed by pcibios layer belongs here.
29 */
30 struct pci_hba_data {
31         unsigned long   base_addr;      /* aka Host Physical Address */
32         const struct parisc_device *dev; /* device from PA bus walk */
33         struct pci_bus *hba_bus;        /* primary PCI bus below HBA */
34         int             hba_num;        /* I/O port space access "key" */
35         struct resource bus_num;        /* PCI bus numbers */
36         struct resource io_space;       /* PIOP */
37         struct resource lmmio_space;    /* bus addresses < 4Gb */
38         struct resource elmmio_space;   /* additional bus addresses < 4Gb */
39         struct resource gmmio_space;    /* bus addresses > 4Gb */
40
41         /* NOTE: Dino code assumes it can use *all* of the lmmio_space,
42          * elmmio_space and gmmio_space as a contiguous array of
43          * resources.  This #define represents the array size */
44         #define DINO_MAX_LMMIO_RESOURCES        3
45
46         unsigned long   lmmio_space_offset;  /* CPU view - PCI view */
47         void *          iommu;          /* IOMMU this device is under */
48         /* REVISIT - spinlock to protect resources? */
49
50         #define HBA_NAME_SIZE 16
51         char io_name[HBA_NAME_SIZE];
52         char lmmio_name[HBA_NAME_SIZE];
53         char elmmio_name[HBA_NAME_SIZE];
54         char gmmio_name[HBA_NAME_SIZE];
55 };
56
57 #define HBA_DATA(d)             ((struct pci_hba_data *) (d))
58
59 /* 
60 ** We support 2^16 I/O ports per HBA.  These are set up in the form
61 ** 0xbbxxxx, where bb is the bus number and xxxx is the I/O port
62 ** space address.
63 */
64 #define HBA_PORT_SPACE_BITS     16
65
66 #define HBA_PORT_BASE(h)        ((h) << HBA_PORT_SPACE_BITS)
67 #define HBA_PORT_SPACE_SIZE     (1UL << HBA_PORT_SPACE_BITS)
68
69 #define PCI_PORT_HBA(a)         ((a) >> HBA_PORT_SPACE_BITS)
70 #define PCI_PORT_ADDR(a)        ((a) & (HBA_PORT_SPACE_SIZE - 1))
71
72 #if CONFIG_PARISC64
73 #define PCI_F_EXTEND            0xffffffff00000000UL
74 #define PCI_IS_LMMIO(hba,a)     pci_is_lmmio(hba,a)
75
76 /* We need to know if an address is LMMMIO or GMMIO.
77  * LMMIO requires mangling and GMMIO we must use as-is.
78  */
79 static __inline__  int pci_is_lmmio(struct pci_hba_data *hba, unsigned long a)
80 {
81         return(((a) & PCI_F_EXTEND) == PCI_F_EXTEND);
82 }
83
84 /*
85 ** Convert between PCI (IO_VIEW) addresses and processor (PA_VIEW) addresses.
86 ** See pcibios.c for more conversions used by Generic PCI code.
87 */
88 #define PCI_BUS_ADDR(hba,a)     (PCI_IS_LMMIO(hba,a)    \
89                 ?  ((a) - hba->lmmio_space_offset)      /* mangle LMMIO */ \
90                 : (a))                                  /* GMMIO */
91 #define PCI_HOST_ADDR(hba,a)    ((a) + hba->lmmio_space_offset)
92
93 #else   /* !CONFIG_PARISC64 */
94
95 #define PCI_BUS_ADDR(hba,a)     (a)
96 #define PCI_HOST_ADDR(hba,a)    (a)
97 #define PCI_F_EXTEND            0UL
98 #define PCI_IS_LMMIO(hba,a)     (1)     /* 32-bit doesn't support GMMIO */
99
100 #endif /* !CONFIG_PARISC64 */
101
102 /*
103 ** KLUGE: linux/pci.h include asm/pci.h BEFORE declaring struct pci_bus
104 ** (This eliminates some of the warnings).
105 */
106 struct pci_bus;
107 struct pci_dev;
108
109 /* The PCI address space does equal the physical memory
110  * address space.  The networking and block device layers use
111  * this boolean for bounce buffer decisions.
112  */
113 #define PCI_DMA_BUS_IS_PHYS     (1)
114
115 /*
116 ** Most PCI devices (eg Tulip, NCR720) also export the same registers
117 ** to both MMIO and I/O port space.  Due to poor performance of I/O Port
118 ** access under HP PCI bus adapters, strongly reccomend use of MMIO
119 ** address space.
120 **
121 ** While I'm at it more PA programming notes:
122 **
123 ** 1) MMIO stores (writes) are posted operations. This means the processor
124 **    gets an "ACK" before the write actually gets to the device. A read
125 **    to the same device (or typically the bus adapter above it) will
126 **    force in-flight write transaction(s) out to the targeted device
127 **    before the read can complete.
128 **
129 ** 2) The Programmed I/O (PIO) data may not always be strongly ordered with
130 **    respect to DMA on all platforms. Ie PIO data can reach the processor
131 **    before in-flight DMA reaches memory. Since most SMP PA platforms
132 **    are I/O coherent, it generally doesn't matter...but sometimes
133 **    it does.
134 **
135 ** I've helped device driver writers debug both types of problems.
136 */
137 struct pci_port_ops {
138           u8 (*inb)  (struct pci_hba_data *hba, u16 port);
139          u16 (*inw)  (struct pci_hba_data *hba, u16 port);
140          u32 (*inl)  (struct pci_hba_data *hba, u16 port);
141         void (*outb) (struct pci_hba_data *hba, u16 port,  u8 data);
142         void (*outw) (struct pci_hba_data *hba, u16 port, u16 data);
143         void (*outl) (struct pci_hba_data *hba, u16 port, u32 data);
144 };
145
146
147 struct pci_bios_ops {
148         void (*init)(void);
149         void (*fixup_bus)(struct pci_bus *bus);
150 };
151
152 /* pci_unmap_{single,page} is not a nop, thus... */
153 #define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME)       \
154         dma_addr_t ADDR_NAME;
155 #define DECLARE_PCI_UNMAP_LEN(LEN_NAME)         \
156         __u32 LEN_NAME;
157 #define pci_unmap_addr(PTR, ADDR_NAME)                  \
158         ((PTR)->ADDR_NAME)
159 #define pci_unmap_addr_set(PTR, ADDR_NAME, VAL)         \
160         (((PTR)->ADDR_NAME) = (VAL))
161 #define pci_unmap_len(PTR, LEN_NAME)                    \
162         ((PTR)->LEN_NAME)
163 #define pci_unmap_len_set(PTR, LEN_NAME, VAL)           \
164         (((PTR)->LEN_NAME) = (VAL))
165
166 /*
167 ** Stuff declared in arch/parisc/kernel/pci.c
168 */
169 extern struct pci_port_ops *pci_port;
170 extern struct pci_bios_ops *pci_bios;
171 extern int pci_post_reset_delay;        /* delay after de-asserting #RESET */
172 extern int pci_hba_count;
173 extern struct pci_hba_data *parisc_pci_hba[];
174
175 #ifdef CONFIG_PCI
176 extern void pcibios_register_hba(struct pci_hba_data *);
177 extern void pcibios_set_master(struct pci_dev *);
178 #else
179 extern inline void pcibios_register_hba(struct pci_hba_data *x)
180 {
181 }
182 #endif
183
184 /*
185 ** used by drivers/pci/pci.c:pci_do_scan_bus()
186 **   0 == check if bridge is numbered before re-numbering.
187 **   1 == pci_do_scan_bus() should automatically number all PCI-PCI bridges.
188 **
189 ** REVISIT:
190 **   To date, only alpha sets this to one. We'll need to set this
191 **   to zero for legacy platforms and one for PAT platforms.
192 */
193 #define pcibios_assign_all_busses()     (pdc_type == PDC_TYPE_PAT)
194 #define pcibios_scan_all_fns(a, b)      0
195
196 #define PCIBIOS_MIN_IO          0x10
197 #define PCIBIOS_MIN_MEM         0x1000 /* NBPG - but pci/setup-res.c dies */
198
199 /* Don't support DAC yet. */
200 #define pci_dac_dma_supported(pci_dev, mask)   (0)
201
202 /* export the pci_ DMA API in terms of the dma_ one */
203 #include <asm-generic/pci-dma-compat.h>
204
205 extern void
206 pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region,
207                          struct resource *res);
208
209 static inline void pcibios_add_platform_entries(struct pci_dev *dev)
210 {
211 }
212
213 #endif /* __ASM_PARISC_PCI_H */