Ok. I didn't make 2.4.0 in 2000. Tough. I tried, but we had some
[davej-history.git] / include / asm-mips / pci.h
blob77c99d3473f53b2f6d0325bf4f37c96a3f054b31
1 /* $Id: pci.h,v 1.10 2000/03/23 02:26:00 ralf Exp $
3 * This file is subject to the terms and conditions of the GNU General Public
4 * License. See the file "COPYING" in the main directory of this archive
5 * for more details.
6 */
7 #ifndef _ASM_PCI_H
8 #define _ASM_PCI_H
10 #ifdef __KERNEL__
12 /* Can be used to override the logic in pci_scan_bus for skipping
13 already-configured bus numbers - to be used for buggy BIOSes
14 or architectures with incomplete PCI setup by the loader */
16 #define pcibios_assign_all_busses() 0
18 #define PCIBIOS_MIN_IO 0x1000
19 #define PCIBIOS_MIN_MEM 0x10000000
21 extern inline void pcibios_set_master(struct pci_dev *dev)
23 /* No special bus mastering setup handling */
26 extern inline void pcibios_penalize_isa_irq(int irq)
28 /* We don't do dynamic PCI IRQ allocation */
32 * Dynamic DMA mapping stuff.
33 * MIPS has everything mapped statically.
36 #include <linux/config.h>
37 #include <linux/types.h>
38 #include <linux/slab.h>
39 #include <asm/scatterlist.h>
40 #include <linux/string.h>
41 #include <asm/io.h>
43 #ifdef CONFIG_DDB5074
44 #undef PCIBIOS_MIN_IO
45 #undef PCIBIOS_MIN_MEM
46 #define PCIBIOS_MIN_IO 0x0100000
47 #define PCIBIOS_MIN_MEM 0x1000000
48 #endif
50 struct pci_dev;
53 * Allocate and map kernel buffer using consistent mode DMA for a device.
54 * hwdev should be valid struct pci_dev pointer for PCI devices,
55 * NULL for PCI-like buses (ISA, EISA).
56 * Returns non-NULL cpu-view pointer to the buffer if successful and
57 * sets *dma_addrp to the pci side dma address as well, else *dma_addrp
58 * is undefined.
60 extern void *pci_alloc_consistent(struct pci_dev *hwdev, size_t size,
61 dma_addr_t *dma_handle);
64 * Free and unmap a consistent DMA buffer.
65 * cpu_addr is what was returned from pci_alloc_consistent,
66 * size must be the same as what as passed into pci_alloc_consistent,
67 * and likewise dma_addr must be the same as what *dma_addrp was set to.
69 * References to the memory and mappings associated with cpu_addr/dma_addr
70 * past this call are illegal.
72 extern void pci_free_consistent(struct pci_dev *hwdev, size_t size,
73 void *vaddr, dma_addr_t dma_handle);
76 * Map a single buffer of the indicated size for DMA in streaming mode.
77 * The 32-bit bus address to use is returned.
79 * Once the device is given the dma address, the device owns this memory
80 * until either pci_unmap_single or pci_dma_sync_single is performed.
82 extern inline dma_addr_t pci_map_single(struct pci_dev *hwdev, void *ptr,
83 size_t size, int direction)
85 if (direction == PCI_DMA_NONE)
86 BUG();
88 dma_cache_wback_inv((unsigned long)ptr, size);
90 return virt_to_bus(ptr);
94 * Unmap a single streaming mode DMA translation. The dma_addr and size
95 * must match what was provided for in a previous pci_map_single call. All
96 * other usages are undefined.
98 * After this call, reads by the cpu to the buffer are guarenteed to see
99 * whatever the device wrote there.
101 extern inline void pci_unmap_single(struct pci_dev *hwdev, dma_addr_t dma_addr,
102 size_t size, int direction)
104 if (direction == PCI_DMA_NONE)
105 BUG();
107 /* Nothing to do */
111 * Map a set of buffers described by scatterlist in streaming
112 * mode for DMA. This is the scather-gather version of the
113 * above pci_map_single interface. Here the scatter gather list
114 * elements are each tagged with the appropriate dma address
115 * and length. They are obtained via sg_dma_{address,length}(SG).
117 * NOTE: An implementation may be able to use a smaller number of
118 * DMA address/length pairs than there are SG table elements.
119 * (for example via virtual mapping capabilities)
120 * The routine returns the number of addr/length pairs actually
121 * used, at most nents.
123 * Device ownership issues as mentioned above for pci_map_single are
124 * the same here.
126 extern inline int pci_map_sg(struct pci_dev *hwdev, struct scatterlist *sg,
127 int nents, int direction)
129 #ifndef CONFIG_COHERENT_IO
130 int i;
131 #endif
133 if (direction == PCI_DMA_NONE)
134 BUG();
136 #ifndef CONFIG_COHERENT_IO
137 /* Make sure that gcc doesn't leave the empty loop body. */
138 for (i = 0; i < nents; i++, sg++)
139 dma_cache_wback_inv((unsigned long)sg->address, sg->length);
140 #endif
142 return nents;
146 * Unmap a set of streaming mode DMA translations.
147 * Again, cpu read rules concerning calls here are the same as for
148 * pci_unmap_single() above.
150 extern inline void pci_unmap_sg(struct pci_dev *hwdev, struct scatterlist *sg,
151 int nents, int direction)
153 if (direction == PCI_DMA_NONE)
154 BUG();
156 /* Nothing to do */
160 * Make physical memory consistent for a single
161 * streaming mode DMA translation after a transfer.
163 * If you perform a pci_map_single() but wish to interrogate the
164 * buffer using the cpu, yet do not wish to teardown the PCI dma
165 * mapping, you must call this function before doing so. At the
166 * next point you give the PCI dma address back to the card, the
167 * device again owns the buffer.
169 extern inline void pci_dma_sync_single(struct pci_dev *hwdev,
170 dma_addr_t dma_handle,
171 size_t size, int direction)
173 if (direction == PCI_DMA_NONE)
174 BUG();
176 dma_cache_wback_inv((unsigned long)bus_to_virt(dma_handle), size);
180 * Make physical memory consistent for a set of streaming
181 * mode DMA translations after a transfer.
183 * The same as pci_dma_sync_single but for a scatter-gather list,
184 * same rules and usage.
186 extern inline void pci_dma_sync_sg(struct pci_dev *hwdev,
187 struct scatterlist *sg,
188 int nelems, int direction)
190 #ifndef CONFIG_COHERENT_IO
191 int i;
192 #endif
194 if (direction == PCI_DMA_NONE)
195 BUG();
197 /* Make sure that gcc doesn't leave the empty loop body. */
198 #ifndef CONFIG_COHERENT_IO
199 for (i = 0; i < nelems; i++, sg++)
200 dma_cache_wback_inv((unsigned long)sg->address, sg->length);
201 #endif
205 * These macros should be used after a pci_map_sg call has been done
206 * to get bus addresses of each of the SG entries and their lengths.
207 * You should only work with the number of sg entries pci_map_sg
208 * returns, or alternatively stop on the first sg_dma_len(sg) which
209 * is 0.
211 #define sg_dma_address(sg) (virt_to_bus((sg)->address))
212 #define sg_dma_len(sg) ((sg)->length)
214 #endif /* __KERNEL__ */
216 #endif /* _ASM_PCI_H */