- Linus: more PageDirty / swapcache handling
[davej-history.git] / include / asm-mips64 / pci.h
blob0112244e3b9cd12bd1ec89e9071fc564dc1cb546
1 /* $Id: pci.h,v 1.4 2000/02/24 00:13:20 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 struct pci_dev;
46 * Allocate and map kernel buffer using consistent mode DMA for a device.
47 * hwdev should be valid struct pci_dev pointer for PCI devices,
48 * NULL for PCI-like buses (ISA, EISA).
49 * Returns non-NULL cpu-view pointer to the buffer if successful and
50 * sets *dma_addrp to the pci side dma address as well, else *dma_addrp
51 * is undefined.
53 extern void *pci_alloc_consistent(struct pci_dev *hwdev, size_t size,
54 dma_addr_t *dma_handle);
57 * Free and unmap a consistent DMA buffer.
58 * cpu_addr is what was returned from pci_alloc_consistent,
59 * size must be the same as what as passed into pci_alloc_consistent,
60 * and likewise dma_addr must be the same as what *dma_addrp was set to.
62 * References to the memory and mappings associated with cpu_addr/dma_addr
63 * past this call are illegal.
65 extern void pci_free_consistent(struct pci_dev *hwdev, size_t size,
66 void *vaddr, dma_addr_t dma_handle);
69 * Map a single buffer of the indicated size for DMA in streaming mode.
70 * The 32-bit bus address to use is returned.
72 * Once the device is given the dma address, the device owns this memory
73 * until either pci_unmap_single or pci_dma_sync_single is performed.
75 extern inline dma_addr_t pci_map_single(struct pci_dev *hwdev, void *ptr,
76 size_t size, int direction)
78 if (direction == PCI_DMA_NONE)
79 BUG();
81 #ifndef CONFIG_COHERENT_IO
82 dma_cache_wback_inv((unsigned long)ptr, size);
83 #endif
84 return (bus_to_baddr[hwdev->bus->number] | __pa(ptr));
88 * Unmap a single streaming mode DMA translation. The dma_addr and size
89 * must match what was provided for in a previous pci_map_single call. All
90 * other usages are undefined.
92 * After this call, reads by the cpu to the buffer are guarenteed to see
93 * whatever the device wrote there.
95 extern inline void pci_unmap_single(struct pci_dev *hwdev, dma_addr_t dma_addr,
96 size_t size, int direction)
98 if (direction == PCI_DMA_NONE)
99 BUG();
101 /* Nothing to do */
105 * Map a set of buffers described by scatterlist in streaming
106 * mode for DMA. This is the scather-gather version of the
107 * above pci_map_single interface. Here the scatter gather list
108 * elements are each tagged with the appropriate dma address
109 * and length. They are obtained via sg_dma_{address,length}(SG).
111 * NOTE: An implementation may be able to use a smaller number of
112 * DMA address/length pairs than there are SG table elements.
113 * (for example via virtual mapping capabilities)
114 * The routine returns the number of addr/length pairs actually
115 * used, at most nents.
117 * Device ownership issues as mentioned above for pci_map_single are
118 * the same here.
120 extern inline int pci_map_sg(struct pci_dev *hwdev, struct scatterlist *sg,
121 int nents, int direction)
123 int i;
125 if (direction == PCI_DMA_NONE)
126 BUG();
128 /* Make sure that gcc doesn't leave the empty loop body. */
129 for (i = 0; i < nents; i++, sg++) {
130 #ifndef CONFIG_COHERENT_IO
131 dma_cache_wback_inv((unsigned long)sg->address, sg->length);
132 #endif
133 sg->address = (char *)(bus_to_baddr[hwdev->bus->number] | __pa(sg->address));
136 return nents;
140 * Unmap a set of streaming mode DMA translations.
141 * Again, cpu read rules concerning calls here are the same as for
142 * pci_unmap_single() above.
144 extern inline void pci_unmap_sg(struct pci_dev *hwdev, struct scatterlist *sg,
145 int nents, int direction)
147 if (direction == PCI_DMA_NONE)
148 BUG();
150 /* Nothing to do */
154 * Make physical memory consistent for a single
155 * streaming mode DMA translation after a transfer.
157 * If you perform a pci_map_single() but wish to interrogate the
158 * buffer using the cpu, yet do not wish to teardown the PCI dma
159 * mapping, you must call this function before doing so. At the
160 * next point you give the PCI dma address back to the card, the
161 * device again owns the buffer.
163 extern inline void pci_dma_sync_single(struct pci_dev *hwdev,
164 dma_addr_t dma_handle,
165 size_t size, int direction)
167 if (direction == PCI_DMA_NONE)
168 BUG();
169 #ifndef CONFIG_COHERENT_IO
170 dma_cache_wback_inv((unsigned long)__va(dma_handle - bus_to_baddr[hwdev->bus->number]), size);
171 #endif
175 * Make physical memory consistent for a set of streaming
176 * mode DMA translations after a transfer.
178 * The same as pci_dma_sync_single but for a scatter-gather list,
179 * same rules and usage.
181 extern inline void pci_dma_sync_sg(struct pci_dev *hwdev,
182 struct scatterlist *sg,
183 int nelems, int direction)
185 #ifndef CONFIG_COHERENT_IO
186 int i;
187 #endif
189 if (direction == PCI_DMA_NONE)
190 BUG();
192 /* Make sure that gcc doesn't leave the empty loop body. */
193 #ifndef CONFIG_COHERENT_IO
194 for (i = 0; i < nelems; i++, sg++)
195 dma_cache_wback_inv((unsigned long)sg->address, sg->length);
196 #endif
200 * These macros should be used after a pci_map_sg call has been done
201 * to get bus addresses of each of the SG entries and their lengths.
202 * You should only work with the number of sg entries pci_map_sg
203 * returns, or alternatively stop on the first sg_dma_len(sg) which
204 * is 0.
206 #define sg_dma_address(sg) ((unsigned long)((sg)->address))
207 #define sg_dma_len(sg) ((sg)->length)
209 #endif /* __KERNEL__ */
211 #endif /* _ASM_PCI_H */