6 #include <asm/arch/hardware.h>
8 static inline void pcibios_set_master(struct pci_dev *dev)
10 /* No special bus mastering setup handling */
13 static inline void pcibios_penalize_isa_irq(int irq)
15 /* We don't do dynamic PCI IRQ allocation */
18 #include <asm/scatterlist.h>
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
30 extern void *pci_alloc_consistent(struct pci_dev *hwdev, size_t size, dma_addr_t *handle);
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.
37 * References to the memory and mappings associated with cpu_addr/dma_addr
38 * past this call are illegal.
41 pci_free_consistent(struct pci_dev *hwdev, size_t size, void *vaddr,
42 dma_addr_t dma_handle)
44 consistent_free(vaddr, size, dma_handle);
47 /* Map a single buffer of the indicated size for DMA in streaming mode.
48 * The 32-bit bus address to use is returned.
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.
53 static inline dma_addr_t
54 pci_map_single(struct pci_dev *hwdev, void *ptr, size_t size, int direction)
57 extern dma_addr_t sa1111_map_single(struct pci_dev *, void *, size_t, int);
60 * for SA1111 these functions are "magic" and relocate buffers. We
61 * only need to do these if hwdev is non-null; otherwise we expect
62 * the buffer to already be suitable for DMA.
65 return sa1111_map_single(hwdev, ptr, size, direction);
67 consistent_sync(ptr, size, direction);
68 return virt_to_bus(ptr);
71 /* Unmap a single streaming mode DMA translation. The dma_addr and size
72 * must match what was provided for in a previous pci_map_single call. All
73 * other usages are undefined.
75 * After this call, reads by the cpu to the buffer are guarenteed to see
76 * whatever the device wrote there.
79 pci_unmap_single(struct pci_dev *hwdev, dma_addr_t dma_addr, size_t size, int direction)
82 extern void sa1111_unmap_single(struct pci_dev *, dma_addr_t, size_t, int);
85 sa1111_unmap_single(hwdev, dma_addr, size, direction);
90 /* Whether pci_unmap_{single,page} is a nop depends upon the
94 #define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME) \
96 #define DECLARE_PCI_UNMAP_LEN(LEN_NAME) \
98 #define pci_unmap_addr(PTR, ADDR_NAME) \
100 #define pci_unmap_addr_set(PTR, ADDR_NAME, VAL) \
101 (((PTR)->ADDR_NAME) = (VAL))
102 #define pci_unmap_len(PTR, LEN_NAME) \
104 #define pci_unmap_len_set(PTR, LEN_NAME, VAL) \
105 (((PTR)->LEN_NAME) = (VAL))
106 #else /* !(CONFIG_SA1111) */
107 #define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME)
108 #define DECLARE_PCI_UNMAP_LEN(LEN_NAME)
109 #define pci_unmap_addr(PTR, ADDR_NAME) (0)
110 #define pci_unmap_addr_set(PTR, ADDR_NAME, VAL) do { } while (0)
111 #define pci_unmap_len(PTR, LEN_NAME) (0)
112 #define pci_unmap_len_set(PTR, LEN_NAME, VAL) do { } while (0)
113 #endif /* CONFIG_SA1111 */
115 /* Map a set of buffers described by scatterlist in streaming
116 * mode for DMA. This is the scather-gather version of the
117 * above pci_map_single interface. Here the scatter gather list
118 * elements are each tagged with the appropriate dma address
119 * and length. They are obtained via sg_dma_{address,length}(SG).
121 * NOTE: An implementation may be able to use a smaller number of
122 * DMA address/length pairs than there are SG table elements.
123 * (for example via virtual mapping capabilities)
124 * The routine returns the number of addr/length pairs actually
125 * used, at most nents.
127 * Device ownership issues as mentioned above for pci_map_single are
131 pci_map_sg(struct pci_dev *hwdev, struct scatterlist *sg, int nents, int direction)
135 for (i = 0; i < nents; i++, sg++) {
136 consistent_sync(sg->address, sg->length, direction);
137 sg->dma_address = virt_to_bus(sg->address);
143 /* Unmap a set of streaming mode DMA translations.
144 * Again, cpu read rules concerning calls here are the same as for
145 * pci_unmap_single() above.
148 pci_unmap_sg(struct pci_dev *hwdev, struct scatterlist *sg, int nents, int direction)
153 /* Make physical memory consistent for a single
154 * streaming mode DMA translation after a transfer.
156 * If you perform a pci_map_single() but wish to interrogate the
157 * buffer using the cpu, yet do not wish to teardown the PCI dma
158 * mapping, you must call this function before doing so. At the
159 * next point you give the PCI dma address back to the card, the
160 * device again owns the buffer.
163 pci_dma_sync_single(struct pci_dev *hwdev, dma_addr_t dma_handle, size_t size, int direction)
165 consistent_sync(bus_to_virt(dma_handle), size, direction);
168 /* Make physical memory consistent for a set of streaming
169 * mode DMA translations after a transfer.
171 * The same as pci_dma_sync_single but for a scatter-gather list,
172 * same rules and usage.
175 pci_dma_sync_sg(struct pci_dev *hwdev, struct scatterlist *sg, int nelems, int direction)
179 for (i = 0; i < nelems; i++, sg++)
180 consistent_sync(sg->address, sg->length, direction);
183 /* Return whether the given PCI device DMA address mask can
184 * be supported properly. For example, if your device can
185 * only drive the low 24-bits during PCI bus mastering, then
186 * you would pass 0x00ffffff as the mask to this function.
188 static inline int pci_dma_supported(struct pci_dev *hwdev, u64 mask)
193 /* This isn't fine. */
194 #define pci_dac_dma_supported(pci_dev, mask) (0)
196 /* Return the index of the PCI controller for device PDEV. */
197 #define pci_controller_num(PDEV) (0)
199 #endif /* __KERNEL__ */