~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
Linux/include/asm-mips/pci.h

Version: ~ [ 2.4.0 ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* $Id: pci.h,v 1.10 2000/03/23 02:26:00 ralf Exp $
  2  *
  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
  9 
 10 #ifdef __KERNEL__
 11 
 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 */
 15 
 16 #define pcibios_assign_all_busses()     0
 17 
 18 #define PCIBIOS_MIN_IO          0x1000
 19 #define PCIBIOS_MIN_MEM         0x10000000
 20 
 21 extern inline void pcibios_set_master(struct pci_dev *dev)
 22 {
 23         /* No special bus mastering setup handling */
 24 }
 25 
 26 extern inline void pcibios_penalize_isa_irq(int irq)
 27 {
 28         /* We don't do dynamic PCI IRQ allocation */
 29 }
 30 
 31 /*
 32  * Dynamic DMA mapping stuff.
 33  * MIPS has everything mapped statically.
 34  */
 35 
 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>
 42 
 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
 49 
 50 struct pci_dev;
 51 
 52 /*
 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.
 59  */
 60 extern void *pci_alloc_consistent(struct pci_dev *hwdev, size_t size,
 61                                   dma_addr_t *dma_handle);
 62 
 63 /*
 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.
 68  *
 69  * References to the memory and mappings associated with cpu_addr/dma_addr
 70  * past this call are illegal.
 71  */
 72 extern void pci_free_consistent(struct pci_dev *hwdev, size_t size,
 73                                 void *vaddr, dma_addr_t dma_handle);
 74 
 75 /*
 76  * Map a single buffer of the indicated size for DMA in streaming mode.
 77  * The 32-bit bus address to use is returned.
 78  *
 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.
 81  */
 82 extern inline dma_addr_t pci_map_single(struct pci_dev *hwdev, void *ptr,
 83                                         size_t size, int direction)
 84 {
 85         if (direction == PCI_DMA_NONE)
 86                 BUG();
 87 
 88         dma_cache_wback_inv((unsigned long)ptr, size);
 89 
 90         return virt_to_bus(ptr);
 91 }
 92 
 93 /*
 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.
 97  *
 98  * After this call, reads by the cpu to the buffer are guarenteed to see
 99  * whatever the device wrote there.
100  */
101 extern inline void pci_unmap_single(struct pci_dev *hwdev, dma_addr_t dma_addr,
102                                     size_t size, int direction)
103 {
104         if (direction == PCI_DMA_NONE)
105                 BUG();
106 
107         /* Nothing to do */
108 }
109 
110 /*
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).
116  *
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.
122  *
123  * Device ownership issues as mentioned above for pci_map_single are
124  * the same here.
125  */
126 extern inline int pci_map_sg(struct pci_dev *hwdev, struct scatterlist *sg,
127                              int nents, int direction)
128 {
129 #ifndef CONFIG_COHERENT_IO
130         int i;
131 #endif
132 
133         if (direction == PCI_DMA_NONE)
134                 BUG();
135 
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
141 
142         return nents;
143 }
144 
145 /*
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.
149  */
150 extern inline void pci_unmap_sg(struct pci_dev *hwdev, struct scatterlist *sg,
151                                 int nents, int direction)
152 {
153         if (direction == PCI_DMA_NONE)
154                 BUG();
155 
156         /* Nothing to do */
157 }
158 
159 /*
160  * Make physical memory consistent for a single
161  * streaming mode DMA translation after a transfer.
162  *
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.
168  */
169 extern inline void pci_dma_sync_single(struct pci_dev *hwdev,
170                                        dma_addr_t dma_handle,
171                                        size_t size, int direction)
172 {
173         if (direction == PCI_DMA_NONE)
174                 BUG();
175 
176         dma_cache_wback_inv((unsigned long)bus_to_virt(dma_handle), size);
177 }
178 
179 /*
180  * Make physical memory consistent for a set of streaming
181  * mode DMA translations after a transfer.
182  *
183  * The same as pci_dma_sync_single but for a scatter-gather list,
184  * same rules and usage.
185  */
186 extern inline void pci_dma_sync_sg(struct pci_dev *hwdev,
187                                    struct scatterlist *sg,
188                                    int nelems, int direction)
189 {
190 #ifndef CONFIG_COHERENT_IO
191         int i;
192 #endif
193 
194         if (direction == PCI_DMA_NONE)
195                 BUG();
196 
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
202 }
203 
204 /*
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.
210  */
211 #define sg_dma_address(sg)      (virt_to_bus((sg)->address))
212 #define sg_dma_len(sg)          ((sg)->length)
213 
214 #endif /* __KERNEL__ */
215 
216 #endif /* _ASM_PCI_H */
217 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.