1 #ifndef ASMARM_PCI_H
2 #define ASMARM_PCI_H
3
4 #ifdef __KERNEL__
5
6 #include <asm/arch/hardware.h>
7
8 extern inline void pcibios_set_master(struct pci_dev *dev)
9 {
10 /* No special bus mastering setup handling */
11 }
12
13 extern inline void pcibios_penalize_isa_irq(int irq)
14 {
15 /* We don't do dynamic PCI IRQ allocation */
16 }
17
18 #include <asm/scatterlist.h>
19 #include <asm/io.h>
20
21 struct pci_dev;
22
23 /* Allocate and map kernel buffer using consistent mode DMA for a device.
24 * hwdev should be valid struct pci_dev pointer for PCI devices,
25 * NULL for PCI-like buses (ISA, EISA).
26 * Returns non-NULL cpu-view pointer to the buffer if successful and
27 * sets *dma_addrp to the pci side dma address as well, else *dma_addrp
28 * is undefined.
29 */
30 extern void *pci_alloc_consistent(struct pci_dev *hwdev, size_t size, dma_addr_t *handle);
31
32 /* Free and unmap a consistent DMA buffer.
33 * cpu_addr is what was returned from pci_alloc_consistent,
34 * size must be the same as what as passed into pci_alloc_consistent,
35 * and likewise dma_addr must be the same as what *dma_addrp was set to.
36 *
37 * References to the memory and mappings associated with cpu_addr/dma_addr
38 * past this call are illegal.
39 */
40 extern inline void
41 pci_free_consistent(struct pci_dev *hwdev, size_t size, void *vaddr,
42 dma_addr_t dma_handle)
43 {
44 consistent_free(vaddr);
45 }
46
47 /* Map a single buffer of the indicated size for DMA in streaming mode.
48 * The 32-bit bus address to use is returned.
49 *
50 * Once the device is given the dma address, the device owns this memory
51 * until either pci_unmap_single or pci_dma_sync_single is performed.
52 */
53 extern inline dma_addr_t
54 pci_map_single(struct pci_dev *hwdev, void *ptr, size_t size, int direction)
55 {
56 consistent_sync(ptr, size, direction);
57 return virt_to_bus(ptr);
58 }
59
60 /* Unmap a single streaming mode DMA translation. The dma_addr and size
61 * must match what was provided for in a previous pci_map_single call. All
62 * other usages are undefined.
63 *
64 * After this call, reads by the cpu to the buffer are guarenteed to see
65 * whatever the device wrote there.
66 */
67 extern inline void
68 pci_unmap_single(struct pci_dev *hwdev, dma_addr_t dma_addr, size_t size, int direction)
69 {
70 /* nothing to do */
71 }
72
73 /* Map a set of buffers described by scatterlist in streaming
74 * mode for DMA. This is the scather-gather version of the
75 * above pci_map_single interface. Here the scatter gather list
76 * elements are each tagged with the appropriate dma address
77 * and length. They are obtained via sg_dma_{address,length}(SG).
78 *
79 * NOTE: An implementation may be able to use a smaller number of
80 * DMA address/length pairs than there are SG table elements.
81 * (for example via virtual mapping capabilities)
82 * The routine returns the number of addr/length pairs actually
83 * used, at most nents.
84 *
85 * Device ownership issues as mentioned above for pci_map_single are
86 * the same here.
87 */
88 extern inline int
89 pci_map_sg(struct pci_dev *hwdev, struct scatterlist *sg, int nents, int direction)
90 {
91 int i;
92
93 for (i = 0; i < nents; i++, sg++) {
94 consistent_sync(sg->address, sg->length, direction);
95 sg->dma_address = virt_to_bus(sg->address);
96 }
97
98 return nents;
99 }
100
101 /* Unmap a set of streaming mode DMA translations.
102 * Again, cpu read rules concerning calls here are the same as for
103 * pci_unmap_single() above.
104 */
105 extern inline void
106 pci_unmap_sg(struct pci_dev *hwdev, struct scatterlist *sg, int nents, int direction)
107 {
108 /* nothing to do */
109 }
110
111 /* Make physical memory consistent for a single
112 * streaming mode DMA translation after a transfer.
113 *
114 * If you perform a pci_map_single() but wish to interrogate the
115 * buffer using the cpu, yet do not wish to teardown the PCI dma
116 * mapping, you must call this function before doing so. At the
117 * next point you give the PCI dma address back to the card, the
118 * device again owns the buffer.
119 */
120 extern inline void
121 pci_dma_sync_single(struct pci_dev *hwdev, dma_addr_t dma_handle, size_t size, int direction)
122 {
123 consistent_sync(bus_to_virt(dma_handle), size, direction);
124 }
125
126 /* Make physical memory consistent for a set of streaming
127 * mode DMA translations after a transfer.
128 *
129 * The same as pci_dma_sync_single but for a scatter-gather list,
130 * same rules and usage.
131 */
132 extern inline void
133 pci_dma_sync_sg(struct pci_dev *hwdev, struct scatterlist *sg, int nelems, int direction)
134 {
135 int i;
136
137 for (i = 0; i < nelems; i++, sg++)
138 consistent_sync(sg->address, sg->length, direction);
139 }
140
141 /* Return whether the given PCI device DMA address mask can
142 * be supported properly. For example, if your device can
143 * only drive the low 24-bits during PCI bus mastering, then
144 * you would pass 0x00ffffff as the mask to this function.
145 */
146 extern inline int pci_dma_supported(struct pci_dev *hwdev, dma_addr_t mask)
147 {
148 return 1;
149 }
150
151 #endif /* __KERNEL__ */
152
153 #endif
154
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.