summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2018-09-11 17:23:21 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2018-09-11 17:23:21 +0200
commit74f9a3c6885e9e9a1d219cfb28b40035f6ebd9d1 (patch)
treebc6ae2d0fd74b3259d0be72528da04d3d6c74ce8 /include
parentb56d4426245e7c4b4729e35a8a7153d4c3bfdf5b (diff)
parent2c72ce0d48f4e38fb8ffb38e56c5b9d62e84c592 (diff)
downloadbarebox-74f9a3c6885e9e9a1d219cfb28b40035f6ebd9d1.tar.gz
barebox-74f9a3c6885e9e9a1d219cfb28b40035f6ebd9d1.tar.xz
Merge branch 'for-next/dma-mask'
Diffstat (limited to 'include')
-rw-r--r--include/dma.h12
-rw-r--r--include/driver.h2
2 files changed, 13 insertions, 1 deletions
diff --git a/include/dma.h b/include/dma.h
index 5fdcb1733c..7f95782635 100644
--- a/include/dma.h
+++ b/include/dma.h
@@ -35,11 +35,21 @@ dma_addr_t dma_map_single(struct device_d *dev, void *ptr, size_t size,
void dma_unmap_single(struct device_d *dev, dma_addr_t addr, size_t size,
enum dma_data_direction dir);
+#define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
+
+#define DMA_MASK_NONE 0x0ULL
+
+static inline void dma_set_mask(struct device_d *dev, u64 dma_mask)
+{
+ dev->dma_mask = dma_mask;
+}
+
#define DMA_ERROR_CODE (~(dma_addr_t)0)
static inline int dma_mapping_error(struct device_d *dev, dma_addr_t dma_addr)
{
- return dma_addr == DMA_ERROR_CODE;
+ return dma_addr == DMA_ERROR_CODE ||
+ (dev->dma_mask && dma_addr > dev->dma_mask);
}
/* streaming DMA - implement the below calls to support HAS_DMA */
diff --git a/include/driver.h b/include/driver.h
index 91653b7946..1b61f20660 100644
--- a/include/driver.h
+++ b/include/driver.h
@@ -82,6 +82,8 @@ struct device_d {
const struct of_device_id *of_id_entry;
+ u64 dma_mask;
+
void (*info) (struct device_d *);
/*
* For devices which take longer to probe this is called