Commit a4b35e1f authored by Deepak Saxena's avatar Deepak Saxena Committed by Russell King

[ARM PATCH] 1620/1: dma_map_single/unmap_single support for ARM

Patch from Deepak Saxena
parent 860b2b0f
...@@ -128,6 +128,28 @@ dma_map_single(struct device *dev, void *cpu_addr, size_t size, ...@@ -128,6 +128,28 @@ dma_map_single(struct device *dev, void *cpu_addr, size_t size,
return __virt_to_bus((unsigned long)cpu_addr); return __virt_to_bus((unsigned long)cpu_addr);
} }
/**
* dma_map_page - map a portion of a page for streaming DMA
* @dev: valid struct device pointer, or NULL for ISA and EISA-like devices
* @page: page that buffer resides in
* @offset: offset into page for start of buffer
* @size: size of buffer to map
* @dir: DMA transfer direction
*
* Ensure that any data held in the cache is appropriately discarded
* or written back.
*
* The device owns this memory once this call has completed. The CPU
* can regain ownership by calling dma_unmap_page() or dma_sync_single().
*/
static inline dma_addr_t
dma_map_page(struct device *dev, struct page *page,
unsigned long offset, size_t size,
enum dma_data_direction dir)
{
return dma_map_single(dev, page_address(page) + offset, size, (int)dir);
}
/** /**
* dma_unmap_single - unmap a single buffer previously mapped * dma_unmap_single - unmap a single buffer previously mapped
* @dev: valid struct device pointer, or NULL for ISA and EISA-like devices * @dev: valid struct device pointer, or NULL for ISA and EISA-like devices
...@@ -152,21 +174,26 @@ dma_unmap_single(struct device *dev, dma_addr_t handle, size_t size, ...@@ -152,21 +174,26 @@ dma_unmap_single(struct device *dev, dma_addr_t handle, size_t size,
/* nothing to do */ /* nothing to do */
} }
#if 0 /**
static inline dma_addr_t * dma_unmap_page - unmap a buffer previously mapped through dma_map_page()
dma_map_page(struct device *dev, struct page *page, unsigned long off, * @dev: valid struct device pointer, or NULL for ISA and EISA-like devices
size_t size, enum dma_data_direction dir) * @handle: DMA address of buffer
{ * @size: size of buffer to map
/* fixme */ * @dir: DMA transfer direction
} *
* Unmap a single streaming mode DMA translation. The handle and size
* must match what was provided in the previous dma_map_single() call.
* All other usages are undefined.
*
* After this call, reads by the CPU to the buffer are guaranteed to see
* whatever the device wrote there.
*/
static inline void static inline void
dma_unmap_page(struct device *dev, dma_addr_t handle, size_t size, dma_unmap_page(struct device *dev, dma_addr_t handle, size_t size,
enum dma_data_direction dir) enum dma_data_direction dir)
{ {
/* fixme */ dma_unmap_single(dev, handle, size, (int)dir);
} }
#endif
/** /**
* dma_map_sg - map a set of SG buffers for streaming mode DMA * dma_map_sg - map a set of SG buffers for streaming mode DMA
......
...@@ -96,6 +96,19 @@ pci_unmap_sg(struct pci_dev *hwdev, struct scatterlist *sg, int nents, int dir) ...@@ -96,6 +96,19 @@ pci_unmap_sg(struct pci_dev *hwdev, struct scatterlist *sg, int nents, int dir)
return dma_unmap_sg(hwdev ? &hwdev->dev : NULL, sg, nents, dir); return dma_unmap_sg(hwdev ? &hwdev->dev : NULL, sg, nents, dir);
} }
static inline dma_addr_t
pci_map_page(struct pci_dev *hwdev, struct page *page, unsigned long offset,
size_t size, int dir)
{
return pci_map_single(hwdev, page_address(page) + offset, size, dir);
}
static inline void
pci_unmap_page(struct pci_dev *hwdev, dma_addr_t handle, size_t size, int dir)
{
return pci_unmap_single(hwdev, handle, size, dir);
}
static inline void static inline void
pci_dma_sync_single(struct pci_dev *hwdev, dma_addr_t handle, size_t size, int dir) pci_dma_sync_single(struct pci_dev *hwdev, dma_addr_t handle, size_t size, int dir)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment