1 #ifndef __ALPHA_PCI_H
2 #define __ALPHA_PCI_H
3
4 #ifdef __KERNEL__
5
6 #include <linux/spinlock.h>
7 #include <asm/scatterlist.h>
8 #include <asm/machvec.h>
9 #include <asm/io.h>
10
11 /*
12 * The following structure is used to manage multiple PCI busses.
13 */
14
15 struct pci_dev;
16 struct pci_bus;
17 struct resource;
18 struct pci_iommu_arena;
19 struct page;
20
21 /* A controller. Used to manage multiple PCI busses. */
22
23 struct pci_controller {
24 struct pci_controller *next;
25 struct pci_bus *bus;
26 struct resource *io_space;
27 struct resource *mem_space;
28
29 /* The following are for reporting to userland. The invariant is
30 that if we report a BWX-capable dense memory, we do not report
31 a sparse memory at all, even if it exists. */
32 unsigned long sparse_mem_base;
33 unsigned long dense_mem_base;
34 unsigned long sparse_io_base;
35 unsigned long dense_io_base;
36
37 /* This one's for the kernel only. It's in KSEG somewhere. */
38 unsigned long config_space_base;
39
40 unsigned int index;
41 unsigned int first_busno;
42 unsigned int last_busno;
43
44 struct pci_iommu_arena *sg_pci;
45 struct pci_iommu_arena *sg_isa;
46
47 void *sysdata;
48 };
49
50 /* Override the logic in pci_scan_bus for skipping already-configured
51 bus numbers. */
52
53 #define pcibios_assign_all_busses() 1
54 #define pcibios_scan_all_fns() 0
55
56 #define PCIBIOS_MIN_IO alpha_mv.min_io_address
57 #define PCIBIOS_MIN_MEM alpha_mv.min_mem_address
58
59 extern void pcibios_set_master(struct pci_dev *dev);
60
pcibios_penalize_isa_irq(int irq)61 extern inline void pcibios_penalize_isa_irq(int irq)
62 {
63 /* We don't do dynamic PCI IRQ allocation */
64 }
65
66 /* IOMMU controls. */
67
68 /* The PCI address space does not equal the physical memory address space.
69 The networking and block device layers use this boolean for bounce buffer
70 decisions. */
71 #define PCI_DMA_BUS_IS_PHYS 0
72
73 /* Allocate and map kernel buffer using consistant mode DMA for PCI
74 device. Returns non-NULL cpu-view pointer to the buffer if
75 successful and sets *DMA_ADDRP to the pci side dma address as well,
76 else DMA_ADDRP is undefined. */
77
78 extern void *pci_alloc_consistent(struct pci_dev *, size_t, dma_addr_t *);
79
80 /* Free and unmap a consistant DMA buffer. CPU_ADDR and DMA_ADDR must
81 be values that were returned from pci_alloc_consistant. SIZE must
82 be the same as what as passed into pci_alloc_consistant.
83 References to the memory and mappings assosciated with CPU_ADDR or
84 DMA_ADDR past this call are illegal. */
85
86 extern void pci_free_consistent(struct pci_dev *, size_t, void *, dma_addr_t);
87
88 /* Map a single buffer of the indicate size for PCI DMA in streaming
89 mode. The 32-bit PCI bus mastering address to use is returned.
90 Once the device is given the dma address, the device owns this memory
91 until either pci_unmap_single or pci_dma_sync_single is performed. */
92
93 extern dma_addr_t pci_map_single(struct pci_dev *, void *, size_t, int);
94
95 /* Likewise, but for a page instead of an address. */
96 extern dma_addr_t pci_map_page(struct pci_dev *, struct page *,
97 unsigned long, size_t, int);
98
99 /* Unmap a single streaming mode DMA translation. The DMA_ADDR and
100 SIZE must match what was provided for in a previous pci_map_single
101 call. All other usages are undefined. After this call, reads by
102 the cpu to the buffer are guarenteed to see whatever the device
103 wrote there. */
104
105 extern void pci_unmap_single(struct pci_dev *, dma_addr_t, size_t, int);
106 extern void pci_unmap_page(struct pci_dev *, dma_addr_t, size_t, int);
107
108 /* pci_unmap_{single,page} is not a nop, thus... */
109 #define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME) \
110 dma_addr_t ADDR_NAME;
111 #define DECLARE_PCI_UNMAP_LEN(LEN_NAME) \
112 __u32 LEN_NAME;
113 #define pci_unmap_addr(PTR, ADDR_NAME) \
114 ((PTR)->ADDR_NAME)
115 #define pci_unmap_addr_set(PTR, ADDR_NAME, VAL) \
116 (((PTR)->ADDR_NAME) = (VAL))
117 #define pci_unmap_len(PTR, LEN_NAME) \
118 ((PTR)->LEN_NAME)
119 #define pci_unmap_len_set(PTR, LEN_NAME, VAL) \
120 (((PTR)->LEN_NAME) = (VAL))
121
122 /* Map a set of buffers described by scatterlist in streaming mode for
123 PCI DMA. This is the scather-gather version of the above
124 pci_map_single interface. Here the scatter gather list elements
125 are each tagged with the appropriate PCI dma address and length.
126 They are obtained via sg_dma_{address,length}(SG).
127
128 NOTE: An implementation may be able to use a smaller number of DMA
129 address/length pairs than there are SG table elements. (for
130 example via virtual mapping capabilities) The routine returns the
131 number of addr/length pairs actually used, at most nents.
132
133 Device ownership issues as mentioned above for pci_map_single are
134 the same here. */
135
136 extern int pci_map_sg(struct pci_dev *, struct scatterlist *, int, int);
137
138 /* Unmap a set of streaming mode DMA translations. Again, cpu read
139 rules concerning calls here are the same as for pci_unmap_single()
140 above. */
141
142 extern void pci_unmap_sg(struct pci_dev *, struct scatterlist *, int, int);
143
144 /* Make physical memory consistant for a single streaming mode DMA
145 translation after a transfer.
146
147 If you perform a pci_map_single() but wish to interrogate the
148 buffer using the cpu, yet do not wish to teardown the PCI dma
149 mapping, you must call this function before doing so. At the next
150 point you give the PCI dma address back to the card, the device
151 again owns the buffer. */
152
153 static inline void
pci_dma_sync_single(struct pci_dev * dev,dma_addr_t dma_addr,long size,int direction)154 pci_dma_sync_single(struct pci_dev *dev, dma_addr_t dma_addr, long size,
155 int direction)
156 {
157 /* Nothing to do. */
158 }
159
160 /* Make physical memory consistant for a set of streaming mode DMA
161 translations after a transfer. The same as pci_dma_sync_single but
162 for a scatter-gather list, same rules and usage. */
163
164 static inline void
pci_dma_sync_sg(struct pci_dev * dev,struct scatterlist * sg,int nents,int direction)165 pci_dma_sync_sg(struct pci_dev *dev, struct scatterlist *sg, int nents,
166 int direction)
167 {
168 /* Nothing to do. */
169 }
170
171 /* Return whether the given PCI device DMA address mask can
172 be supported properly. For example, if your device can
173 only drive the low 24-bits during PCI bus mastering, then
174 you would pass 0x00ffffff as the mask to this function. */
175
176 extern int pci_dma_supported(struct pci_dev *hwdev, u64 mask);
177
178 /* True if the machine supports DAC addressing, and DEV can
179 make use of it given MASK. */
180 extern int pci_dac_dma_supported(struct pci_dev *hwdev, u64 mask);
181
182 /* Convert to/from DAC dma address and struct page. */
183 extern dma64_addr_t pci_dac_page_to_dma(struct pci_dev *, struct page *, unsigned long, int);
184 extern struct page *pci_dac_dma_to_page(struct pci_dev *, dma64_addr_t);
185 extern unsigned long pci_dac_dma_to_offset(struct pci_dev *, dma64_addr_t);
186
187 static __inline__ void
pci_dac_dma_sync_single(struct pci_dev * pdev,dma64_addr_t dma_addr,size_t len,int direction)188 pci_dac_dma_sync_single(struct pci_dev *pdev, dma64_addr_t dma_addr, size_t len, int direction)
189 {
190 /* Nothing to do. */
191 }
192
193 /* Return the index of the PCI controller for device PDEV. */
194 extern int pci_controller_num(struct pci_dev *pdev);
195 #endif /* __KERNEL__ */
196
197 /* Values for the `which' argument to sys_pciconfig_iobase. */
198 #define IOBASE_HOSE 0
199 #define IOBASE_SPARSE_MEM 1
200 #define IOBASE_DENSE_MEM 2
201 #define IOBASE_SPARSE_IO 3
202 #define IOBASE_DENSE_IO 4
203 #define IOBASE_ROOT_BUS 5
204 #define IOBASE_FROM_HOSE 0x10000
205
206 #endif /* __ALPHA_PCI_H */
207